Detecting QNAN in Control logix

zankorel

Member
Join Date
Dec 2008
Location
Hunter Valley
Posts
173
Hi All,

I have relatively obscure problem with floating point numbers.

My setup is a CompactLogix with a Prosoft MVI Modbus TCP Card. The Prosoft card is retreiving a floating point number from a remote device via Modbus TCP and transferring it to the Compactlogix CPU via the backplane. i then use a CPS instruction to convert the two INT's into a REAL datatype.

Somewhere along the line the data is being corrupted (or timing is screwing up) and the result is that i get a 1.#QNAN (ie not a number) error occasionally.

What i need is a way to detect that the data has errored so i don't use it until it becomes good again. Does anyone have any ideas? Ive tried GRT > 0, but that allows a QNAN through.
 
Hmm, without much knowledge of what's going on this is what I'd do:

Do calculations, store to a temp REAL number called temp

if !Error bit
result = temp
 
The "S:Minor" minor fault and "S:V" overflow bit both are true when you divide by zero and create an undefined number (1.$ or 1.QNAN in RSLogix 5000).

Edit: Found an RA Knowledgebase article addressing exactly this issue:

http://rockwellautomation.custhelp.com/app/answers/detail/a_id/59895

Process the number by multiplying it by 1.0 to intentionally create a S:V overflow, and you can then avoid processing it in your actual code.

Those not-a-number are always the result of an operation with an invalid result; the COP or CPS instruction shouldn't cause one by itself.

Does the 1.QNAN show up in the result of the CPS instruction, or in the Input table of the MVI69, or somewhere else down the line ?
 
Last edited:
The "S:Minor" minor fault and "S:V" overflow bit both are true when you divide by zero and create an undefined number (1.$ or 1.QNAN in RSLogix 5000).

Edit: Found an RA Knowledgebase article addressing exactly this issue:

http://rockwellautomation.custhelp.com/app/answers/detail/a_id/59895

Process the number by multiplying it by 1.0 to intentionally create a S:V overflow, and you can then avoid processing it in your actual code.

Those not-a-number are always the result of an operation with an invalid result; the COP or CPS instruction shouldn't cause one by itself.

Does the 1.QNAN show up in the result of the CPS instruction, or in the Input table of the MVI69, or somewhere else down the line ?

Thanks for your suggestion Ken.

the 1.QNAN looks to appear when the source device updates its data and the MVI module has a brief period where the two 16 bit INTs representing the REAL are mismatched. The MVI seems to blindly send this data to the CPU even though it is setup to realise that the memory location refers to a floating point number. Anyway the result is that for a significant number of scans the CPU computes a NAN result when the two mismatched INTs are copied to a REAL tag.

Anyway, it ended up that the simplest solution can often be the easiest to overlook. I prefaced the computation using the NAN prone data with a LIM instruction which weeded out the NAN value.

Something to be beware of when transferring floating point data with a prosoft MVIxx module.
 

Similar Topics

I've been called to a site to assist with an ASi fault. The line has been down for a couple of weeks following a failure of the ASi power supply...
Replies
6
Views
1,292
I am looking at an application where I will need to detect small hairline cracks in stamped metal parts. The sensing will need to be done in the...
Replies
10
Views
1,115
Hello everybody, I am working on a project which has HMI FTView SE 13 (Local) and controllogix L71 PLC. I have a question how does PLC detect a...
Replies
0
Views
509
So, we have one servovalve that is very critical to machine operation and idea is (or was) to detect if valve gets disconnected from analog output...
Replies
11
Views
2,870
I had bought a used PLC before but I had to return it. Once in a while its run mode shut off momentarily. I had the PLC on my desk. (No I/Os...
Replies
22
Views
5,352
Back
Top Bottom