FutureHorizon
 
I'm testing OpenPLC interfacing with different devices and I'm trying to establish a Modbus RTU reading of an RTD slave device with 8 RTD channels.
I don't see a Modbus RTU option under Remote devices, so how do I work with RTU devices in version 4?
 
Do I need to use Python and put the data in a shared memory or how is this thought to be accomplished?
 
I'm doing a lot of testing to see what is possible and how, great fun :-)
 
I'm using the runtime v4 and a usb-RS485 converter installed on linux (not in Docker).
Reply 0 0
Write a reply...
FutureHorizon
Sorry, this was put in bug reports by mistake...
Reply 0 0
thiagoralves
Make sure you’re using the latest version of the editor and runtime. Then after adding a Modbus device you can pick TCP or RTU on the configuration
Reply 0 0
FutureHorizon
I'm using editor 4.1.2, runtime from a week ago. Under remote devices I can only add a Modbus TCP device.
If I select it I don't get an option to enable RTU
[203128%2F9670903%2Fmceclip0]
Reply 0 0
FutureHorizon
[203128%2F9670906%2Fmceclip0]
Reply 0 0
thiagoralves
Make sure you’re using the latest version of the editor and runtime. Then after adding a Modbus device you can pick TCP or RTU on the configuration
“Then after adding a Modbus device you can pick TCP or RTU on the configuration”
Reply 0 0
FutureHorizon
I'm sorry, I was actually using 4.1.1 !
Somehow I opened the wrong version! I see that option now!
Reply 1 0
FutureHorizon
I believe I have everything set up correctly, but the serial bus is not communicating.
I don't have an option to enable modbus RTU in the configuration tab.
[203128%2F9670914%2Fmceclip0]
 
[203128%2F9670915%2Fmceclip0]
Reply 0 0
FutureHorizon
I get this hint from the console output, but I don't see what configuration is missing?
 
Modbus RTU device "RTDs" is missing a serial port configuration and will be skipped.
Modbus RTU device "RTDs" is missing a serial port configuration and will be skipped.
Modbus RTU device "RTDs" is missing a serial port configuration and will be skipped.
Modbus RTU device "RTDs" is missing a serial port configuration and will be skipped.
Modbus RTU device "RTDs" is missing a serial port configuration and will be skipped.
[14462:0208/151438.707333:ERROR:atom_cache.cc(230)] Add chromium/x-internal-source-rfh-token to kAto
msToCache
Modbus RTU device "RTDs" is missing a serial port configuration and will be skipped.
Modbus RTU device "RTDs" is missing a serial port configuration and will be skipped.
[14462:0208/152559.412047:ERROR:atom_cache.cc(230)] Add chromium/from-privileged to kAtomsToCache

Reply 0 0
FutureHorizon
Serial bus is running!
Reply 1 0
FutureHorizon
I'm trying to convert the real registers to real values and I created a FB that does this. But I cannot add a word to a dword and I also cannot convert word to dword, as there is not word_to_dword type caster.
I am not able to do:
 
ch1_union_in : DWORD;
CH1_L : WORD;
CH1_H : WORD;
 
ch1_dword := SHL(CH1_H, 16) + CH1_L;
ch1_real := DWORD_TO_REAL(ch1_dword);
 
I get output:
 
[08-02-26 16:46:20]: iec2c process exited with code 1

[08-02-26 16:46:20]: /home/service/PLC projects/RTDModbusRTU/build/OpenPLC Runtime v4/src/program.st:27-19..27-38: error: Data type mismatch for '+' expression.

[08-02-26 16:46:20]: 27 | ch1_union_in := ch1_union_in + Ch1_L;

[08-02-26 16:46:20]: | ^~~~~~~~~~~~~~~~~~~~

[08-02-26 16:46:20]: 1 error(s) found. Bailing out!

[08-02-26 16:46:20]: Stopping compilation process.

How do I work around this or how do you usually convert modbus registers to reals?

Reply 0 0
FutureHorizon
I also don't find unions in the user defined data types, is it possible to have it included? It's very useful for data conversions.
Reply 0 0
FutureHorizon
Perhaps if I could use %MD memory and set a group to start in this area? Is this possible?
Reply 0 0
thiagoralves
Union is not part of the IEC standard. You can use your SHL technique to join two WORDs in a DWORD, you just need to convert the WORDs to DWORD before you cal SHL due to the strict type enforcement of IEC languages. However, converting DWORD to REAL later will only convert the integer numerical part stored in the DWORD. IEC conversions are true conversions, not typecasts. I believe the easiest way to do that is through a C/C++ function block.
Reply 0 0
FutureHorizon
Yes, it's not a straight forward solution. Is this also why use of %MD is not implemented in the modbus client?
It would be nice to just read the values as reals and no have to deal with all the word juggling.
Reply 0 0
Write a reply...
Reply