tobby
After seeing some demo of openPLC communicating with Factory IO(video below), I have interest in Modbus TCP between esp32 and Factory IO. The scenario will be similar with the video to read DI of factory IO and write output to DO of factory IO. However, with setting below(Fig.1,2,3), it seems to be nonworkable. Is there any suggestion for the setting or limitation? I'm grateful for your suggestion!
 
 
 
 
Fig.1
[203128%2F8737321%2Fmceclip0]
 
Fig.2
[203128%2F8737317%2Fmceclip0]
 
 
 Fig.3
[203128%2F8737315%2Fmceclip0]
thiagoralves
You enabled a Modbus server on both ends. One of them must be the client. On ESP32, OpenPLC only supports Modbus server. So you must configure your Factory IO to act as a client (Modbus master) and read / write the I/O locations of the ESP32. The main catch with this approach is that Modbus does not allow a client to write to inputs. So you will have to convert all your variables to %QX, %QW to be able to write to all of them from Factory IO.
Reply 1 0
tobby
1. You mean I need to config Factory IO to Modbus client in order to read inputs or coils?
2. It means that I should replace %IX0.1 with %QX0.1, too?
Reply 1 0
thiagoralves
1. Yes
2. Yes
Reply 1 0
renn146
I am having the same issue here. Could you explain how did you solve it?
I tried replacing the %IX for %QX, but I can't get the code to work properly.
Reply 0 0
thiagoralves
Start by replacing the Modbus server on Factory IO with a Modbus client. Then on OpenPLC upload dialog, make sure you have enabled Modbus TCP and upload your code to the ESP32. Make sure all your variables are in QX / QW locations. Power is still at an %IX location.
Reply 0 0
renn146
Thank you in advance for helping me Thiago.

I have already configured the FactoryIO as a Modbus Client. I also enabled the Modbus TCP and uploaded the code to the ESP32. The connection between FactoryIO and ESP32 is working. The problem is during the execution of the Ladder.

Expectation: when I press the Start Button (normally as %I0.0) it sets the Power (coveyor) and when I press the Stop Button (NC) it should reset the Power.
Reality: the coveyor only activates if I hold down the Start Button.

My doubt is what I should change to achieve the "expectation". Which location I should use for Power, since the "inputs" are in %QX0.0 and %QX0.1.
Reply 0 0
thiagoralves
If the conveyor is moving, then your problem is not on the connection with Factory IO. Instead, most likely the problem is in your code.
Reply 0 0
renn146
Exactly.
I am just having trouble in figuring out which changes I must do to fix the execution. Using the Start button as %QX0.0, Stop button (NC) as %QX0.1 and the the SET and RESET coils for Power (coveyor) as %QX0.2 is not working.

Is there anyway I can configure the OpenPLC Runtime in the ESP32 just like we can do on Windows or Linux (via localhost:8080). Because if so, I could just connect the FactoryIO as a slave to the ESP32 Runtime and I would not have this problem with Modbus Client?!
Reply 0 0
thiagoralves
As I said before, your problem is not on the connection. That's already working. The problem is in your ladder logic code. Your code is wrong, so it doesn't behave the way you wanted it to behave.
 
I took a look at your picture a few posts above. If you're using the same code, then it looks like that's wrong. Your NC stop contact is constantly resetting the Power coil. Unless your stop input is inverted (logic high when you're not pressing it). In that case, maybe the location of your stop coil is set incorrectly, so it is not reading the stop signal properly. Make sure you're using Modbus coil 1 on Factory IO (OpenPLC %QX0.1).
Reply 0 0
renn146
I tried removing the Stop Button and testing only the Start, but nothing changed:

4.png

I also tried setting the own start, but it had the same output:

1.png

When holding down Start:

2.png

After releaising Start:

3.png

Also, in every case I tested, when adressing the Power as %QX, nothing happens in both OpenPLC Editor and FactoryIO:

5.png

Only "works" (activate) when it adress' is with %IX:

6.png

Basically, SET and RESET are not working for some reason I can't figure out.

Reply 0 0
thiagoralves
Coils map to %QX. Inputs map to %IX. You must use Coils for everything on Factory IO, so that you can use %QX for everything on OpenPLC. Also, your Factory IO sensor is on Coil 2, that's %QX0.2 on OpenPLC, not %QX0.1.
Reply 0 0
renn146
I was not using the sensor, so it did do no diference being in Coil 2. My %QX0.1 was a Stop Button, that I removed only to test your suggestion from your previous comment.

I tried using only coils but still nothing changes. SET and RESET seems to not be working.

Is there anyway I can access the runtime monitor in the ESP32?
Reply 0 0
thiagoralves
No, there is no way to access the runtime monitor on the ESP32 as you can on the Windows / Linux runtime because it does not exist on the ESP32. That runtime is for Linux and Windows targets. The ESP32 runtime does not have a webserver like that, neither Modbus master functionality.
 
On the ladder program, SET and RESET work just fine. Make sure you're not trying to SET or RESET a variable that is being controlled by Factory IO (like setting or resetting Start itself). If Factory IO is writing to that variable constantly, it could mess up the variable value. Make sure you understand the difference between inputs and outputs on Factory IO. You can use Coils for both inputs AND outputs, but Factory IO will WRITE to inputs (sensors, buttons, etc), and READ from outputs (actuators, conveyors, etc).
 
Also, the way that the debugger works is tied to the inputs you're receiving. Just because you don't see the green lines activating the SET instruction it doesn't mean that the variable hasn't been set. Click on the glasses icon to explore the actual value of the variable being set and you will see that it is being activated as it should. Take a look at this sequence of screenshots. I'm running this on an actual ESP32 target, and using Radzio RMMS to trigger the coils just like Factory IO would:
 
Screenshot 2024-09-09 at 1.25.06 PM.png
 
Screenshot 2024-09-09 at 1.26.06 PM.png
 
Screenshot 2024-09-09 at 1.26.16 PM.png
 
Screenshot 2024-09-09 at 1.26.32 PM.png
 
Screenshot 2024-09-09 at 1.26.41 PM.png
 
As you can see, local_var is being set and reset just fine. I believe you're mixing things up and having weird configurations between Factory IO and OpenPLC. As I said before, make sure you're using Coils for EVERYTHING on the Factory IO side, including the conveyor belt. Then on OpenPLC side, just use %QX variables for the stuff you want to be connected with the Factory IO coils.
Reply 0 0
renn146
Understood.
These tips really clarified my mind. I'll run new tests here and then come back with feedback.
Thank you very much

Best regards from Brazil
Reply 0 0
Reply