How to Captuure Serrial Data -PASM ?
Siri
Posts: 220
To anybody who can spare a minute or two:
What I am trying to do is to capture 3 Bytes of data sent out from a pulse-ox.(measuring oxygen saturation in blood)
The data format is Baud 9600-8bits-N-1 no flow control.
I know I have to use ShiftIn routine to capture the data.This machine sends out 3 Bytes of Data representing
Heart Rate,Oxygen saturation and Status of the sensor.
My question is How do I know which Byte I am capturing(The 3 bytes are always in the same successive order) so
when I capture the 3 Bytes they are in the dame order each time I begin capturing the data?
In other words is there a some sort of a signal/instruction that does this.
Secondly How do I put them in separate variables in PASM which can be passed on to the SPIN or
if placed in one variable then the the 3 bytes to be read and put in separate variables using SPIN.
I am trying to understand by looking at various serial routines used in the serial objects but there is not much
detailed explanations given as to How and Why of it - so I can really understand the subject.
Thank you.
Regards,
Siri
What I am trying to do is to capture 3 Bytes of data sent out from a pulse-ox.(measuring oxygen saturation in blood)
The data format is Baud 9600-8bits-N-1 no flow control.
I know I have to use ShiftIn routine to capture the data.This machine sends out 3 Bytes of Data representing
Heart Rate,Oxygen saturation and Status of the sensor.
My question is How do I know which Byte I am capturing(The 3 bytes are always in the same successive order) so
when I capture the 3 Bytes they are in the dame order each time I begin capturing the data?
In other words is there a some sort of a signal/instruction that does this.
Secondly How do I put them in separate variables in PASM which can be passed on to the SPIN or
if placed in one variable then the the 3 bytes to be read and put in separate variables using SPIN.
I am trying to understand by looking at various serial routines used in the serial objects but there is not much
detailed explanations given as to How and Why of it - so I can really understand the subject.
Thank you.
Regards,
Siri
Comments
If there's no header for the data, you may need to read in a byte and then figure out which it is by comparing it with whatever the valid range for that piece of data would be. The sensor status byte must have certain codes that represent certain things (valid data, etc.), and it's probably easiest to look for that one.
Post Edited (sylvie369) : 10/14/2008 3:34:59 PM GMT
I'm not sure if I understand your question, why.
Why not to use a FullDuplexSerial object ? (or similar)
You'll have those recieved data in a spin program.
I guess you're missing something with the "sender", should be some signal that advice you, when the data stream begins.
So in that way, you'll recognize wich one is.
Do you have a datasheet of the pulse-ox ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
Knowing that it would be pointless to generate such a stream which cannot be determined there must be some means to do that - Perhaps a preceding synchronisation pulse, a header byte, the length of gap between sets of three bytes, or maybe data bytes have distinct value ranges.
Any of the serial I/O drivers will deliver the received information in the order it's received. You don't necessarily know what the sensor is doing when you start receiving. It may have already sent the 1st of 3 bytes, so your program may think it's received the 1st byte when it's actually received the 2nd byte. The only way to deal with this is to reset or restart the sensor after the program has started. If there's a delay between readings, you can use that to synchronize your program with the sensor.
The receive routines in all the serial I/O drivers deliver one byte at a time. You call a receive function and it returns the next byte received. All of this is in Spin. Call the receive function 3 times and you get 3 successive byte values which you can store in different variables. If you use FullDuplexSerial, the actual receive routine is in assembly language, but the object hides that from you. All your program sees is a set of Spin routines. Simple_Serial is completely written in Spin.
displayed on VGA monitor using SPIN as you all have pointed out.
What I an trying to do is to learn to do the same display of data using PASM.
In SPIN when ever I start the program it correctly displays the data.
Thanks,
Regards,
Siri
Here is the SPIN Code:
Thank you for your advise.I see the point now - all PASM routines are not superior/faster or suited for all propeller
tasks.
I would'nt waste any more time on this as SPIN does it well.
Thanks to all for the time.
Regards,
Siri