Qaseem
Hi there,
I encounter two problems in OpenPLC webserver:
1. the actuator(LED at QX0.0) does not appear in the monitoring tab?
2. when I run the program in the browser, I got an internal server error but when go back I found the program is running. I installed the new version of OpenPLC but still, I encounter this problem.

Thanks
Quote 0 0
Qaseem
I run the attached simple program that reads a single digital input from a slave using Modbus TCP. First, I defined the slave in OpenPLC webserver. A slave is ModbusServerPro simulation running on my laptop. However, when I tried to run the program, I don't see the openPLC reads the actual value it always reads 0. I dumped the network as you see in third photo it received 1. Why does the openPLC read 0 instead of the actual value and what should I do to let the OpenPLC read the actual value?

Lastly, I am planning to replace the simulation with a Modbus slave script (using python3 and pymodbus) and would like to read an integer value. Should I use %IW0 or MW0? and what type of encoding should the slave use to encode the int number in a way that can be read by OpenPLC ? Should I add any statement to the custom layer to decode the received value?

Many thanks,
Quote 0 0
thiagoralves
Qaseem wrote:
Hi there,
I encounter two problems in OpenPLC webserver:
1. the actuator(LED at QX0.0) does not appear in the monitoring tab?
2. when I run the program in the browser, I got an internal server error but when go back I found the program is running. I installed the new version of OpenPLC but still, I encounter this problem.

Thanks

Can you post the program that is causing this error? If you’re getting errors when you start the runtime, it might be a bad hardware driver configuration. You can try stopping OpenPLC service with

sudo systemctl stop openplc 

and then start OpenPLC manually by running ./ start_openplc.sh from the OpenPLC_v3 folder. Then start the runtime again and check on terminal if you get any errors. Then post the errors here to help us understand what might be wrong.
Quote 0 0
thiagoralves
Qaseem wrote:
1. Why does the openPLC read 0 instead of the actual value

Because you’re using the wrong address in your program. If you check the documentation on the OpenPLC project website about slave devices, you will see that slave devices attach to address 100 and above (i.e. %QX100.0). You can see the exact location your slave is attached on the slave devices page.
Qaseem wrote:
and what should I do to let the OpenPLC read the actual value?

Use the correct address.
Qaseem wrote:

Lastly, I am planning to replace the simulation with a Modbus slave script (using python3 and pymodbus) and would like to read an integer value. Should I use %IW0 or MW0? 

Neither of those. If you’re reading an analog input (Modbus Input Register) then it will be %IW100 and up. You can also read Modbus registers (Modbus Holding Register) if you add them to the read section of your slave device configuration and they will also show up as %IW100 and up.
Qaseem wrote:
what type of encoding should the slave use to encode the int number in a way that can be read by OpenPLC ? Should I add any statement to the custom layer to decode the received value?

There is no encoding necessary. Modbus is a dead simple protocol. All registers are pure 16-bit numbers, not encoded in any format. If you’re using pymodbus, it will know what to do. You just have to provide the integer you want to send to pymodbus.
Quote 0 0
Qaseem
Many thanks for your response. The OpenPLC can now read the value. I was confusing the range % IX0.0 - % IX99.7 appears in the  Modbus Address Mapping page but I applied your correction(%IX100) for digital input and
(%IW100) for an Input Register and both work with the Modbus simulation(ModbusServerPro).  I will use pymodbus server version and test these registers.
Quote 0 0
Qaseem
With regard to the monitoring page, please find attached screenshots for the error that appears after I run the program, the settings I chose for the hardware and the webserver and the program that I am running. Thanks in advance!
Quote 0 0
thiagoralves
Did you write this program manually (like in notepad or some code editor) or was it generated by OpenPLC Editor? Just because it looks out of the format for variable declaration, hence why the parser is having trouble to parse it. There should be a space between the ':' and your variable type like this:
Testvar AT %IW100 : INT;

If this code was automatically generated by OpenPLC Editor, I will have to take a look at that, because it is generating wrong code. If this was created by you manually, then just add a space after %IW100 and %QX0.0 and the error will go away.
Quote 0 0
Qaseem

Oops!  I did! I was thinking I can change this simple code but never thought that it would cost me days of thinking about the monitoring issues! Thanks for this lesson and I appreciate your response.
Quote 0 0