Thank you Claes, much appreciated.
I managed to get continuous read and write on demand working for Dig, Int16s, Int32s and Reals with a sample project and an Automation Direct Click PLC. Using a couple of different methods.
Somethings I noticed that may help others:
- 'Identity' in the Proview IO channels refers to the relative byte in the Proview IO map - before understanding this I had trouble mapping the IO. You can also see what is going on when you look at the MB TCP Slave Input and Output map in the runtime Navigator (Nodes-Getingstarted-IO-ModbusMaster-IOInterface) in my project.
- I think for most modbus tcp devices the Modbus Slave setting 'SingleOp' needs to be 'Yes' otherwise the Proview protocol implementation sends multiple modbus transactions in ethernet packets (and the PLC wont respond to all of them)
- The PLC thread looking after the comms should have the Halt-Delay Action set to 'No' or 'Message' and not 'Emergency Break' or when comms are interrupted they will not restart.
- Byte order for Int32 and Float32s in the PLC is different to Proview and needs to be manipulated. I used this as a guide.
www.proview.se/v3/index.php/forum/3-help...ian-conversion#11502 Thank you @Brunad. Note that I could Brunad’s referenced method to get values into Proview but not to write them back to the slave PLC. To write back successfully I needed to use 32bit Ii and Io interfaced with float32 signals.
- To set, reset and toggle digitals I created three scripts – these also allowed me to interact with buttons, checkboxes and radio buttons. They also ‘lookup’ the associated SendOp variable.
- I managed to get an indicator working that shows the communications link status although I think it was lucky. I
associated a value with an indicator Nodes-Gettingstarted-IO-ModbusMaster-IOInterface.Status##Bit[0]
- Similarly I managed to get a status on the group read commands by placing some logic in the Proview PLC and comparing the status Enum variable.
A couple of questions that I am seeking some input on that I have not been able to work through:
1. How can I monitor the Modbus TCP Slave module Status attribute? Eg to implement data validity and communications loss alarms? I am not even able to determine the datatype although when I use GetAttribute and printf it is a long number.
2. Are there any functional limitations (such as access/security, web use) of setting variables and SendOP the way that I have in the scripts? i.e. Using GetAttribute(), GetParent and SetAttribute() in xtt script.
3. Is there a simple way to evaluate expressions (Eg to operate indicators) rather than adding additional variables and proview plc code. For example to operate the indicator when the command module status is equal to 0 (status OK). Example signal is: Nodes-Gettingstarted-IO-ModbusMaster-IOInterface-modRdReals.Status
Images below for reference. I have also attached the PLC file (free programming software available from automation direct) and a project back-up as it may be of use. Script files are in /usr/local/pwrp/gettingstarted.
Set the SendOp variable with button:
Comms Arrangement:
Variables:
Type Conversion:
Check Box:
Graphics:
Script Example:
Slave PLC Code: