Shop OBEX P1 Docs P2 Docs Learn Events
Using Datalogger Demo code — Parallax Forums

Using Datalogger Demo code

FalconFalcon Posts: 191
edited 2012-01-17 05:04 in BASIC Stamp
I've read many of the threads on the 27937 Memory Stick Datalogger but haven't found the answers I'm looking for.

I have the Memory Stick Datalogger and have the Test and Demo codes working fine on a BS2.

I'd like to work this into my current BS2px-based Home Monitor project to log events with data and time stamp. It basically loops through 16 sensors and executes various LDC, PINK, DEBUG and V-Stamp commands based on if a sensor condition changed.

My questions concern the logic in where in a multi-slot program to place the various snippets of code. I see the following "functions" in the Parallax Demo code:

1. Initialize Transmit line
2. Sync Command Character
3. Switch To Short Command Mode
4. Prompt Device For Status
5. Purge
6. Open data file
7. Write data
8. Close data file
9. Get data

Which part(s) would I run just once at BS2px program load?

Which part(s) would need to execute during each loop?

Would I need a menu option (or loop exit) to initialize the USB stick?

Would I need a menu option (or loop exit) to eject the USB stick?

Would I need a menu option to open or close a data file?

I imagine I would go to a Sub Routine similar to the LCD, PINK, etc., when a condition changes. Would that just replace this part of the Demo with my data?
DEBUG "Open!", CR, CR, "Writing Data...", CR
  FOR counter = 1 TO NumSamples         ' Number Of Samples To Log
    HIGH Sensor                         ' Charge Capacitor
    PAUSE 1                             ' Wait 1 ms
    RCTIME Sensor, 1, result            ' Measure Discharge Time
    DEBUG "Sample ", DEC5 counter, " of ", DEC5 NumSamples,
          " --> ", DEC5 result, CR      ' Display Results
    SEROUT TX\CTS, Baud, [$08, $20, $00, $00, $00, $0D, CR,
          DEC5 counter, ",", DEC5 result, CR, LF, CR]
    PAUSE 500                           ' Write Results/Delay
    GOSUB Get_Data                      ' Purge Receive Buffer
  NEXT

I think I can get my data organized and formatted to be written to the Memory Stick, I just don;t know which of these function are required where.

I appreciate any suggestions.

falcon

Comments

  • bsnutbsnut Posts: 521
    edited 2011-11-18 21:29
    Would that just replace this part of the Demo with my data?
    I would follow the layout of the code that is in the demo and work from there how you want your setup to work
  • FalconFalcon Posts: 191
    edited 2012-01-17 05:04
    bsnut wrote: »
    I would follow the layout of the code that is in the demo and work from there how you want your setup to work
    I'm now back to working on the Datalogger code after having to solve a couple other issues.

    bsnut,

    I appreciate the reply, but that doesn't really answer any of my specific questions. I plan to use the Demo code as written as much as possible but which parts would only be executed once at initialization (when power is applied to the circuit)? The project I'm working on uses 5 of the slots in a BS2p module. Slot 0 will be mostly initialization. After that the code will circulate through Slots 1 - 4 until Reset.

    I understand that while my main code is running I will mostly use the "Write Data" snippet, but when/where would I insert the "Close Data File" snippet.

    I see this Demo caode as about 9 different snippets/functions, but I do not understand the logic in 1. when each is to be run, and 2. how to place the individual snippets

    I appreciate all replies and suggestions,

    falcon
Sign In or Register to comment.