Shop OBEX P1 Docs P2 Docs Learn Events
Simple Timer — Parallax Forums

Simple Timer

Twisted PairTwisted Pair Posts: 177
edited 2007-05-17 01:22 in BASIC Stamp
I'm looking for information to build a simple count-up or count-down timer that uses a BS2/BS2P-24 Etc,·and a Serial LED Display Etc. Any information would be helpful.


Thank you
Twisted Pair

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-15 23:09
    Start with the tutorials that you can download from Parallax's website.· On the main page, there are menu items.· Download is one.· In the submenu, you'll find Stamps in Class Tutorials.· Go there and download "What's a Microcontroller?".· That will get you started.· Other useful ones include the StampWorks manual that's based on their Professional Development Board, but applied to Stamps in general.

    By the way, do you mean "serial LCD display"?· That's what's used now more commonly.· If so, have a look at the datasheets that come with Parallax's serial LCD displays (downloadable from the webstore page for the item).

    How fast and how accurately do you need to count?· If it's a second or 1/10 second count, you will do fine with the Stamp.· If it's faster or needs to have high resolution (milliseconds), you'll need to use some kind of external time counter and time source and the Stamp will act as the display controller.
  • Twisted PairTwisted Pair Posts: 177
    edited 2007-05-16 00:07
    Hi Mike,
    I was hoping for something that was already in the forum or elsewhere. The display is a SLED-C4C LED Clock Display from Reynolds Electronics. The timing is not critical (not real time). Here is what I want to do. Have count-up timer which is user adjustable from zero to ten minutes and at the end of the cycle sound off a buzzer for a few seconds Etc. I have on hand a BOE board, BS2 and a BS2P-24 Module as well as a SLED-C4C LED Clock Display. I have the books from Parallax and many of the downloads. Do you know of any similar project that has already been done ?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-16 01:55
    I don't remember any such counter/timer although it sounds like a fairly common thing and I'm sure others have done it.· Several people have mentioned the SLED display.· I'd suggest you use the BS2p24 just because it has some additional features compared to the BS2 and you already have it.· You need to figure out how you want to set/reset the timer.· Do you want pushbuttons or a keypad?· There are plenty of examples of both between the downloads you already have and the Nuts and Volts columns.· I suggest the following tasks:

    1) Get the display working with the BS2p24 and your BOE.· You'll be able to use it for help in debugging.

    2) Get the pushbuttons or keypad you want and get it to work so you can set the "alarm" count.

    3) Do the up timer that's started with a pushbutton or key press.· Get it to look the way you want on the display.

    4) Combine #s 1-3.

    5) Add a compare of the current time to the alarm time.· If they're equal, use FREQOUT to generate a tone or a set of tones for the alarm.· I'm sure there's a diagram in the "What's a Microcontroller?" showing how to connect a small speaker to the Stamp and use it for noisemaking.

    Somebody may have done something like this before, but why wait when you can do it easily enough with what you already have and learn in the process.
    ·
  • Twisted PairTwisted Pair Posts: 177
    edited 2007-05-16 02:22
    Ok mike, Thanks for the help.
    PS: Will I need an external timing crystal for the BS2p-24 ?


    Thank you
    Twisted Pair
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-16 02:29
    I have posted a few times a counter based on the DS1302 RTC. Instead of storing the real time it is reset to 00:00 and begins counting up. Your code checks to see when the correct minutes and seconds have elapsed. Since I have already created some code for your display as well this would be a trivial thing. I will see what I can whip up.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Twisted PairTwisted Pair Posts: 177
    edited 2007-05-16 02:40
    Thank you chris. I just noticed that I missed a Parallax module sale this past weekend. I could have used a couple more of the BS2p-24 modules, But thats my luck....


    Thanks again Chris....
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-16 02:56
    The Stamps use a resonator which works like a crystal. It's not quite as accurate, but it's pretty good. As you may have noticed, the Stamps can time external events to within 2 microseconds or better (on the faster Stamps). The PAUSE timing is quite accurate as well.
  • Twisted PairTwisted Pair Posts: 177
    edited 2007-05-16 03:02
    These Stamps and what they can do are amazing. Thanks for all your advice Mike.



    Twisted Pair....
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-16 04:41
    Okay, I threw together a quick piece of code to demonstrate your requirements using my DS1302 Template. I added a single line to display using your SLEDC4 display into the original subroutine and then added to lines to initialization to reset it and show the decimal point. Other than that everything is straight forward. There are two constants, one for target minutes and one for target seconds. These could be set via push button but for purposes of this demo and for the sake of brevity I used constants. Currently the counter is set to count to 1 minute 25 seconds. When it reaches that point it turns on the status LED but you could also have it activate a relay, buzzer, etc. I built this on a Board Of Education in about 15 minutes (including code). Note that the minutes and seconds must be in hex notation (not value) because they are stored in BCD format in the DS1302. Hours could easily be added and more features. For those who don’t have the display connected I also printed to the DEBUG screen. The SLEDC4 is set to 9600 bps. I hope this code helps you out. If you have any questions let me know. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Twisted PairTwisted Pair Posts: 177
    edited 2007-05-16 15:39
    That was quick Chris. Wow....Will I need a crystal for the DS1302 ?



    Thank You
    Twisted Pair
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-16 17:05
    Yes, a crystal is required for the DS1302. With a little clever programming this could actually be done without the DS1302, but you would have to tweak the timing of the loop for the BS2p to get it right since you'd be using a small PAUSE value within a loop to implement the counter.· The push button I used had an internal LED, which is why I have the LED turn on to signify ready then go out when you press the button coming back on when the timing cycle is complete.· With minor changes this could also just reset itself and start over.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Twisted PairTwisted Pair Posts: 177
    edited 2007-05-16 20:39
    Ok Chris, I will order the parts needed (plus some other toys), to get this timer up and running. I will need to add a few pushbuttons and code to this project to allow for setting the minutes and seconds by means of pushbuttons. What is the difference between a Pushbutton and a Tactile Switch as listed on the Parallax Web-Site ?


    Thank You
    Twisted Pair
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-16 22:16
    The switches will be the same…The ones we have plug into the breadboard area on a development board. Code for incrementing the minutes and seconds can be found in a few places. Most notably the Stamp Works manual I think covers this or, I will attach a DS1307 code for the BS2p which shows how the time was set in it. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Twisted PairTwisted Pair Posts: 177
    edited 2007-05-16 23:11
    Thanks for the info Chris, I will try and sort it out. I just placed an order with Parallax so I will have to wait for the DS1302 plus the other goodies before I can try adding the pushbuttons and code. In your last post, did you mean to say DS1307 or DS1302 ?


    Thank You
    Twisted Pair....
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-05-17 01:22
    I meant DS1307 in that it is the code I attached which has button routines for setting the time. This would need to be adapted to the DS1302 which is very similar. If you’re still having problems when you get the parts let me know and I will see what I can do. I ran out of time last night. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.