Reading 2 16bit registers and making a float

crono141

Member
Join Date
Apr 2018
Location
South Carolina
Posts
14
Hey all,

I have an AcuDC energy meter which provides data on voltage, current, and power over RS-485/Modbus RTU. It provides float values in two 16 bit registers that I'm trying to read with a Micrologix 1400 microcontroller.

First I tried reading the data as 32-bit values, but kept getting errors. What I gathered from my research was that this was because the meter didn't store things in 32-bit registers, but instead 2X 16 bit registers. So instead, I'm reading each value as 2X 16-bit registers and storing them in 2X integer addresses.

Now I'm trying to get the integer addresses combined into a single float address that I can read and manipulate with the PLC (I need to do some math on these readings). I had read that I could use CPW (copy word) and take the source integer address and copy to the float destination, with a length of 2. Unfortunately, this appears to do nothing, because the float address remains zero even though the source integers have a value. This leads me to believe "I'm doin it wrong".

The AB Micrologix instruction set on CPW isn't very helpful either. Can anyone with experience please point me in the right direction?
 
Just tried. No change.

I tried changing the destination address from the float to another integer just to be sure that the CPW is running, and it is. I know the order is important. The first word is most significant (from the meter) and the second is least significant. Should I swap these first?

EDIT: Well, I tried that too, and came up with the same result: an empty float value.

EDIT AGAIN: Solved it. I had logic later in the program writing zero's back to this value. I did have to swap least and most significant words though. Thanks for the help!
 
Last edited:
With a CPW, the length will need to be 2.

Also, you might need to swap word order or even byte order depending on how that is done in the other device.

But, if you have values in the integers and still get zero in the destination, even if you have length wrong, it makes me suspect that the logic is either not being scanned or the destination is being overwritten by other logic.
 
I would also suggest trapping the math overflow bit when you are doing this. If your CPW just happens to execute while the MSG is partially completed, you can end up with bogus bits that end up trashing your result. If the result is for some critical control reason, it might also be a good idea to buffer it (store it in a spare float register) and then only copy it to the useful destination if the overflow bit is not set... This scenario seems impossible but it is not, as I found out in a real life situation where my MSG was from a radio modem which probably made it more likely to actually occur at a more variable time during the rest of the PLC scan.
 
We are polling this data once every 10 seconds, so it isn't process critical, just informational. As long as the overflow doesn't cause a fault that halts execution, we'll be ok.
 

Similar Topics

:banghead: Got my E-Designer 7 yesterday, and using E-410 landscape to read some data (currently) from FX1S-15MR-ES/UL. I am able to read IOs...
Replies
1
Views
2,502
Hi Everyone, I am not proficient in RSLogix 500 so I have a question regarding the evaluation of N7:0 data as an input. So as I understand in...
Replies
1
Views
68
Trying to setup a message read via Ethernet. I have the path setup as 1, 1, 2, 192.168.66.10 I get an error code 1, ext err 315. I am beating...
Replies
9
Views
229
Dear all, I don't know why setup of password became challenging and weird. After setting up the password and try to upload the ladder from the plc...
Replies
3
Views
171
hi all, i have a plc i need to get info from for a site im working on: I have a 1764 Micro Logix 1500 LSP Series C (See Attached Image) im...
Replies
2
Views
372
Back
Top Bottom