LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using pulse width modulated signal (square wave) to control when a signal is turned on or off

Solved!
Go to solution

Using pulse width modulated signal (square wave) to control when a signal is turned on or off

Greetings All

I'm trying to use a labview created pulse width modulated signal (square wave) to control when a signal is turned on or off.

Here's my logic and graphic example:
1) The source wave signal is continuous
2) Use a PWM (square wave) created in labview to control when the signal is turned on or off
3) If PWM signal (amplitude) is greater than 0 play signal if PWM is not greater than 0 don't play signal.

I'm actually using this to step sequence / pulse several separate magnetic coils using my audio card (which has several audio output channels), I have a signal in labview played constantly.  Than compare it to the PWM (square wave) which controls if the signal gets played on each separate channel or not.  That way I can control which coil is on and off and in what sequence they are activated. 

I couldn't find an edge detection for a square wave created in labview so I tried Limits but that doesn't seem to work unless I change the phase manually and that only goes from 1 to -1.  I'm just trying to compare the PWM (square wave edges) already created by labview / play a signal if the pulse is greater than 0 and it turns off the signal if it's less than 0.

 

Should I be doing this another way

 

Tia

Message Edited by sal22 on 08-16-2009 06:09 PM
Message Edited by sal22 on 08-16-2009 06:10 PM
0 Kudos
Message 1 of 9
(7,520 Views)
Here's an example of the pulse train with source signal
0 Kudos
Message 2 of 9
(7,497 Views)

Hi Sal,

 

Based on your AC-PWM2.gif, it looks like all you need to do is pull out the y component of your waveform and check if the magnitude is > 0. Then use a case structure to choose whether or not you output the current value of the source signal.

Will
CLA, CLED, CTD, CPI
LabVIEW Champion
Choose Movement Consulting
choose-mc.com
0 Kudos
Message 3 of 9
(7,474 Views)

Greetings,

 

I tried it two ways using amplitude and levels and fft spectrum.  The values don't seem to update the way I need them to (basiclly showing a 0 or a 1).   I compare the Y values like you recommended but they don't ever seem to update.

 

tia

Message Edited by sal22 on 08-19-2009 10:05 AM
Download All
0 Kudos
Message 4 of 9
(7,458 Views)

I was still thinking bringing it back to only outputting the signal when your square wave is high, similar to the community example below. Just think of the Boolean = true to be when your square wave is high.

 

http://decibel.ni.com/content/docs/DOC-6383

Will
CLA, CLED, CTD, CPI
LabVIEW Champion
Choose Movement Consulting
choose-mc.com
0 Kudos
Message 5 of 9
(7,430 Views)

Thanks for the example but the reason I was doing it this way was due to the fact that I have 8 signals to control so the basic True/False  wouldn't work.  My logic was to have one square wave generator controlling all 8 signals by changing the duty cycle / phase shift of each one separately.

 

I was trying to use a square wave to create a software based adjustable pulse train that turned on and off 8 other signals.

 

1) Basically taking the controlling square wave signal apart for each 8 source signals

2) adjusting the phase / duty cycle of each one (will be able to create my own "sudo pulse train")

2) building the waveform again 

2) Do an Analog to digital conversion of controlling square wave

3) Digital to Boolean of each controlling square wave

4) Square wave is now turned into Boolean will Control if loop is turned on or off

 

It looks like the main problem is converting the square wave to Boolean

 

thanks for all the help

 

 

Message Edited by sal22 on 08-20-2009 11:43 AM
0 Kudos
Message 6 of 9
(7,416 Views)

Maybe I am misunderstanding you, but it sounds like you are taking a single square wave, converting it to 8 separate square waves with which you turn on your output signals. Why not start with 8 separate square waves with which you can control their individual duty cycles?

 

To convert a square wave to Boolean, all you should need to do is compare its value to a threshold like 0.5. The compare VI will output true if the value is > 0.5, and false if the value is < 0.5.

Will
CLA, CLED, CTD, CPI
LabVIEW Champion
Choose Movement Consulting
choose-mc.com
0 Kudos
Message 7 of 9
(7,394 Views)

Yes I'm trying to use just one square wave signal to control them all.  From your reply the image below should work but it doesn't due to the fact that one is a boolean array and the other is just boolean.

 

 

0 Kudos
Message 8 of 9
(7,373 Views)
Solution
Accepted by topic author sal22

A waveform contains an array of values. You must check each value and react to it accordingly:

 

checkThreshold.png

Will
CLA, CLED, CTD, CPI
LabVIEW Champion
Choose Movement Consulting
choose-mc.com
Message 9 of 9
(7,340 Views)