Introduction: Arduino PLC 32 I/O+State Machine+SCADA or HMI
Many ways to program, to control and to supervise an industrial system with arduino.
Step 1: Introduction
In this instructable I will deal with:
- 2 methods to program an arduino linked to a sort of machine including pusbuttons, switches and LEDs
1- The first method with the arduino 1.6.x IDE using SM library (State Machine)
2-The second method using Yakindu, a state digram editor project created with eclipse environement: you draw your state machine, and it generates the code to transfer to the Arduino board.
In association with
- 2 ways of supervising the the machine with a SCADA or virtual HMI running:
1- under Android 4.4: Unigo Evolution, a free app with no code only items to place on a screen and modbus TCP
2-under Windows 8: a free project AdvancedHMI which needs Visual Studio 2013, no code and items to place on a screen and modbus TCP
So you draw your functional sequences with a SFC (in automation: Sequential Function Chart), you translate it in a state diagram (very closer), you program it (Yakindu or Arduino SM lib) and then you supervise it with a SCADA (Unigo android or AdvancedHMI Windows).
Step 2: Description of the Real Board:
I used an Arduino UNO board, not a clone because Yakindu can't send any program to any clone just UNO and Mega board.
I could have 32 digital I/O with 2 SPI expander like MCP23S17 (2x16 I/O) and 2 more analog 12 bits outputs (real analog not PWM filtered) with 2 SPI DAC like MCP4921.
I didn't draw the ethernet shield but you need it to supervise your system: so pins 4, 10, 11, 12 and 13 must not be used for anything else and obviously pin 0 and 1 for RX TX only.
The real board pics:
8 pushbuttons are necessary:
- 4 for the manual mode : one for light on each led
- 1 for emergency stop: if pushed, you are in normal mode, release: emergency
- 1 for automatic mode which launch the sequential light on and off of each led, if release: manual mode, to control each led with no sequence
- 1 for RUN in automatic mode
- 1 for STOP in automatic mode
4 led to simulate whatever you want (relay, valve...)
I give the name of each buttons and leds I used in the programs.
Step 3: What Sequence to Program? SFC and State Diagram
I made a very simple SFC to describe what the system is supposed to do.
3 SFC are needed:
- SFCsecu to go on or out the emergency mode, it's the master SFC which launches the others
- SFC auto manual launched by SFCsecu, you can reach the automatic mode or the manual mode
- SFC run stop, scanning and memorising if somebody pushed DCY (RUN) or FCY (STOP)
These SFC are running in pseudo-multistaking.
Then I translate them in a state diagram:
- a master machine (Emergency) launching 2 other slaves
- a slave for scanning and memorising DCY and FCY
- a slave to reach the automatic or the manual mode
Another thing: when you push DCY you can pilot the analog output with a virtual trimer on a scada, when you push FCY the analog outputs fall to 0V.
The state diagram helps you to program the arduino.
Step 4: Programing With Arduino IDE 1.6.X
I give you the code to translate the previous diagrams . I needed 3 additionnal libs I give you too.
You will also need the address table to understand what pins you use for what and the modbus registers corresponding addresses.
Step 5: Programing With YAKINDU
First download the free project version 2.9 (not pro) on:
Then follow the supplied tutorial: there are some modifications compared to the last time I download the program, only for the names of different parts of the "xxxconnector.cpp" file to complete.
The pics: the drawing of the state machine, the view of the folder in the project and its imported libraries from arduino, the view of "xxxconnector.cpp" to make link beetween the transitions/the states and the real inputs/outputs of the board or of the SCADAs.
I give you the project you just will have to import in your auto-created workspace.
Also provided: the needed libs to import to Yakindu and some changes to do described in the tutorial.
Step 6: Supervise It With AdvancedHMI
First download Visual studio Express 2013 or more at:
Then download the AdvancedHMI project on:
I give you the pics of the SCADA I drawn (with the corresponding modbus registers addresses) and programed with no code, the project modified and a brief tutorial.
Step 7: Supervise It With Unigo Evolution
You need an android devide with android 4.4 (kit kat) and a 7 inches screen.
I give you the pics of the SCADA I drawn (and the corresponding modbus registers addresses) and a brief tutorial to use Unigo, no code needed, a folder which contains pictures of industrial lights and buttons to put in the UniGOPictures folder created on your internal SD by the app, and the project.
Step 8: Conclusion
It was a huge task to put together 2 different ways of programing and 2 different ways of supervising. It's hard at the begining to be used to each ways skills. But now it works and once understood, you can now control more complicated systems.
Many thanks to a lot of world wide tutorials, to Archie (AdvancedHMI), to RenéB2 (Yakindu) and to Mikael Andersson (Unigo Evolution) and to the arduino libraries developpers who allow me to do such a "technology-storming" project.
Sans eux j'aurais peut être souffert d'un sentiment d'incomplétude infinie pour l'éternité. J'exagère un peu.