Help Programming a Heel Strike/Toe Lift Pressure Switch
surfertmex
Posts: 8
Hey everyone,
Excuse me for any newbness I may exude - I am a beginner and have very little experience.
I am programing a BoE-USB to work with a Heel Strike / Toe Lift lift pressure switch. The heel switch and toe switch are two separate switches, with the heel switch going to P6 and the toe switch going to P7. When pressure is put on the heel, the heel switch closes, and when pressure is put on the toe, the toe switch closes. I am currently able to measure the amount of time elapsed when a person's heel strikes the ground to when that person's toe lifts off the ground. However, I need to be able to measure at what time each step is taken. For example, step 1 was taken after 3000ms of time was elapsed, step 2 was taken after 5000ms of time was elapsed... step 300 was taken after 355000ms of time was elapsed... and so on. I do not know how to code this. In addition, I need to be able to record this data on a flash drive using a Memory Stick Datalogger (IC: 27937). For that, I am using some example code provided on the Parallax website and have hooked it up using the quickstart guide. My code is as follows:
Also, if possible, I want to measure the amount of time elapsed when a persons toe lifts off the ground to when that persons heel returns to the ground. I don't know if this is possible, though, due to the necessity to record the data and the amount of "lag time" recording the data takes. The measurements need to be as accurate as possible.
Any help in this is much appreciated.
Thank you in advance!
Excuse me for any newbness I may exude - I am a beginner and have very little experience.
I am programing a BoE-USB to work with a Heel Strike / Toe Lift lift pressure switch. The heel switch and toe switch are two separate switches, with the heel switch going to P6 and the toe switch going to P7. When pressure is put on the heel, the heel switch closes, and when pressure is put on the toe, the toe switch closes. I am currently able to measure the amount of time elapsed when a person's heel strikes the ground to when that person's toe lifts off the ground. However, I need to be able to measure at what time each step is taken. For example, step 1 was taken after 3000ms of time was elapsed, step 2 was taken after 5000ms of time was elapsed... step 300 was taken after 355000ms of time was elapsed... and so on. I do not know how to code this. In addition, I need to be able to record this data on a flash drive using a Memory Stick Datalogger (IC: 27937). For that, I am using some example code provided on the Parallax website and have hooked it up using the quickstart guide. My code is as follows:
' {$STAMP BS2} ' {$PBASIC 2.5} ' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- TX PIN 8 ' Transmit Data --> 27937.4 (RXD) RTS PIN 9 ' Request To Send --> 27937.6 (CTS) RX PIN 10 ' Receive Data <-- 27937.5 (TXD) CTS PIN 11 ' Clear To Send <-- 27937.2 (RTS) ' -----[noparse][[/noparse] Constants ]------------------------------------------------------- Baud CON 84 ' Serial Baud Rate 9600 bps (BS2) ' -----[noparse][[/noparse] Variables ]------------------------------------------------------- buffer VAR Byte(15) ' Input Buffer index VAR Byte ' Index Variable ioByte VAR Byte ' Input/Output Storage work VAR Word ' Work Variable flag VAR Bit ' Event Status Flag timeCounterX VAR Word ' Heel Strike timeCounterT VAR Word ' Toe Strike stepCounter VAR Word ' -----[noparse][[/noparse] Initialization ]-------------------------------------------------- DEBUG CLS, "Heel / Toe Strike Transducer Program V0.2 Beta", CR, CR PAUSE 3500 DEBUG "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 "Done!", CR, "Synchronizing..." DO SEROUT TX\CTS, Baud, [noparse][[/noparse]"E", CR] ' Sync Command Character GOSUB Get_Data ' Get Response PAUSE 250 LOOP UNTIL ioByte = $0D ' Wait For Carriage Return DO SEROUT TX\CTS, Baud, [noparse][[/noparse]"e", CR] ' Sync Command Character GOSUB Get_Data ' Get Response PAUSE 250 LOOP UNTIL ioByte = $0D ' Wait For Carriage Return ' -----[noparse][[/noparse] Program Code ]---------------------------------------------------- Main: DEBUG "Done", CR, "Switching to Short Command Mode..." SEROUT TX\CTS, Baud, [noparse][[/noparse]"SCS", CR] ' Switch To Short Command Mode GOSUB Get_Data ' Purge Receive Buffer DEBUG "Done!", CR, "Waiting for Memory Stick..." Check_Drive: DO SEROUT TX\CTS, Baud, [noparse][[/noparse]CR] ' Prompt Device For Status GOSUB Get_Data ' Purge Receive Buffer IF buffer(0) = ">" THEN ' Check For Ready Prompt EXIT ' If Ready Then Exit Loop ELSEIF buffer(0) = "N" AND buffer(1) = "D" THEN DEBUG "." ' Device Ready But No Memory Stick ELSEIF buffer(0) = "D" AND buffer(1) = "D" AND flag = 0 THEN DEBUG "Connected!", CR, "Accessing..." flag = 1 ' Memory Stick Ready ELSE DEBUG "." ENDIF PAUSE 250 ' Command Retry Delay LOOP DEBUG "Ready!", CR DEBUG "Opening Data File..." ' First Delete File SEROUT TX\CTS, Baud, [noparse][[/noparse]$07, $20, "datafile.txt", CR] GOSUB Get_Data ' Purge Receive Buffer ' Then Create File SEROUT TX\CTS, Baud, [noparse][[/noparse]$09, $20, "datafile.txt", CR] GOSUB Get_Data ' Purge Receive Buffer DEBUG "Open!", CR, CR, "Writing Data File...", CR, CR FOR stepCounter = 1 TO 10 DO LOOP UNTIL IN6 = 1 timeCounterX = 0 timeCounterT = 0 DO timeCounterX = timeCounterX + 1 LOOP UNTIL IN7 = 1 DO timeCounterT = timeCounterT + 1 LOOP UNTIL IN7 = 0 DEBUG "Step # ", DEC stepCounter , CR, CR, "Stance time = ", DEC timeCounterX + timeCounterT , " ms.", CR, CR SEROUT TX\CTS, Baud, [noparse][[/noparse]$08, $20, $00, $00, $00, $0D, CR, DEC stepCounter, ", ", DEC timeCounterX + timeCounterT , CR, LF, CR] PAUSE 200 ' Write Results/Delay GOSUB Get_Data ' Purge Receive Buffer NEXT DEBUG CR, "Closing Data File...", CR, CR ' Close File (MUST CLOSE!) SEROUT TX\CTS, Baud, [noparse][[/noparse]$0A, $20, "datafile.txt", CR] GOSUB Get_Data ' Purge Receive Buffer ' Open Fil For Read Mode PAUSE 2000 ' Dramatic Pause DEBUG "Data collection complete." STOP ' -----[noparse][[/noparse] Subroutines ]----------------------------------------------------- Get_Data: index = 0 ' Reset Index Pointer DO ' Receive Data SERIN RX\RTS, Baud, 100, Timeout, [noparse][[/noparse]ioByte] buffer(index) = ioByte ' Add Received Byte To Buffer index = index + 1 ' Increment Index Pointer IF index > 14 THEN Timeout ' Check For Overflow LOOP Timeout: RETURN
Also, if possible, I want to measure the amount of time elapsed when a persons toe lifts off the ground to when that persons heel returns to the ground. I don't know if this is possible, though, due to the necessity to record the data and the amount of "lag time" recording the data takes. The measurements need to be as accurate as possible.
Any help in this is much appreciated.
Thank you in advance!
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Now if you just need seconds only
Here is a Second Counting Register Not reading the data from the DS1302 chip in BURST MODE
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/6/2009 9:38:58 PM GMT
Is it possible to display milliseconds using that code???
No· DS1302 is not capable of doing·milliseconds
You would need to use a different time chip
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Rich H