LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate Signal for Fixed Time and File Output

Hello,

 

I am trying to create a test bench that does the following:

  • Allows the user to enter a start and stop frequency. This generates an array with those values and the frequencies in between. I have accomplished this.
  • The frequencies are then used to generate a signal. Each frequency will generate a 50ms pulse with a slight delay between pulses. Example: a 250 kHz square wave will be generated for 50ms. After a delay, a 249 kHz square wave pulse will be generated. Repeat for remaining frequencies. I've been using a sine wave for testing because it's easier to see changing values for testing.
  • Every 5 ms the data will be read and the last read value will be put to a file. I was testing every 5ms, but the faster the better. So for 250 kHz, the data is recorded when the signal starts, 5ms into the pulse, 10ms into the pulse, etc. Repeat for each frequency.
    • The data will be recorded to a .xlsm ideally. However, I wanted to tackle one issue at a time so I'm using .xlsx for now. I know I'm supposed to use the RGT but I'm having trouble with that as well.

The problem that I'm running into is that I can't get the pulse to generate for just 50ms. Ideally I want this actual pulse generation time to be controlled from the front panel. I have done a great deal of searching and not found something that quite satisfies what I'm trying to do. My current .VI is attached. I would appreciate any guidance, and I hope I've provided a sufficient amount of information.

 

Thank you.

0 Kudos
Message 1 of 9
(3,275 Views)

RakeTowel97,

 

What hardware are you using for this?

 

VanCamp

0 Kudos
Message 2 of 9
(3,218 Views)

I am using an Analog Discovery Kit 2 to generate a signal and also as a scope

0 Kudos
Message 3 of 9
(3,202 Views)

RakeTowel97,

 

I did some looking into the VI you are working off of. I assume the idea is that the simulate signal VI is meant to produce data until the elapsed time VI interrupts it after "Time Target (s)" seconds? The way the current program operates, both express VIs inside the loop must complete before the next iteration occurs. This means that the elapsed time VI will never actually interrupt the simulate signal vi - it will just wait for it to finish. The amount of data generated by the simulate signal VI is only dependant on the "samples per second" and "number of samples" parameters. In order to generate 50 ms of data, you need to know the sample rate of the device this will go to, and based on that, how many samples you need to output.

 

Unfortunately, these cannot be programmatically changed in the express VI, meaning this architecture will not allow you to change the time target. To do this, you will have to switch to using the "Basic Function Generator" VI instead of the "Simulate Signal" VI.

 

VanCamp

Message 4 of 9
(3,188 Views)

Vancamp, 

 

thanks for taking a thorough look at my VI. You do have the right idea with how I want the code to execute. So in reality of my actual application, I'm using the Digilent FGEN Run and FGEN Configure Standard Waveform VIs. I used Simulate Signal VI for a demonstration. Your insight was very helpful though, despite this difference, as I have a better understanding of LabView now. I made that little demo VI because I thought it would simplify things and make it easier for somebody to assist me. Attached is my real VI with parts. Note: This will not open/run properly without the Digilent Waveforms LabView components installed. 

It is a bit sloppy because I've been doing a lot of experimenting 

0 Kudos
Message 5 of 9
(3,179 Views)

RakeTowel97,

 

Same idea still applies. Whether you use the "Configure Standard Waveform VI" or the "Simulate Signal" subVI, you will need to set the sample frequency to be the same as what you wish to output, and configure the number of samples to give you 50 ms of data. I think you will still be better served by using the "Basic Function Generator" VI.

 

VanCamp

0 Kudos
Message 6 of 9
(3,167 Views)

VanCamp,

 

I'm trying to use the Basic Function Generator VI but I cannot get it to work with the Digilent WaveForms function generator. Just as a basic test I made the attached VI and it throws up an error, and I'm not sure why. Any ideas?

 

0 Kudos
Message 7 of 9
(3,161 Views)

VanCamp,

 

I'm trying to use the Basic Function Generator VI but I cannot get it to work with the Digilent WaveForms function generator. Just as a basic test I made the attached VI and it throws up an error, and I'm not sure why. Any ideas?

 

Download All
0 Kudos
Message 8 of 9
(3,161 Views)

I don't have those Digilent VI's, so I may not be very helpful on that front. But, I would assume that you should be using the "configure arbitrary waveform" vi before using the "run" VI.

 

What error do you get? Does Digilent have VI's that you can use as examples of how to get a basic program working?

 

VanCamp

0 Kudos
Message 9 of 9
(3,147 Views)