LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Signal Generation Timing Loop Behavior

I am trying to generate various simple waveforms in LabVIEW, which will then be output to various DAQ devices, amplifiers, etc.  I would like the user to be able to change the signal's amplitude and frequency (and phase too, if possible) while the program is running.

I've put together the attached simplified file.which works fine as long as I am willing to accept slow frequencies (i.e. those that still retain some resolution with a 0.1 s time delay).  (Note that for output devices I would simply tie into the "Simulate Signal" output.)

I would like to be able to use this VI at higher frequencies, but if I change the 0.1 s time delay to accommodate them, the output timing goes way off.  For example, change the frequency to 1 Hz and the Time Delay to 0.01 s, and you'll see that the output is much faster than 1 Hz.  I assume this may have to do with the relationship between this time delay, the samples per second, and number of samples of "Simulate Signal."

Is there a simple way to solve this problem using Simulate Signal, or am I going to have to use a different method to create my waveforms?
0 Kudos
Message 1 of 5
(3,024 Views)
You could try to remove the time delay completely. Now configure the "Simulate signal" express VI and check "Simulate acquisition timing" instead
 
Also remember, if you want to be able to change the Phase at runtime, the terminal must be inside the loop.
0 Kudos
Message 2 of 5
(3,018 Views)
Aha, that appears to have worked (although I'll have to double check higher frequencies on the oscilloscope).  Thanks!

As to the less important issue of being able to change the phase while the program is running, I had already tried putting the Phase input into the loop, but it doesn't have any effect there (hence why I took it out, just to remind myself that indeed it doesn't have an effect).  See the attached version, where I have two signals.  Once the program is running, changes in the "Phase Lead" box have no effect.  They will take effect upon a subsequent run.

Any suggestions?
0 Kudos
Message 3 of 5
(3,006 Views)
You must reset the signal simulator after making a phase change.  I tried putting in an event structure that would send a true to the reset inputs of both simulators when the phase value was changed.  That gave a delayed effect.  The signal would reset before the new phase took hold.  In other words, when I changed phase 0 to 90, no effect.  Then I changed 90 to 0, and the 90 phase shift displayed.  If I clicked inside the phase control, added a space, and pressed Enter, the 0 phase shift would take place.  So you have to send the new phase before the reset is applied.  Maybe a sequence structure inside the event structure would work.  The event is phase value change.  First frame would be to send the new phase value.  Next frame is to send reset.  Maybe you would need a delay between the two frames.  I'm not sure if the first frame output goes immediately, or waits until the entire sequence is completed.  I'll try it when I get a chance.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 5
(2,995 Views)

Here is a vi that will change the phase on the fly.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 5
(2,989 Views)