LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with analog input, processing the signal, and analog output

Hello,
 
I'm trying to read a signal continuously, process it by applying a bandpass filter (and in the future, a delay) and converting to a square wave, and using analog output to send it to an instrument. My hardware is a PCI-6031E for input and a PCI-6733 for output. I am reading at 5k samples per second, trying to filter out a 60 Hz component to generate a 60 Hz square wave. I am reading 5000 samples each time the VI is called, so that displays are updated every second.
 
However, when writing out, the data is crammed in the first half second, with the rest of it stuck either at the high or low point of the square wave. Thus, the output frequency of the signal is 120 Hz instead of 60 Hz.
 
What could be the issue? I tried to use shift registers to correct the problem, but that does not happen. When checking the waveforms, they are made of 5000 points with a dt of 0.0002, which should translate to 1 second of data.
 
I attach the diagram of the code, and images of the signal before output and the measured ouput.
 
Thanks!
 
 
0 Kudos
Message 1 of 10
(2,976 Views)

Hi Villalro,

      The digital output shown in "Time Graph" seems to require a 120Hz signal coming out of the Butterworth filter - with the amplitude of leading and trailing portions falling below your "threshold limit"  and being "clipped".  The frequency-domain chart indicates a strong 120Hz component in the input (and practically nothing at 60Hz.)?  If you're still working on this, it would be good to know the value of "high-cutoff freq." and "low-cutoff freq."Smiley Happy

Cheers.

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 2 of 10
(2,953 Views)
Thanks for your answer... The plots I posted do not show it, but the signal coming out of the butterworth filter is indeed 60 hertz (6 peaks in 0.1 seconds). The square wave generated is also 60 Hz. The values I used for the cutoff frequencies are 50 and 70 Hz.

I believe the problem is either with the VI's used (or the mode chosen) or with the loop structure, since it seems to read the data right, but cram it in half the time it needs to when generating the output, although I am open to any suggestions.

Thanks!
0 Kudos
Message 3 of 10
(2,943 Views)
Re: the problem is either...
Also chart configuration for "Trigger Signal".  Chart's have a Scaling properties that could cause this.  Right-click on the chart and select "Scales".  Id be curious what the values were/are for:
Scaling Factors,
   Offset & Multiplier.
also Autoscale?
   Minimum/Maximum
 
Don't know what I was thinking before - "digital" value out of compare can't be zero (of course.):smileytongue:
Cheers.
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 4 of 10
(2,931 Views)

Offset is zero and multiplier is 1... Autoscale is off.

What is really unusual is the fact that the measured output signal seems to be made of 0.5 seconds of square wave (at twice the required frequency) and 0.5 seconds of either +4 or -4, as if the output got stuck or was filling out with the last requested condition.

Does it help if I upload the code?

0 Kudos
Message 5 of 10
(2,917 Views)


villalro wrote:

Does it help if I upload the code?


It could.Smiley Happy
While the answer might already be obvious to somebody else, It's not obvious to me and the code will include a lot of detail - as well as enable an actual "test-drive".Smiley Wink
 
Cheers! 
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 6 of 10
(2,908 Views)
Here it is... Again, thanks for taking the time to look into this!
0 Kudos
Message 7 of 10
(2,895 Views)

Hey, I still can't reproduce any unexpected behaviour, though suspect that the threshold value of 2 may produce some unexpected - asymetric - behaviour.

Here's a VI I used to test your code - maybe it will help understand this behaviour.

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 8 of 10
(2,886 Views)
The problem seems to be with the actual write process, because the signal looks fine up until the data supplied to the DAQmx Write vi. I'm thinking it should be a problem with the timing or with the way the data is processed inside the loop, which causes some data to be lost. The problem should not show on the vi you supplied since there are no DAQmx vi's in it.
0 Kudos
Message 9 of 10
(2,867 Views)

Hi villalro,

I see the image you posted about only having a the square wave being generated for part of the time.  What I don't see is the filter output that corresponds with that - the values that trigger the +/- 4 volt logic levels.  Does the partial square wave correspond to the data you read that's over the Threshold Limit in your VI?

If what is coming out of the DAQmx write is different from the square wave image you posted, how are they different?  Can you post an image of the DAQmx write output?

Kevin S.
Applications Engineer
National Instruments

0 Kudos
Message 10 of 10
(2,834 Views)