serString byte selection from array
I am attempting to read a 9 byte response from a pressure sensor coming into a BS2pe at 9600 baud. The response is coming in at 10hz for 10 seconds for a total of 100 samples. I need to extract the 3rd, 4th, 5th and 6th byte. I have the following code:
I find that this only shows the 3rd byte and loses the other 3 desired bytes. By changing the SKIP and serString\n values in the SERIN line, I can grab the selected bytes. Can this be done in a command single line? Splitting it into 4 lines induces some serious delays and I miss most of the data I'm looking for.
How do I capture the desired bytes and put them into an array so that I may do math upon them?
' {$STAMP BS2pe} ' {$PBASIC 2.5} ' {$PORT COM1} serinPin CON 9 n9600 CON 16468 reps VAR Byte serString VAR Byte(10) serString(9) = 0 HIGH 3 'triggers the 16F88 to send initialization pulse to Druck 33X sensor PAUSE 10 LOW 3 'resets trigger 16F88 pin PAUSE 500 'waits for initialization response to pass main: DO SERIN serinPin, n9600,[noparse][[/noparse]SKIP 2,STR serString\7] DEBUG DEC serString," ",DEC reps," ",CR reps = reps + 1 LOOP UNTIL (reps >= 100)
I find that this only shows the 3rd byte and loses the other 3 desired bytes. By changing the SKIP and serString\n values in the SERIN line, I can grab the selected bytes. Can this be done in a command single line? Splitting it into 4 lines induces some serious delays and I miss most of the data I'm looking for.
How do I capture the desired bytes and put them into an array so that I may do math upon them?
Comments
you could take all the 100 results into excel but only use the data you need in a formula.
Your options are to iterate through serString(0) serString(1) serString(2) serString(3) or try
DEBUG·STR·serString\4,"·",DEC·reps,"·",CR
Jeff T.
The device is running solely on the stamp, not connected to the computer. Therefore, I'll need a local math solution. i have used the PLX-DAQ software, though, and find it very useful. thanks for the response.
That looks useful for me. I'll set up the hardware here at home tonight and give it a try.