DSL
Hello.
 
I program ESP8266 as a Slave device and set up TCP Modbus, like this:
 
Slave.png
 
Modbus is set up correctly and function as it should.
 
Then I load PLC program in Runtime like this:
 
Master.png
 
Slave device is set up as it should, and it works.
 
Now, the idea is simple, to pass values of variable LEDG assigned to %QX0.0 that is on Slave device to variable LED0 on Runtime. I try to access it using their Modbus address %QX100.0 but it does not work. Slave devices execute program on their own, as but
nothing happens on runtime side.
 
To put it simple, I know how to activate Coil or read Contact from Runtime that is on Slave, but, how to read Coil from Runtime that is on Slave, I do not know. Can someone help me, please?
Reply 0 0
thiagoralves
You can’t read coils, only set them. The purpose of a slave device is to serve as an IO expansion. Inputs are read, outputs are set.
Reply 0 0
DSL
So, first bulet: Read discrete output coil (0x01) from https://autonomylogic.com/docs/2-5-modbus-addressing/ as Modbus addressing is not implemented, am I correct?
 
Also, from: https://autonomylogic.com/docs/2-6-slave-devices/ there is a statement: Note: Keep in mind that you can add any logic to this blank project, but if you do, it will supersede the commands received from the OpenPLC Runtime master. This could be useful if, for example, you want to perform fast, real-time tasks locally on the Arduino board (like counting pulses for example), and then have this information available for the bigger OpenPLC Runtime running as master somewhere else. If all you want is to just expand the number of I/O points on your master OpenPLC Runtime, then just leave the project blank.
 
So, how can I: "...and then have this information available for the bigger OpenPLC Runtime running as master somewhere else" can use information from Slave device in bigger OpenPLC Runtime running as a master?
Reply 0 0
thiagoralves
Read discrete coil is implemented as slave, not as master. I.e. you can query an OpenPLC device for its coils. You cannot have an OpenPLC device configured as master to read coils from another slave. As I said previously, the master Modbus on OpenPLC serve only to expand local IOs. In that sense, you only want to read inputs and write to outputs. And that’s what it does, cyclically.
 
Once you attach a slave device, the remote slave’s IO will be mapped to the master OpenPLC on the 100 address space as if they were local IO to the master. You can use the 100s variables on the master program as you would do with any local IO
Reply 0 0
DSL

First, I want to thank you for your fast responses.

Now, I want exactly this:

Once you attach a slave device, the remote slave’s IO will be mapped to the master OpenPLC on the 100 address space as if they were local IO to the master. You can use the 100s variables on the master program as you would do with any local IO

But I do not know how to do this. If I have results of some operation on a slave device that is connected to the master, that result would be normally assigned to a variable in %QX space, or not? Now, that same value is still in %QX space, but looking from master perspective it is in 100s range, so far so good.

 

If I want to write to this variable, been in %QX space, it will work, booth, from slave and from master, but if I want to use state of this variable for further calculations at slave I will just assign this variable by name to a contact element and that contact element will share the state of this variable, basically I am using output value of previous operation as input condition for next operation, nothing special.

 

If I want to use state of this variable, that is located on attached slave and placed in slave local %QX space, let's say %QX0.0 in master their address will be %QX100.0 (assuming it is Slave device 0). I can not assign this variable by name to contact element on master, as I am doing on slave, I can access this variable only by their address, but then you said it is not how it is working.

 

Above, you stated: "and then have this information available for the bigger OpenPLC Runtime running as master somewhere else"

 

So, how exactly I can use state of this variable, located at %QX100.0 for further calculations, on master?

 

Either I can use result from slave in calculation on master or not. If I can, I would like to know how. If I can not, the above statement is not correct. Third option is that I am missing something obvious (most probable option, I think), so can you please explain to me?

 

Have a nice day.

Reply 0 0
thiagoralves
 
As you will see on the video, and as I have said before, the slave device functionality is meant specifically to expand the master's I/O. It is not meant for an "at will" communication between two devices. The idea is that the slave's IOs will then become the master's IOs once the slave is attached to the master, so all calculations must happen on the master itself. If for whatever reason you need to send some information from the slave device to the master, then your only route would be to map one of the slave holding registers as read (you have this configuration on the slave devices configuration page). Then that holding register will be mapped in the %IW100 segment of your master, and will be read only.
Reply 1 0
DSL
Thank you so much.
Reply 0 0
AlexS
Hello, I would like to use a CONTROLINO MAXI as a master (Modbus RTU) with several slaves.
The slave is the physical devices, first such as smartmeter (eastron SDM120M) and the second slave is a smartmeter (SDM72M). The two should be queried cyclically and the value read should be used for further calculations.
I have already watched all the videos and forums on the topic. Unfortunately I can't find a suitable example.
 
Could you please provide an example (program, code) for Modbus communication?  E.g. defining (I/O) variables.
This will help me a lot in the beginning.
I have already integrated one meter into the Arduino. It works. But I would like to continue working with openPLC.
Thanks in advance.
Reply 0 0
thiagoralves
OpenPLC on microcontrollers (which is the case of the Controllino device) does not support Modbus master mode, only slave
Reply 0 0
reccles
Hi, fantastic software, many thanks.
 
I have a project to supervise multiple Modbus Thermostats. These Thermostats can also be locally controlled via their keypads.
For example Setpoint changes, Frost mode etc. The original idea was that the controller would switch ON/OFF a Global Frost mode.
 
[203128%2F8707890%2Fmceclip0]
Proposed system
 
[203128%2F8707869%2Fmceclip0]
example: Modbus address for setting mode.
 
From the comments in this discussion, am I right in my conclusion that this cannot be achieved with the OpenPLC runtime?
Because the code treats the remote I/O as local memory? From a quick test I have found that the runtime will overwrite "Local" Thermostat changes.
Is there a way of disabling writing to the slave address via logic? that can be switched on & off.
 
Many thanks if you can give some comments.....
Reply 0 0
thiagoralves
Yes, attaching slave devices to the runtime will treat them as local memory, so the runtime will keep writing to the slaves cyclically. You could write a PSM driver (Python code that replaces the hardware layer) that can talk to the slaves according to your logic, but that might take too much work.
Reply 1 0
reccles
Hi
 
Thanks, as expected, but needed to check. Writing a PSM driver sounds a bit above my pay grade. 
 
I have had fun refreshing my PLC coding skills.
 
Cheers
 
[203128%2F8708219%2Fmceclip0]
Reply 0 0
reccles
Hi
 
Update, solved the problem by using the HMI as a Master/Slave gateway.
[203128%2F8715212%2Fmceclip0]
 
If anyone needs a similar solution......
The HMI has 2x RS485 ports that can be configured either as a Master or a Slave.
Programmed using "KinsealStudio" (free). Along with the HMI interface this Software can also be used to create C+ code to create events to update external slave devices.
OpenPLC is now collecting all the data from the Thermostats via the HMI, and can update but not over-write the setpoint values via an additional address in HMI.
 
cheers Richard
[203128%2F8708219%2Fmceclip0]
Reply 2 0
Reply