itsmoked
Electrical
- Feb 18, 2005
- 19,114
I was commissioning a PLC based filter-plant controller yesterday and needed to display the instantaneous flow. I had the flow coming in as a pulse per gallon. And was expecting a flow of around 20GPM.
To get the most recent instantaneous value I decided to count how many 10ms periods occurred between rising edges of the flow pulses. Then I would essentially invert that captured count of 10ms periods and multiply by 6000 to get gallons per minute. [(1/10ms counts) x 100 ms/s x 60s/min].
I ran the system and the indicated flow was 20~21GPM. Sweet! Then I looked at the actual flow meter and saw it was doing only 14GPM. Gack! My calculated flow was off by quite a bit.
Reviewing my method:
I was using a _10ms system generated contact to increment a counter.
When a flow pulse rising edge came in I would snatch the counter value into a register.
Then I would reset the counter in the next rung down.
The counter would again start totalizing the 10ms contact closures generated by the PLC.
Then I'd do the above mentioned math and send the result off to the HMI display.
After a whole lot of head scratching I realized that the pulses coming from the water meter were about 4.2 seconds apart. Yet the totals my counter was coming up with were numbers like 286 (10ms periods) which, of course, means 2.89 seconds!! (Hence the greater indicated flow from the inverted result)
I'd always wondered about the asynchronous aspects of a PLC, where it comes by on a scan and checks a system contact at some quasi beat frequency - what happens? Since the scan time was running 5~6ms the system generated _10ms contact was being missed about 1/3 the time. Nasty. Now I know.
There's probably a better way but I don't see it on this relatively simple PLC (CLICK).
Keith Cress
kcress -
To get the most recent instantaneous value I decided to count how many 10ms periods occurred between rising edges of the flow pulses. Then I would essentially invert that captured count of 10ms periods and multiply by 6000 to get gallons per minute. [(1/10ms counts) x 100 ms/s x 60s/min].
I ran the system and the indicated flow was 20~21GPM. Sweet! Then I looked at the actual flow meter and saw it was doing only 14GPM. Gack! My calculated flow was off by quite a bit.
Reviewing my method:
I was using a _10ms system generated contact to increment a counter.
When a flow pulse rising edge came in I would snatch the counter value into a register.
Then I would reset the counter in the next rung down.
The counter would again start totalizing the 10ms contact closures generated by the PLC.
Then I'd do the above mentioned math and send the result off to the HMI display.
After a whole lot of head scratching I realized that the pulses coming from the water meter were about 4.2 seconds apart. Yet the totals my counter was coming up with were numbers like 286 (10ms periods) which, of course, means 2.89 seconds!! (Hence the greater indicated flow from the inverted result)
I'd always wondered about the asynchronous aspects of a PLC, where it comes by on a scan and checks a system contact at some quasi beat frequency - what happens? Since the scan time was running 5~6ms the system generated _10ms contact was being missed about 1/3 the time. Nasty. Now I know.
There's probably a better way but I don't see it on this relatively simple PLC (CLICK).
Keith Cress
kcress -