LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a timed pulse outside a loop?

I'm new to labview and trying to create a VI that can do a stepped swept sine. i.e it outputs the first frequency for a set amount of time, then the second frequency for a different time and so on. All of the frequencies and times need to be adjustable. I've created some test code that takes four times and frequencies and writes them to an output. I've also created a sine wave generator to an analog ouput. Individually they generally work ok, but I can't get them to work in conjunction.

 

The issue is that the sine generator/analog output won't work in a timed loop, so I need to put them outside a loop. The rest of the code needs to be inside a loop, because it has to be timed - I have used the loop iteration counter to generate 1ms pulses. The code doesn't work because the loop won't pass it's output until it has completed, but I can't see any way to get around this.

 

I've tried to generate a pulse outside a loop, using a square wave, but the output of the square wave is an array, so I can use zero crossing to swith a boolean signal. I'm used to working with PLC's where I would have no end of timers, counters, flip flops etc to choose from, non of which appear to be available to me in LabView.

 

There must be an elegant way to do this - but I can't see what it is.

0 Kudos
Message 1 of 3
(2,413 Views)

Hi Doug,

 

My name is Oli, I'm an Applications Engineer at NIUK, thanks for your post.  The description you've used as to what you are trying to generate isn't quite consistent, so I just wanted to check that I've understood everything correctly.

 

It sounds like you want to create a series of frequency steps in your sine wave something like this:

 

frequency 1 - wait - frequency 2 - wait... etc.

 

You called it a 'stepped swept sine' though, which to me suggests that you want to smoothly transition (sweep) between each of the frequencies rather than step between them.  Can you clarify which you would like to do?

 

Stepping between frequencies is easy to achieve, to do this, we would normally need to use a 'State Machine' architecture.  State Machines allow us to move between a series of 'states' in any order we like - this can be determined at compile time (statically determined) or at run time (dynamically determined).

 

So what we can do for your application is to have a setup 'state' and then pass to the first state where we read the first frequency and time, then pass that data to our generation VI to actually output that frequency.  After the time has elapsed, we then move to the second state, where, again, we read our data and update the output accordingly.  Then continue to do this for all of the states (frequency steps) and then close off our DAQ write tasks in the final state.

 

There is a really good article here that explains what a state machine is and how to use it.  I would suggest you read through that and that should get you going.

 

I have also attached an state machine template with some comments to better explain the above just in case I haven't been clear.  It won't work as it is currently, but it'll give you something to work from/add to if you like.

 

It isn't quite clear if you want to use Sine waves or Square waves?  If you can clarify this for me too, I can point you to some resources that will help.

 

If you have any issues, please let me know and I'll be happy to assist.

 

Best Regards,

Oli
LabVIEW Student Ambassador
National Instruments UK
0 Kudos
Message 2 of 3
(2,386 Views)

Hi Oli,

 

Thanks - I need to do an instantaneous transition from one frequency to another using sine waves.

 

I will have a look at the VI that you have sent.

0 Kudos
Message 3 of 3
(2,379 Views)