Accurate timing on a Basic Stamp?
Tom-n-Tony
Posts: 12
in BASIC Stamp
Is there any way to get an accurate time on the Basic Stamp? Following the tutorials in “What’s a Microcontroller” I understand the concept of using a For...Next loop to approximate time, but that requires that you know how long the instructions inside the loop take to execute. I’m interested in some kind of timer that will set a Pin to HIGH on a defined interval. I could then construct my programs inside a Do Loop that would monitor the Pin. I saw that Parallax offers a timer chip, but wondering of there is any ‘native’ on-board functionality that will do this.
Thanks in advance for your input,
Tom
Thanks in advance for your input,
Tom
Comments
http://www.emesystems.com/OLDSITE/BS2index.htm#misc
One simple expedient is to connect a capacitor to a pin through a 100 ohm resistor, and also connect the capacitor to 5 volts Vdd through a 1 M resistor. At one point in your DO loop, make the pin a low output to discharge the capacitor, and them return the pin to input, so the cap can start to charge up through the 1M. The instructions in the loop continue and have to finish before the capacitor can charge up to the 1.4V threshold. The loop sits there waiting for that to happen, whence the loop cycles. Timing of the loop is regulated externally by the RC time constant, even if there happens to be wobble in the instruction path. A bit longer time can be had by discharging down from 5V to 1.4V. Choose the capacitor appropriately. That said, the 555 timer would be more accurate.
Many real time clock chips have a square wave output at 1 Hz, and that can be useful for what you want to do, especially if you also need the most accurate real time or alarms.
Any thoughts would be appreciated.
Thanks,
Tom
+1
Thanks for your help!
Tom
You presume correctly.
I need software for a Parallax USB Oscilloscope. Help?
turbineguy