Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp 2 measuring time — Parallax Forums

Basic Stamp 2 measuring time

sam_dsam_d Posts: 2
edited 2006-04-27 18:58 in BASIC Stamp
Hey Everybody,

I am a Mechanical Engineering student and have been working on a design project involving a hybrid golf cart. I am using a Basic Stamp 2 module alongwith the carrier board for our charging control circuit. My question involves trying to measure a signal for a certain amount of time.

I am trying to measure a digital input and would like to program the module to activate an IF loop only if it gets a high input for over 5s (or some other value). However, I cannot seem to work out how I would do that. Could someone give me some ideas regarding this? This is my first time ever working with microcontrollers so I am a bit lost really!

Thanks in advance!

-Sam

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-04-27 10:00
    Sam -

    Take a look at the Pulsin and Count commands. Both are used for analyzing input signals.
    One or the other should do what you need.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • stamptrolstamptrol Posts: 1,731
    edited 2006-04-27 11:34
    The general process to do what you want is to have two loops.

    The first keeps checking for the input. When the input is detected, a second loop is used to start counting some PAUSE value, perhaps 100 msec or 200 msec.

    After each increment, go back to the first loop and see if the input is still high. Keep doing this until you've counted a suitable number of 200 msec intervals.
  • metron9metron9 Posts: 1,100
    edited 2006-04-27 14:26
    Here is a clock program I wrote for the bs2 using just resistors and a capacitor (second post in this thread)
    http://forums.parallax.com/forums/default.aspx?f=5&m=94508&g=94637#m94637

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • sam_dsam_d Posts: 2
    edited 2006-04-27 18:58
    I used the count function and it seemed to serve our purpose well, so thanks a lot bruce! Also thanks to everyone else for your suggestions. I am fairly certain I will be sticking to designs with the Basic Stamp for projects in the future after having seen how easy it is to work with, and the excellent forums you guys have set up here.

    -Sam
Sign In or Register to comment.