Connect MCU to PLC (via DevicetNet or Ethernet) - Page 1
Forum section: electronics / projects

author: atwoz
author_rank: Regular Contributor
timestamp: August 16, 2013, 04:06:20 am
content: I want to send some data to a AB Compact Logix L33ER PLC from a MCU. The interfaces available are Ethernet, USB and DeviceNet. I have no problem using any of those 3 communication protocols however I have no experience with PLC's. I know they use some ladder logic where you use inputs and outputs and such. I need to send 8 bytes of data from the MCU to the PLC but I don't know how the PLC needs to receive that data.How can you handle some data strings in ladder logic, is that possible?Do I have to use some protocol so that the MCU appears as just inputs/outputs to the PLC?If anyone could point me to the right direction I really would appreciate it.I need to build an Input/output expansion that talks serially to the PLC, and I need 64 inputs. The MCU will read some pins and report their state to the PLC using one of those protocols.Thanks a lot.

author: lgbeno
author_rank: Frequent Contributor
timestamp: August 16, 2013, 04:41:40 am
content: Just curious why you wouldn't buy something off the shelf to do this? If you must, I think that Ethernet might be your best bet. I think that there are blocks in rs logix where you can open a socket and get out data then wire it to io tags.Device net is a proprietary protocol based in CAN. Found one interesting app notehttp://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en012120

author: atwoz
author_rank: Regular Contributor
timestamp: August 16, 2013, 01:39:40 pm
content: Hello. I´m actually thinking about buying one ofthis. That way I would be able to send bit information to the PLC.I know this is the simple way, I just wish there was another way, that way I would save $500 USD.Thanks.

author: lgbeno
author_rank: Frequent Contributor
timestamp: August 17, 2013, 03:14:39 am
content: Yeah I'm sure it can be done, only problem is that you would probably sink more than $500 worth on time into it. I think compact logix does serial too, that could be a realistic option...

author: boz
author_rank: Regular Contributor
timestamp: August 18, 2013, 10:21:35 am
content: I have not used CANBUS but I can give you an example with MODBUS which is a simple challenge response protocol with error check bits which uses RS485 differential serial protocol (MODBUS over ethernet which is basically the same but goes through a serial to ethernet converter, your PLC may support this!).MODBUS is a very simple protocol suitable for 8 bit micros and well documented at modbus.org. In MODBUS your device would provide 64 registers to the PLC which can be read via a MODBUS request, the registers you present can be mapped anywhere in its 0..32000 range you just need to tell the PLC what range you've defined so it can read themThe PLC will issue the MODBUS function 0x04 (Read multiple registers) or 0x03 (read single register) to get the data. You will send the data and a checkbit and echo the 0x03 or 0x04 and thats it!PLCs dont handle floating points or strings well, if your data has decimals then you must use some formula to convert it to an 8 or 16 bit integer, if you have strings this will just be an array of ASCII bytes (No UNICODE).You can also send the data by writing to mapped registers in the PLC.CANBUS may be similar but I dont knowPLC's are smoke and mirrors there is nothing difficult in them, the hardest part is getting the information from the programmer and trying to understand them and their program - Remember they are more likely to be trained an electrician than a programmer and talk relay coils and switches not bits and bytes!

author: nctnico
author_rank: Super Contributor
timestamp: August 18, 2013, 12:44:31 pm
content: Look at the Anybus product range here:http://www.hms.se/The MCU sees a parallel memory interface; the module makes sure the inputs and outputs are processed on the bus.