Elliot
According to the documents, the hardware layer is responsible to update openplc buffers and handles the inputs/outputs. When I use the webserver runtime, I just upload a simple PLC program and select a BLANK hardware layer (which seems do nothing according to the code), and the program works properly just as what I've designed (but I expected it to fail since the hardware layer is blank).
So do I go wrong somehow? Or do I misunderstand the usage of hardware layer?
Hope someone can help me with my confusion.
Thanks a lot!
Reply 0 0
thiagoralves
The hardware layer is the module responsible for bridging your PLC code and your hardware. A blank hardware layer will just do nothing with the hardware, but it doesn’t mean that your program won’t run
Reply 0 0
Elliot
@thiagoralves Thank you for your reply!
I use a modbus slave device and the output on the device is just  what I wrote in the program, so I guess the modbus device input and output is another path apart from the hardware layer .cpp files? Since I use a blank hardware layer and I supposed to get no output on hardware.
Reply 0 0
thiagoralves
Yes, a slave device is, well, a slave device, handled by the Modbus module. The hardware layer will handle local IO points
Reply 0 0
Elliot
So the initializing of slave device is also handled by the Modbus modules right? since the doc mentioned that we need upload a dummy program to slave devices.
But when I read the source code, I couldn't find the corresponding code for slave devices. Could you please tell me some details?
Reply 0 0
thiagoralves
You need to upload a dummy program to Arduino boards so that they can become slave devices. By itself, an Arduino board is just an Arduino board, that from factory blinks the built in LED. It doesn’t know how to be a Modbus slave device. If you buy any industrial Modbus slave device it will work out of the box with OpenPLC, no programming or dummy program required.

This dummy program comes with the OpenPLC runtime for microcontrollers, which gives the Arduino board the ability to talk over Modbus and act as a slave device of another OpenPLC runtime master.
Reply 0 0
Elliot
So the running code in slave devices is the same as the master? How do the slave KNOW it's the slave and response to the master's modbus request?
Reply 0 0
thiagoralves
Of course not, the code that runs on the slave is its own, unless you program it with the same program as your master.

I guess you’re missing some basic definitions here. What makes a device slave or master is merely its position in the SCADA architecture you build. Any (or most) PLC can be set as slave, master or even both at the same time.

Some devices act, as we like to call them, as “dumb slaves”. This means that they don’t run any code on them, just obey whatever I/O commands they receive from the master. They’re most used as I/O expansions. Uploading a blank program to the arduino board essentially transforms it into a dumb slave, as it will not run any PLC code, but has the OpenPLC runtime that will allow it to respond to Modbus requests as a slave device
Reply 0 0
Reply