Shop OBEX P1 Docs P2 Docs Learn Events
Is there a way to "reset" a program? — Parallax Forums

Is there a way to "reset" a program?

ocean billocean bill Posts: 15
edited 2012-05-02 14:39 in BASIC Stamp
I have a BS2 program that includes a Parallax Data Logger. The program runs fine right after I download the program from a pc. When the program is operating correctly, the data acquired from a sensor is stored to a flash drive at regular intervals. My problem is when I switch the stamp's power off and then switch it back on, the data logger has trouble synchronizing and the program hangs up.

I'm wondering if I need some sort of reset at the beginning of the program or something that emulates the process when I download the program from a pc. Obviously, I want to disconnect from the pc so the BS2 is portable and able to run reliably each time it is turned off and back on. Incidentally, I don't switch-off the stamp while the data logger is writing to the flash drive.

Thanks for any help,
Bill

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-01 20:33
    Any form of reset does the same thing including cycling the power or downloading a program. Part of your problem may be due to the Stamp being reset without resetting the datalogger.
  • ocean billocean bill Posts: 15
    edited 2012-05-02 11:15
    Thanks Mike. Your observation makes sense. To reset the datalogger, do I need to initialize some of the variables used in the datalogger code, such as counters and flags, or is there a more general way to do this? I am not very knowledgeable about the datalogger code and it is mostly a cut and paste subroutine.
    Bill
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-02 11:38
    I'm not quite sure how to reset the datalogger without cycling power to it. The Vinculum chip, which it's based on, has a reset pin, but it's not brought out to the connector. One of the other connectors on the board may have a reset pin, but I'd have to find find my datalogger board and trace out the wiring to tell for sure. Perhaps someone else knows? It'll take me a day or two to check.
  • ocean billocean bill Posts: 15
    edited 2012-05-02 12:09
    Here is snipit of the code:

    Datalog: '
    'DEBUG CLS, "Memory Stick Datalogger Demo V1.0", CR, CR, "Initializing..."
    PAUSE 200 ' Allow Time To Settle
    HIGH TX ' Initialize Transmit Line
    LOW RTS ' Take Vinculum Out Of Reset
    PAUSE 600 ' Allow Time To Settle
    DEBUG "Synchronizing..."

    Would setting RTS HIGH reset the Viniculum? If so, would that be something to try?
    Bill
  • davejamesdavejames Posts: 4,047
    edited 2012-05-02 12:15
    Mike Green wrote: »
    I'm not quite sure how to reset the datalogger without cycling power to it.


    Welllllll...a wild idea.

    Would it be possible to initerrupt the Datalogger power with a transistor (or FET) so that a pin from the Stamp drives the xistor, which turns it on/off?
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-02 12:36
    RTS won't help you since it's not a "real" reset. /RESET is on the Vinculum's pin #9 and /PROG is on the Vinculum's pin #10. It looks like the 3 pin header sticking up from the board labelled "R" (/RESET), "P" (/PROG), and "G" (ground) could be used. Connect "R" to an I/O pin and make it low for 100ms or so, then change the I/O pin back to input mode. That should reset the Vinculum chip just as if the power were cycled.
  • ocean billocean bill Posts: 15
    edited 2012-05-02 14:39
    Thanks Mike. I will try that in the future and let you know.

    Thanks davejames. I was thinking something similar to your suggestion, but hadn't thought of using a transistor for the switch.
    bill
Sign In or Register to comment.