Arduino and programming in FLProg

Onze verontschuldigingen, dit bericht is alleen beschikbaar in Amerikaans Engels. Voor het gemak van de kijker, is de inhoud hieronder weergegeven in de alternatieve taal. Je kunt klikken op de link om naar de actieve taal over te schakelen.

  Want to program Arduino, but don’t know how or don’t have the time for learning Arduino C language? Meet FLProg – visual programming Arduino for “non-programmers”.

What is Arduino?

  Arduino is microcontroller based on single board hardware and software. Arduino boards are able to read inputs – from any sensors, switches and write an output Digital or analog PWM. You can tell your board what to do by sending a set of instructions to the microcontroller. To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing.

  Arduino is used in thousands of projects, from everyday objects to more complex machines and instruments.

  Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast prototyping. As soon as it reached a wider community, the Arduino board started changing to adapt to new needs and challenges, it got wearable, used for 3D printing, and suitable for industry. All Arduino boards are completely open-source, empowering users to build them independently and eventually adapt them to their particular needs. The software is open-source as well. Projects that can be created in Arduino are limited only by imagination.

Example of the smallest and the biggest boards

Arduino Mini Arduino Due
Flash Memory 16 KB 512 KB
SRAM 2 KB 96 Kb
EEPROM 512 B 4 KB
Clock Speed 8 or 16 MHz 84 MHz
Digital I/O Pins 14 (6 PWM) 54 (12 for PWM)
Analog Input Pins 6 12

  But what is there to do for people who are not familiar with C/C++ coding but still want to have some fun with this microcontroller?

  This is where we get a hand from the visual programming tools, such as the FLProg (one of the best examples).

FLProg

  FLProg tool allows you to create firmware for Arduino boards, using graphical FBD (Function Block Diagram) and LAD (Ladder Diagram) languages, which are a standard in programming of industrial controllers. Programming in this software is similar to Siemens, but of course, much simplified.

  The software has slightly extended the classic functionality of these languages by adding functional blocks responsible for working with external devices. They are “wrappers” over libraries designed to work with them. The program runs on a computer with Windows OS or Linux.

  When creating a new project, you will be asked to choose the programming language, and specify the board on which the project will be implemented:

Fig. 1 Project initialization

  Here is the list of supported Arduino boards:

  • Arduino Diecimila
  • Arduino Duemilanove
  • Arduino Leonardo
  • Arduino Lilypad
  • Arduino Mega 2560
  • Arduino Micro
  • Arduino Mini
  • Arduino Nano (ATmega168)
  • Arduino Nano (ATmega328)
  • Arduino Pro Mini
  • Arduino Pro (ATmega168)
  • Arduino Pro (ATmega328)
  • Arduino Uno
  • Intel-Galileo

  After the project is completed, it gets compiled. Once the compilation is done, the program “Arduino 1.5.7” with the loaded sketch of your project will automatically open up. In the “Arduino IDE 1.5.7” program you will need to specify the COM port number to which your controller is connected, select its type, and transfer the sketch into the controller.

  Let’s see what is inside of the program:

  1. Is where inputs, outputs and temporary bits are placed and configured;
  2. Network for creating logic of your sketch;
  3. Library with all the blocks.
Fig. 2 Program structure

  This software has a big variety of predefined blocks, which are enough for creating whatever you want, but it also allows you to create your own blocks.

Fig. 3 Available blocks

  This is how a very simple sketch programmed in FBD (Function Block Diagram) looks like. All the blocks are placed by a simple Drag and Drop. After that you can configure them.

Fig. 4 Program sketch

My project

  At home I have a gas boiler for heating. For best randament, flexible setting and to maintain a stable temperature it requires a Thermostat to be installed. My first experience to buy a new one, was a failure. It had a defect. So I decided to make my own.

  First of all my thoughts were – what do I want from this device? I wanted it to show the real temperature on display, the currently set temperature, humidity in the room. And of course I want to be able to control it. So, this is what I bought:

  • Arduino Mini – on ATmega 328
  • Temperature sensor – DS18B20
  • Humidity sensor – DHT11
  • Display – LCD 16×2 with i2c port
  • Encoder wheel – for switching the temperature
  • Relay 5v – for switching the on-off output
  • Potentiometer – for modifying the brightness on the display
  • Plastic case
  • Power supply – 5V

  For all of the above I spent around – 25$. And the advantage is that I can modify and update the hardware and the software whenever I want. For example my thoughts about upgrading my device are: I can install a gas sensor, to shut everything off in case of a gas leak. I could also add a GSM board, and set it to send me a message containing the boiler state when I am away. Also I want to make it wireless via Radio or WiFi modules. And I want it to have a color display with more settings. Everything I want I can do now, and FLProg will help me a lot with that.

  This is how my setup looks like right now:

Fig. 5 Thermostat. Exterior view

  The temperature is changing by 0.1. The hysteresis is 0.4 °C and the last set temperature is saved, even if electricity shuts down.

  And the logic part:

Fig. 6 Logic part of the thermostat

  First of all we get the inputs from sensors, then convert them into TEXT (string) for showing on display, set the position and add some constants (set, C, t=, RH). For changing the temperature I used the block for Encoder wheel. On changing the value it writes into the EEprom memory, and then reads it from there. I scaled the value from 1 to 0,1 by dividing it, so it lets me change the temperature by 0.1. The real temperature is compared with the set temperature and it returns a positive or negative output.

  Everything looks pretty simple after some time of using and understanding the blocks from the library in this software.

The reasons I chose Arduino

  • Inexpensive – Arduino boards are fairly inexpensive compared to other microcontroller platforms. The pre-assembled Arduino modules cost less than $10;
  • Cross-platform – The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux operating systems. Most microcontroller systems are limited to Windows only;
  • Pretty simple programming environment – The Arduino Software (IDE) is not very hard to use for beginners, yet it’s flexible enough for advanced users to take advantage of as well;
  • Open source and extensible software – The Arduino software is published as open source tools, available for extension by experienced programmers. The language can be expanded through C++ libraries;
  • Open source and extensible hardware – The plans of the Arduino boards are published under a Creative Commons license.

  Here are some other Ideas and Projects which can be implemented with Arduino:

  • Home Automation
  • Security Access Using RFID Reader
  • Mini Telegraph
  • Candy Dispenser
  • Table Cleaner Voice Controlled Arduino Robot + WiFi Camera
  • Auto Ultrasonic Car
  • Social websites bot
  • Different small (and not only) robots
Share this article:

Pavel Burlacu
PLC Engineer