Shop OBEX P1 Docs P2 Docs Learn Events
BS2: Uploading Real-Time Clock Using PC System Time — Parallax Forums

BS2: Uploading Real-Time Clock Using PC System Time

rjk5rjk5 Posts: 3
edited 2006-10-26 19:50 in BASIC Stamp
I have used data acquisition software (Windows 2000/XP) that allows the real-time clock of a data logger to acquire the system time of the serially-connected PC. I am interested in doing the same thing with the Pocket Watch B of my·Stamp 2 project, but I am willing to substitute another real-time clock if necessary. Has anyone successfully maintained the real-time clocks of their stamps through the serial connection with the PC? If so, please advise as I do not wish to reinvent the wheel.

rjk5·

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-10-24 19:35
    Hello,
    ·
    ·· In order to accomplish this task the PC will need software running that monitors the serial port for a request from the BASIC Stamp for the time.· It would then reply with the time and/or date information.· You would need to empirically test to determine the lost time in the transfer and account for that as well.· I tend to use the DS1302 in all of my projects because of the wide operating voltage, battery backup and charging circuit, and the RAM which is also backed up.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Larry~Larry~ Posts: 242
    edited 2006-10-25 18:47
    This is what I use in qbasic I attached the EXE file of this same program.

    COLOR 14, 11, 1

    CLS

    INPUT " WHAT COM PORT (1 OR 2)"; X$

    IF VAL(X$) = 1 THEN GOTO ONE

    IF VAL(X$) = 2 THEN GOTO TWO

    ONE:

    OPEN "COM1:9600,N,8,1,CD0,CS0,DS0,OP0,TB0,RS" FOR RANDOM AS #1

    GOTO START

    TWO:

    OPEN "COM2:9600,N,8,1,CD0,CS0,DS0,OP0,TB0,RS" FOR RANDOM AS #1

    GOTO START

    START:

    CLS

    LOCATE 10, 15

    PRINT "THE TIME IS "; TIME$, "THE DATE IS "; DATE$

    PRINT #1, MID$(DATE$, 1, 2)

    PRINT #1, MID$(DATE$, 4, 2)

    PRINT #1, MID$(DATE$, 9, 2)

    PRINT #1, MID$(TIME$, 1, 2)

    PRINT #1, MID$(TIME$, 4, 2)

    PRINT #1, MID$(TIME$, 7, 2)

    CLOSE #1

    LOCATE 15, 25

    PRINT " THE DS1302-RTC HAS BEEN SET "

    SLEEP 5

    CLS

    END



  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-10-25 20:26
    Hello,
    ·
    ·· That could work if the Stamp Module was waiting for those characters that are being sent.· My own thoughts were to leave the PC side program running monitoring the port for a command byte from the PC to get the time and then send it.· You’re also sending the time in this program as a series ASCII characters, whereas it would take less bytes and be easier to deal with if you sent the binary values BCD packed.· This would be 3 bytes for the time, for example.· The method you posted will send 12 bytes total, as far as I can tell.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Larry~Larry~ Posts: 242
    edited 2006-10-26 19:36
    I have no Idea, I did this years ago it was for a ds1302 it was something quick and dirty. The bs2 was waiting for the data per a clock programming switch, when on it went to serin waiting for input. I sent this just for an Idea of what could be done without much work.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-10-26 19:50
    There’s certainly nothing wrong with doing it this way…I just wanted the original poster to know what would need to be done to read the data, and you to know how it could be sent more efficiently.· If it works, it works.· You certainly don’t need to change it.· Perhaps the original poster can use it like it is.· Take care.

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