Loque101
So I'm doing some tests triggering the program on my OPLC Runtime over Modbus. I have a holding register value (%MW0) that is being converted to a boolean control bit in my program. The bit is being used as a switch to enable a blinking output (%QX0.0). Using an Ignition gateway to send a value of either 1 or 0 to the holding register, which should in turn activate and deactivate the control bit. When I simulate this very simple program in OPLC Editor, it works with no issue. I can force a value other than 0 into the holding register tag and my output blinks. I don't have (or shouldn't have) anything over Modbus that would be overriding that output coil. Is there something I'm missing?

OPLC_EditorProgram.png OPLC_RuntimeMonitor.png 
Reply 0 0
thiagoralves
There could be other issues on this that I can't tell without the full program. For example, I don't know if the ao_BlinkSpeed = 0 would affect the output, or if the UINT_TO_BOOL is effectively converting the value as you expect. To be on the safe side, I would replace the UINT_TO_BOOL with a GE block. If mi_Start_BitWord is greater than or equal to 1, then the Blinker coil is activated.
Reply 0 0
Loque101
So what I have in that first screenshot is the entire program. ao_BlinkSpeed isn't being used yet, only do_BlinkingOut and mi_Start_BitWord. But that's a good idea, I'll swap it and see if that fixes the issue. I mostly just wanted to see if I could come up with a way to simulate having discrete inputs since Modbus can't write to them and I don't have any actual hardware I/O devices. So if I can fake it with some holding registers and an HMI, great lol.
Reply 0 0
thiagoralves
Well, in that case it will be much simpler for you to use modbus and write to discrete outputs that you're not using or that are not physically present on your board. For example, if your runtime is running on a Raspberry Pi, the location %QX1.3 does not exist physically on the board, but exists internally on OpenPLC buffers. You can use this location as memory and put on whatever logic you want associated with that. %QX1.3 is accessible through modbus on coil address 11.
Reply 0 0
Loque101
Ahhh, I didn't consider just using discrete outputs to trigger things. That will definitely be easier. It looks like the age old solution of reinstalling the software seemed to do the trick though lol. I guess yesterday I hadn't noticed that I was getting this error when loading the program in:

Optimizing ST program...
Generating C files...
POUS.c
POUS.h
LOCATED_VARIABLES.h
VARIABLES.csv
Config0.c
Config0.h
Res0.c
Moving Files...
Compiling for Raspberry Pi
Generating object files...
Generating glueVars...
varName: __QX0_0 varType: BOOL
varName: __QX0_1 varType: BOOL
Compiling main program...
Package libmodbus was not found in the pkg-config search path.
Perhaps you should add the directory containing `libmodbus.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libmodbus', required by 'virtual:world', not found
hardware_layer.cpp:35:10: fatal error: linux/types.h: No such file or directory
35 | #include <linux/types.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
modbus_master.cpp:31:10: fatal error: modbus.h: No such file or directory
31 | #include <modbus.h>
| ^~~~~~~~~~
compilation terminated.
Error compiling C files
Compilation finished with errors!


I guess I didn't notice the last line, as it still shows the program listed in the Programs page and I can still run the PLC. Looks like I was missing a couple of header files. I did a rebase of the runtime client and the program is compiling and running just fine now lol. But thanks for all the help! I'm sure I'll have a ton more questions later 😆
Reply 0 0
Reply