From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Square waveform to digital output

I'm new to Labview and I can't figure out how to do this.

I want to continuous generate a square waveform 1kHz and then digital output it with Digital I/O functions (Traditional DAQ).  I can generate the square wave but don't know how to digital output it. Can anyone help with this?? I'm using Labview 7.0.

0 Kudos
Message 1 of 8
(3,955 Views)

Hi,

 

Thanks for posting on our forum.

Are you trying to do an "hardware timed" or a "software timed" digital output.
Hardware timed generation: uses an hardware clock on the board, with this method you will have a better speed and accuracy, but not all the board are able to do that. For example, you won't be able to do that with an E-Serie Board.
Software timed generation: you are using a software loop. The accuracy and the speed are not as good as with the hardware timed generation.

I attach an example VI for a software timed DO.
You will find other examples here:
C:\Program Files\National Instruments\LabVIEW 8.6\examples\daq\digital

Best regards,

Thomas B. | CLAD
National Instruments France

0 Kudos
Message 2 of 8
(3,933 Views)

Thanks for the help Thomas B.

 

I'm using  PCI-6024E Board. I have tested your example and in the output (line0)  the signal isn't at 1kHz. The frequency is very important to me, how can I force the frequency in the signal??

 

I have made a small change in your example.

0 Kudos
Message 3 of 8
(3,918 Views)

Hi,

 

First of all, if you want, you can speak french.


PCI-6024e cannot do hardware timed Digital Output.
(see attached picture)

 

You will only be able to do a software timed generation.It means that you will have a while (or for) loop, and at each iteration of the loop, you will update the state of your digital output.
The VI "Write to digital port.vi" allows you to set the state of a port.
For example, if the width of the port is 8 bits, and the data ("pattern" input of this VI) is 255, all the output will be at "True" (255 in decimal = 11111111 in binary).


Please find attached a slightly modified version of my VI. It toggles (=revert state) a port at a desired frequency.
At an iteration of the loop, the port is at 255, so all the lines are at true, at the next iteration of the loop, the port is at 0, so all the lines are at false.


However, the while loop will not be able to run as fast as we want and the loop duration might change slightly as the processor is used by other programs (Internet explorer, anti-virus...) on the computer. The duration of one iteration of the loop might be a few millisecond less or more than the desired value.

So if you want to generate a square wave that is precisely at 1KHz, you will have to use another board (for example this one: https://www.ni.com/en-us/support/model.pci-6220.html , if you look at the specifications for the Digital I/O, you will see that the DIO can be hardware clocked ).

 

Best regards, 

Thomas B. | CLAD
National Instruments France

0 Kudos
Message 4 of 8
(3,897 Views)
 

Thanks again!

 

I'm don't speak French.  LoL

 

Would this be possible to do with DAQmx functions?

0 Kudos
Message 5 of 8
(3,848 Views)

It does not matter what driver you use. The limitation is the hardware as already mentioned.

 

Your board does have a counter/timer and you can use that to generate a square wave.

0 Kudos
Message 6 of 8
(3,845 Views)
But  how can I do that ? Can you please help me with that.
0 Kudos
Message 7 of 8
(3,814 Views)
Help>Find Examples is the place you should always start. If you run into problems with the examples, then post here.
0 Kudos
Message 8 of 8
(3,812 Views)