From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate square waveform at 100 KHz from PXI-6713 ?

I want to generate a square wave at 100 KHz with 90 % duty cycle. Any one please help me in this regard...as soon as possible...I am developing my application in VC++, using NI drivers...

Thanx in advance.
0 Kudos
Message 1 of 7
(3,039 Views)
You will want to use one of the counters on the PXI-6713 to generate the square wave. The PXI-6713 uses the DAQ-STC counter. Take a look at the STC examples in the C:\Program Files\National Instruments\NI-DAQ\Examples\VisualC\Ctr\ directory, in particular the STCgenerateSquareWave.C example. Simply change the timebase to the internal 20 MHz clock (instead of 100kHz) and set the LOWcount and HIGHcount to 20 and 180 respectively, instead of 50 and 50. This will drive the output low for 20 clock counts and high for 180, which will give you the 90% duty cycle at 100kHz. Also, be sure to set the device number and counter number appropriately.

It is always a good idea to take a look at the example code provided by National Instruments before starting a project
. Much of the work may have already been done for you. You can also find example code on the web site at ni.com/support.

Regards,

Brent R.
Applications Engineer
National Instruments
Message 2 of 7
(3,039 Views)
Hello;

You can use one of the NI-DAQ shipping examples together with one general purpose counters available of that board to accomplish that task.

A good start point for you is the one that can be found at: C:\Program Files\National Instruments\NI-DAQ\Examples\VisualC\Ctr, and is called "STC generate Square Wave.c".

Hope this helps.
Filipe A.
Applications Engineer
National Instruments
Message 3 of 7
(3,039 Views)
Hi Brent,

Thanx for your information...I've gone through the example and modified according to our requirement...

In that, I want to have the amplitude of the waveform between 0 V and 0.4 V...I mean Vol=0 Volts and Voh=0.4 Volts.

I thought, this can be possible by including the API function AO_VWrite.

This function requires Analog Output channel number...but we are generating our square waveform from General Purpose counter (GPCTR0_OUT) Connector Pin No. 2.

Can you help how to achieve the vol & voh values stated above ?

Thanx in advance
sriram.
0 Kudos
Message 4 of 7
(3,039 Views)
Sriram,

The analog output functionality on the 6713 is completely separate from the counter operations. The analog output is capable of switching between any arbitrary voltage (+/-10V range), however the maximum update rate of 1 MS/s is not fast enough to give you a good square wave at the frequency you have specified. You could try one of the buffered analog outout examples and see if the results are good enough for your application. I am fairly certain that you should be using the counter output.

As far as I know the counter output is TTL only. You could add some external circuitry, such as an op amp or even a simple voltage divider, to drop the voltage down to 0.4V. There are a variety of ways to get the desired voltage levels using a
very simple circuit.

Regards,

Brent R.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 7
(3,039 Views)
Hi Brent.

Thanx for your information....

Actually I need a square waveform at 100 KHz, with Vol = 0.0 V and Voh = 0.4 V

Can you please explain me exactly, how the update rate of 1 MS/s affects my waveform's frequency.

I gone thro the Update rate Vs Frequency calculations as explained in the Appendix B of PXI 6713 Manual.
But couldn't arrive at the exact solution.

plz help me

Thanx Brent.

sriram.
0 Kudos
Message 6 of 7
(3,039 Views)
Sriram,

The calculations in Appendix B refer to generating a clean sine wave signal not a square wave.

The 1 MS/s update rate means that every 1 us the card can switch to a new output voltage level. To get the 100kHz, 90% duty cycle square wave, this means that the signal will be at 0.4V for 9 update periods (9us) and at 0.0V for exactly one update period. In theory, the analog output on this card will exactly achieve the waveform you want. In practice, effects like slew rate limitataions will give you a less than perfect square wave.

It may seem like 1 MS/s should be fast enough to generate a signal that is *only* 100kHz. This would almost be true for a sine wave (10 updates would give a somewhat stair-stepped wavef
orm), however the 100kHz square wave signal you have described actually contains frequency components well beyond 1MHz.

Take a look at the buffered analog output examples. You should be able to get a reasonable representation of the signal you want, which may be good enough for your application. It all depends on what you consider a "good" square wave. The counter output will give you an excellent square wave.

Regards,

Brent R.
Applications Engineer
National Instruments
0 Kudos
Message 7 of 7
(3,039 Views)