07-23-2010 10:13 AM - edited 07-23-2010 10:14 AM
Don't try to change your square wave. You can modify the parameters in my code so that the EKG pulses come at the same time as the square wave pulses. Instead of two graphs, you can put both signals on one graph, one above the other.
To modify the parameters, don't change the amplitude on my square wave generator or you will get some square wave pulses. Change the number of samples on the square wave generator to make longer or shorter DC (straight line part). Trial and error. Change it so that the straight line ends where the square wave goes hi. To see this, put both signals on one graph.
To make the ECK pulse fit inside the square wave pulse, change the frequency, number of samples, and sample rate. This is going to be tedious trial and error.
To make each rising square wave pulse coincide with the EKG pulses, you will have to change the entire length of the total EKG cycle. This includes the long DC before the p wave, the short DC between the p and QRS and t waves, and the long DC after the T wave. By trial and error, you can make this happen. Try it. Don't touch the amplitude or offset of the square wave generator. If you change the amplitude of the triangle wave generators, you will probably have to change the offset too.
07-26-2010 12:09 PM
Instead of going through all these errors and trials, I'm thinking of triggering EKG signal when square wave is generated. I want to use a function generator to generate square waves of 5 V. When the amplitude is greater than 2 V, it automatically triggers EKG signal. This way I don't have to go through converting square wave to EKG signal. How do I go about modifying the current programming? OR is there any simple way?
07-26-2010 02:01 PM
@keni wrote:
Instead of going through all these errors and trials, I'm thinking of triggering EKG signal when square wave is generated. I want to use a function generator to generate square waves of 5 V. When the amplitude is greater than 2 V, it automatically triggers EKG signal.
You mean a trapezoidal wave? Because a (pure) square wave with an amplitude of 5V does not have a 2V level. That still won't solve your basic problem of setting the length of the ECG. With all the time that has passed you would have already gone through the trials and errors (and then some) to get the waveform you want. I fail to see what's so difficult about trying what has already been explained to you several times.
07-26-2010 02:06 PM
@keni wrote:
Instead of going through all these errors and trials, I'm thinking of triggering EKG signal when square wave is generated. I want to use a function generator to generate square waves of 5 V. When the amplitude is greater than 2 V, it automatically triggers EKG signal. This way I don't have to go through converting square wave to EKG signal. How do I go about modifying the current programming? OR is there any simple way?
When you say you want to use a function generator, do you mean a real function generator (hardware instrument) or one of the function generators in Labview (software)? How are you gong to generate the EKG signal? Are you going to use my code? If so, you need to modify it to create only one EKG pulse. You need to answer these questions before we can proceed.
The trials and errors do not involve converting the square wave to EKG. Either you are missing the point, or you are not wording you post very well. The square wave will remain unchanged. We will be using a square wave edge to know when to generate the EKG.
07-26-2010 03:19 PM
I will be using the real function generator (hardware instrument). The EKG signal from your program looks good enough. So, yes i'll be using your code. I want to display that EKG signal whenever square wave kicks in from function generator. If it's possible both on the same graph.
07-26-2010 04:18 PM - edited 07-26-2010 04:21 PM
You will need some type of DAQ device to capture the function generator output in real time, and display the waveform a waveform chart. You will have to look for a rising or falling edge in every loop iteration. When the proper edge happens, you will have to generate just one EKG cycle to the waveform chart. How fast is your square wave? If it is greater than 1KHz, you will not be able to do this in Labview continuously. The only thing you could do is to capture a few cycles of the square wave, process it to produce the EKG, then display them on a graph, all after the square wave generator has output its signal. Not in real time, more like after the fact.
This is not a trivial task.
After reading a previous post, your square wave looks like it is close to 1Hz (920ms per cycle). So you can do this in Labview, but you need DAQ hardware to capture the signal. Do you have a DAQ board (analog in or digital in).
07-26-2010 04:33 PM
Depending on the DAQ card you are using, you could use the signal from the square wave to trigger the DAQ card and would not need to read the square wave at all.
07-27-2010 09:50 AM
Yes, I am using DAQ device. I have attached the file for DAQ and the graph of signal.
07-27-2010 09:55 AM - edited 07-27-2010 09:57 AM
That's next to worthless in determining whether you can have the DAQ card automatically trigger.
Look at the shipping examples for analog output - especially those that reference a hardware trigger. That is, once you determine the actual DAQ card you are using and whether it supports an external trigger.
p.s. With that DAQ Assistant, you are doing the worst possible thing for real time control. You would be outputing the waveform as much as 10 seconds after the pulse occurs. Think about the simple mathematical relationship between sample rate and number of samples to read.
07-27-2010 10:19 AM
They are using NI-USB 6008 just for testing purpose. If it works they will be getting the advance one, i guess.