Shop OBEX P1 Docs P2 Docs Learn Events
Count — Parallax Forums

Count

argmafiaargmafia Posts: 30
edited 2006-03-10 03:40 in BASIC Stamp
on the BS2 is there a way to keep track of·or count the pulses on a certain input pin without using the pulsein command?· The reason I can't use the pulsein command is because I need·to count the pulse·for an undetermined amount of time.· ·I was trying to use a for loop but was unable to.

Comments

  • argmafiaargmafia Posts: 30
    edited 2006-03-08 22:45
    Another question is there a 24 volt power supply we can use for our basic stamp 2? We need that much voltage because we need to power 3 stepper motors, 3 photosensors, an lcd, and a keypad. Would you happen to have some sample schematics to hook it up without using the BS2 carrier board?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-03-08 22:57
    argmafia -

    The COUNT command will accumulate the number pulses over a FINITE period of time, but to countinously check over a more infinite or undetermined period time, you will indeed need to use a FOR ... NEXT loop. The following is just a simple example:

    PulsePin PIN 1 ' Arbitrarily assign pin port 1
    Pulses VAR·WORD 'Count to a max. of·65535 pulses
    TimeToStop VAR BIT 'Stop flag (set elsewhere)
    NO CON 0
    YES CON 1

    ProgramStart:

    Input PulsePin 'Set pin port to INPUT mode
    Pulses = 0
    TimeToStop = NO

    PulseLoop:

    'GOSUB OtherTasks 'Jump out and do other tasks quickly, if necessary

    IF TimeToStop = YES GOTO ExitProgram: 'Time to display and quit?

    If PulsePin <> 1 GOTO PulseLoop 'Is pulse present, if not try again

    Pulses = Pulses + 1 'Accumulate pulses

    GOTO PulseLoop 'Return and check again

    ExitProgram:

    DEBUG "Pulse Count Total = ", Pulses

    END

    Regards,

    Bruce Bates



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 3/8/2006 11:17:13 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-03-08 22:59
    I would not hook 24V to the stamp, especially if you are not using a carrier board. This is because the voltage regulator is the old style where excess voltage is dumped as heat. The regulator on the stamp is very small meaning it is very inefficent in cooling itself from the heat it produces. Looking at the spec shows it is only rated for 15V:

    attachment.php?attachmentid=73657


    It sounds like you need a seperate counter circuit that you can read in the value when you want it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
    236 x 40 - 1K
  • argmafiaargmafia Posts: 30
    edited 2006-03-08 22:59
    I tried the FOR NEXT loop but I am not doing it right. I don't get what the PulsePin PIN 1 means???
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-03-08 23:19
    argmafia -

    Check it again, the posting ran away from me <sigh>.

    Bruce

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-09 05:38
    argmafia said...
    Another question is there a 24 volt power supply we can use for our basic stamp 2? We need that much voltage because we need to power 3 stepper motors, 3 photosensors, an lcd, and a keypad. Would you happen to have some sample schematics to hook it up without using the BS2 carrier board?
    The BASIC Stamp Super Carrier Board is one of the only boards that would allow you to power it from 24 volts.· The reason is that the BASIC Stamp on that board is powered from the Boards regulator and is getting 5V.· On many other boards the BASIC Stamp is powered from VIN, which cannot exceed 15V (BS2) or 12V (Anything higher).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-03-09 05:46
    How fast are the pulses you are trying to count, and what determines the amount of time for counting? There is a big difference between 1 pulse per 10 seconds for an hour, versus 10000 pulses per second for one second.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • SteelSteel Posts: 313
    edited 2006-03-09 20:09
    "The BASIC Stamp Super Carrier Board is one of the only boards that would allow you to power it from 24 volts. "

    --But is the voltage regulator itself capable of handling that high of voltage? Most 5V Regulators begin getting inefficient and heating up after 12V...?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-10 03:40
    Well, you could look up the datasheet on the regulator...But I think we've already done that since it's rated at that voltage.· Of course, the current won't be as high at that voltage, but that's to be expected.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.