PDA

View Full Version : Basic Stamp 2 measuring time



sam_d
04-27-2006, 05:00 PM
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

Bruce Bates
04-27-2006, 06:00 PM
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 -->

stamptrol
04-27-2006, 07:34 PM
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.

metron9
04-27-2006, 10:26 PM
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_d
04-28-2006, 02:58 AM
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