Introduction: Arduino-tomation Part 1

Picture of Arduino-tomation Part 1

I recently got a small industrial machine which makes little cars toys. This machine is supplied with pneumatic energy (10 BARS) and electrical energy. So I decided to pilot the process with a micro-controller but it's not really an industrial solution. The reasons for pros and the cons on this french site:

http://www.automation-sense.com/blog/automatisme/d...

and this one:

www.linkedin.com/pulse/plc-vs-arduino-assem-zakari...

The process will be controlled by a special adaptator of my own on which you will be able to connect an Arduino Uno board or an Arduino Mega board (soon in the part 2). The adaptor also includes a possible Atmega644p-1284p connection (clone of arduino board, see one of my past instructables projects). Another skill of the project: to be controlled over ethernet with a cheap Ethernet Shield on a special industrial communication protocol (Modbus TCP).

Step 1: The Machine to Repare and Adapt: Before/after

Picture of The Machine to Repare and Adapt: Before/after

This machine called "MAJORICC" is made of 4 parts:

1- to transfer the pieces

2- to put wheels on it

3- to cover the car

4- to make it crimped

This machine needs about 20 sensors/buttons (digital) and about 12 lights/actuators (digital) to control the process. So the arduino is very limited in I/O. So I decided to exploit this micro-controller at his maximum capabilities in disigning an adaptor including 12 digital inputs and 8 digital outputs.

About the security:

-emergency stop to switch off the power on the pneumatic actuators and to initialise the program in the microcontroller

-a special valve to switch off the pressure on the actuators

-a "real desk" with switches/buttons/lights allows you to control the machine in 2 ways: manually and automatically. The virtual control desk will DO NOT include the emergency stop button because it's not safe.

I give the electrical/pneumatic schematic of the system and the electronical schema of the PCB adaptator.

Step 2: Some Things About the PCB Adaptator and the Ways to Control a Process

This PCB will be connected with an Arduino Uno board (programed via USB) or include an Arduino 644p/1284p (programed via USBasp).

The table presents the different links beetween the sensors/buttons/lights/actuators and the digital I/O of the micro-controllers.

To program and to control the process, 3 ways are available (see the comparative solutions):

- the Ladder programing, a language well known in automation and respecting the IEC61131 norm.

-the SFC progaming (grafcet in french), a language to discribe the desired sequences of the process, you can transform to ladder by a special method and respecting the IEC61131 norm.

-the State machine programing in C or by a GUI, seems like a SFC with some difference on the formalism and respecting the SYSML or UML2 rules.

So many methods and many ways to transfer the program to the microcontroller: USB/USBasp/hex files/ino files.

Step 3: First Way: SFC and Ladder Programing

Picture of First Way: SFC and Ladder Programing

I will take a very simple example:

-a rising edge on DCY , the actuator T is push out

-another rising edge on DCY, the actuator T is pulled in

-if emergency stop is pushed: the power and the pressure are off, the program is initialized.

You need to draw the sequence (SFC) and then convert it to a ladder program. What is SFC or Grafcet ? Here..

https://en.wikipedia.org/wiki/Sequential_function_...

https://fr.wikipedia.org/wiki/Grafcet

The method is explained here:

http://docslide.fr/documents/api-du-grafcet-au-lad...

To implement the code I used LDmicro 4.1.2: you draw, it compiles a hex file and the you transfer it to

-Arduino Uno board with USB and Xloader

-or to Arduino clone644p/1284p with USBasp and Khazama Avr

I give you LDmicro, Xloader and KhazamaAVR

I give you too the source programs for Uno board and clone boards on LDmicro.

Step 4: Second Ways: the State Diagram Programing (no GUI), a SFC Evolution

Picture of Second Ways: the State Diagram Programing (no GUI), a SFC Evolution

SFC and State Diagram are very similar. To upload a state machine in the micro-controller we will use the arduino IDE 1.6.5 for the Uno board (and USB) and an arduino 1.0.5 with atmegas 644p/1284p (Sanguino Board embedded, see one of my instructables).

The program has no GUI: only C code and you 'll need a special library: SM library which allows you a complete execution of state machine (concurent states, run/stop on states...).

One thing for arduino clone644p/1284p: the I/O 18-19-20-21 have been modified in the script I provide, you must disable the JTAG mode. This microcontroller is able to control 32 I/O, so It can run the process.

The arduino uno is not able to control all the process.

In the next part, if you want to use an ethernet shield, 4 I/O can not be use anymore (SPI bus dedicated to WIZNET5100).

The comments in thes scripts are sometimes in french (sorry).

I tried to have exactly the same sequence and running like in the ladder part.

Step 5: Second Way: the State Diagram (no GUI) With HMI and Ethernet Shield.

Picture of Second Way: the State Diagram (no GUI) With HMI and Ethernet Shield.

If you connect an ethernet shield on the boards, you can't use some pins anymore as I/O. These pins are needed for the SPI bus (comments in the source programs).

You will need to add a special library: Mudbus, to control the MODBUS tcp communication (see one of my Instructable article).

The HMI is free and available on the SourceForge. I gave the source. If you push one time a button, actuator T is out, another time, actuatorT is in. The emergency stop is programed in the microcontroller, not on the HMI.

I give you the source code for Uno and clone644p/1284p.

Step 6: Third Way: a State Diagram (with GUI and Not So Much Code), YAKINDU V3.0

Picture of Third Way: a State Diagram (with GUI and Not So Much Code), YAKINDU V3.0

I discovered this freeware owing to René B2, one of the developpers who give good advices.

This freeware allow you to design and draw a state machine (SFC like) you can directly download to the micro-controller. At this time YAKINDU can only download to Arduino Uno and Mega board and others but not to my Arduino clone via USBasp.

I give a tutorial to install YAKINDU on your PC. No need to have Eclipse. I use 2 versions: V3.0 on 64 bits and V2.9 on 32 bits.

The most difficult things was to include library in the software. Now it's done.

I give 2 project source code to import to your YAKINDU workspace.

Some usefull websites:

https://www.itemis.com/en/yakindu/statechart-tools...

https://wendehals.github.io/arduino_sct_tools/

Step 7: To Conclude:

To control this system Arduino Uno have not enough I/O. You can use an SPI I/O expander but you need a special library for the IC MCP23S17: the programing solution is arduino IDE+SM lib or Yakindu.

To control this system Arduino clone644p/1284p have just enough I/O: LDmicro is sufficient. But you can use an SPI I/O expander and it will need too a special library for the IC MCP23S17: the programing solution is arduino IDE+SM lib or Yakindu.

Keep in mind that If you want to use an ethernet HMI, you will loose 4 I/0.

In the part 2, I will experiment a new PCB including 20 digital inputs and 12 digital outputs. I will use arduino clone644p/1284p and Arduino Mega board (the best solution) both solution connected with an ethernet shield.

Thanx to all interesting and working tutorial and to RenéB2 who ignite the project.

Comments