Writing a Decimal DINT to a Float REAL

Saturn_Europa

Member
Join Date
May 2016
Location
USA
Posts
58
I wrote some code in a compact logix using rs logix v.20.04 back in February. This code counts the number of pumps running a remote pump station than pushes this to a SCADA server.

I got a call last week, 4 of the pump stations I programmed are only reading 1 pump running even tough they might have 2 or three pumps running.

I looked up the code and I am using an ADD and adding up each pump running to a DINT. I then use a MOV to move the value for the DINT to a REAL. The REAL is written to SCADA.

Is this my problem? Should I be using a COP?
 
Do you ever reset the DINT to zero? Or does it just keep counting up? If so you may have counted too high for the DINT to hold.

You can add 1 to a REAL too, that way skipping the step of having to convert it.
 
The MOV instruction converts between datatypes, so a small integer value will be represented correctly and exactly as a REAL.

A COP instruction would copy the raw bit patterns across to the REAL, resulting in an incorrect value.

The problem must be elsewhere in the code.

Here's a question; does the MOV instruction come after the ADD instructions, in the same program or routine ?

I've gotten into trouble before when I had a value that incremented during the routine but was grabbed and moved to an HMI tag by an asynchronous Periodic task routine. Sometimes that event happened in the middle of my routine, because the tasks are not synchronized.

The easy workaround is that I always use a "scratchpad" tag in routines like that, and only move the result to the tag used by the rest of the program/HMI in a single COP or MOV instruction after the calculations are complete.
 
Logic looks ok to me unless you overwrite the number of running pumps somewhere else.

Check if your RNG input is being set. Maybe the pump get run request but no feedback is being set. However you probably have an alarm for such event.
 
Last edited:
In the ADD instructions source B you should put the tag NUMBER_OF_PUMPS RUNNING in order to have accumulation of pumps running.
but what happend when the pump stops.
 
you can try something like this:

kbvhu9.png
 
Tarik's solution seems most appropriate. No risk of a DINT overflowing, the only possible computed outputs are dynamically 0, 1, 2 or 3 at any given time.
 
The code will never show more than 1 pump running, each rung is writing a 1 to the Number_of_Pumps_Running.

You will need to add 1 to Number_Of_Pumps_Running and store it in Number_Of_Pumps_Running, then you will be good to go 🍻

/Holmux
 
Please see attached screen shot of code

Shouldnt your source b be the Number of pumps running? And out destination should also be Number of pumps running. It looks like you are adding 1 + 0 each rung and outputting to number of pumps running.
 
Your code will return 1 if some pump is running or 0 if not, but it doesn't count the number of pumps running

In the ADD instruccions Source B must be NUMBER_OF_PUMPS_RUNNING, not zero
 

Similar Topics

Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
1
Views
81
Hello all, I'm currently working on a servo motor linear positioning system (ball screw). I'm all set up regarding communication between my HMI...
Replies
1
Views
86
Hello All: I have a Windows 10 PC running a FTView ME Station 10.00. I have a .mer file version 6.00. It has been running well on it for a long...
Replies
1
Views
158
My R55 Ingersollrand is tripping on motor overload and im falling to see the trip history it is writing Acquarring texts
Replies
0
Views
130
Hi. Not the fist time I'm saying this but just to give a background. 95% of my PLC programming has used Schneider over the last 10 years on...
Replies
66
Views
4,881
Back
Top Bottom