LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

function code vs. table register in Modbus.

Solved!
Go to solution

I just started to know the protocol of modbus.


To my understanding, a table (range) of register seems to be related with a function code (FC) but it is ambiguous to me.

It seems to be important because the starting address in each FC is based on the offset in related table of register.

 

For example, I can read and write a boolean type of parameter through FC 01/05 (discrete coil).

But the manual for a instrument indicated boolean data type in different range of register for analog input/output (e.g. 30004.2/40004.2).

 

In this case, I am wondering if I can use FC 22 (bit mask operation) to change some individual bits in boolean byte.
Or do I need to read a U16 value of parameter using FC 03 first then modify the bits and write the U16 parameter?

 

*)Sorry for my question without trying in my instrument because writing bits can happen unexpected result in many bit parameters.

 

labmaster.

0 Kudos
Message 1 of 2
(1,597 Views)
Solution
Accepted by topic author labmaster

I haven't heard of function code 22 before, but a quick search seems to indicate it's not supported by many devices, so it might not be supported by your device.

 

If it is supported, then I expect it should work, although I haven't seen any clear documentation of how it's supposed to work. I'm assuming the bit mask says which bits you want to modify and then their values will be toggled, but that doesn't give you control if you want to force a specific value on the bit.

 

Ideally, either the device or the master are in charge of any specific register, which means that there aren't any collisions, because the device never writes to registers which the master is expected to modify, but that depends entirely on the specific device.


___________________
Try to take over the world!
0 Kudos
Message 2 of 2
(1,547 Views)