Interfacing with industrial PLC and HMI

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
devnull
Posts: 452
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Interfacing with industrial PLC and HMI

Post by devnull » Sat Mar 28, 2020 3:51 am

I know this is a bit off-topic, but hopefully someone here may have direct experience or knowledge about this.

I need to read (not write) cycle and status information from industrial machines, now I know that there are so many different machines and so many different manufacturer and models of PLC.

The data would be received by a microcontroller, probably micropython-based and would then process it, and send it to a web based database application, I dont need help with that part !

I am considering purchasing a PLC for development and testing, of course there are soo many, but I was thinking about the Seimens S7-1200 which is affordable, the STEP7 software is very expensive, although there is a light version only for this device, as well as a 30 day trial version.

I am aware that PLCs use PROFIBUS, MODBUS and ETHERNET for communication, and converting to / from one of these protocols is not what I am trying to understand.

I have also looked at videos about programming Siemens PLCs using the STEP7 software and understand the concept, however I am not looking to control the PLC but only to read relatively simple status / cycle information such as:

- Start Time
- Cycles Completed
- End Time

So given that there are numerous machines and numerous manufacturers of PLCs and numerous models of PLCs, is there any commonality whatsoever in communicating with them and requesting data via say MODBUS ?

Do they all follow a common standard of language / commands such that no matter which you connect to, the data sent and received across the bus would be the same ?

Help from anyone who has experience with this would be very helpful, as at the moment I am still very much in the dark, despite spending several hours googling this subject to try and understand more.

Thanks

VicLuna
Posts: 8
Joined: Fri Sep 13, 2019 8:36 pm

Re: Interfacing with industrial PLC and HMI

Post by VicLuna » Sat Apr 11, 2020 9:13 am

Hi

I can not help you about it, but I should say that I'm interested to this topic too.
How to connect ESPxxxx with PLC.

Regards

rpr
Posts: 82
Joined: Sat Oct 27, 2018 5:17 pm

Re: Interfacing with industrial PLC and HMI

Post by rpr » Sat Apr 11, 2020 3:40 pm

I have been using the Advantech ADAM-xxxx series of PLCs which use modbus. Most of the ones I have used are networked over wired Ethernet so can be accessed by any computer over the network.

They provide Windows GUI and other software and also Linux drivers. But most can be used directly via Python modules such as pymodbus/pymodbustcp etc. I have usually had to use the Windows PC software for initial device setup such as IP addresses, input/output configuration. Sometimes there are specialized functions such as calibration etc which can only be done with the Windows software.

I have not yet tried talking to these over micropython as there is no need since there is always a more powerful workstation. Though there is a possible use case with some of the PLC which are serial or rs485 based. Another situation would be if no wired Ethernet was available at the location.

How do the devices that you are trying to control communicate to provide the information? That would dictate the choice of the PLC module.

User avatar
emtee
Posts: 14
Joined: Thu Jun 14, 2018 4:55 pm
Location: West Kootenay, BC, Canada

Re: Interfacing with industrial PLC and HMI

Post by emtee » Tue Apr 14, 2020 6:29 am

I have over 30 years of Industrial Automation experience and I'll try to answer some of your questions. I'm not sure of your own background and experience so I will assume minimal knowledge of Industrial Automation protocols. I have a lot of years experience with Modbus protocol. Modbus is used by a very wide variety of PLCs, RTUs and other weird and wonderful devices. It is a relatively simple protocol that was established in the late 1970's and early 1980's.

I don't have much experience with PROFIBUS and it is a more complex protocol than Modbus. I would suggest Modbus would be easier to implement in microPython.
devnull wrote:
Sat Mar 28, 2020 3:51 am
I am aware that PLCs use PROFIBUS, MODBUS and ETHERNET for communication, and converting to / from one of these protocols is not what I am trying to understand.
You are mixing communication protocols (PROFIBUS, Modbus) with communication medium (Ethernet).
PROFIBUS and MODBUS specify communications protocols, that is, the sequence of bytes transferred between devices. Additional, PROFIBUS also describes the electrical interface to be used for communications. Both protocols can use a serial connection for communications, typically RS-232, RS-485 and RS-422.

Ethernet is a communications medium. Ethernet does not specify the sequence of bytes to be transferred.

Both PROFIBUS and MODBUS can use Ethernet to connect devices together. With PROFIBUS, the protocol used is PROFINET. Modbus can either be the serial protocol or ModbusTCP.
devnull wrote:
Sat Mar 28, 2020 3:51 am
I have also looked at videos about programming Siemens PLCs using the STEP7 software and understand the concept, however I am not looking to control the PLC but only to read relatively simple status / cycle information such as:

- Start Time
- Cycles Completed
- End Time

So given that there are numerous machines and numerous manufacturers of PLCs and numerous models of PLCs, is there any commonality whatsoever in communicating with them and requesting data via say MODBUS ?
The short answer is "Yes, there is commonality". The Modbus protocol specifies the byte sequences to read data and write data. The specification can be found at modbus.org. The tricky part is determining where the data you wish to read is stored in the device, in your case Start Time, Cycles Completed and End Time. Modbus has the concept to storing data in Registers. For your purpose, the data you wish to read are analog values. The registers for analog values are 16 bit values, either signed (-32,768 to 32,767) or unsigned (0 to 65,535).
The other tricky part is how a value like a Start Time is represented. It could be stored in the number of seconds since Jan 1, 1970 00:00:00 (Unix style) or some other form.
You can think of the Register address as specifying the slot in an array of 16 bit values. Which slot a value like Cycles Completed is stored in is determined by the PLC program. Which brings us to you next question:
devnull wrote:
Sat Mar 28, 2020 3:51 am
Do they all follow a common standard of language / commands such that no matter which you connect to, the data sent and received across the bus would be the same ?
Again, the short answer is "Yes, there is a common standard of language". Most PLCs adhere to the IEC 61131-3 standard. However, each manufacture has their own implementation. Think of the commonality and differences between the programming languages C, C++, C# and Objective-C (I'm assuming you may have some background in programming).

I'll stop here as there is a lot more I could write, but I don't know if what I've said so far makes sense to you.
I'm happy to monitor this discussion and answer any additional questions.
TTFN

Post Reply