Shop OBEX P1 Docs P2 Docs Learn Events
Timekeeping chip and Datalogger — Parallax Forums

Timekeeping chip and Datalogger

TabiriTabiri Posts: 23
edited 2010-12-15 16:37 in BASIC Stamp
I have both the datalogger and the timekeeping chip hooked up - separately - to the BOE. (I also have the crystal hooked to the timekeeping chip as well). What I would like to do is have the datalogger take certain measurements at specific times, according to the clock on the timekeeping chip. I don't have any ideas on how to connect them on the protoboard or on how to program that. Could I have some help with this?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-11-29 18:41
    When you hook them up by them selves what pins do you use? Try connecting them to pins so they don't share any (except power) and get that working. Your code needs to check the time every once in a while and then do the logging when the time is correct.
  • TabiriTabiri Posts: 23
    edited 2010-11-30 17:09
    How do I do the coding? Would I just write the time to a file, and then have the datalogger check that file once in a while and log when at the right time? Or should I just have the timekeeping chip keep the time on the chip, and have the datalogger refer to that for the time?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-30 17:28
    The datalogger doesn't function independently. It's completely driven by commands from the Stamp, so there's no way for the datalogger to check anything. Similarly, the real-time-clock doesn't function by itself except to count up the time and date and check for the alarm time and date to occur. When the alarm goes off, it simply sets an I/O pin. That's all.

    The Stamp (and Stamp program) has to do all the work. It has to sample the time or sample the alarm pin, decide when it's time to log something, then communicate with the datalogger to log the data to the memory stick file.
  • TabiriTabiri Posts: 23
    edited 2010-12-01 16:57
    Thank you.

    So all the datalogger does is log data to the memory stick file?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-12-01 17:07
    The datalogger can read and write files on the memory stick and it can interface to some other non-memory USB devices like a mouse or keyboard or joystick or printer, but this interfacing is not straightforward and you have to know a lot about the internals of the device you're trying to use.
  • TabiriTabiri Posts: 23
    edited 2010-12-06 16:38
    Ok. Thanks.
  • TabiriTabiri Posts: 23
    edited 2010-12-06 17:43
    Ok, I have another problem. I was using this code:
    http://www.vanguard-co.com/download/basic_stamp_accesories/ds1302Rtc.pdf
    (it's on page 9)

    and I was going to put in a line of coding that if the clock reached a certain time, go to a subroutine to display a debug statement (using and if-then statement). However, when it gets to right after the "then" in the coding it keeps expecting a label. Why is it doing that, and how do I fix it?

    I put an attachment of the code I'm using on here.

    more timekeeping.bs2
  • MoskogMoskog Posts: 554
    edited 2010-12-06 23:15
    You didnt attach the program with the error message so I cant tell you exactly what is wrong with your code.
    Usually you put a GOTO or GOSUB after the "then" in your IF THEN statement. In case of a GOSUB you do have to specify what subroutine you want the program to go to.
    Like this:
    IF (something) THEN GOSUB Test

    Now the program will go to the subrotine named Test and return back when it reach the RETURN command at the end of that subroutine.

    Don't forget to decide PBasic version on top of your program, usually like this:
    ' {$PBASIC 2.5}
  • TabiriTabiri Posts: 23
    edited 2010-12-07 17:44
    Yeah, sorry about the program. I guess I attached it wrong.
    Thanks for the help; I hadn't even noticed the PBasic version was missing.

    I fixed that and encountered another problem, however.
    more timekeeping.bs2
    I marked out the problem with a big HERE.

    I tried to make some debug statements appear onscreen if a certain second was reached, and then disappear after that second was gone. what seems to be happening though, is the debug statement stays on screen far after it was supposed to. Is there some command I'm missing in there?
  • MoskogMoskog Posts: 554
    edited 2010-12-07 23:49
    Tabiri
    I think your code is not the best one for what you plan to do. The code you are using is more a tricle-charge code and its a little bit confusing when learning the 1302.
    I recommend you take a look at Chris Savage's discussion on this time keeping chip here
    The thread is including some excellent examples on using the 1302 and is much easier to understand then the program you are working on.
    He also made a template ready for you to develope the way you wish.

    Beside of that, when comparing values out of the DS1302 you write
    IF seconds = 4 THEN GOSUB no

    Try this way instead:

    IF (seconds = $04) THEN GOSUB........
  • TabiriTabiri Posts: 23
    edited 2010-12-08 17:36
    Thanks for the help.
    I put the if-then statement in the way you said, but it didn't change it. The debug statement still stays up on the screen.

    I did look at the demo code thread. I uploaded the template, but all it displays is 00/00/00 00:00:00:00
    I am unsure if that means something is wrong, or if the template wasn't meant to display the time.
  • MoskogMoskog Posts: 554
    edited 2010-12-09 03:51
    Well,, your DEBUG statements won't disappear because you never tell them to. You do a good job on solving that problem by making the Blank-subroutine but you never call it up.
    Try change this line: IF seconds > 5 THEN GOSUB loopi
    to
    IF seconds > 5 THEN GOSUB Blank


    On the Template-issue its correct that DEBUG screen shows 00/00/00 00:00:00:00
    at the beginning. (As long as the RTC-time is not set)
    But the seconds should begin to increase once the program is started. If it doesnt, thats probably because the PIN-connections on the BS2 is uncorrect, refer to Chris' picture in his first post. PIN connections can be different compared to your project. Also remember the X-tal and the 5V.

    Hope this helps.
  • TabiriTabiri Posts: 23
    edited 2010-12-09 17:06
    Thank you. I put in the blank subroutine and it works perfectly.
    Also, I looked at the picture and moved some jumper wires and resistors around, and now the template works perfectly too.

    Thank you very much :)
  • CraigLCraigL Posts: 8
    edited 2010-12-11 11:58
    I have been interested in building a similar datalogging tool. Would you be willing to share your schematic?

    Thanks.
  • TabiriTabiri Posts: 23
    edited 2010-12-13 16:36
    Me? If so, I don't have a camera so I can't take pictures, but if you want I can try to describe it; I've also got some links that help.
  • TabiriTabiri Posts: 23
    edited 2010-12-13 17:08
    I've got another problem; the crystal has stopped working. I even took that crystal out and put in another one, but it still won't work.
  • CraigLCraigL Posts: 8
    edited 2010-12-13 20:58
    Tabiri wrote: »
    Me? If so, I don't have a camera so I can't take pictures, but if you want I can try to describe it; I've also got some links that help.

    Links would help. I have found "App Kits" or "Application Notes" really helpful in the past. Easier for me to cheat off of an example than go from pure theory and data sheets! I have made good use of the example projects in Parallax "What’s a Micro...", and "Signals..." in the same fashion. But I can't find any data logging App Kit or other that combines a 555, Stamp, and a data module - all which I have assembled. Thanks in advance for all the help.
  • TabiriTabiri Posts: 23
    edited 2010-12-14 17:34
    Well I just hooked up the datalogger normally - http://www.parallax.com/Portals/0/Downloads/docs/prod/comm/MemoryStickDataloggerV1.1.pdf
    timekeeping chip - http://www.vanguard-co.com/download/basic_stamp_accesories/ds1302Rtc.pdf
    and - http://forums.parallax.com/showthread.php?77867-DS1302-Demo-Code-%28Updated%29&highlight=chris+savage+ds1302
    I used Chris Savage's picture to hook it up.
    I'm using a DS1302 timekeeping chip, so i'm not really sure if these would help with a 555.
  • TabiriTabiri Posts: 23
    edited 2010-12-15 16:37
    On another note, if anyone can help, all my timekeeping chip displays on the debug screen is
    SUN 01/01/00 00:00:80.
    I think the problem is the crystal, but even after replacing it nothing has changed.
Sign In or Register to comment.