Shop OBEX P1 Docs P2 Docs Learn Events
display time in debug — Parallax Forums

display time in debug

chasingchasing Posts: 14
edited 2011-02-24 05:49 in BASIC Stamp
Is there a way to display the current time in the debug screen?

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-02-20 06:21
    The STAMP generates the serial stream to the debug window. You would need a real time clock somewhere in the loop. The RTC could be connected to the STAMP or the STAMP could get the time form another system that has a clock..
  • StampmysterStampmyster Posts: 27
    edited 2011-02-20 07:23
    Hello,

    I think you might want to hook up a DS1302 Timekeeping Chip.They sell them in the Parallax store.

    They are inexpensive and easy to use. If you use a battery with it, it will remember the time. (There is a battery charging circuit built in.)

    Good Luck!
  • ercoerco Posts: 20,257
    edited 2011-02-20 14:34
    Per the replies here, there's no built-in RTC in a Stamp. You can fake a clock by writing a program with multiple nested pauses and DEBUG statements. With patience, you can get it reasonably accurate for a while, but it will eventually drift since there is no thermal compensation.
  • chasingchasing Posts: 14
    edited 2011-02-21 02:21
    I had a feeling of that. I couldn't find any commands relating to time display, so I figured I would have to add a circuit. Thank you all for your help.
  • ercoerco Posts: 20,257
    edited 2011-02-21 08:21
  • chasingchasing Posts: 14
    edited 2011-02-21 13:10
    @Erco: LOL.

    My plan is to have the time displayed on the debug screen when an event is triggered ( servo spins, RFID card is swiped, programmer's wife starts nagging, etc). I looked at the DS1302 and will be picking up one as well as the 32.768 KHz crystal.
  • ercoerco Posts: 20,257
    edited 2011-02-21 13:53
    I built an electromechanical gizmo for a friend that goes off every hour, like a clock chiming. I used a $10 wristwatch with a "chime" function. The voltage to the piezo beeper was high enough to trigger the input pin on the EMC uC that runs the whole sequence. It's running strong 3 years later, same watch battery, and the accuracy is incredible, it's always within a few seconds of my computer's internet time. I've considered using that hourly chime method to recalibrate a Stamp software clock every hour. It would be easy to write a clock program that wouldn't drift more than a few seconds per hour, and that error goes away every hour. Food for thought.
  • electrosyselectrosys Posts: 212
    edited 2011-02-21 15:39
    Here is an easy code for showing time on Parallax serial LCD, you have to change the SEROUT to Debug command, for show the time on Debug screen.
    ' Example Program: Parallax, ClockApp.bs2 
    ' Display elapsed time with BS2 and Parallax Serial LCD.
    
    ' {$STAMP BS2}                              ' Stamp directive
    ' {$PBASIC 2.5}                               ' PBASIC Directive
    
    hours          VAR     Byte                  ' Stores hours
    minutes      VAR     Byte                  ' Stores minutes
    seconds      VAR     Word                 ' Stores 1/10 seconds
    
    SEROUT 14, 84, [22, 12]                   ' Start LCD & clear display
    PAUSE 5                                         ' Pause 5 ms for clear display
    SEROUT 14, 84, ["Time Elapsed...", 13]       ' Text + carriage return
    SEROUT 14, 84, ["  h    m    s"]           ' Text on second line
    DO                                                    ' Main routine
    
     ' Calculate hours, minutes, seconds
    IF seconds = 60 THEN seconds = 0: minutes = minutes + 1
    IF minutes = 60 THEN minutes = 0: hours = hours + 1
    IF hours   = 24 THEN hours   = 0
    
    ' Display digits on LCD on line 2.  The values 148, 153, 158
    ' place the cursor at character 0, 5, and 10 for the time values.
    
    SEROUT 14, 84, [148, DEC2 hours,153, DEC2 minutes,158, DEC2 seconds ]
    
    PAUSE 991                                  ' Pause + overhead ~ 1 second
    seconds = seconds + 1                      ' Increment 1/10 second counter
    LOOP                                         ' Repeat main routine
    
  • deltabossdeltaboss Posts: 10
    edited 2011-02-24 05:49
    wow this is truly awsome if I were to extrapolate on this how would i go about adding days
Sign In or Register to comment.