08-27-2012 04:17 PM
I'd like to generate an analog voltage output 0-5V that has a varying amplitude, as shown in the figure. The maximum voltage is 5V and the low voltage a percentage of that, but I don't need to vary the amplitude during the VI execution.
Solved! Go to Solution.
08-29-2012 05:40 AM
Hi kmargaris,
Thanks for your post and diagram.
I'm going to make a number of assumptions here:
1. You're using LabVIEW.
2. You're using some kind of NI Multifunction DAQ device.
3. You're at least a little bit familiar with LabVIEW.
The easiest way to do this is to use the DAQ Assistant to perform a finite analog voltage generation.
The DAQ assistant can be found in the functions palette under Express >> Output >> DAQ Assistant and when you place it down you'll want to select Generate Signals >> Analog Output >> Voltage>> then select your device.
You would configure it as shown (you may want to use different values for Samples to Write and Rate (Hz)):
You can then wire an array of values to the data input of your DAQ Assistant, your analog output voltage will then update with the next value in the array, every time a new sample is written. The code would look something like this:
I've drawn your signal on there too so you can see how it relates to the values in the array. Using this method, you'll need to specify a rate such that the timing of your signal is appropriate, similarly, the number of samples to write will denote how long the output task takes.
For instance, if your rate is 1Hz and your no. of samples to write is 25, with the example above you'll have a signal that remains at 1 volt for 6 seconds, then 2 volts for 7 seconds, then 5 volts for 2 seconds, 1 volt for 1 second and then back to 2 volts for the remaining samples.
I hope this helps,
Kind Regards,
09-04-2012 09:01 AM
Hi Joel,
Thanks for the reply, it works! Your assumptions were correct, I am using labview and a NI DAQ (6341).
Would it be possible to do the same task with counter output and not an analog one?
09-04-2012 09:07 AM
Hi Kmargaris,
Well done, I'm glad you got it working.
Counter output is a little different, you generally use it for outputting a pulse or a pulse train (repeated pulses). Counter outputs are only compatible with TTL logic (0v low 5v high) so you would have to output a digital signal.
In summary, you wouldn't be able to acheive this task with a counter output.
Kind Regards
09-04-2012 09:17 AM
Hi Joel,
Thanks for claryfing this. So it is feasible with digital output, but these are software control, right? So how accurate is the timing in this case?
09-04-2012 09:31 AM
With digital outputs you are limited to two levels. Low and High. (1 and 0). These are output from the DIO lines as DC voltage levels. The two levels can be anything, but most commonly 0v is used for low, and 5v is used for high. This (along with some other specifications) is called TTL logic.
There are some cards that allow you to choose the digital voltage levels, but your multifunction DAQ does not provide this functionality.
You could do something similar with digital output, where you only used 0v and 5v levels.
You're absolutely right that software control timing is less accurate than hardware control timing, however, if you did a digital output task in this way, and set it up to do finite or continuous samples, it would be using hardware timing and would therefore be very accurate (in accordance with the specifications in the device spec sheet).