Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

generating a square wave with a compact DaQ chassis and NI 9474 module

Hello,

 

I am trying to generate a square wave to power a relay using a compact DaQ chassis and a NI 9474 digital I/O module.  I wrote some code in LabVIEW using the "Simulate Signal" VI and DAQmx.  When I watch the actual signal on an oscilloscope it is acurate at frequencies of 1 Hz and 2 Hz but when I set the "SImulate Signal" to 4 Hz the actual signal output does not read properly, the duty cycle is all over the place and the frequency is incorrect.  Can someone help me solve this problem?  I will attach a copy of my code.  Thank you.

 

MarmonIG 

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

Your duty cycle and frequency isn't constant because you are doing a software timed output task.  Updates are written as fast as they can be which is dependent on a number of factors.

 

Fortunately there is a solution.  You need to do a hardware timed task.  On the cDAQ-9172 this is called "Correlated Digital".  Correlated because the chassis cannot generate a timing signal on its own and has to rely on an external clock which correlates your digital task to that external signal.  The best way of doing this is using an internal counter to generate the clock for your digital task.

 

Take a look at the example "Cont Write Dig Port-Ext Clk.vi".  You can modify this to work with what you are trying to generate. Next open "Gen Dig Pulse Train - Continuous.vi".  This will use an internal chassis counter to generate your sample clock.  Set your counter to be cDAQ1/_ctr0.

 

Back on the write dig port example, set your external clock to be "/cDAQ1/Ctr0InternalOutput".  You can merge these two examples to create your application.

 

If you're just trying to generate a signal with a known frequency and duty cycle on one or two lines, there is an easier way.  Ignore the digital example and just look at the digital pulse train example.  Make sure your module is in slot 5 or 6.  Set the counter to cDAQ1/Mod5/ctr0.  Set the frequency and duty cycle.

 

Let me know if that works for you.

 

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