Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

writing to upper/ lower bytes of a MODBUS register

I am developing a program to interface to an older MODBUS device.  I have to read and write upper and lower bytes of several MODBUS holding registers.  For example, the upper and lower bytes of 40012 should contain an 2 different integer values, 12 & 20.  To view the upper byte I inserted an expression INT(MOD1/256) and to view the low byter I inserted the expression MOD(MOD1,256).  This allows me to properly view the intergers.  I then created a Pot and created a connection to that holding register.  I selected the source as remote and inserted the previously listed expression.  The correct value is displayed on the Pot but I when I change the value on the Pot, the register value is not change.  What am I doing wrong? 
0 Kudos
Message 1 of 2
(3,887 Views)
If you set INT(MODBUS40012/256) as the remote source of a pot, the pot can't control the MODBUS40012's value. To meet your requirement, I think you need to configure the "connections" of modbus object.
1. create a pot, without remote source.
2. right click modbus object, edit connections... , do following configurations
   400012.8 = int(Pot/128)
   400012.7 = int(mod(Pot,128)/64)
   400012.6 = int(mod(Pot,64)/32)
   ......
   400012.1 = int(mod(Pot,2)/1)
3. update the pot's value, then the lower byte of 40012 will be updated.
Ryan Shi
National Instruments
0 Kudos
Message 2 of 2
(3,870 Views)