Shop OBEX P1 Docs P2 Docs Learn Events
How can I sincronize a computer's clock with a basic stamp 2 — Parallax Forums

How can I sincronize a computer's clock with a basic stamp 2

Pantro040475Pantro040475 Posts: 8
edited 2012-02-25 11:56 in BASIC Stamp
Hi, need help to sincronize a computer's clock with a basic stamp.
What I'm trying to do is to turn on an alarm in a different time of the day and I need to know if there is a command for the BS2 to do this.
Thank you.
Miguel zepeda.

Comments

  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2012-02-21 10:10
    Since a Basic Stamp has no clock, where do you propose to get the current time? If you had a RTC (real time clock) like the DS1307 hooked to the stamp, you could write a PC program to connect to the stamp using RS232 (serial port) to get the time. If you are using Windows, there is probably an API (application program interface) which would let you set the clock.

    You could also go the other way and update the RTC from Windows - it will be a mutli-layer application in any case...
  • Pantro040475Pantro040475 Posts: 8
    edited 2012-02-21 12:05
    Ron, I trying to use the RTC from windows and get the current time from there. So where can I get the API?
    What command do I have to use to comunnicate the BS2 with the computer?
    Thank you.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2012-02-21 12:39
    Ron, I trying to use the RTC from windows and get the current time from there. So where can I get the API?
    What command do I have to use to comunnicate the BS2 with the computer?
    Thank you.

    You want the Basic Stamp to obtain the current time from your Windows computer, correct?

    If that's your goal, you need to have a program running on the computer and a serial connection between them.

    If you are using one of the Parallax boards like the Board of Education (with a 9 pin serial port or USB port), you can use the programming cable to communicate.

    What PC programming experience do you have?

    You can use various languages such as Visual Basic, C++, etc or even a VBScript to get the PC time and send it to the Basic Stamp. If you are not changing the PCs time, it should be pretty simple (depending on your PC programming skill level)...

    You woud use the BS2 Serin and Serout commands.

    Why do you need to get the time?
  • Pantro040475Pantro040475 Posts: 8
    edited 2012-02-21 13:13
    You are rigth.
    I have little experience in programming, We need to get the time because we have a computer controlling a ID checker for workers, it register at what time they come in and go out and now we have to use the computer's clock to turn on a buzzer.
  • RickBRickB Posts: 395
    edited 2012-02-21 13:27
    Many compilers and interpreters for the pc have a time command to retrieve the time from the pcs' clock-calendar chip. Free versions of many of them are available for download. A very short program could be written to read it and send it out the serial port.
  • Pantro040475Pantro040475 Posts: 8
    edited 2012-02-22 15:26
    Rick, Could you tell me a name of specific compiler or interpreter software that I can download that will be very helpful.
    Thank you.
  • $WMc%$WMc% Posts: 1,884
    edited 2012-02-22 16:26
    Pantro:
    '
    Take a look at Just Basic.com, Its a free compiler.
    '
    Theres an example code called "Clock2.BAS" in the example folder that might be of help to you. It reads the PC's clock and displays it graphically.
    '
    Also take a look at the serial example "TERMINAL.BAS",It shows how to open a com port.
    '
    You can use the program/debug line to talk to your PC.(RS232) with the Basic Stamp.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-02-22 22:42
    You might be able to directly get a time stamp via Telnet or a Putty program in Windows. If so, this would be much easier than the many other Windows alternatives as it directly provides the serial port interface.

    http://www.extraputty.com/features.html <=== Take a look here. This is 'ExtraPutty'

    PuTTY is a public domain free download version of software equal to TELNET and ExtraPuTTY has the timestamp feature you require.

    I am not sure if the latest Windows still comes with TELNET that includes a timestamp feature.
  • MoskogMoskog Posts: 554
    edited 2012-02-24 08:34
    Another idea is to read the time out of a GPS-module. Thats what I'm going to do as my next addition to my weather station project. My 1302 RTC is running a little too fast so I plan to make a syncronization once every night or so. What I'm not so sure about so far is how to handle daylight saving time but I guess I will find a way.
  • Mike GMike G Posts: 2,702
    edited 2012-02-25 11:56
    Pantro040475, Ron gave you excellent advice. Pick up an RTC.

    Otherwise, entering the lines of code below at the command prompt or in a test file with a bat extension will send the date and time to COM3 at 2400 baud. No compiler needed. With a little research and Windows scheduler, I'm sure you can come up with appropriate logic to accomplish the task.
    @ECHO OFF
    CLS
    MODE COM3: baud=2400 parity=N data=8 stop=1>NULL
    DATE /T > COM3
    TIME /T > COM3
    
Sign In or Register to comment.