I suspect the timer will not reset until it reaches 150 (1.5 Secs), I doubt the timer will reset on putting a zero into the accumulated word (pulse_Current) It seems to be an IEC timer & I have tried on a couple of IDE's & it will not reset the timer until the 1.5 secs is up, however, not used this platform so cannot be sure.
We cannot see the status of the scale block, the min/max seem unusual never had an analogue use such high values but then they could be 32 bit conversion, also as op is using simulator it looks like he is putting a fixed raw value into the scale block has the op got the value correct for 60 LPM The max value
is 2,147,483,647 Really ????
That works out at 14,316,548.933 per litre so the value in the raw analogue would be 858,992,936 or do my eyes deceive me.
13,107 is correct for 4ma but the max input should be 65,535 according to the document, so where he got that value from I have no idea.
I've got much agreement with what has been posted. My answer is to use a pulse output meter and count the pulses. I try to avoid integrating 4-20 milliamp stuff whenever I can.
@sparkie et al.: yes, dedicated hardware would be much better in the real world.
Yes next time I'll bought a flow meter for a totalizing application I'll go for something more appropriate thant 4-20mA. Probably the learning curve that hitting me
OP (@jpmorasse; see below ): this is an interesting exercise for learning PLC programming, but for the reasons @sparkie mentioned, and others, one would be unwise to do totalizing in PLC beyond as an exercise. That said, if you stick with this, we folks here will very likely be able to help you. However, if you never post again, then you will be just like all the others and our widdle hearts will be broken (sniff sniff).
Issues (our story so far)
All in all, not a bad puzzle to spend time on for a Sunday afternoon during a pandemic waiting on the Super Bowl to start.
- @parky and others: scaling is suspicious
- @Steve Bailey and others: 36 extra ticks per 100cs is suspicious
- @drbitboy and others: integer vs. floating point math in totalizer formula
P.S. The correlation between the image below and OPs moniker is meant for humor only, not as an insult. Think Br'er Rabbit.
View attachment 57242
The p2k analog modules are 16 bit, In.Max should be around 65536.
The SCL instruction works with Floats as well if you want more resolution.
If you want to sample every 1 second there's an 2 second system bit that turns on for 1 second and off for 1 second. An NOE or'd with an NCE can give you 1 second samples. How much drift an error there would be with that I have no idea. For less precise things it works well as it removes the timer.
Also I'll like to find documentation about the type of ''value'' found in PLC's. Like in the shown picture(Float, integer, BCD?)
...So With all your comment I came back with this new program and to problem look like it's solve.
I'll now try to improve it so any hint or comment is more than welcome.
:site: