LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquiring signal from the serial port

Hi all

 

I am working on a project for my thesis . i am trying to acquire a ECG signal from the serial port . i have implemented the ECG circuit and it works fine . what i have here as attached files is a VI that i was lately working on . it works perfectly and i am able to acquire the signal from the serial port . but the dilema is im having a hard time with explaining why ? 

 

to go further on the explanation ,

 

ECG test(1) VI  is the VI that i was working on lately.it is giving me a real very noisy signal . i am expecting to have an ECG signal with PQRST complexes .

 

but when using . ECG vi i am having a real ECG signal with approximately 50 % heart beats shown . 

 

i just wanna go further with the filtering of the signal and applying discrete wavelet transform on the signal so that clinicians can easily read the signal .

 

can you guys suggest anything ?

 

Bill David
0 Kudos
Message 1 of 9
(3,831 Views)

to be more precise 

 

ECG tes VI   is giving me results number 1 .

 

ECG VI  is giving me results number 2

 

I hope i made it clear.

 

Bill David
0 Kudos
Message 2 of 9
(3,825 Views)

I work a lot with serial comms and also with ECG signals.  But I am having trouble understanding your question.

 

You have two different VIs?

And they are producing 2 different results?

And you want to know why?

 

If that is the case, can you explain what is different between the two VIs?

 

I opened them, and they look significatly different.  Both in how they acquire and process the data.  So oviosuly, they are going to display significantly different results.

 

But my first thought is that if you are receiving your data via a serial cable, then your LV code will have zero effect on the noise.  The noise is already there.  Not much you can do about it from the code, except to try and filter it out after-the-fact. 

http://www.medicollector.com
0 Kudos
Message 3 of 9
(3,810 Views)

Dear josborne . no m not trying to look at the difference in results between the 2 VI.

 

i mean that i m trying to use the perfect VI among them the thing which allows me to have the best ECG reading ever. ECG VI is giving me a good results . but need to apply filtering on it as well as to apply discrete wavelet transform in order to suppress the high frequencies that are present in the signal . 

 

i have posted the second VI ( ECG test (1) )  in order for you sir to answer me why is it giving me that much noise . 

 

if we can just apply filtering and discrete wavelet transform on one of the VI codes it would be perfect .

 

Bill David
0 Kudos
Message 4 of 9
(3,805 Views)

Bill David,

 

1. It appears that you have the serial port set to terminate both reads and writes on a line feed character. When using termination characters you do not need to use Bytes at Port. Using Bytes at Port and termination characters simultaneously often produces garbage data because you get partial messages which are then misinterpretted.

2. What do the read string and bytes read indicators show when running?

3. How many data points do you receive (or expect to receive) with each read?

4. What is the format of the data as it comes in on the serial port? The reason I ask this is that your data conversion seems rather convoluted.

5. What does the data in the shift register in ECG Test(1) look like?

 

Lynn

0 Kudos
Message 5 of 9
(3,803 Views)

Dear johnsold,

 

First i was using the basic serial read and write example in the examples . but im not writing anything to the port . im just reading from it .  i can delete that . but it feels like it has nothing to do with the reading process as long as i am writing to the port .

 

1 - the attched picture shows you the string that i am reading from the serial port .

2 - i have no idea about the amount of bytes being sent from the microcontroller . im just reading whatever bytes offered by the serial port and trying to convert those bytes into numbers and then plot them .  i dont even know how many bytes are being sent from the microcontroller . because when the analogue signal come in to the input of the UC it just convert it to digital then send it directly to the serial port by USART.

3- the microncontrolller is sending words or bytes to the serial port . ( I am using 16F874 from microchip ) it is an 8bit microcontroller .

 

Bill David
0 Kudos
Message 6 of 9
(3,796 Views)

Bill David,

 

Both of the VIs you posted send "*IDN?\n" on every iteration of the loop.

 

1. Try changing the read string indicator to '\' Codes Display or Hex Display. That will indicate all the characters and will show the hex values for any unprintable characters.

 

2, 3. You are converting the string to an array based on a space character as a separator between elements and End of Line between rows. But because  termination characters are enabled on VISA Read, you will never get any EOL characters in read string. Thus you will only get one row in your arrays. If the microcontroller is not sending the space and EOL characters (and you did not mention them), then your conversion process is completely meaningless.

 

3.a. If the conversions are 8-bit, then you should convert all bytes as individual U8 or I8 integers rather than whatever you are doing now. If the conversions are more than 8 bits, then you need to know exactly how the microcontroller is formatting the data: endian, bit packing, bit padding, ...

 

Lynn

0 Kudos
Message 7 of 9
(3,783 Views)
It also seems you are comparing apples to oranges. You really need to add a display of the original waveform before you start applying all of those wavelet functions. I don't have that toolkit but it would be a lot easier to see where the problem is instead of just assumimg you now have a noisy signal instead of thinking there isn't a mistake in the way you are using them.

p.s. Have you considered using the biomedical toolkit for the post processing instead of reinventing the wheel?
0 Kudos
Message 8 of 9
(3,741 Views)

Hi Bill David,

 

I think that trying the above suggestions might help you solving the issue. Trying the NI LabVIEW Biomedical Toolkit as Dennis_Knutson suggested might also help - there is an evaluation version, so that you can simply try the functionality for your signal.

Best regards,
Jano
0 Kudos
Message 9 of 9
(3,712 Views)