LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading photoplethysmograph waveform with serial port on PC using Labview

Solved!
Go to solution

 Hi every body,


I am trying to acquire Real-time Photoplethysmography waveform from serial port using Labview.I have succeeded to acquire data from serial port by using following features:

 

-Baudrate:38400

 

-databits:8

 

-stopbit:1

 

-No parity bit

 

-Delay before reading from serial port: 10 ms (based on what has been written in the manual that every 10 ms there will be a frame in serial port)

 

 

After reading string will be converted to byte array to be able to extract those bytes related to waveform (1&2 byte in a frame) same for SOP2 (6&7)

(what is read in serial port is in decimal and has to be converted to hexadecimal based on whta the prodeuct software is doing to get result.that In waveform properties I ahve selected hexadecimal representation)

 

Then as mentioned in manual I join those two values to plot waveform.

 

Although I have used on digital band pass filter for pulse waveform but not considerable change has been seen (low cutoff frequency:0.5 high cutofffrequeny:10).

 

I have attached my program and result in front panel as well as manual for the sensor. Result is still far away from what is supposed to be. I am wondering if you could help me  and let me know your opinion about the program and protocol that is used. I have to get result as soon as possible. Please let me know if you need more information.

 

Regards,

 

Download All
0 Kudos
Message 1 of 17
(4,419 Views)

You have no synchronization of the data. You are not using the VISA Configure Serial Port Correctly. Your termination character should be the ETX character (0x3), not LF (0xA). Nor should the configure be inside a while loop. You only need to configure once.

 

Do a read of 11 Bytes (no VISA Bytes at Serial Port) and if you have set the termination character correctly, the read will automatically terminate when the ETX character is detected. If the actual number of bytes is less than 11, discard the data. Read again and you will be synched. The rest is just parsing the byte array.

 

p.s. Just noticed that you are not joining the data. Building an array is not at all the same thing. You need the Join Numbers function to combine single bytes.

Message 2 of 17
(4,411 Views)

Dear Dennis,

 

Thanks for your prompt reply. I really appreciate your help. I found your answers really helpful.

 

Concerning Number of bytes at port, I have set the number of bytes to be read as 11 bytes but when I use the prperty node it will return zero, although I think it will show the available number of bytes at serial port but it should not be zero, However return count at VISA read is 11  same as what is set.

 

About end termination char , According to mannual I set it to ETX=0x3 but when each byte array is displayed the termination byte in array is not 3.

 

Regarding delay before reading, Since I have termination Char then there is no need to set the delay. because When data is in the desired order , the frame will be read(every 10 ms based on mannual).

 

About joining two bytes, I used join number function but it did n't give the result in the way I want.  I need to connect tw byte of array to be considered as one decimal value I mean if byte array is:

 

12

31

21

45

46

47

56

78

90

74

 

I want to get second & third one  3121 as decimal value!

 

I am beginner in Labview, I am really sorry if my questions are simple.Thanks for your attention.

 

Regards,

Download All
0 Kudos
Message 3 of 17
(4,390 Views)

Hi guys,

 

I really need your suggestion, no idea?

0 Kudos
Message 4 of 17
(4,363 Views)

Bytes at Port and VISA Read in New.vi run in parallel so you have no way to know which executed first. If the Read runs first, it is reasonable that Bytes at Port would return zero.

 

If you have a termination character bing sent by the remote device, you do not need Bytes at Port (unless you want to watch for buffer overflow).  You also do not need a delay before read. The Read function will wait until it gets the termination character or the byte count, which ever comes first. Typically when using termination characters, byte count is set to a larger value.  The termination character is removed by the read function so it will NOT appear in the output string.

 

You program has the termination character set to 0xA = line feed, not ETX. You should change the value in the control and then Edit >> Make Current Values Default.

 

I do not understand your comments about the data conversion process. Are you saying that you receive a string which has decimal values of the byte array second and third elements which are 31 and 21 (0x1F and 0x15) and you want the result to be 3E3 + 1E2 + 2E1 + 1?  In that case you need to multiply element 1 by 100 and add the result to element 2.

 

Lynn

0 Kudos
Message 5 of 17
(4,343 Views)

Thanks for your attention.

 

First of all, concerning being removed the end char, so this is where the problem will be appear. Since I am assuming that I have one frame with 11 bytes (based on what has been Witten in the manual)

 

Communication protocol:
-. STX = 0xFA
-. ETX = 0xFB
-. Total 11byte Transmit
-. STX + Wave(2byte) + Hr(2byte) + Spo2(2byte) + Bar data(1byte)
+ Wave gain(1byte) + Status(1byte) + ETX

 

Then after string to byte array conversion. I assumed that output is in the same order as above and then I have get the value related to second & third byte related to waveform and then join them together. but In case of removing end char in output, my assumption is probably wrong.

 

 

About joining bytes, my goal is to put the decimal values in second & third byte together as one decimal value. That I succeeded to do it by using the attached program

 

Could you please let me know your opinion about what should be done to extract those values related to waveform. So many thanks.

 

 

Download All
0 Kudos
Message 6 of 17
(4,331 Views)

What would help is if you ran the VI until you had data in the string indicator, stopped it, and then went to Edit>Make Current Values Default, save the VI and posted that. Along with that, give an indication of what the values are supposed to be.

0 Kudos
Message 7 of 17
(4,321 Views)

You have also posted two different values of ETX (0x3 which is in standard ASCII tables and 0xFB).  Please be as specific as possible about your data and your protocol.

 

Lynn

0 Kudos
Message 8 of 17
(4,311 Views)

 

Hi everybody,

 

Sorry for my delay. I was trying to figure out my problem. So far I understood that my problem was regarding the way that I connect dynamic data to graph. There has to be used one conversion from dynamic data.

 

Although still a small problem, there is always sudden drop at waveform to zero value. I am not sure if it is related to using this conversion palette.

 

Regarding description about my project, the value for ETX is 0xFB.the project is about getting the output of one sensor which is supposed to show pulse waveform.

 

Waveform is some specific bytes that have to be extracted from each frame and then converted to hexadecimal. So far this step has been done but problem is that some sudden drop is existed in the waveform. I have attached the manual the manual as well.

.

 

Looking forward to hearing your suggestions. Thanks for your help.

 

 Regards,

 

 

 

Download All
0 Kudos
Message 9 of 17
(4,281 Views)

 

Hello again,

 

 

no idea why am I getting zero values ? what do you think about using interpolation?

 

 

 Thanks

0 Kudos
Message 10 of 17
(4,260 Views)