From Float to Integer Using MUL Instruction

Steve Cav

Member
Join Date
Aug 2006
Location
Clitheroe
Posts
71
Hi,

Currently using a MUL instruction (PLC-5) to convert a floating point to an integer to send up a SCADA system.

No float comms exist (and can't take the PLC down to create), so the easiest way was to multiply the pressure by 10 and then the SCADA system will divide by 10 to give us the pressure to 1 decimal place. i.e. MUL F8:18 10 N25:57

When the reading is processed by SCADA it will reset the N25:57 to -1 and await the next reading.

However, although this seems to work fine 99% of the time, I have on occasion seen the value -7 in the word rather than -1!

The SCADA team are convinced they can only set it to -1, so I'm just seeking a 2nd opinion that the above is coded correctly and if not, what the best way is!

Steve
 
Is the SCADA system sending a analog value of -1?

If so you might want to consider having the SCADA toggle a bit ( momentary) and then with some logic in the PLC move a value of -1 to N25:57.
 
That would be one way. However, the plant generally works on the method above.

Also, the paperwork involved in order to change the SCADA system is unfortunately prohibitive.

In reality, if the current PLC software has a hole in it, then any fix will have to be done at the PLC end.
 
Where did you see the -1 value (scada or RSLogix5)?
How is the data getting from the PLC to the scada (polling at the scada or explicit messaging)?

What are the typical values? Is it possible that the source is really generating the -7 value you have seen?

Are you certain that the address of the integer is not used anywhere else in the program? Be sure to check for indirect addressing, and bit level access (especially the sign bit!).

Can you tell us the brand of the SCADA system?

Can you post the logic?

I have no answers, only questions, but this problem has me quite curious. I do hope you are able to find the cause and let us in on it.
 
-1 seen in both the PLC data table (6200 software) and SCADA.

The SCADA writes directly into the PLC data table. Typical values are aroung 450 and SCADA writes a -1 into the data table when it has read the value.

I've checked the SCADA logs and they definitely write a -1 into the data table and then a -7 gets written in by the PLC.

I've been through the code line by line and cannot see how the PLC writes this value in and that includes indirect addressing.

SCADA system is yokagowa - but this system has existed for years and the technique used is all over the place and proven.

It is definitely the PLC end, just can't find it!

Unfortunately, not a work so can't post logic, but basically:-

Xic N56:2/1. ONS. B40/0. MUL. F8:0. 10. N25:57

N25:57 is message to SCADA, when SCADA 'read' value it writes -1 to N25:57
 
Where does F8:0 come from? Is it possible that value is going to a -.7 occasionally?

You could create a trap to monitor that possibility.

I assume this is not causing any problems but just like to know what is causing it.
 
Last edited:
F8:0 is a scaled analogue value

I.E N11:0 * scaling factor + offset where N11:0 is raw analogue (0-4095)

99 times out of 100 it works fine and -7 is not seen.

However, if it happens it brings that machine to a stop due to oneshots etc. I can botch my way round it, but would prefer to determine exactly what is going on.

Having checked the code, I can't see how -7 gets in to F8:0
 
F8:0 is a scaled analogue value

I.E N11:0 * scaling factor + offset where N11:0 is raw analogue (0-4095)

99 times out of 100 it works fine and -7 is not seen.

However, if it happens it brings that machine to a stop due to oneshots etc. I can botch my way round it, but would prefer to determine exactly what is going on.

Having checked the code, I can't see how -7 gets in to F8:0

It's possible that the value is coming from the analog input you are scaling.

So if N11:0 * scaling factor + offset = -7, then reverse the formula, i.e. (-7 - offset)/scaling factor = x. Plug in your numbers and this will tell you what analog value will return a scaled value of F8:0. Then latch a trap bit if N11:0 = x. This will confirm if the -7 is coming from your analog input, or some other source to F8:0.

Typically, when scaling an analog input, especially for display, I like to "clamp" the result between two acceptable limits, i.e.: (assuming F8:1 is the scaling factor and N7:1 is the offset, and your pressure reading is between 0-100 psi)

Code:
BST CPT F8:0 N11:0*F8:1+N7:1 NXB LES F8:0 0 MOV 0 F8:0 
NXB GRT F8:0 100 MOV 100 F8:0 BND
Let us know what you find out.

Cheers,
Dustin

🍻
 
Will give it a go on Monday and feed back.

I also clamp analogues for display. However, this isn't for display, it's used to compare gas pressurisation of a rod with a manual gauge.

I.E the rod has to be welded within a pressure range (approx 445 - 454 PSI) and before production starts they perform a pressure test. To do this they pressureise the rod and when stable press a button on the HMI which sends the pressure to SCADA and enter the value on manual gauge also into SCADA. The higher system then either allows or stops welding based on a comparison.


Cheers
 
Last edited:
Another possibility that occurs to me: Is anything writing to N25:57 on the bit level? -7 in 16-bit signed binary is 1111111111111001. So if something else occasionally in your program either OTU's or scans false an OTE on N25:57/1 and N25:57/2, then -1 would become -7. Might be worth taking a look at...
 
I checked at the bit level also and nothing else appears to be writing to N25:57, either a word or bit level.

It must be F8:0 that's going to -7.

I'll add the error trapping code and prove it one way or another
 

Similar Topics

Hi. I'm using a Modbus ProSoft where I basically map data to a big INT array. Example, where GX_I_63HPU is a REAL, MNETC.DATA.WriteData[200] an...
Replies
21
Views
428
How do I convert a float to an integer? I've got a floating-point number D606, value 3999.863. I need to convert it to an integer (4000), then I...
Replies
14
Views
4,148
I can't quite figure out what the issue is here. I read some things about floating point integers and rounding and I assume that's my issue but...
Replies
13
Views
3,904
I have a Float that is F45:10 and I need to convert it to an integer to display on an HMI that is in VB.net and we can't change. I look on the AB...
Replies
8
Views
9,418
Hi all Why would The instruction [MOV s:37 F8:18] = 2015.0 in an (SLC 1747-L552C) and [MOV s:37 F191:0] = 55331E-034 in an (SLC 1747-L553) I...
Replies
13
Views
2,286
Back
Top Bottom