Shop OBEX P1 Docs P2 Docs Learn Events
Combining Temp/Humidity Sensor Program with a Simple Movement Program - Page 8 — Parallax Forums

Combining Temp/Humidity Sensor Program with a Simple Movement Program

15681011

Comments

  • Andrew (ARLISS)Andrew (ARLISS) Posts: 213
    edited 2008-03-05 19:23
    Mr. Allen,

    I've tried the new program, "RoboRocket_Mar04_ta.bs2". Everything on it works except for the movement sequence, which doesn't start. I've tried the program both connected to the computer with a DEBUG screen (which is also attached) and on its own. Just to let you know, I do not have any LED's installed on the robot because I do not have an appropriate resistor. Any suggestions?

    Thanks for your help,
    Andrew
    219 x 217 - 10K
  • Andrew (ARLISS)Andrew (ARLISS) Posts: 213
    edited 2008-03-05 19:27
    Mr. Kibler,

    I have translated your morse code! You said "THANKS IT RUNS NO DATALG".

    Andrew
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-05 19:34
    Tracy,

    (...·· .·· ...· previous post)

    ··· "Thanks" ·turn.gif

    ··· "It works!"

    ··· "No DataLog"

    Quote of the day (from another previous post): "Perhaps I'm just envious of retentive young minds!" (*Aren't we all?!)

    The new program works! It shows elapsed time, temperature, and humidity every 11 seconds.·Then,·a little over·a minute after initialization it runs the robot's ground movement sequence, then collects one data sample, then it goes ithrough the ground movement sequence again. As you mentioned in your post, 'datalogging' is not yet enable.

    What are your thoughts·about recording data every second during descent as someone suggested previously? Bruce, what do you think? What about collecting 3 to 5 samples each time it stops and measures humidity once·the robot is·on the ground? Are you guys coming to Huntsville next month to watch (y)our robot take wings and fly...?! We placed the engine order with NASA, and it's beast of an engine, as long as your forearm, and every bit as big in diameter. Hang on!

    ····hop.gif··· <
    · *Robot, flying.... Hang on!··· freaked.gif

    You should see a post from Andrew shortly with a project update, comments, questions,·and the results from some of his experimental trials. He's also ordered two more RTC's and crystals (for himself!)


    Regards,

    Mark
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-05 19:41
    Andrew,

    ·· Be patient, and re-read Mr. Allen's post (the one with the program attached.) Then 'read' the program and see if you can figure out why the ground movement subroutine 'doesn't work'. It ran fine on my robot here. How long did you wait after the program initializes? Let me suggest that you start 'Phidippides', then wait at least three minutes before making any conclusions. Please report back to the forum.

    Clever kid! You deciphered the Morse code fast! Why not post a short message in Morse code with your reply to Mr. Allen and Mr. Bates?! I'll look for your reply, and for your attached 'experimental trials' reports.

    -...·· -.--···.

    Mr. Kibler··
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-05 19:45
    Andrew,

    ·· From the data you attached I conclude that your house is more humid than·my house today, by about 10%.·We've just used the program, two robots,·and our data to make our first real scientific conclusion!

    I wonder why it's less humid here? Any ideas...? (think... you'll figure out why!)

    Mr. Kibler
    Andrew Mahn said...

    Mr. Allen,

    I've tried the new program, "RoboRocket_Mar04_ta.bs2". Everything on it works except for the movement sequence, which doesn't start. I've tried the program both connected to the computer with a DEBUG screen (which is also attached) and on its own. Just to let you know, I do not have any LED's installed on the robot because I do not have an appropriate resistor. Any suggestions?

    Thanks for your help,
    Andrew

  • Andrew (ARLISS)Andrew (ARLISS) Posts: 213
    edited 2008-03-05 19:54
    Mr. Kibler,

    It does not move, I've turned it on and let it sit for five minutes. I've also checked that the servos are plugged in correctly, and they are. Any suggestions?

    - .... .- -. -.- ...
    Andrew
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-03-05 20:15
    Folks -

    These dots and dashes give me a headache, so I try to avoid them as best I can smile.gif

    I suppose the "how long" question is best answered when you know how long it takes from the apogee to the earth landing?

    Another question which I'd intended to post last night, and forgot to: How do you know this "cat" will land on its "feet"? Is this a super-slow descent situation?

    Thank you for the unattributed but acknowledged worthwhile quote of mine "Quote of the Day" above. Lots of truth in that thinking.

    Speaking for myself and not the rest of the "Peanut Gallery" (thanks Tracy, now I feel included), I won't be headed for Huntsville to watch your rocket launch - sorry.

    I hope today bugs get worked out quickly! If I can help I'll be around here, on and off.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Programming can't be all that difficult, it's nothing but 1's and 0's
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2008-03-05 21:09
    Andrew, I can see that your system does not have a real time clock attached, but I heard that you have one on order. Did you figure out why the movement sequence does not start? Look at the time displayed on your debug screen. How long does it take to get to one minute?

    We should probably include a "failsafe". Change following line in the main loop section and add a line as follows:

    IF minute=$01 OR index2>10 THEN land=1 ' set flag to start movements after one minute or on count
    index2=index2+1 ' this is just going to count the times through the loop, add this line.

    If you do that there will be two conditions -- the regular one that depends on the clock, and the backup that depends on going through the main loop 10 times. If the RTC is not installed or stops working for any reason, the backup counter will do the job.

    If you want to eliminate the morse code for the temperature and humidity, just comment out the two GOSUB Morse_reading lines. And maybe change the threshold for index2 to something like 100. Then the humidity and temperature readings will occur at one second intervals as you'd like in flight. And when you get your real time clock, it will use that in preference to the counter for the timing.

    --     ---     ...-    .         ---    -.-       ..--..
    



    When I was in school, the big thing was amateur radio, so we had to take a code test. But it isn't something I've done for a long time -- skills retention, not! I'm glad you get a kick out of it.

    Maybe Mr. Kilber can help you find another LED and resistor combination. I have a couple of other interesting things you can do with the LED. A green LED is a good choice.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-03-05 22:33
    Tracy -

    As I remember, you have the two pin ports assigned to the LED pins set up as bi-polar. Why not have them use a bi-polar LED and really drive then nuts smile.gif

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Programming can't be all that difficult, it's nothing but 1's and 0's
  • Andrew (ARLISS)Andrew (ARLISS) Posts: 213
    edited 2008-03-05 23:06
    Mr. Allen,

    I still cannot get the movement to start. There isn't anything wrong with the servos because I've tested them in a seperate program that just makes them move. There is also a new lithium battery connected, so there shouldn't be any power issue. Any suggestions?

    Andrew
    .- -. -.. .-. . .--
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2008-03-06 00:29
    .- -. -.. .-. . .--

    Please alter the DEBUG line in the main loop as follows:

    DEBUG CR,HEX2 hour,":",HEX2 minute,":",HEX2 second, TAB, DEC index2
    



    There is a change at the end of the line, to print a tab and the value of the variable index2. Did you make the other changes that I suggested, using "index2"?

    Then run the program again for a couple of minutes and post a screen shot of the debug output screen. The variable index2 should be advancing and when it passes 10, the servos should start.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-06 01:00
    Tracy,

    ·· Is it possible that Andrew's servos aren't running because his robot doesn't have an RTC chip on it yet? Just a hypothesis.·He also doesn't have a LED/resistor 'test light' made or attached. I'll have him make one (or three) at Sunday's practice so he can develop his 'fine motor skills' (<---- clever play on words!)

    You commented: "...maybe change the threshold for index2 to something like 100 [noparse][[/noparse]so]·the humidity and temperature readings will occur at one second intervals."

    I'm unsure exactly where to do this. Is it the line command:

    PAUSE 192*iobyte.BIT0 (index-1)+64

    I do not see many instances of index2 that can be changed to 100. Also, is the 'BELL' command supposed to make a bell-like sound...? Andrew, does your program 'ding' when it starts? My doesn't (and so maybe we'll win a 'no-bell' prize for our efforts!)

    The robot has airplane cable criss-crossed across the top with a ball swivel attached. That's where the 58" diameter parachute·is attached. Because this set-up shifts the robot's center of gravity really low, it lands-- cat-like and on its treads-- every time. Meow.

    Thanks,

    Mark
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-06 01:04
    This is the name of our rocket
    ·-..· .-· .·· -..·· .··· .-..··· ..-·· ...··= Daedelus

    It'd be cool to put the name on the rocket in Morse code...!
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2008-03-06 01:08
    Bruce, I do use a bicolor LED on my boards, and having both red and green is pretty useful. I wasn't sure the rocketeers would have a bicolor LED available.

    But in any case, I have other plans to use the green LED as a light sensor as well as an indicator. I'm glad that Mark used a green LED.

    Mark, if you have the LED hooked up, please try the following program and tell me what happens when you shade the LED or expose it to more light:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' program LEDphotometer.BS2
    ' Tracy Allen, EME Systems
    ' makes an LED act as a photodiode light sensor
    ' and the same LED flashes as feedback.
    ' Flashing rate is proportional to photocurrent.
    ' The period is also printed on the debug screen. 
    
    ledP  PIN 12    ' anode of LED (long lead)
    ledN  PIN 13     ' cathode of LED (flat side)
    ' Note on circuit.  A resistor in the range of 270 to 1k ohm 
    ' should be in series with the LED.
    ' A capacitor of ~100 pf can be placed in parallel with the LED.
    ' More capacitance for brighter light.
    ' No capacitor necessary for dim indoor light.
    
    wx VAR WORD
    wy VAR WORD
    
    
    ' initialized, 
    HIGH ledP   ' forward bias LED to produce light
    LOW ledN
    PAUSE 200
    
    ' program
    photometer:
    DO
      LOW ledP        ' reverse bias LED &  capacitance
      HIGH ledN    
      wy=-1
      DO
        RCTIME 13,1,wx   ' allow photodiode to discharge capacitance and measure time
        wy=wy+1          ' it may take more than one cycle
      LOOP UNTIL wx    ' until done
      DEBUG CR,DEC wy,".",DEC4 wx**10000   ' show result
      HIGH ledP     ' blink the LED
      LOW ledN
      PAUSE 20      ' 20 millisecond flash
    LOOP
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-06 01:10
    Andrew,

    ·Please print out Mr. Allen's long post above when you can, then put it in your team binder. There's a wealth of information there. Please note that:

    13 total words =·the same as 26 bytes = 52 nibbles = 104 bits

    Please remind me Sunday to·help you·make the LED-resistor set-ups so you have·three or four·to use and keep.

    Mr. Kibler
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-06 01:34
    Tracy,

    ··· You commented: "[noparse][[/noparse]The Morse code] is in the rocket program for feedback during debugging. Just look at it as a groups of long and short flashes that can convey information."

    Do the letters "S, O, N, F, B, C, W, and E" have any special·significance? Is each letter attached to a specific output/port/function? I think we'll keep the Morse code in the program because now Phidippides (our robot) can communicate with us...!

    Mark
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2008-03-06 02:09
    Mark (and Andrew), Yes, the program is waiting for the RTC to indicate that one minute has passed, and that is kind of impossible if the RTC is not there and always reads absolute zero!

    The reference to index2 was in a couple of lines I wanted to add to the program to failsafe the RTC and also to act as sample counter .
    IF minute=$01 OR index2>10 THEN land=1 ' set flag to start movements after one minute or on count
    index2=index2+1 ' this is just going to count the number of samples, add this line.
    DEBUG CR,HEX2 hour,":",HEX2 minute,":",HEX2 second, TAB, DEC index2
    




    To avoid confusion , I am attaching a revised version of the complete program that you can use and should, I think, should make Andrew's robot walk after a minute or two, even without an RTC.

    There is not much significance to the letters S, O, N, F, B, C, W, and E, except to signify Foreward, Backward, Clockwise, counterclockWise and End. You can add other letters as needed. There is a Morse code routine in there ithat will tap out complete messages stored in eeprom, and I had included an "SOS" message. I hope that will not be necessary!

    Oh, and that should be

    13 total words = the same as 26 bytes = 52 nibbles = 208 bits

    Not 104 bits. There are 16 bits in a word, 8 bits in a byte, 4 bits in a nibble.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 3/6/2008 2:25:16 AM GMT
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-06 02:45
    Tracy,

    ·· Sorry that I missed this post on the previous page. I loaded this program and ran it as you asked. At first the LED blinks fast, maybe three times a second, and the values are displayed on the screen are approximately 1.0: 1.01, 1.03, 1.01, etc., etc. When I shield the LED (I sense that it's something more than a light emitting diode!), it blinks slower and the values increase proportion to the amount of darkness. What is this gizmo?!·(And·the creative, scientific side of me says: "And how could it be used...?) Andrew and friends will have fun experimenting with this. When we solder·more on Sunday, is it better to use the green LEDs? Do the other colors of LEDs also hold their own respective 'secrets?!

    Mark
    Tracy Allen said...
    Bruce, I do use a bicolor LED on my boards, and having both red and green is pretty useful. I wasn't sure the rocketeers would have a bicolor LED available.

    But in any case, I have other plans to use the green LED as a light sensor as well as an indicator. I'm glad that Mark used a green LED.

    Mark, if you have the LED hooked up, please try the following program and tell me what happens when you shade the LED or expose it to more light:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' program LEDphotometer.BS2
    ' Tracy Allen, EME Systems
    ' makes an LED act as a photodiode light sensor
    ' and the same LED flashes as feedback.
    ' Flashing rate is proportional to photocurrent.
    ' The period is also printed on the debug screen. 
    
    ledP  PIN 12    ' anode of LED (long lead)
    ledN  PIN 13     ' cathode of LED (flat side)
    ' Note on circuit.  A resistor in the range of 270 to 1k ohm 
    ' should be in series with the LED.
    ' A capacitor of ~100 pf can be placed in parallel with the LED.
    ' More capacitance for brighter light.
    ' No capacitor necessary for dim indoor light.
    
    wx VAR WORD
    wy VAR WORD
    
    
    ' initialized, 
    HIGH ledP   ' forward bias LED to produce light
    LOW ledN
    PAUSE 200
    
    ' program
    photometer:
    DO
      LOW ledP        ' reverse bias LED &  capacitance
      HIGH ledN    
      wy=-1
      DO
        RCTIME 13,1,wx   ' allow photodiode to discharge capacitance and measure time
        wy=wy+1          ' it may take more than one cycle
      LOOP UNTIL wx    ' until done
      DEBUG CR,DEC wy,".",DEC4 wx**10000   ' show result
      HIGH ledP     ' blink the LED
      LOW ledN
      PAUSE 20      ' 20 millisecond flash
    LOOP
    

  • Mark in NHMark in NH Posts: 447
    edited 2008-03-06 03:01
    Tracy,

    ·· I added these commands·previously, and I just downloaded and ran the updated version of the program.

    ·· IF·minute=$01·OR·index2>10·THEN·land=1·'·set·flag·to·start·movements·after·one·minute·or·on·count

    ·· index2=index2+1·'·this·is·just·going·to·count·the·number·of·samples,·add·this·line.

    ·· DEBUG·CR,HEX2·hour,":",HEX2·minute,":",HEX2·second,·TAB,·DEC·index2


    I still can't figure out·where to change the threshold for 'index2' to 100 so that samples are recorded every second or so. They're still being recorded every 11 seconds.

    So why doesn't the blinking green LED slow down and speed up with increased light or darkness with this program, as it did with the other one? Are all the LEDs different?

    Mark and the Rocketeers
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2008-03-06 03:59
    Mark,

    If you want to show data at one second intervals, comment out the two lines in the main loop that say
    ' GOSUB morse_reading <---- commented out, two places in the main loop.

    Also change the following line in the main loop:

    IF minute=$01 OR index2>100 THEN land=1 ' set flag to start movements after one minute or on count

    Change it so it reads index2>100 instead of index2>10. The upshot of those changes is that the program will no longer tap out the temperature and humidity in Morse code, and therefore it will run around the main loop much faster, and data will be captured at one second intervals. Also the failsafe for the RTC will not kick in for 100 seconds (=100 samples).

    I just stuck the Morse in there until the thumb drive is reimplemented. On the spaceflight, you will collect data at one second intervals and there will certainly be no need for Morse code. -.-- . ... ..--..

    See what happens when you shine a brighter light on the LED/photometer. The kids can have fun with that. Green or yellow LEDs work better for this than red ones. The LED/photometer is a separate program--It uses the LED in reverse bias mode as a photodiode to measure light in addition to forward bias mode to produce light. It is one of those reciprocity things. The command RCTIME that you see in the photometer program is the one that measures the light level falling on the photodiode and a side effect is the change in pulse rate from the LED.

    That light-measuring capabiltity is not implemented in the roborocket program. However...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 3/6/2008 4:08:26 AM GMT
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-07 03:36
    Tracy,

    ·· We made the changes you suggested so the robot takes readings every second during descent (changed 2>10 to 2>100, then commented out the two 'GOSUB morse reading' commands. We·did that yesterday, without commenting out the GOSUB commands (or so we thought), but it didn't work. Today's fix did.

    Attached is the latest verison of the program, and it's Jim-dandy just like it is. It records samples every second as we had hoped it would and it also takes a ground reading each time it runs one ground movement subroutine. The kids were happy to see that 'Phidippides' still 'speaks' to them-- in Morse code, of course!-- when s/he moves forward, makes a turn, etc.·The Morse code·adds a nice touch to·(y)our robot, and gives it a bit of a·personality. The kids love it!

    Several 'new'·kids trickled into the lab after school today to marvel at the robot and all it can do. They heard that exciting things were going on inside the lab, and out, and they were curious. They experimented with·the program, and the Rocketeers·showed the newbies how to change some of the settings ('movementtime', etc.) to make differnet things happen.·And they all LOVE dabbling with the LED...! "Is it just a light?" they asked, and "How can we make one?" and "Can you make a regular light bulb do that?" (I can't, but·I'm sure you guy can, if there's a way.)

    One thing that happens from time to time is the readings spike up to weird numbers (temperature = 651, humidity is similarly absurd.) It seems to be loose wires each time, even though loose wires aren't visible. I'll be glad to get things 'hardwired' (e.g. soldered) to ix-nay the ires-way.

    We'd like to move into (re)programming the Datalogger so it records data (elapsed time, etc.)·again. The program is perfect(ly functional)·as it is, recording elapsed time, sample number, temperature, and humidity. What do·'we' do next (as if we're doing a whole lot of the programming... I feel more guilty than you·may realize, and I am very thankful there are nice people like you and Bruce and friends left in the world. Thank you.)

    Let me know what·our next move is. Sunday's practice will see an·overflow capacity crowd at the Kibler·home labortatory, as young Andrew's uncle is coming to·watch/help, along with a few other parents and a several new kids. It's wonderful to·watch this excellent·learning opportunity·capture even more bright new minds·(and a few of the foggier older minds, too!)

    Best regards,

    Mark and the Rocketeers.
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-07 03:45
    All--

    Forwarded from my e-mail to the forum:

    " Mr. Kibler,

    I am unable to access the forum from my computer today. Here is my response post if you want to post it from your house. Also, the debug window/program is attached (*NOTE: It's on the previous post as an attachment.)

    Thanks,
    Andrew

    Mr. Allen,

    I've made the changes you've suggested, and the program seems to run fine. However, the movement is still not starting! I've tried the new program both connected to the computer and on its own. Maybe the problem is not having an RTC chip yet (as suggested by Mr. Kibler)? I am supposed to get my RTC today, but I wouldn't want to attempt to solder it (I've never done something so small). What are your suggestions?

    *ANDREW - We'll solder the crystal to·your new·RTC chip this Sunday when you uncle is at practice. (Don't sneeze, or you risk losing the crystal!)
  • phil kennyphil kenny Posts: 233
    edited 2008-03-07 06:13
    Mark,

    When you get ready to add in the Memory Stick Datalogger code,
    I suggest that you include the following comments. They will help
    whoever has to read and analyze the information stored on the flash
    drive :
    ' data format with RTC clock time included
    '
    ' 2 bytes hour
    ' 1 byte ","
    ' 2 bytes minute
    ' 1 byte ","
    ' 2 bytes second
    ' 1 byte ","
    ' 3 bytes temperature integer part
    ' 1 byte "."
    ' 1 byte temperature decimal part
    ' 1 byte ","
    ' 3 bytes humidity integer part
    ' 1 byte "."
    ' 1 byte humidity decimal part
    ' 1 byte CR
    ' ----------------------------
    ' 21 bytes total per record
    
    



    I'll leave Tracy with the task of helping you with the Datalogger
    initialization code.

    Here is the command for writing to the flash drive. Note that the
    21 bytes and the sequence they are written in are as noted above.
    ' Write data with time to flash drive
    
      SEROUT TX\CTS, Baud, [noparse][[/noparse] $8,$20,0,0,0,23,CR, hour DEC2, "," , minute DEC2, ",", seconds DEC2, "," , tC.BIT15*13+32,DEC3 ABS (tC/10),".", DEC1 ABS tC,",",DEC3 (rhLin/10),".",DEC1 rhLin,CR]
    
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-07 15:10
    Phil,

    ·· Thanks for the post. We'll add the comments so that whomever reads the· documentation·can read and·analyze the program and

    the information stored on the flash drive. Thanks too, for the line command for how to output the data to the Datalogger. I suspected that

    it was a SEROUT line command, and I tried the other evening to make it write data to the Datalogger myself·(with marginal success) using a

    SEROUT command and by trying to decipher the numbers ($09, etc., etc.) I'm learning, slowwwwwwwwly.



    Last night I knocked one of the wires off the Parallax board (about 11 PM) and plugged it back into the wrong spot without realizing it. I started getting

    abberent data (temp = 615, etc.) and I dizted around with·the program·until 1 AM (yawn!) until I realized what I did.· lol.gif···· Geesh! The morning is

    already long...!



    Mark··
  • Mark in NHMark in NH Posts: 447
    edited 2008-03-07 15:22
    Phil,

    · I forgot to ask: where exactly in the program does the SEROUT command go? Is·it the only command needed in order to write the data to the Datalogger?

    Thanks,

    Mark
  • phil kennyphil kenny Posts: 233
    edited 2008-03-07 15:59
    Mark,

    Look at the program labeled, Rocketeers_tta080223.BS2 that Tracy Allen posted on
    2-24-08.

    Find the lines that begin with
      ' log measurments in flash drive file
      GOSUB open_DataFile
      SEROUT TX\CTS, Baud, [noparse][[/noparse] $8,$20,0,0,0,14,CR,tC.BIT15*13+32,DEC3 ABS (tC/10),".", DEC1 ABS tC,",",DEC3 (rhLin/10),".",DEC1 rhLin,CR,LF,CR]
      PAUSE 1                             ' Delay in Writing Data 1000 = 1 second, 500 = 1/2 second, etc.
      GOSUB close_dataFile
    
    



    That's where my replacement SEROUT statement goes.
    ' Write data with time to flash drive
    SEROUT TX\CTS, vBaud, [noparse][[/noparse] $8,$20,0,0,0,23,CR, hour DEC2, "," , minute DEC2, ",", seconds DEC2, "," , tC.BIT15*13+32,DEC3 ABS (tC/10),".", DEC1 ABS tC,",",DEC3 (rhLin/10),".",DEC1 rhLin,CR, LF, CR]
    
    



    There is a LOT of other Vinculum related code that needs to be included as well.

    I suggest waiting for a post from Tracy before you make any modifications.

    There was a slight error in my earlier post on the data format. I omitted two bytes at
    the end, namely, LF and CR. The comments for the data format should read:

    ' data format with RTC clock time included
    '
    ' 2 bytes hour
    ' 1 byte ","
    ' 2 bytes minute
    ' 1 byte ","
    ' 2 bytes second
    ' 1 byte ","
    ' 3 bytes temperature integer part
    ' 1 byte "."
    ' 1 byte temperature decimal part
    ' 1 byte ","
    ' 3 bytes humidity integer part
    ' 1 byte "."
    ' 1 byte humidity decimal part
    ' 1 byte CR
    ' 1 byte LF    <=======
    ' 1 byte CR   <======
    ' ----------------------------
    ' 23 bytes total per record  <=======
    
    



    Note that this changes the total bytes written in the SEROUT statement from 21 to 23.

    phil

    Post Edited (phil kenny) : 3/7/2008 4:13:00 PM GMT
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2008-03-07 17:16
    Hi Phil,
    I wonder if the time separator should be ":" instead of comma, and that way it will parse directly as time into Excel? There is the sign of the temperature (either space or - from tC.BIT15*13+32).

    ' data format with RTC clock time included
    '
    ' 2 bytes hour
    ' 1 byte ":"    <---- colon?
    ' 2 bytes minute
    ' 1 byte ":"  <--
    ' 2 bytes second
    ' 1 byte ":"  <--
    ' 1 byte sign, either - or space   <----- sign?
    ' 3 bytes temperature integer part
    ' 1 byte "."
    ' 1 byte temperature decimal part
    ' 1 byte ","
    ' 3 bytes humidity integer part
    ' 1 byte "."
    ' 1 byte humidity decimal part
    ' 1 byte CR
    ' 1 byte CR    <=======   CR before LF?
    ' 1 byte LF   <======
    ' ----------------------------
    ' 24 bytes total per record  <=======
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 3/7/2008 5:30:50 PM GMT
  • phil kennyphil kenny Posts: 233
    edited 2008-03-07 18:03
    Tracy,

    Your suggestion regarding the addition of colon separators between the
    hour, minute, second time variables is an improvement over what I showed.

    However, the colon between the second and sign byte should be changed
    to a comma. See my markup of your code below.

    If you want to store a space or "-" that character has to be explicitly sent to
    the flash drive. This requires a modification of the SEROUT statement I posted earlier.
    That statement also needs an adjustment to insert the two extra colons as well as
    changing the byte count parameter.
    Tracy said...

    ' data format with RTC clock time included
    '
    ' 2 bytes hour
    ' 1 byte ":" <---- colon? okay
    ' 2 bytes minute
    ' 1 byte ":" <-- okay
    ' 2 bytes second
    ' 1 byte ":" <-- No. make this a comma
    ' 1 byte sign, either - or space <
    sign? Yes, if it is explicitly made part of the data stream.
    ' 3 bytes temperature integer part
    ' 1 byte "."
    ' 1 byte temperature decimal part
    ' 1 byte ","
    ' 3 bytes humidity integer part
    ' 1 byte "."
    ' 1 byte humidity decimal part
    ' 1 byte CR
    ' 1 byte CR <======= CR before LF? Not according to the Parallax demo code.
    ' 1 byte LF <======
    '
    ' 24 bytes total per record <=======

    The three byte sequence at the end is shown as CR, LF, CR in the Parallax demo
    code for the Datalogger. However, the Vinculum data sheet only specifies a
    single CR and not the CR, LF, CR.

    I really don't know why Parallax included them, but my Datalogger program has
    them and the file can be imported into Excel just fine.

    They should verify that the correct data gets logged on the flash drive for negative
    temperatures by spraying the sensor with freeze spray coolent

    The Rocketeers haven't made any mention of exactly how the flash drive file will be
    analyzed, but Excel is the likely choice.

    Perhaps it is worth encouraging Mark et al to actually try reading the
    Datalogger file during the debugging process and before the rocket lifts
    off just to see if the data being recorded is what they expect, and in the
    proper format.

    phil

    Post Edited (phil kenny) : 3/7/2008 6:15:31 PM GMT
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2008-03-07 18:22
    Okay, I'll put in a new header section as follows. The actual data on the card will be 23, not 24 byte, I think, because the final CR is part of the Vinculum protocol, not part of the data per se.

    I agree 100+ percent about checking that the data is really being written as expected and can be charted.

    ' -----[noparse][[/noparse] Thumb Drive Data Format ]-----------------------------------------
    '
    ' data format with RTC clock time included
    '
    ' 2 bytes hour
    ' 1 byte ":" <---- colon as time separator
    ' 2 bytes minute
    ' 1 byte ":"
    ' 2 bytes second
    ' 1 byte ","    <-- comma as field separator
    ' 1 byte sign, either - or space 
    ' 3 bytes temperature integer part
    ' 1 byte "."
    ' 1 byte temperature decimal part
    ' 1 byte ","
    ' 3 bytes humidity integer part
    ' 1 byte "."
    ' 1 byte humidity decimal part
    ' 1 byte CR   <---- CRLF as record separator
    ' 1 byte LF 
    ' 1 byte CR <--- does not appear in data file, this is for the Vinculum as command terminator
    ' ----------------------------
    ' 24 bytes total per record <=======
    



    and this will go into the later code.

    ' Write data with time to flash drive
    SEROUT TX\CTS, vBaud, [noparse][[/noparse] $8,$20,0,0,0,24,CR, hour DEC2, "," , minute DEC2, ",", seconds DEC2, "," , tC.BIT15*13+32,DEC3 ABS (tC/10),".", DEC1 ABS tC,",",DEC3 (rhLin/10),".",DEC1 rhLin,CR, LF, CR]
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • phil kennyphil kenny Posts: 233
    edited 2008-03-07 18:28
    That should work now.

    Since it is easy to get the byte count wrong, that was another purpose served by
    explicitly laying out the format in comments.

    phil
Sign In or Register to comment.