Shop OBEX P1 Docs P2 Docs Learn Events
High Speed Counting — Parallax Forums

High Speed Counting

MelMel Posts: 6
edited 2005-06-15 19:20 in BASIC Stamp
I have a project where I am trying to count pulses coming from a turbine flow meter. I tried some of the StampWorks experiments such as #16 Counter.bs2 it did not appear to be able to count fast enough. I tried the following code (See Below) and it appeared to work OK on the workbench with a function generator supplying the pulses but is less reliable in real life with the pulses coming from the flow meter (flow meter is more erratic as valve opens and closes)
·
Basically I want to wait until input 10 goes low (signaling the sol valve opened).· Start counting pulses on input 0 and when the count gets to 725·· Make output 15 low (signals correct volume has been measured), reset the count and wait to do it all again.
·
According to the meter documentation at Maximum flow rate the pulse freq would be 828 Hz - under normal circumstances I should be well below this.·
·
What is the best way to accumulate a count at these speeds and what is the max freq I can expect to be able to count?
··
My thoughts on this code (Extracted from #17 FreqIn1.BS2) were to look at the COUNT every 1/20 of a second find the count for this period and add it to a running total
·
‘======= CODE SNIPIT ==========
Hold:
OUT15 = 1
IF IN10 = 1 THEN Hold··············· 'Wait for input 10 (TEN) to go low
DEBUG CLS
·
Main:
COUNT 0,50,Cycles
DEBUG HOME, 10, "Cycles Per Second: ", DEC (Cycles * 20),CR
L2Count = L2Count + Cycles
IF L2Count >= 725 THEN Done
GOTO Main
·
Done:
DEBUG CLS
DEBUG "Were Done ",CR
DEBUG "Cycles Per Second: ", DEC (Cycles * 20),CR
DEBUG ? L2Count, CR
OUT15 = 0
PAUSE 1000
L2Count = 0
GOTO Hold
·

Comments

  • BeanBean Posts: 8,129
    edited 2005-06-15 11:36
    You may need a schmitt trigger gate to clean up the pulses coming from the flow meter.
    Also you are going to miss pulses because the DEBUG line sends serial data to the PC, and the program must wait for the data to be sent.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012

    Product web site: www.sxvm.com

    "If you keep doing what you always did, you'll keep getting what you always got."
    ·
  • MelMel Posts: 6
    edited 2005-06-15 19:20
    Bean,

    The flow meter is equipped with a board that amplifies and conditions the low-amplitude signal from the magnetic pickup coil on the meter.· From there I have it going into a OPTO22 type module (IDC5 Gordos) that converts the DC pulse of 12 volts to a 5 volt logic.· From the specs for the OPTO22 it states Maximum Turn-On Time .2 mSec and Maximum Turn-Off Time .4 mSec .· That would be around 1600 Hz or almost twice as fast as the meter pulses.· The pulses from the meter on an Oscilloscope look like a nice square wave with a constant amplitude and only the freq varying with the flow.

    Your make a good point about the DEBUG statements.· I had not thought of the time (and counts) lost while communicating with my Laptop.· The DEBUG statements are not needed in the final version and I was only using them for troubleshooting.·· I am going to remove them and do some more testing.· The problem is that I am measuring the flow of Liquid Nitrogen at 100 psi· so I can’t just fill up a bucket and measure what came out.· It comes out very fast (almost violent) and then changes to a gas also very rapidly.
    ·
    Do you have any other ideas about the program?· What would be the recommended way to accumulate a fast changing count?· What is the fastest rate I could expect to be able to count reliably with a BS2 Stamp?
    ·
    Thanks in advance
    Mel

    Post Edited (Mel) : 6/15/2005 7:35:03 PM GMT
Sign In or Register to comment.