Shop OBEX P1 Docs P2 Docs Learn Events
External 1ms Timer driven by Crystal Oscillator... — Parallax Forums

External 1ms Timer driven by Crystal Oscillator...

ryfitzger227ryfitzger227 Posts: 99
edited 2012-05-22 18:30 in BASIC Stamp
Okay.. for this please read the thread below..
http://forums.parallax.com/showthread.php?139810-DS1302-amp-BS2-as-ET-Timing-System&highlight=ds1302

Now, in this post Mike Green talks about creating an external timer driven by a crystal oscillator.

He recommended, however, to use another microcontroller. Ex: Propeller. Yes, I would probably agree. The only thing is that the only programming language I know is PBASIC. I don't want to have to learn how to user the Propeller language. I'm also controlling my program with a GUI via Visual Basic, and I only know how to do that through the Stamp.

My project is basically like a Stopwatch. A car breaks an infared beam, sending a signal to the stamp. The stamp starts the timer, and when the car breaks the beam again, it stops the timer. Next, the time is displayed on the Visual Basic Program. (Think of the infared beam, and the car breaking it, as a pushbutton on a stopwatch and you pressing it.) As we all know, the stamp isn't a very good/accurate timer, so I will need some help.. And I figure the only way that will have to work is this "external 1ms timer." So I just need to know what that is, and how to use it.

Can someone give further detail on this "external 1ms timer?" As in like a schematic, maybe an example code on how the stamp would read it, stuff like that. I'm fairly new to this, and I would really like to see this work. Haha.

Any help is appreciated!!
-Ryan

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-05-22 16:19
    External Counter/Timer chips are available for many CPU families, however most of those are programmable via a multi-bus parallel interface. You could use 74xx series logic chip, such as timers and clock them with a pulse triggered by your start event and then latch the count at the end. The parts count and complexity may be more than you want to deal with here.

    For example, here is a hobbyist-level frequency counter constructed from 74xx logic. I built something similar in college. There are a lot of cips here, but then to get the data into the BASIC Stamp Microcontroller you would also need some shift registers connected to the Parallel outputs.

    The main reason the Propeller is mentioned is that it has the speed and hardware to do what you're trying to do. Otherwise you will need a some external hardware to capture your counts and get them into the BASIC Stamp Microcontroller.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-05-22 18:11
    How long is the duration you will be measuring?

    The Stamp can do pretty well to about 1ms resolution with timed loops. The loop does not use PAUSE like you did in the other thread. Instead it is a tight loop that simply counts as fast a possible from beginning to end of the event. The count advances at about 1400 counts per second (plain BS2). When the event ends, the program multiplies the number of counts accumulated times a calibration factor that you have to determine once. It might be accurate enough.

    Here at this URL is more description. There are also a couple of links active to external timer chips. Both Al Williams and Peter Anderson used to formulistas here, and both of them had (or maybe still have) Stamp-friendly timer chips for sale.
  • ryfitzger227ryfitzger227 Posts: 99
    edited 2012-05-22 18:30
    Alright. Forget about milliseconds, etc. The main reason why I used ms was because if you divide it by 1000 you'll get seconds. Ex: 12345ms/1000 = 12.345sec. Therefore you go all the way back to the thousandths place.

    The main reason i'm relying on the forums is because the guy I originally ask for things like this is in a big partnership with IBM, and I don't like bothering him. He asked me for the parameters of the system.. Like if all I needed was seconds, tenths, hundredths. (He didn't even give me the option for thousandths! Haha) He also told me that it wouldn't be too complicated (either the code or circuit).. I'll just talked to my "customer" and he said that we could go to hundredths. So forget about that.

    Is there an easy way to do this... ?
Sign In or Register to comment.