LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I set up analog 0-10 VDC output pulses with varying duty cycles?

I am trying to control a 400 watt laser so that it can pulse on and off within a few milliseconds. The laser controller reads a 0-10 VDC signal, with 0V being 0 watts and 10V being 400 watts. I am using a PCI-6221 DAQ and LabVIEW 8.0.
 
It seems that all of the examples have square waves that are symmetric about the 0 volt range. I need a square wave that goes from 0-10VDC with different on/off timespans. I would like to have something as follows:
 
1) 0 seconds = laser off
2) .001 to .002 seconds = laser on at full power
3) .002 to .009 seconds = laser off
4) Repeat steps 2-3 500 times
 
Any ideas?
 
Michael Fidler
 
0 Kudos
Message 1 of 10
(3,464 Views)
Howdy,

I believe others have said here that with Windows, you won't get any more accurate than 1ms timing. If that's ok with you, then it seems a simple Sequence inside a While loop should do the trick. At the start of the program, set the Analog Output channel to 0. Then, in the while loop, Step 1 is output 10V, add a Wait for 2ms, then Step 2 is output 0V for 7ms. Repeat until you press stop. Or, if you want exactly 500 cycles, use a For Loop instead of the While.

Make sense?

B-)
0 Kudos
Message 2 of 10
(3,444 Views)

Thanks for your reply. I didn't know about Timed Sequences.

Alright, I am getting closer but it is still not working correctly. I have it set up now to have the laser on for 10ms and then off for 10ms. I'm reading the VDC output from the DAQ with a digital oscilloscope. With the current settings, I am reading "On" for 10ms and "Off" for about 17ms.

Do you know why it would be doing this? I tried subtracting the "Frame Duration" values to account for them, but that didn't work. Any ideas?

Michael J Fidler

0 Kudos
Message 3 of 10
(3,421 Views)

Michael:

Another option you may want to look at is use the onboard counter/timers to generate a pulse train with deterministic timing (precise frequencies and on/off times)

You could take the TTL compatible (0-5V) output and use a buffer or optoisolator to scale it up to a 0-10V level pulse. There are a lot of examples in LabVIEW help about generating pulse trains.

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 4 of 10
(3,417 Views)

Michael,

My suggestion would be to either use a counter, as mentioned earlier in the post, or to create a waveform of one period (on and off of your pulse) which you will write to the buffer before you start generation. You can then do a continuous write, and this signal will repeat until you stop. This knowledgebase helps explain digital regeneration.

I would also suggest looking at some of the examples which ship with LabVIEW. These can be founder under ‘Help >> Find Examples…>> Hardware Input and Output >> DAQmx >> Digital Generation’

David L.
Systems Engineering
National Instruments
0 Kudos
Message 5 of 10
(3,409 Views)

Alright, I'm an Aerospace Engineer and not Electrical, so keep in mind that this is all new to me.

AnalogKid, if I were to use your method does that mean I would need another circuit board to scale the digital output signal to the 0-10VDC signal? Is that what a buffer or optoisolator does?

David, I think you linked from an internal website and it doesn't work for me, but I assume you meant to link to the following site:

http://digital.ni.com/public.nsf/allkb/7e2b7cfa5f440ab68625706200567ee3

I modified this VI slightly so that I could directly manipulate the Duty Cycle. I also changed it to go from 0-10VDC instead of -5-+5VDC square wave. While this outputs a square wave to the waveform graph, it doesn't exactly output a square wave from the DAQ. If you look at the photo I attached of the oscilloscope, you will notice that it takes about 1.5 ms to ramp the voltage from 0 to 10VDC. Is this a limitation of the DAQ that I am using?

Thanks again for everyone's help.

Michael Fidler

 

Download All
0 Kudos
Message 6 of 10
(3,399 Views)

Michael,

 

I ran your code, but was unable to reproduce the problem you are seeing. I measured the signal in two fashions’. I brought the signal back into the card (LabVIEW_Square Wave.JPG) and into a benchtop scope (Benchtop scope_Square Wave.jpg).

I would like to ask that you run the attached code twice. The first time, please run it with the analog input as ‘Dev1/_ao0_vs_aognd’. This take the analog output and compares it with the cards AO ground, therefore eliminating the need for external connections and simply doing internal routing. The second time, please run it with the analog input as “Dev1/ai1”, and wire your AO channel to an AI channel. These tests are to ensure that there is not a stray capacitance in your scope, the probe, etc. Let me know the results (pictures are always great)

David L.
Systems Engineering
National Instruments
0 Kudos
Message 7 of 10
(3,373 Views)
Thanks for all of your help, David. I'm not sure what the problem was with my set-up, but the next day everything ran as it should have without any transients.
 
Since then I re-wrote the VI so that I can input the "on" time and the "off" time for the square wave, but I am still having problems.
 
Right now the only way I can stop the output signal (and hence the laser) is to hit "stop 1" and then "stop 2", which completely stops the program. Then I can change "on", "off", and "volts" values if I want and restart the program. Is there a more elegant way to stop the program (and end up with 0VDC output) than this? Whenever I try stoping it using a differant method I get an error (see attached jpg). Eventually I would like to hook up a sensor to stop the laser when it sends a signal to the DAQ.
 
Also, I am running 8.0 so I couldn't open your 8.2 VI.
 
Michael J Fidler
Download All
0 Kudos
Message 8 of 10
(3,310 Views)

Michael,

What’s going on is that the ‘first call.vi’ is only called once, and so the second time you start the generation, the DAQmx Start.vi is not called, and the error you are seeing is thrown. I have posted below your VI with a few minor changes.

I made the inner case structure enter the ‘DAQmx Start’ state any time the while loop has its first iteration (an iteration of ‘0’ (zero indexed)). This will force the DAQmx Start vi to run more than once if you stop and start your generation. I also put a DAQmx write just before your DAQmx clear to implement the idea of outputting 0v before the generation stops. Since we are doing this after the inner while loop stops, we can take it away from the false case of the outer case statement.

Good luck with the project!

David L.
Systems Engineering
National Instruments
0 Kudos
Message 9 of 10
(3,266 Views)
The rise time on the pulse had to have been a loose connection or bad probe.  That is a typical rise time for a RC circuit
0 Kudos
Message 10 of 10
(3,238 Views)