GX developer: converting oil delta P to flow rate...

Mas01

Member
Join Date
Oct 2020
Location
Leicester, England
Posts
1,109
One of the engineers has asked me to add code to the PLC to calculate oil flow rate based on delta pressure, using the equation below:
Flow rate (litres/s) = 0.6940783481429 * SQRT[ dP/0.00312689635143916 ]

dP is the delta pressure in Bar.

In MELSEC GX developer, I don't know how to represent the numbers to so many decimal places (or if it's even possible...can I just create a K-value?). Also, not sure how to perform a square root function in GX developer.

Can anyone help?
 
Can you find a GX developer manual, perhaps in PDF form, either post a link or the manual itself here? Then we can all pore over it.
 
For a Q series PLC double precision floating point does up to 15 significant digits, which is enough for you based on what you wrote here.



You'll want to use the EDMOV command with the SQRD command. These are the floating point double precision (64bit) version of the regular move and square root commands.



ED/ is the 64 bit divide command.



All of this is in the Q series programming manual.
 
Real constant are starting with E, with GxWorks and Gx IEC developer, you don't need even that E.
 
... 0.6940783481429 * SQRT[ dP/0.00312689635143916 ]
SQR D32 D34

E* D34 E12.4122854 D34


N.B. Assumes dP is a float in [D33,D32], and the float result will be in [D35,D34]; if dP is a 16- or 32-bit BIN, a FLT or DFLT instruction will be required.


...
 
I tried entering the long decimal numbers using Exxxxx, but when I pressed ok, the values were truncated (see picture). Not sure why, but it's probably accurate enough, right?

IMG_20220309_090630.jpg
 
I wrote the code to the PLC.
Does anyone know why F416 is ------ when I try to do the SQRD operation? It's value is correct on the previous line.

IMG_20220309_092140.jpg
 
If you want more precision then you have to use 64 bit real so this would be

[ED/ D100 E1.0123456789321 D104]
Remember though a 64 bit real requires 4 16 bit registers & once you get your answer it will be in double precision so to keep that you must maintain the use of double precision.
What you have done is use a single precision float in a double precision float that is why it does not work.
You have to do one of two things, convert the divide into 64 bit (means moving the registers as it requires 4 or if the double precision is not required just use SQR not SQRD
One other way is to convert the result of the 32 bit D416 (D416 & D417) into a double using the ECON function [ECON D416 D500]
 
Last edited:
No it wouldn't it will be evaluating it as a 64c bit number so using D416 is seen as D416, D417, D418 & D419 so if D418, 419 have any other values even 0 in them then it is not a valid 64 bit real.
 

Similar Topics

I'm trying to verify a project with a PLC. The Transfer Setup menu item is grayed out and every time I click Verify with PLC, I get an error...
Replies
1
Views
61
Well, I've decided to start a new project, and like all projects, it has already gone horribly wrong. I purchased a PLC device (supposedly a...
Replies
2
Views
113
Does anybody have any samples of how to "Create and Use" UDT's in CCW Developer Edition? (I am using v22) I can't find any information from...
Replies
3
Views
321
I'm trying to manually convert a Beijer E200 HMI project onto to a new Mitsubishi GOT gs2107-wtbd. The PLC is a very old A-series AS1CPU and is...
Replies
1
Views
385
Hi One of the PLC's that I maintain/update is a Mitsubishi Q-Series, probably installed about 10 years ago. At the moment, ALL the wires from...
Replies
13
Views
1,175
Back
Top Bottom