Bringing Freewave Wave Contact registers into CompactLogix PLC

Legend! Swapping them has my Y-Total coming in properly. I'll bookmark that page for the future in case something like this happens again.

Word and byte order always need to be considered when dealing with 32bit values and Modbus. There were only 16 bits in the alphabet when Modbus was invented, so there was never an official standard for how to transport DINTs and REALs. Kinda like "why would anyone need a 40Mb hard drive or more than 128k ram?"

Good drivers like those by Red Lion will let you set up the driver for all the possible combinations, but sometimes you have to do it the old school way.
 
Late, but I can confirm what @OkiePC said, including the reason for the noise in the low bits.

Code:
 >>> struct.unpack('hh',struct.pack('f',1016.702))
(11502, 17534)

>>> struct.unpack('hh',struct.pack('f',1016.702[COLOR=Blue][I][B]15[/B][/I][/COLOR]))
(11504, 17534)

>>> struct.unpack('f',struct.pack('hh',11504,17534))
(1016.7021484375,)
Perhaps it should be considered, since there may be a stream of these 16-bit INT pairs representing adjacend 32-bit floats, if the values of adjacent floats are similar, that there could also be a not uncommon off-by-1 Modbus mistake here, in which case Modbus is retrieving the high 16-bit word for float N and the low 16-bit word for float N+1, and it might not be noticed with the methods shown here.

Code:
>>> struct.unpack('f',struct.pack('hh',0,17534))
(1016.0,)

>>> struct.unpack('f',struct.pack('hh',-1,17534))
(1019.9999389648438,)
>>>


That said, 11504 being accurate to 5 sigfigs of the expected answer is pretty convincing that off-by-1 is not happening.
 

Similar Topics

If have a need (trust me its a need) to bring the System Management Console to the foreground while the HMI is running. I am trying to to this...
Replies
40
Views
11,359
I am not very experienced (2 yr) so this question is for people who know both what is going on with data science currently and have experience...
Replies
0
Views
1,107
Hi guys, While trying to upgrade a Siemens MP370, it hung somewhere in the process and gets about halfway through the creation of its disk...
Replies
4
Views
2,773
I'm fairly well-versed in programming GE 90-30 PLCs with Proficy ME, but I can't figure out how to open a project that was created on a different...
Replies
4
Views
9,843
Can you use an existing OPC over Industrial Ethernet connection to update code on a S7-300 PLC using Siemens Step 7? I found something somewhere...
Replies
1
Views
3,114
Back
Top Bottom