LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adjusting the frequency of a square wave generated by CTR0_OUT of NI-Elvis II.

Solved!
Go to solution

Hi everyone,

 

I've been asked to modify the frequency of a square wave generated using DAQ assistant whose output is wired to pin A0 of the NI-Elvis II board. The A0 pin is connected to the CTR0_OUT and the DAQ assistant is set to generate signals based on this counter output. The task says to modify the frequency of a 10 ms pulse train by wiring a numeric control to the input of the wait(ms) function. 

 

I start by configuring my DAQ assistant as shown below:

 

Screenshot (78).jpg

And so I generate a square wave with a frequency of 50Hz (1/20ms) in the instrument launcher oscilloscope. This is simply done by having the DAQ assistant running in a while loop terminated with a stop button. Only now I don't know how to change the frequency of the pulse train with code  simply using the wait (ms) function.I figured I must increase the width of the idle time by introducing a sizeable delay which I have tried. 

At first I researched the wait(ms) function and found out that any code that it runs in parallel with will execute if it takes longer to execute than the delay value. If the DAQ assistant writes 100 samples at a rate of 1kHz that would mean a time between samples of 100 ms. I then figured that I would need to introduce a delay encompassing 100 samples which take 100 ms each (10,000 ms) As shown:

 

Screenshot (79).png

This is the best I was able to understand how the software might be working with the hardware. I thought I'd increase the delay to start the sampling of the signal from CTR0_OUT in increments of 10000 ms so to increase the idle time and hence increase or reduce the frequency of a pulse train with a duty cycle of 10ms. 

This doesn't work and I still get a 50Hz square wave. If somebody could shed some light on this for me I'd greatly appreciate it, I have been researching this stuff for hours and can't seem to wrap my head around it. I now believe that a sample refers to both a high and a low pulse and not some arbitrary sample value on the period of the square wave at increasing increments in time but I still can't modify my signal in labview code.

 

Thanks,

Simon.

0 Kudos
Message 1 of 5
(4,302 Views)

Hi sburton,

 

This doesn't work and I still get a 50Hz square wave.

As has been defined in the DAQAssistent: 10ms HIGH, 10ms LOW. Makes 20ms per cycle or 50Hz pulses (aka "square wave")…

 

I now believe that a sample refers to both a high and a low pulse

Yes.

You use a counter output to generate pulses: One pulse is one sample.

 

I still can't modify my signal in labview code.

Change the configuration of the DAQAssistent to get other frequencies.

Or get rid of this ExpressVI and use plain DAQmx functions!

 

Btw. why did you mark your message as "LabVIEW NXG" when you use "old"/"classic" LabVIEW?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(4,295 Views)
Solution
Accepted by topic author sburt0n

Thanks for clarifying some stuff there for me. I realised I misinterpreted the problem and was actually required to use the digital I/O pins on the NI-Elvis II board to generate a square wave whose frequency is adjusted with numeric control. Here is the solution which solved the problem.

 

I set the numeric control to 1 and I get a square pulse with 10ms high and low time (50% duty cycle). 

 


Screenshot (80).png

0 Kudos
Message 3 of 5
(4,264 Views)

Hi sburton,

 

Here is the solution which solved the problem.

The solution should be:

1. Delete the 2nd sequence frame with its content

2. Remove the first seqnece frame

3. Give e meaningful label to "numeric 3"

4. Create a shift register and initialize it with TRUE

5. use this shift register as input for the DAQAssistent.

6. Use a NOT function to create the data for the right terminal of the shift register

7. as a bonus you should replace the DAQAssistent by plain DAQmx functions…

In the end it will look similar to this:

check.png

Does the ELVIS support CounterOutputs? Then DAQmx will handle the pulse generation, with an easy and accurate duty cycle setting!

Have you tried those example VIs coming with LabVIEW?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(4,259 Views)

Hi GerdW,

Yes the NI Elvis does support counter outputs where the frequency is a fixed value. The exercise required to use digital I/O instead. Thanks for your alternative solution. I will refer back to this in the near future.

S.

0 Kudos
Message 5 of 5
(4,235 Views)