If you’ve spent any time on a factory or plant floor, it is a good bet you’ve run into PLCs (Programmable Logic Controllers). These are rugged computers that do simple control and monitoring functions, usually using ladder logic to set their programs. [plc4u] wanted to connect a smart card reader to an Allen Bradley PLC, so he turned to an Arduino to act as a go-between.
The Arduino talks to a USB card reader using a USB host shield. Then it communicates with the PLC using an RS232 link and the DF1 protocol that most Allen Bradley PLCs understand. You may not need a smart card, but once you know how to communicate between an Arduino and the PLC, you could do many different projects that leverage other I/O devices and code available on the Arduino and connects to existing PLC installations. Just remember that you’ll probably need to ruggedize the Arduino a bit to survive and be safe to the same level as a PLC (which might include a NEMA enclosure or even an explosion-proof box).
We’ve covered more than one open source PLC project before. If you want to learn more about the ladder logic PLCs use, there’s a good video on the subject. The video below, however, shows the smart card reader in action.
PLC Photo: By Cmarcante (Own work) [CC BY-SA 3.0], via Wikimedia Commons
I had a similar project about a decade ago for a customer. Instead of using sim cards, it was RFID cards and it read via RS232 directly into the ML1100 (networked version of the one he used). It broke down the hexadecimal into the bits of the 26-bit format and calculated parity to verify a valid card read, all done in ladder logic. It was a fun little project and I’ve done the same thing again, this time into programmable scale terminals. Sounds like this project was just an excuse to tie an arduino into a PLC as I’d bet there are RS232 sim card readers out there…
Good to see some real industrial equipment on here.
Yeah..unless the internet took a dump the world is full of of rs-232 Sim reader/writers.
Satellite hackers predate USB.
I might be more impressed if the Arduino was doing the heavy lifting and no just acting as usb->serial bridge.
Good work on a cheap effective solution that gets the job done but not sure why the author went this route exactly.
I suppose the real feat is programming the plc to do more than monitor sensors and flip switches.
You may want to look into PLC’s a little more.
As a systems engineer for a controls integrator, I applaud this project, very cool.
sorry but PLC’s don’t just do simple control and monitoring – the one pictured is a low end – I have worked on systems that had over 1,000 I/O and did data tracking, bar code reading and some fairly fancy stats and analysis of ongoing real time data analysis and systems that had a dozen or more PLC’s in a network talking to each other.
yes they are ugly in some ways and not very glamorous – but they are designed with safety in mind – have built in watchdog timers so if your program hangs for some reason the whole system turns the outputs off so you don’t have a runaway piece of equipment.
I would never call them simple. Yes some of the systems I worked on only controlled a few I/O, but others were larger with the printouts running thousands of lines of code and the listing several inches thick
>I would never call them simple.
+1!!
Ladder and “Grafcet” (that’s the french word, don’t know the translation…) are simple things when you just barely look at them, but the details of these things and especially the software tools you need to programm a PLC are anything but not simple (and probably very expensive too)!
Grafcet = Sequential function chart (SFC).
I’ve had the idea to use arduinos as cheap I/O for PLCs, but haven’t had any need, since companies don’t like that sort of hacks. Also most industrial fieldbusses require special chips and/or protocol stacks, especially if you want any faster speeds out of them. Of course some RS-232/485 based ascii protocol is easy stuff (especially if the specs are open), but ethernet (except modbus TCP, but that can require to license a library for the PLC side) or CAN based are different beasts.
There are several small PLCs (or smart relays if you will) built from “arduinos” though, with tougher inputs/outputs etc. working with industrial voltages and temperatures. For small jobs i’d rather use any of those than Siemens or Omron or any big player smart relays. Mostly they just use the arduino IDE for programming and i’ve been looking for a graphical programming language for arduinos, and yeah i’ve found them, but most projects seem very slow moving or dead and that sort of thing won’t fly in industrial environment. Useless to use time to do stuff in a language, that dies in a year or 2.
Thanks for the translation!
PLC with enough inputs/outputs can lead to significant saving when it can replace multiple controlers at home.
For example heating (with 1-wire), heatpump, A/C, outside blinds, lights* and others with quite simple ladder logic.
*as for the lights, if on/off is not enough, translators from modbus to dali exist and there are no limits You can do
I would only consider arduino (or msp430 for me) if some translator not readily available is required. Audio control perhaps
Nice to see PLC on hackaday anyway
Ya I don’t know much about PLCs myself no; which I suspect contributed to my puzzlement as to why you wouldent just use $15 Chinese serial iso Sim card reader directly, write the same code for the PLC and skip the Arduino.
Because if the PLC does no support a way to communicate in your own protocols or it costs money to buy a library for that, it just might be cheaper to use an arduino in between. Also that sort of stuff is not fun to write in LAD or FBD or SFC, and ST might not be a supported option. I once had a project where the serial communication was half way done in ladder and i threw it out and did it in ST, since it’s horrible to do stuff like that in ladder.
The PLC banged up to the arduino is a old but reliable beast, but it most likely is limited in functionality except for what it’s originally designed for.
It’s from the age where the term “do one thing and do it well” reigned supreme, unlike modern PLC’s which has just as many tricks up their sleeves as modern microcontrollers.
So while it MIGHT be plausible to interface a card reader directly with it, it would be more time consuming (and therefore expensive) than abusing a arduino as a lowly translator.
It seems pretty obvious that he used an arduino because the PLC lacked a general purpose RS232 port. The port he is using in the video only speaks DF1 protocol. Some PLCs can have RS232 add-on cards, but they are much more expensive than an arduino.
That being said, it seems like making a RS232 -> DF1 converter would be easier than USB -> DF1, but sometimes you want to make things work with what you have. This is why we call it hacking.
In a way it’s an impressive hack, getting the Arduino to convert to the specific and special protocol and avoiding having to find some obscure reader and adapter that AB sells and requires a support contract to find.
Ruggedizing the Arduino a bit for industrial environments doesn’t really just stop at a fancy case, you’d need wiring changes and input protection and other such features to keep it from being damaged or confused by noise, or destroying the signal on any of the cables with noise , or other problems that you’ll see industrial gear have unique solutions for. The programming cable for my PLC has an extra wire coming from the connector that gets put to the PLC frame ground just for noise suppression, for example.
Seeing industrial gear get coverage is nice, however it would be nicer if someone who was really familiar with industrial gear did the articles, as it seems PLCs are something you guys just aren’t used to or think as highly of as a Pi or arduino.
Hmm… actually I spent many years on chemical plant floors with DCSs, PLCs, and the like (granted a few years ago with HP1000s, TDC2000/3000, Applied Automation, etc.). Yeah I oversimplified what it takes to cram a board into that environment although I still have some boards sitting in Hoffman enclosures on poles in some very unlikely places. But I don’t think you can really judge what I know about PLCs by one write up about someone else’s’ project any more than I can judge your expertise by one blog comment post. My guess is that no one is going to just put an Arudino in a zip lock bag and get approval to stick it out on the floor.
That’s pretty neat but I wouldn’t trust it on the factory floor. This is why we put the card reader at the HMI and use software to send the data to the PLC. However for the Controllogix platform (first picture) you can get modules that do RFID. We used them for a client when Walmart started pushing for RFID being attached to everything.
Not sure if it exists for Micrologix platform (in the video) as that’s more of a single purpose PLC. The Micrologix is somewhat limited and not as expandable. Think of it running a single machine in your plant VS the Controllogix which can run the entire plant.
That arduino needs to run flawlessly 24/7 365 in a typically noisy environment. Plus we almost never use 12 volts. 24 VDC or 110 VAC are normal for control signals. Most equipment runs 110, 230 or 480 VAC.
Industruino anyone ?
The USB to DF1 conversion is very cool. It allows the PLC to receive the card data directly into a high level tag, variable, which may then be used in the high level ladder, structured text or other IEC 61131-3 language used on the PLC. The Allen Bradley ControlLogix RS232 port does support ASCII for use with legacy barcode readers, weigh scales and other simple serial devices. Next, I’d like to see an Arduino tasked to act as an ODVA compliant Ethernet/IP server. The PLC could the scan the Arduino as I/O or message explicitly.
Hi, how do you link arduino with PLC? please can you send me the library of arduino?