LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read ECG Raw data from microcontroller

Hi all,

I have searched all around this forum for my answer but haven't found yet though I know that it may be quite simple for you as I first use LV for a week. I'm studying Biomedical course and to know more about it I try to acquire ECG signal from an ECG hardware system. That has an ECG simulator and transfers signal to receiver which is built in microcontroller nRF24LE1 and connect to PC via COM port.The microcontroller sends 17 bytes to port per packet which always has byte 0 is A5 and byte 1 is 5A (in HEX). The packet provides data for 6 channels but ECG data is only on channel 1 with byte 4 (high byte) and byte 5 (low byte). Baud rate is 57600 and sample rate at 256 Hz with resolution as 4096, non handshaking.It works fine when I use another software to display ECG signal (Brainbay), still I haven't got it in LV yet. I made a simple vi to extract ECG data from 17 bytes read using VISA Read, but I received the wrong ECG signal waveform. I checked first two bytes, if they are both right A5 and 5A then calculate byte 4 and byte 5 to result. I attached my VI below.

Could anyone check it for me where I was wrong?

0 Kudos
Message 1 of 20
(4,459 Views)

Here is a quick modification

 

Problem: You don't sync with your data.

What did I mod: collect and buffer the data from the serial

used match pattern to find the start bytes and exactly 15 bytes more (the 15 dots) (Im shure this could be done more elegant with a magic regular expression;) )

If found catch byte 4 and 5 and used the join number to build a word.

 

Changed the buffer display to Hex

 

I didn't check how it behave when you have more valid data in the buffer....

 

Have fun

 

If more problems come up, catch some data in the buffer (modify the match pattern so the buffer will get bigger and bigger **) right click the buffer and make this data default, save the vi and post it , That way we can try with real data ....

 

**) of course your buffer must be monitored. if bigger than 34 characters something is wrong!

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 2 of 20
(4,456 Views)

Thank you very much , indeed. I got the right ECG now. I'll learn how to sync the data too. I feel LV is so interesting now 😄

Best regards

0 Kudos
Message 3 of 20
(4,433 Views)

Hi Henrik,

 

From acquiring ECG, to find out RR interval and Heart rate as well, I added block of RR interval and HR calculation inside while loop. I used peak detector.vi and for the threshold I use Max & Min function, however it led to wrong values of threshold (very very high) and got no heart rate.

Could you please take a look on my vi again?

 

Rgs,

 

Shuri

0 Kudos
Message 4 of 20
(4,413 Views)

In the false case where the appended ECG array terminal is you are creating an array with one element.  The rest of your program will not produce any meaningful results from one data point.

 

Build Array does not accumulate anything into the array.  All it does is create an array with the elements wired to its inputs. Thus one input produces an array with one element.

 

What you probably want to do is to put the array in a shift register.  In the false case you can add to the array.  In the true case just pass the array through.  Get rid of the local variable.  Just wire the array after the case structure to the threshold logic.  There are better ways to add data to the array, but just try this for now.

 

Lynn

Message 5 of 20
(4,410 Views)

Dear Lynn,

 

Thanks so much for your advice, I corrected the mistake and got the right HR now 🙂

0 Kudos
Message 6 of 20
(4,374 Views)

Hi all,

 

I'm still continuing with my ECG system and now have a problem with WA Denoise vi. I'd like to detrend and then denoise ECG raw signal before calculating something else. But it always happened the error "Wavelet Analysis Toolkit:  The input signal is empty." at WA Denoise vi when I run my vi. It still has the signal after the WA Detrend vi. I replaced the Serial COM module by an ECG array, WA Denoise worked fine. So what was wrong here? I attached the pic of error and my vi, could somebody take a look at it for me, pls

Tks

0 Kudos
Message 7 of 20
(4,347 Views)

Hey Shuri,

 

It looks like you are doing some interesting stuff here! I had a few questions/suggestions that might be able to help narrow down where the problem is occurring before you made the change from the Serial COM module.  Does the signal come up as empty on both instances of the WA Denoise VI but produce data in other parts of the VI? You could try to put it in highlight execution mode and watch it step through the program on the block diagram to see where the signal stops working. Another option would be able to put probes on the signal wire at various points such as before and after it goes through the WA Detrend VI. This may help show you where the problem is actually occurring.

 

Is it possible for you to continue on using the ECG Array or do you need to have it use the Serial COM module?

 

Hope this helps some!

 

Joe S.

Applications Engineer

National Instruments

 

0 Kudos
Message 8 of 20
(4,320 Views)

Hi Shuri,

 

Now that you have your ECG data coming into LabVIEW and you are working on signal processing, you may find some of the tools in the NI Biomedical Starter Kit helpful - it's a free download from NI Labs here: https://decibel.ni.com/content/docs/DOC-12646

 

You may also find more help when it comes to biomedical-specific stuff on our Biomedical User Community at ni.com/biomedusers

 

Steve

0 Kudos
Message 9 of 20
(4,315 Views)

Henrik,

I've been writing some specific commands to a microcontroller using the RS232 port but trying to get the response from the same received line, I keep getting different answers (hex I guess). I've tried to change the timeout, also including a wait sequence after the READ function but nothing good happens!

I need to write commands and received its response to 4 different units (microcontrollers) so, I'm using a USB to 4-port 232 serials (Serials USBG-4COM from www.coolgear.com).

A simple command will ask for its VERSION (which is 7 bytes written) and the answer can be of any length up to 32. How can I get the raw response from the microcontroller without worry about its length?

 

I'll be thank fully.

0 Kudos
Message 10 of 20
(4,293 Views)