Shop OBEX P1 Docs P2 Docs Learn Events
Timer with inputs adding time; where to start? — Parallax Forums

Timer with inputs adding time; where to start?

tahlorntahlorn Posts: 18
edited 2011-10-25 09:11 in BASIC Stamp
Hi all!

Looking for some pointers (directed to tutorials would be fine) for where to get started.

I am still rather new to the Basic Stamp. I am building a system that primary function is to be a timer. I would also want another program / function running in parallel that was counting the number of input signals and adding it to the time.

The project would be a laser maze. Once the program starts the timer counts up, and every time the Stamp gets an input signal (would be from the receiver of the laser system) it would add time to the clock. Time would be displayed on, well, a display.

Is there a tutorial out there that would be able to help me? Click to start timer, click to stop, and shown on a display would be the base for one part, but the part I am really uncertain about is adding time to the clock. Would the system be easiest as a timer that adds time to it continuously (jumps from 30 seconds to 50 seconds is a laser beam is broken due to a 20 second penalty) or to just time it normally, and then add the penalty time at the end for how many times the laser beams have been broken ( time_total = stopwatch_time + 20*beam_count )? I have never worked with a timer, my experience has just been for servo and stepper motor systems.

Any advice, pointers, or links would be greatly appreciated! As I build this project I will be certain to update here and share!

Thanks!

-Michael

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-10-25 08:47
    From the main Parallax webpage, click on the "Resources" tab and you will see a link to the Nuts and Volts Columns index. Also from the main webpage, click on the "Downloads" tab, then either click on "Basic Stamp Documentation" or on "Educational Tutorials & Translations". Fundamental references are the "Basic Stamp Syntax and Reference Manual" and the "What's a Microcontroller?" tutorial.

    Timers are difficult with the Stamps because there's no independent timer. You can use the PAUSE statement as a kind of fairly accurate "tick", but you have to account for the execution time of other statements (see here under app-notes link). In your case, this may not be too much of an issue since the times are on the order of seconds. Another solution is to use an external real-time clock like the DS1302 from Maxim / Dallas. There are examples of this in the Nuts and Volts Columns.
  • tahlorntahlorn Posts: 18
    edited 2011-10-25 09:11
    Thanks for the reply Mike Green. I will definitely look through that.

    I will work on getting one of the DS1302 modules and play around with it. Hopefully there is an easy spot to add in time additions. Once I have an actual timer up and running I will come back here and ask for more guidance, or share my success. Danke!

    -M
Sign In or Register to comment.