Arduino & PLC comms....

Has anyone any experiance in hooking up a PLC to an arduino?

Im working on a project and would like to do this to save on some serious circuit building? Ive had a look around but cant seem to find any information on this.

Any help would be greatly appreciated.

VR

Well it’s certainly possible because a Arduino has serial communications capablities. The typical PLC comm link uses MODBUS protocol which can be either used in a binary mode or a ASCII mode.

However many details would be required as every PLC model is pretty unique. Also most PLC require a proprietary software package to program the PLC and they can be quite costly as it’s an industrial based product.

So while it’s possible there may be better cheaper ways to accomplish PLC like tasks directly from an Arduino. Perhaps you just want the Arduino to be a user interface to an existing PLC system? More details might get you better ideas.

Lefty

My background is from industrial PLC programming and im SLOWLY getting to grips with programming the Arduino.

I have the arduino getting all the analog input data from the sensors and using the PWM to control cooling fan speeds and lighting but i wanted to interface the arduino to a PLC so i could use the relay and timer functions very easily, and then have all the data outputted on a touch screen HMI.

Here is the PLC im looking at:

http://web4.automationdirect.com/adc/Overview/Catalog/Programmable_Controllers/CLICK_Series_PLCs_(Stackable_Micro_Brick)

And the HMI:

http://web4.automationdirect.com/adc/Overview/Catalog/Operator_Interfaces/C-more_Micro-Graphic_Panels/C-more_Micro-Graphic_Panels_-a-Keypad_Bezels(3_inch_only)

The PLC doesnt have enough analog IO and PWM so i wanted to use the arduino with all the code i have made so far. Do you think i will be able to communicate back and forth and have the data go from the arduino, through the PLC and be displayed on the HMI???

I know the PLC can accept RS232 so i just was wondering if the arduino would work with it???

Do you think i will be able to communicate back and forth and have the data go from the arduino, through the PLC and be displayed on the HMI???

I know the PLC can accept RS232 so i just was wondering if the arduino would work with it???

Yes, it’s certainly doable. The Arduino would have to be the modbus master and the PLC the slave. The Arduion would have to send it’s values to the PLC and if applical be displayed on the HMI and the Arduino can request any data the PLC has from it’s input, outputs and function blocks.

You will have to understand the modbus serial protocol, be able to send and receive CRC error detection and know the PLC addresses for the variables you wish to get from or send to the PLC. There are lots of modbus protocol C libraries on the web and shouldn’t be too hard to convert them to the Arduino.

If your PLC can handle standard RS-232 voltage levels then all you would need is a MAX232 type voltage convertor to convert the Arduino’s TTL level serial data to RS-232 voltage levels, that part is pretty simple, one chip.
Lefty

In my previous life in Industrial Process Control I used Allen Bradley PLCs in just such a manner, interfaced with some specialized instruments. The AB units had simple serial in and out instructions which could be used to write and read PLC memory blocks and registers.

That was over 15 years ago. I’m sure that modern PLCs have much more capable serial I/O now.

I used a few rungs at the top to initialize, similar to what is show below (remember this was 15 years ago).
The parts in braces { } were actually quite a bit more complicated than what is shown, so consider them to be macros.

|                                        |
*----]/[---*-------{SERIAL WRITE MEM A}--*
|  CONFIG  |                             |
|          |                             |
|          *---]/[------------------( )--*
|             TIMER 1             CONFIG |
|                                        |
|                                        |
|                                        |
*--] [----]/[-*-----{SERIAL READ MEM B)--*
| CONFIG   RUN|                          |
|             |                          |
|             *-{COMPARE A=B}-------( )--*
|             |                     STRT |
|             |                          |
|             *-------[TIMER 1 TD ON 1]--*
|                                        |
|                                        |
|                                        |
*---] [----------*------------------( )--*
|   STRT         |                  RUN  |
|                |                       |
*---] [----------*                       |
|   RUN                                  |
|                                        |
|                                        |
*----]/[----------------------[RESTART]--*
|    RUN                                 |
|                                        |
... main body of the program

Even though im quite a novice at programming both PLC’s and Arduinos, do you think im trying to bite off more than i can chew?

Purchasing a $70 PLC is not too big of a deal, but im wondering how much head scratching will be involved. Ive done alot of research on the internet and there is nothing out there specific to Arduino PLC interfacing.

VR

Ive done alot of research on the internet and there is nothing out there specific to Arduino PLC interfacing.

That’s because you are probably the first to do it :slight_smile: Actually you are not bitting off too much really. It’s just learning about the serial communications needed for your C based Arduino sketch to talk to your PLC software. There will certainly be a learning curve for you and you should start simple, say learn to make the Arduino blink a light that is wired to your PLC’s output. Then learn to read a PLC input into your Arduino, etc etc. You will have to spend some time learning the PLC software and learning how to set it up, etc etc.

It sounds like a fun project, get to it already :wink:

Lefty

Thanks Lefty,

That sounds like a good idea. Im not going to be doing too much complex comms, more like using the arduino for the analogue and PWM functions, using the PLC for all the timer and relay functions and then have both of them outputted to the Touch screen HMI for real time displaying and number inputting for parameter changing.

VR