
Bar (Customer) asked a question.
More Efficient Ladder Logic recommendation for Incrementing a R0 based on flow meter input
Hello,
I have a flow meter input ($HsCtrTmr1.acc), and would like to change a R0 value every time the flowmeter shows an additional 200 counts (This R0 is the duty cycle for a PWM output to a pump test the pumps at different speeds). What would be a more efficient ladder diagram so this step approach does not need to be used? (Also, I'm assuming the "Leading Edge Powerflow Modifier" will work as intended in the ladder below?) I think I could reset the .acc every 200 counts, but then would loose the accumulation value which would also be nice to have. Thanks
Your "Leading Edge Powerflow Modifier will work, but your >= < logic will not work. After 200, the rung would never go false to reset the "modifier". The math would only be done 1-time, at 200, R0 would always be 17.08.
One way (of many) could be:
.Acc = 200----|------(modifier)------Math
.Acc = 400----|
.Acc = 600----|
This would be very cumbersome if you have a high count. If a high count, possibly dividing by 200, and triggering the Math instruction when the remainder is zero.
This is what I had in mind when I said "triggering the Math instruction when the remainder is zero".
"D0" is what I am using to simulate your count .Acc.
"D1" is the remainder from dividing the count by 200.
"D0>1" is to prevent triggering the math when the count is "0".
One "gotccha" is that with a High Speed Counter that runs on a separate processor - based on the high speed input frequency, it can definitely increment multiple counts from one PLC scan to the next.
The .HARDWARE accumulator keeps track - this is where all the advanced HSIO functionality works. But for basic ladder access, the .Acc member in the HS Counter is only updated at the bottom of the PLC scan. Hence, it could equal 198 this scan, but then equal 201 the next PLC scan (normal ladder would never see the HARDWARE counter values of 199, and 200).
Since we don't need to TRAP the actual "event" of transitioning from < 200 to > 200, but just recognize it in ladder, it may be best to set up "previous scan Acc" in a D register that gets updated at the bottom of the logic scan (see $tBottomOfScan System task). Then in regular ladder $Main or wherever, compare when the D < 200 and the actual .Acc >= 200 and trap that event (no need for one shot leading edge contact?)
Maybe this would work?
There's still a HUGE gotcha if the frequency is so fast, it can increment > 200 counts within a SINGLE PLC scan? HSIO can measure 1 MHz. With a 1ms PLC scan, that means a 1 MHz pulse will count 1000 EVERY SCAN! So, how fast is your high speed input? How slow is your slowest PLC scan?
If it is too fast or your Ladder is too slow, you may need to utilize scaling of some kind within your HSIO Counter configuration, or even use interrupts? This is the primary function of HSIO features - when Ladder scan is too slow - just use HSIO!
Good catch on the timing gotcha! IF the PLC scan can catch, say within 8 counts of 200, and the control can handle this "error". The remainder idea could still work. Instead of "D0 (count) > 1, AND D1 (remainder) = 0, THEN MATH (R0+7.08). The following could work: " "D0 (count) > 10, and D1 (remainder) < 10, THEN MATH (R0+7.08).
But could there be another way to "test the pumps at different speeds"?