Hi Dave. I found the attached pdf that is implying the protocol.
Ioannis
The SpO2 module I use is of none parity.
I wonder the PIC have the problem to read the bytes if the bytes are sent into PIC in endless stream. I tried to send only 5 bytes, 10 bytes and 15 bytes data in SpO2 module's data format and the PIC can process well using the code I wrote.
Then I tried to let PIC sent out each byte it read in from a endless bytes stream. The output of the PIC is different from the data it read in.
That's not the issue. How many STOP bits is the issue. If, as the only reference I could find for the BCI protocol says, it uses 8N2, you cannot handle it - all of the PBP methods require 1 stop bit. Two stop bits could explain the erratic results. You need to provide a link to the datasheet for the specific SP02 device you are using.
Last edited by dhouston; - 16th June 2009 at 12:56.
I try my best to translate the manual as the manual is originally written in Chinese language. The manual is too simple and not really provides the details.
serial port setting:
- 1 start bit + 8 data bit + 1 stop bit, no parity
- baud rate: 4800 baud
- 5 bytes format, 60 packages per second, bit 7 is the synchronous bit
byte 1:
- bit 7: synchronous bit, as 1
- bit 6: 1=instruction for pulse sound
- bit 5: 1=SpO2 decrease, 0=OK
- bit 4: 1=searching time too long, 0=OK
- bit 3-0: signal strength (0-8), represent signal strength of pulse
byte 2:
- bit 7: synchronous bit, as 0
- bit 6-0: pulse wave diagram
byte 3:
- bit 7: synchronous bit, as 0
- bit 6: pulse rate bit 7
- bit 5: 1=search pulse, 0=OK
- bit 4: 1=sensor error, 0=OK
- bit 3-0: pulse bar diagram
byte 4:
- bit 7: synchronous bit, as 0
- bit 6-0: pulse rate, (bit 6 to bit 0)
byte 5:
- bit 7: synchronous bit, as 0
- bit 6-0: SpO2
OK - it has only one stop bit. It appears that various manufacturers use their own protocol.
60 packets per second x 5 bytes per packet x 10 bits per byte = 3000 bits per second which, at 4800bps, means 30 (or fewer - depends on pace) idle bit-times between packets.
I would capture 10 bytes, scan them for the first initial byte (>127) and then look at the following 4 bytes for your data.
EDIT: 9 bytes would guarantee one complete packet.
Last edited by dhouston; - 16th June 2009 at 18:10.
Hmm, seems that is like the pdf I posted. Is it the same module?
Based on the infos and the idea of Dave's:
Hope this will get you started. Don't forget the defines for the Hserout command to set it at 9600.Code:array var byte[9] temp var byte i var byte j var byte get_new_data: SerIn2 PORTB.7,16572,[str array\9] for i=0 to 8 temp=array[i] if temp.7=1 then goto send_at_9600 next i hserout ["Not found!",13,10] goto get_new_data for j=i to i+4 hserout [array[j]] next j goto get_new_data end
Ioannis
Bookmarks