You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old July 30th, 2021, 07:28 AM   #1
TheCanboy
Member
United States

TheCanboy is offline
 
Join Date: Jun 2021
Location: North Dakota
Posts: 7
Question Bringing Freewave Wave Contact registers into CompactLogix PLC

Hi all, I have picked up a job where the previous automation guy selected some Freewave Radios (WC20i-485 into WC45i stick gateway) to transmit from a Cameron NuFlo Scanner 2000 Micro EFM. I have downloaded the Modbus Client AOI from Rockwell’s website, and set up everything as best I could according to the documentation. I’m going to the site to download the project today, but just looking at the code I don’t see where my values will come in, or how I select which value will be coming in. There are 2 modbus radios collecting Y-Total from Scanners, 1 flare meter and 1 sales meter. I hope someone has experience polling data from these radios and can advise on writing their values into a tag on the PLC. Thanks for reading, I will be able to reply with additional information if needed while on site today.

Edit: Modbus CLIENT, not server

Last edited by TheCanboy; July 30th, 2021 at 07:32 AM. Reason: Wording
  Reply With Quote
Old July 30th, 2021, 07:40 AM   #2
Contr_Conn
Member
United States

Contr_Conn is offline
 
Contr_Conn's Avatar
 
Join Date: Sep 2003
Location: Ohio
Posts: 2,292
I am not familiar with radios but had some exposure to Modbus TCP AOIs.
My recommendation is to get AOIs working on hard wired connection first, without radios, then setup radios.

In AOI data will be coming into the tag assigned to the Ref_ModbusData parameter.
What to read will be defined under one of five transaction tags. Transaction will also define where exactly data will arrive in Ref_ModbusData tag.

Good luck.
  Reply With Quote
Old July 30th, 2021, 02:04 PM   #3
TheCanboy
Member
United States

TheCanboy is offline
 
Join Date: Jun 2021
Location: North Dakota
Posts: 7
I have the two communicating now. Does anyone who’s worked with this AOI know how I can change the data type to a REAL without breaking the code? I’m pulling in a 32 bit floating point.
  Reply With Quote
Old July 30th, 2021, 02:08 PM   #4
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,336
Are you getting that 32-bit floating point as two 16-bit registers using the AOI now?
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
  Reply With Quote
Old July 30th, 2021, 03:16 PM   #5
TheCanboy
Member
United States

TheCanboy is offline
 
Join Date: Jun 2021
Location: North Dakota
Posts: 7
Quote:
Originally Posted by drbitboy View Post
Are you getting that 32-bit floating point as two 16-bit registers using the AOI now?
Nope, itís just coming in as 32640 on one of the holding register data points
  Reply With Quote
Old July 30th, 2021, 04:01 PM   #6
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,336
Quote:
Originally Posted by TheCanboy View Post
Nope, itís just coming in as 32640 on one of the holding register data points
  1. I am going to assume that is a 16-bit integer.
  2. Is it possible the floating-point value you are expecting is positive infinity?
    1. Can you make it some value other than infinity?
  3. Is there a 16-bit zero on one side or the other of the 32640?
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
  Reply With Quote
Old August 4th, 2021, 03:18 PM   #7
TheCanboy
Member
United States

TheCanboy is offline
 
Join Date: Jun 2021
Location: North Dakota
Posts: 7
Quote:
Originally Posted by drbitboy View Post
  1. I am going to assume that is a 16-bit integer.
  2. Is it possible the floating-point value you are expecting is positive infinity?
    1. Can you make it some value other than infinity?
  3. Is there a 16-bit zero on one side or the other of the 32640?
Sorry, I got pulled off of that at the beginning of this week. I re-set up the AOI from scratch and now itís coming in as 12 INTs. When I try to COP those with a length of 11 into a REAL it returns 22222.0
  Reply With Quote
Old August 4th, 2021, 03:24 PM   #8
OkiePC
Lifetime Supporting Member
United States

OkiePC is offline
 
OkiePC's Avatar
 
Join Date: Mar 2005
Location: ENE of Nowhere Oklahoma
Posts: 11,100
The COP instruction looks at the data type of the Destination to determine how to utilize the Length parameter. I think you would want to choose 6 since your destination is REAL (32 bits) and your source is 16 bit (INT) words, all twelve INTs will be copied bit-for-bit into 6 consecutive REALs. That is me making the assumption that all 12 INTs actually represent 6 REALS. Earlier in the thread, you mentioned 1 floating point (REAL) number.
__________________
You've been taken, but you don't know it yet.
  Reply With Quote
Old August 4th, 2021, 04:26 PM   #9
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,336
1) Do you know what the floating-point values should be? If there is noise, Knowing to +/-10% or better is good enough.


2) Post the decimal (or hexadecimal) values of the 12 holding registers you are seeing.


The rest of the solution is basically bookkeeping the bits.
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
  Reply With Quote
Old August 4th, 2021, 05:47 PM   #10
Yashka
Member
United States

Yashka is offline
 
Join Date: Nov 2019
Location: WV
Posts: 78
Quote:
Originally Posted by TheCanboy View Post
Sorry, I got pulled off of that at the beginning of this week. I re-set up the AOI from scratch and now itís coming in as 12 INTs. When I try to COP those with a length of 11 into a REAL it returns 22222.0
Take a look at the documentation for the byte order.
  Reply With Quote
Old August 4th, 2021, 08:56 PM   #11
TheCanboy
Member
United States

TheCanboy is offline
 
Join Date: Jun 2021
Location: North Dakota
Posts: 7
Quote:
Originally Posted by drbitboy View Post
1) Do you know what the floating-point values should be? If there is noise, Knowing to +/-10% or better is good enough.


2) Post the decimal (or hexadecimal) values of the 12 holding registers you are seeing.


The rest of the solution is basically bookkeeping the bits.
The value for the register I was pulling was 890.68 (it’s the y-total for a sales meter so should be exact)
Once the PLC pulled it in, my HoldRegister_4xxx[0] through [11] had these values:
896
18521
768
18183
-3904
18653
-8192
17930
15360
17948
896
18521

I noticed the last 2 repeated so I just tried COPing those into the REAL to see if that worked. I got 2.3 or so. After that I rebooted the Freewave gateway and cleared the data from the registers in the PLC side, then the Modbus TCP client transactions wouldn’t complete and the overload bit was set to 1 in transaction diagnostics.
Edit: even though my overload bit was 1, the Freewave gateway’s log was registering successful transactions
  Reply With Quote
Old August 4th, 2021, 09:46 PM   #12
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 3,336
Summary


Try some nearby Modbus addresses until you find a 17502.


TL;DR

Code:
$ python
>>> import struct

>>> struct.unpack('f',struct.pack('hh',896,18521))[0]
222222.0
>>> struct.unpack('f',struct.pack('hh',896,18521))[0]-222222
0.0

>>> struct.unpack('f',struct.pack('hh',768,18183))[0]
34563.0
>>> struct.unpack('f',struct.pack('hh',768,18183))[0]-34563
0.0

>>> struct.unpack('f',struct.pack('hh',-3904,18653))[0]
454534.0
>>> struct.unpack('f',struct.pack('hh',-3904,18653))[0]-454534
0.0

>>> struct.unpack('f',struct.pack('hh',-8192,17930))[0]
8888.0
>>> struct.unpack('f',struct.pack('hh',-8192,17930))[0]-8888
0.0

>>> struct.unpack('f',struct.pack('hh',15360,17948))[0]
9999.0
>>> struct.unpack('f',struct.pack('hh',15360,17948))[0]-9999
0.0
>>> struct.unpack('f',struct.pack('hh',15361,17948))[0]-9999
0.0009765625
So there are five floats: three values (222222.0, 8888.0, and 9999.0) that are floating point representations of whole numbers (integers) of repeating decimal digits, plus two other floating point values that are either odd or odd multiples of two; those are unlikely to be random occurrences.

Also this:
Code:
>>> struct.unpack('hh',struct.pack('f',890.68))
(-21627, 17502)
>>> struct.unpack('f',struct.pack('hh',-21627,17502))[0]
890.6799926757812

>>> struct.unpack('f',struct.pack('hh',-21629,17502))[0]
890.6798706054688
>>> struct.unpack('f',struct.pack('hh',-21625,17502))[0]
890.6801147460938

>>> struct.unpack('f',struct.pack('hh',0,17502))[0]
888.0
>>> struct.unpack('f',struct.pack('hh',-1,17502))[0]
891.9999389648438
The -21627 might vary depending on the next digit of 890.68, but the 17502 covers all values in the range [888.0:892.0).


Cf. https://en.wikipedia.org/wiki/Single...rmat:_binary32
__________________
i) Take care of the bits, and the bytes will take care of themselves.
ii) There is no software problem that cannot be solved with another layer of indirection.
  Reply With Quote
Old August 6th, 2021, 12:14 PM   #13
TheCanboy
Member
United States

TheCanboy is offline
 
Join Date: Jun 2021
Location: North Dakota
Posts: 7
Quote:
Originally Posted by drbitboy View Post
Summary


Try some nearby Modbus addresses until you find a 17502.


TL;DR

Code:
$ python
>>> import struct

>>> struct.unpack('f',struct.pack('hh',896,18521))[0]
222222.0
>>> struct.unpack('f',struct.pack('hh',896,18521))[0]-222222
0.0

>>> struct.unpack('f',struct.pack('hh',768,18183))[0]
34563.0
>>> struct.unpack('f',struct.pack('hh',768,18183))[0]-34563
0.0

>>> struct.unpack('f',struct.pack('hh',-3904,18653))[0]
454534.0
>>> struct.unpack('f',struct.pack('hh',-3904,18653))[0]-454534
0.0

>>> struct.unpack('f',struct.pack('hh',-8192,17930))[0]
8888.0
>>> struct.unpack('f',struct.pack('hh',-8192,17930))[0]-8888
0.0

>>> struct.unpack('f',struct.pack('hh',15360,17948))[0]
9999.0
>>> struct.unpack('f',struct.pack('hh',15360,17948))[0]-9999
0.0
>>> struct.unpack('f',struct.pack('hh',15361,17948))[0]-9999
0.0009765625
So there are five floats: three values (222222.0, 8888.0, and 9999.0) that are floating point representations of whole numbers (integers) of repeating decimal digits, plus two other floating point values that are either odd or odd multiples of two; those are unlikely to be random occurrences.

Also this:
Code:
>>> struct.unpack('hh',struct.pack('f',890.68))
(-21627, 17502)
>>> struct.unpack('f',struct.pack('hh',-21627,17502))[0]
890.6799926757812

>>> struct.unpack('f',struct.pack('hh',-21629,17502))[0]
890.6798706054688
>>> struct.unpack('f',struct.pack('hh',-21625,17502))[0]
890.6801147460938

>>> struct.unpack('f',struct.pack('hh',0,17502))[0]
888.0
>>> struct.unpack('f',struct.pack('hh',-1,17502))[0]
891.9999389648438
The -21627 might vary depending on the next digit of 890.68, but the 17502 covers all values in the range [888.0:892.0).


Cf. https://en.wikipedia.org/wiki/Single...rmat:_binary32
I think there was some problem with my TCP communication, after toying with it I've got the 32 bit float coming in as 2 INTs.

The Y-Total value is:
1016.702

The values of the 2 INTs are:
17534
11504

When I COP them into a real I get:
6.82881442e-012

It's worth noting that my overload bit is still getting set to 1 even when I mess with the PollInterval, but it seems like data is coming through anyway. Not sure what's going on with that
  Reply With Quote
Old August 6th, 2021, 12:34 PM   #14
OkiePC
Lifetime Supporting Member
United States

OkiePC is offline
 
OkiePC's Avatar
 
Join Date: Mar 2005
Location: ENE of Nowhere Oklahoma
Posts: 11,100
Your words are swapped. I used this tool: https://www.h-schmidt.net/FloatConverter/IEEE754.html

Plugged in your correct result ( 1016.702 ) on the top field and hit enter. I then took the HEX results from the bottom field:
0x447e2cee
I swapped the words (not bytes):
0x2cee447e

Hit enter and I get:
6.77197100479e-12

Not exactly the same as what you had, but close enough to make me think the difference is based on rounding or some small change that occurred to your Y-Total when you recorded it versus the data arriving in the PLC,

So I think you need to reverse the order of the INTs before you COPy them.
__________________
You've been taken, but you don't know it yet.

Last edited by OkiePC; August 6th, 2021 at 12:44 PM.
  Reply With Quote
Old August 6th, 2021, 12:53 PM   #15
TheCanboy
Member
United States

TheCanboy is offline
 
Join Date: Jun 2021
Location: North Dakota
Posts: 7
Quote:
Originally Posted by OkiePC View Post
Your words are swapped. I used this tool: https://www.h-schmidt.net/FloatConverter/IEEE754.html

Plugged in your correct result ( 1016.702 ) on the top field and hit enter. I then took the HEX results from the bottom field:
0x447e2cee
I swapped the words (not bytes):
0x2cee447e

Hit enter and I get:
6.77197100479e-12

Not exactly the same as what you had, but close enough to make me think the difference is based on rounding or some small change that occurred to your Y-Total when you recorded it versus the data arriving in the PLC,

So I think you need to reverse the order of the INTs before you COPy them.
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.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
SD Card for Phoenix Contact ILC series PLC FNC LIVE PLC Questions And Answers 1 May 22nd, 2019 03:32 PM
TCP/IP Communication between CompactLogix PLC/ Matlab AnotherPLCguy LIVE PLC Questions And Answers 2 May 2nd, 2019 11:55 PM
CompactLogix L32E PLC need to change its IP DavidRuan LIVE PLC Questions And Answers 6 September 6th, 2016 07:52 PM
PLC: V and Z registers vs. D registers Pita LIVE PLC Questions And Answers 0 February 6th, 2013 04:04 AM
Normally open or closed or... Phil Melore LIVE PLC Questions And Answers 15 February 3rd, 2003 08:14 PM


All times are GMT -4. The time now is 04:55 PM.


.