02-19-2020 04:11 PM
I have set of PDU specs by schneider electric motionstage, it's configured to communicate following Modbus TCP. I am new to modbus library, but my understanding is that for the PDU I'd like to write (see attach), the modbus library master example set holding register will provide function code 0x10, I will need to set the start writing address to be 0x0043 (decimal 43), which will be part of the PDU constructor to build final PDU
So, I convert the rest of byte array 00 02 04 208(D0) 00 00 07 with the utility function (Bytes to U16) to 2 1232 0 (https://github.com/NISystemsEngineering/LabVIEW-Modbus-API/tree/master/Utility) , which seems incorrect, because the reverse conversion (U16 to U8) is not correct -> 00 02 04 208 00 00 (missing 7)
How should I correctly set my PDU at the holding register via Modbus Library? (As I am now, disregard I set the holding register as 2 1232 0 or 2 1232 7, I am getting error 538183 (Invalid value)
02-19-2020 04:46 PM
Why are you calling the low level VIs of the Modbus library? Simply call the appropriate method, most likely "Write Multiple Holding Registers" with the correct register address and data. Let the library build and parse the PDUs.
02-19-2020 04:52 PM
In my PDU example, what would be the U16 holding register value be ? I called the low-level utility to check what the U16 value is supposed to be..
02-19-2020 05:43 PM
Without seeing the spec for your specific device, it is difficult to say what your data values should look like. However, the Modbus library is 0 based for it's addressing, so to start writing at address 43, you would actually wire 42 to the starting address input of the Write Multiple Holding Registers vi. The content of the U16 array for the data is dependent on the specific device. Their documentation should let you know what the data should look like.
02-20-2020 02:08 PM
So after probing, I realized the Modbus write to multiple resisters function will set the size, starting address & bytes to write in the final PDU, so I only need to set the data part which is D0 07 to holding resgister in the Modbus Master example, I am still getting an error 538184 occured at Function 16, which shows possible server device failure, but has no clue how to clear this error from here..
02-20-2020 02:10 PM
Here's the Manufacturer specification in attachment. I was referring to section 6.5.1 to set MA 512000 starting at register address 0x43
02-20-2020 03:07 PM
According to the documentation, the Move to absolute position (Register 0x43) requires 4 bytes of data. Also, as indicted earlier the NI Modbus library is 0 based, and the actual Modbus specification is 1 based. There, you should be inputting 66 (0x42) as your starting address and pass in a 2 element array of U16 values for the position. I did not read the entire spec to determine what those 4 bytes represent or how they are ordered.
02-20-2020 03:13 PM
@Mark_Yedinak wrote:
According to the documentation, the Move to absolute position (Register 0x43) requires 4 bytes of data. Also, as indicted earlier the NI Modbus library is 0 based, and the actual Modbus specification is 1 based. There, you should be inputting 66 (0x42) as your starting address and pass in a 2 element array of U16 values for the position. I did not read the entire spec to determine what those 4 bytes represent or how they are ordered.
I disagree. Looking at page 4-15 of that attached pdf, the very first register is acceleration and it says it is address 0x0000 - 0x0001 (4 bytes) Thus two registers and that their description in the manual is starting at 0.
Generally, the 1-based stuff is when they put a prefix in front 40001 and 40002 would be holding registers reached at indices 0 and 1.
Why did Modbus do register addressing this way? 0-based makes sense from the software realm, but it just leads to confusion when sometimes a document refers to the 40001 scheme and other things refer to a 0000 scheme.
Note that the 0-based scheme is not just a LabVIEW thing. It is the byte values that are actually being transmitted if you ever do port sniffing even when using a piece of Modbus client software that at the user interface level uses the 40001 type of 1-based addressing.
02-20-2020 03:20 PM
Well, I did state that I didn't read the whole manual. I simply skimmed down to find the Move Absolute register that the OP was concerned about. Either way, I am not sure what happens when only 2 bytes get written to the device at that register and how it would be handled by the device.