News:

  • April 16, 2026, 07:15:00 PM

Login with username, password and session length

Author Topic: X0 Totalizer Program Help Wanted  (Read 11888 times)

Scada_Guy

  • Newbie
  • *
  • Posts: 3
X0 Totalizer Program Help Wanted
« on: August 15, 2011, 11:57:54 AM »
I am using a D0-06DR plc with DirectSoft 5.3
I have a pulsed input from a flow meter which has a range of 100Hz at 40 gpm. I understand that this means that 100 pulses per second for 1 minute is 40 gallons of flow. I have installed the meter into X0 and get a pulse when there is flow. I have:
LD K10
OUT V7633
LD K1
V7634
UDC CT174
CT174 is working just fine. when there is flow, it counts and when there is no flow it doesn't count. The typical flow rate of the meter is approx 20 gpm for several minutes at a time based on an outside source, meaning not controlled by the plc or an automated valve. I am not sure how to tell when there is flow inorder to add flow and totalize etc. This is my first experience with a pulsed input.
I have used analog flow meters before and they are somewhat straight forward. When there is no signal/flow, the value is zero or less than some value, you can load a zero, or do something else if needed.
Can anyone can help me with some code or direction?
Thank you in advance...



b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Re: X0 Totalizer Program Help Wanted
« Reply #1 on: August 15, 2011, 12:04:42 PM »
I haven't used these but does that also mean that 6000 pulses = 40 gallons regardless of the time period. Then 150 pulses = 1 gallon. Each time the counter is => 150 add one to a count and subtract 150 from the counter total.
An output is a PLC's way of getting its inputs to change.

Scada_Guy

  • Newbie
  • *
  • Posts: 3
Re: X0 Totalizer Program Help Wanted
« Reply #2 on: August 15, 2011, 02:14:25 PM »
You have hit the nail on the head. 150 pulses equals 1 gallon. So I LoadDouble the counter CT174 and compare to K150 (Pulses for 1 gallon) and as special registers(SP61 & SP62) become true, I reset CT174 and increment another UDC counter CT0 which stores the total number of gallons.
Thanks for your Help... :)

Scada_Guy

  • Newbie
  • *
  • Posts: 3
Re: X0 Totalizer Program Help Wanted
« Reply #3 on: August 15, 2011, 02:15:25 PM »
& or

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: X0 Totalizer Program Help Wanted
« Reply #4 on: August 15, 2011, 09:13:12 PM »
A few points:

If you check this every scan, you should never get into the high word of CTA174.  That would let you treat it as one 16-bit register in length which would let you use a standard ">" comparison contact instead of the more awkward CMPD.

Also, you don't CLEAR the register if it's over 150 counts, you SUBTRACT 150 from the pulse count as b_carlton noted, and add one to the gallon count.  (I'm assuming you can do arithmetic on the high-speed counter count like you can on the accumulator of a normal counter -- Hosties?).  Most of the time you won't happen to check it when the count is exactly 150.  Assume that on one check the count is 149 so you don't do anything.  Between then and the next scan, the total reaches 160.  This kind of latency is unavoidable.  If you clear the counter, those 10 counts or 0.06 gallons are lost permanently.  If you leave 160 - 150 = 10 in the register, they're lost for this cycle, but they still get counted in the next one.  Even after accumulating 100000 gallons, the latency error doesn't accumulate; you can only be off by the amount that flowed during the last scan.  Subtracting even covers for the extreme case of this issue.  Let's say your scan time is so long that 1000 counts have accumulated by the time you check the counter.  If you add 1 to the gallon count and clear, you've lost 5.7 gallons.  With the subtraction method, you only subtract 150 and add a gallon.  But...the pulse count will still be at 850!  Each of the next five scans will also report a total > 150, and all those gallons will get counted, albeit a bit late.

Finally, nothing says you have to totalize only complete gallons.  You can add a tenth of a gallon every time your counter exceeds 15 instead if you want.
« Last Edit: August 15, 2011, 09:25:55 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: X0 Totalizer Program Help Wanted
« Reply #5 on: August 15, 2011, 10:12:09 PM »
Why not use a single preset set at 150 , then increment gallons and do the reset in the interrupt?

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: X0 Totalizer Program Help Wanted
« Reply #6 on: August 15, 2011, 10:45:23 PM »
I was wondering if you could do that -- set an interrupt based on a count.  Been a while since I used the built-in HSC's.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.