Ok, so I have it working now and I thought it worthwhile to share 1 or 2 things that confused me.
Firstly, I made sure my hardware and wiring was working to the RevPi Connect:
1. Disable Codesys runtime (I just did 'sudo systemctl stop codesyscontrol', followed by 'sudo systemctl disable codesyscontrol'
2. Then set Modbus RTU slave up in Pictory and test this with QModMaster, exactly per this tutorial:
https://kunbus-gmbh.atlassian.net/servi ... /416055479
3. Note: in Pictory, the Modbus RTU slave is set up to look at etc/ttyRS485 and 19200 Baudrate, and parity set to None
Then, with the above proven to work, I went to focus on Codesys settings. I will just say what worked after trying a few options:
0. Obviously re-enable CodesysControl first: 'sudo systemctl enable codesyscontrol' and 'sudo systemctl start codesyscontrol'
1. Delete the Modbus RTU slave from Pictory and don't forget to do 'save as start config' and 'reset driver'
2. Don't put anything in '/etc/CODESYSControl.cfg' (
this is contrary to this instruction:
https://revolutionpi.com/tutorials/bei ... u-slave-2/)
3. Add the following to '/etc/CODESYSControl_User.cfg':
[SysCom]
Linux.Devicefile=/dev/ttyUSB
Strange how in Pictory you use etc/ttyRS485, but in Codesys config it's etc/ttyUSB !
4. In your Codesys project, make sure you set the Baudrate and Parity (I kept same as before: 19200 and None) on the Modbus_Com serial port. Also, select COM port 1!
5. And then, obviously map your variables and call them in a POU.
6. Note that if there is no Master reading or writing, the Modbus Serial Device will still show a dead bus, although the Modbus Device above it will show to be running happily. Once there is actual trafic on the bus, everything goes green.
The main confusion is around the use of etc/ttyUSB instead of etc/ttyRS485 on the Connect and then the fact that this must be in CODESYSControl_User.cfg, which is not what the tutorial states.
Good luck everyone.
Koen