Simple single point analog output with NI-DAQmx in VC++ 6.0

Specs: NI-DAQmx 7, VisualStudio C++ 6.0,  PCI-6722,8channel AO
We have a very simple application: set a voltage (actually 6 different channels) and keep until we want it changed again, perform the change very quickly in response to an image capturing algorithm. So I don't need any waveforms or buffering.
In this forum post http://forums.ni.com/ni/board/message?board.id=231&message.id=3283&query.id=18094 you talk about an AOOnePoint example, but I get an error that the NI-DAQ driver does not support my device.
I may need to use NI-DAQmx, but how? I have a working sample, but it seems a bit slow and certainly overkill of this simple application:
// Link with \DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib
#include "NIDAQmx.h"
void SetVoltage( double voltage )
    DAQmxErrChk (DAQmxCreateTask("",&taskHandleAnalog));
  DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandleAnalog,sChannel,"",m_MinVoltage,m_MaxVoltage,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleAnalog,"",Freq,DAQmx_Val_Rising,DAQmx_Val_ContSamps,NUMBER_OF_AO_SAAMPLES));
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandleAnalog,NUMBER_OF_AO_SAAMPLES,0,1.0,DAQmx_Val_GroupByChannel,data,&written,NULL));
DAQmxErrChk (DAQmxStartTask(taskHandleAnalog));

Sorry about this multi posting, I don't know how to delete it

Similar Messages

  • NI-DAQmx VisualStud​io C++ 6 Single point analog output

    Specs: NI-DAQmx 7, VisualStudio C++ 6.0,  PCI-6722,8channel AO
    We have a very simple application: set a voltage (actually 6 channels) and keep it until we want it changed again, perform the change very quickly in response to an image capturing algorithm. So I don't need any waveforms or buffering.
    In this forum post http://forums.ni.com/ni/board/message?board.id=231​&message.id=3283&query.id=18094 you talk about an AOOnePoint example, but I get an error that the NI-DAQ driver does not support my device.
    I may need to use NI-DAQmx, but how? I would like to use something like AO_VWrite(,,), maybe for 6 channels in one call. But I can't find it in NI-DAQmx. It seems I need to setup buffers and frequencies. I have a working sample, but it seems a slow and certainly overkill of this simple application:
    // Link with \DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib
    #include "NIDAQmx.h"
    double[2] data;
    int taskHandleAnalog;
    int written;
    void Init()
        DAQmxErrChk (DAQmxCreateTask("",&taskHandleAnalog));
        DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandleAnalog,"Device and Channel Info","",0,10,DAQmx_Val_Volts,NULL));
        DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleAnalog,"",1000,DA​Qmx_Val_Rising,DAQmx_Val_ContSamps,NUMBER_OF_AO_SA​AMPLES));
        DAQmxErrChk (DAQmxWriteAnalogF64(taskHandleAnalog,NUMBER_OF_AO​_SAAMPLES,0,1.0,DAQmx_Val_GroupByChannel,data,&wri​tten,NULL));
        DAQmxErrChk (DAQmxStartTask(taskHandleAnalog));
    void SetVoltage( double voltage )
        data[0] = voltage;
        data[1] = voltage;
        DAQmxStopTask(taskHandleAnalog);
        DAQmxErrChk (DAQmxWriteAnalogF64(taskHandleAnalog,NUMBER_OF_AO​_SAAMPLES,true,10.0,DAQmx_Val_GroupByChannel,data,​&written,NULL));

    Hi,
    It looks like you simply wants to output voltages on the analog output channels, but only wants one update at a time with no waveforms or buffering in DAQmx.
    As I'm sure you know there are really just 3 types of measurements.  Single Point, Finite, and Continuous.  Since you want a single value at a time it's just a Single Point operation.
    You can find DAQmx examples for single point operations in this path:
    C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Analog Out\Generate Voltage\Volt Update
    Simply place the DAQmx Write Code within a loop and you will be updating one value at a time, but multiple times when "we want it changed again".
    Dennis Morini
    Field Sales Engineer
    National Instruments Denmark
    http://www.ni.com/ask

  • Single shot analog output: How to pulse this. Probably easy, I'm at a loss.

    Hello.
    I have a piece of machinery that my system is connected to.  Every time it reaches a proximity sensor (It's a reciprocating unit), I need to do a single pulse of 5v out of my analog output.  It has to be fast, it has to stop until the sensor is reached again, and it can't stay 'on' for long.
    I've attached my VI.  I'm using a voltage input via DAQ assistant, routed through some logic to produce a 'true' boolean every time that sensor is reached, and that boolean is connected to a case structure with voltage out tasks created in DAQmx.
    My problem is that the machine won't reverse while the case is still true and there's still the 5v being called by the true case on the case structure.  It has to pulse, then stop, then be allowed to come back when the proximity sensor is reached again.  As it is now, the machine reaches the prox and then the whole system stops, as the 'true' condition on the case structure, and subsequent voltage output, remain high.
    I've attached the VI and heirarchy as well.
    I've tried a few different things here, as well as just using a DAQ assistant with N samples, but that would just retrigger when the loop repeats anyway.
    I'd love to sit and bang my head against this til I get it, but I'm under a time constraint.  Help!
    Still confused after 8 years.
    Solved!
    Go to Solution.
    Attachments:
    using create channel.vi ‏94 KB
    logicsub.vi ‏32 KB

    Ralph, without knowing the exact DAQ card that you are using, it is difficult to give you the best solution. If you want to continue with the solution that you currently have, try adding a shift register to the outer while loop to track the previous value of the boolean. In this way, we can keep multiple values that are above the threshold from causing multiple pulses. Next add a time delay after the DAQmx Write, then add another DAQmx Write to set the output back to your low value. Remove all code from your "false" case. See attached VIs. Please let us know what model of DAQ card you have as we may be able to do something clever like a retriggerable pulse train if your card can support it.
    Charles Chickering
    Charles Chickering
    Architecture is art with rules.
    ...and the rules are more like guidelines
    Attachments:
    using create channel.vi ‏98 KB
    logicsub.vi ‏29 KB

  • How do I configure 128 channels of DIO and 128 channels of Analog output with the availabili​ty of 3 pci slots

    I have only 3 slots of PCI or 4 slots of ISA bus, I want to configure with the minimum possible modules to attain 128 channels of DIO and 128 channels of analog output. This is inturn fed to the PCM (Pulse code Modulator). The cards will be placed in industrial PC.

    Associate Engineer-Marketing,
    Using just those 3 PCI slots you're not going to be able to get the 128 analog output channels. You will probably want to go either the MXI-3 (PCI bus extender) to a PXI chassis or E Series DAQ card to a SCXI chassis for such a high channel count system. Which analog output cards and which digital I/O cards you will want depends on your application. You will have to decide whether you will need static or dynamic analog output as well as whether you need clocked digital I/O or not. I highly recommend contacting our internal sales department at 1-800-433-3488. They are great at helping specify systems.
    Ames
    Applications Engineering
    National Instruments

  • How to synchroniz​e two analog output with USB-6353 sharing a trigger

    I'm have the need to synchronize two analog output on the same device (USB 6353) sharing a trigger signal on PFI0.
    The programming environement is Visual C++ , and the code I wrote is as following:
    DAQmxCreateTask ("", &Ao0TaskHandle);  // is the task handle for the analog output Ao0
    DAQmxCreateVoltageChan((Ao0taskHandle,"Dev1/Ao0","​",-5.0,5.0,DAQmx_Val_Volts,NULL);
    DAQmxCfgSampClkTiming(Ao0taskHandle,5000.0,DAQmx_V​al_Rising,DAQmx_Val_ContSamps,1000);
    DAQmxCfgDigEdgeStartTrig(Ao0taskHandle,"/Dev1/PFI0​",DAQmx_Val_Rising);
    DAQmxCreateTask ("", &Ao1TaskHandle);  // is the task handle for the analog output Ao1
    DAQmxCreateVoltageChan((Ao1taskHandle,"Dev1/Ao1","​",-5.0,5.0,DAQmx_Val_Volts,NULL);
    DAQmxCfgSampClkTiming(Ao1taskHandle,5000.0,DAQmx_V​al_Rising,DAQmx_Val_ContSamps,1000);
    DAQmxCfgDigEdgeStartTrig(Ao1taskHandle,"/Dev1/PFI0​",DAQmx_Val_Rising);
    DAQmxWriteAnalgF64(Ao0taskHandle,1000,FALSE,10.0,D​AQmx_Val_GroupByChannel,AOdata,NULL,NULL);  AOdata is a buffer containing a sinwave
    DAQmxWriteAnalgF64(Ao1taskHandle,1000,FALSE,10.0,D​AQmx_Val_GroupByChannel,AOdata,NULL,NULL);
    DAQmxStartTask(Ao0taskHandle);
    DAQmxStartTask(Ao1taskHandle);
    What happen as result of the code is that only the Ao0 channel get the sinwave output , but not the Ao1 . It seems the two channels are not synchronized.
    What is wrong in my code?
    Please any help non referred to a LabView soloution , first because I'm not a LavView programmder and secondly the project impose C++ as the unique environement.
    Thanks
    Enky

    It will depend on what you are programming the NI 5112 device with.
    If you are using LabVIEW, you can use the example program attached below. In it, it will show you how this is done.
    If you are using VB, VC++ or CVI, you can look at one of the NI 5112 shipping examples that are installed on your computer. These are located in the VXIPNP folder. For example, the VC++ example would be located here:
    C:\VXIpnp\WinNT\NISCOPE\Examples\c\MStudioC++\5112​Sync
    These examples will show you how to synchronize the two digitizers.
    Let me know if you have any questions about these examples.
    Brian
    Attachments:
    Multiple_NI_PXI-5112_Synchronization_Demo.llb ‏151 KB

  • How to structure the DMA buffer for PXie 6341 DAQ card for analog output with different frequencies on each channel

    I'm using the MHDDK for analog out/in with the PXIe 6341 DAQ card.
    The examples, e.g. aoex5, show a single Timer  (outTimerHelper::loadUI method), but the example shows DMA data loaded with the same vector size.
    There is a comment in the outTimerHelper:rogramUpdateCount call which implies that different buffer sizes per channel can be used.
       (the comment is: Switching between different buffer sizes will not be used)
    Does anyone know what the format of the DMA buffer should be for data for multiple channels with different frequencies ?
    For example, say we want a0 with a 1Khz Sine wave and a1 with a 1.5Khz sine wave.  What does the DMA buffer look like ?
    With the same frequency for each channel, the data is interleaved, e.g.  (ao0#0, ao1#0; ao0#1, ao1#1, ...), but when the frequencies for each channel is different, what does the buffer look like ?

    Hello Kenstern,
    The data is always interleaved because each card only has a single timing engine for each subsystem.
    For AO you must specify the number of samples that AO will output. You also specify the number of channels. Because there is only one timing engine for AO, each AO will channel will get updated at the same time tick of the update clock. The data will be arranged interleaved exactly as the example shows because each AO channel needs data to output at each tick of the update clock. The data itself can change based on the frequency you want to output.
    kenstern wrote:
    For example, say we want a0 with a 1Khz Sine wave and a1 with a 1.5Khz sine wave.  What does the DMA buffer look like ?
    With the same frequency for each channel, the data is interleaved, e.g.  (ao0#0, ao1#0; ao0#1, ao1#1, ...), but when the frequencies for each channel is different, what does the buffer look like ?
    In your example, you need to come up with an update rate that works for both waveforms (1 KHz and 1.5 KHz sine waves). To get a good representation of a sine wave, you need to update more than 10x as fast as your fastest frequency...I would recommend 100x if possible.
    Update Frequency: 150 KHz
    Channels: 2
    Then you create buffers that include full cycles of each waveform you want to output based on the update frequency. These buffers must also be the same size.
    Buffer 1: Contains data for the 1 KHz sine wave, 300 points, 2 sine wave cycles
    Buffer 2: Contains data for the 1.5 KHz sine wave, 300 points, 3 sine wave cycles
    You then interleave them as before. When the data is run through the ADC, they are outputting different sine waves even though the AO channels are updating at the same rate.

  • Ni-DAQ single-point analog sample latency.

    I am maybe in my own little world here in wanting to do software-triggered analog sampling and wanting to do it fast. Having bought a PCI-6014 which is capable of 4 microsecond analog sampling I found a simple AI_Read took 95usec. I was somewhat disappointed. Much reading of FAQs and other's postings here didn't help. I posted my own question and got little help.
    Well, having spent days working out such problems as how to access hardware under windows I would just like to throw this to the NI world:
    Digital in/out: was 6 usec. now 0.9usec.
    Analog in: was 95usec. Now 19 if a channel/gain change is required. 6 usec if not.
    To the hardware developers - lets have a cheer. The register-level programming is a bit con
    voluted, but that comes with the territory when the triggering, etc, is so flexible.
    To the software developers - boo, hiss. Wake up, get your act together. So far as programming the card is concerned I did exactly as described in the "E-Series register-level programming manual". The no-change-to-gain-channel case just does the last, trigger step.
    Now, imagine what I could charge if I could make the latest nVidia or ATI video card go 10x faster. I suspect those guys know how to write drivers though.

    Hi Michael,
    There's no question that efficiencies can be exploited once we start using RLP. Configuring the hardware is definitely quicker using this approach. However, programming specific applications using RLP begins to be a headache once you leave the realm of the simple application.
    Using the NI-DAQ driver on the other hand gives me a consistent, intuitive interface over almost all of their hardware products. I am also able to pick up LabVIEW, look at some example code and have an application up and running in less than a couple hours without ever programming data acquisition before. NI-DAQ also has an abstraction layer which offers programming benefits but will invariably add some delay to function calls.
    It is also important to note that acquisition times are not lost because of the latency of the configuration calls. You will be able to acquire triggered and continuous data at hardware rates!! The only benefit that is lacking is if you want to start a software call to the card in 6us. But this seems to be a mute point since your software timing is OS dependent anyway. Why push a software call to be 6us when your are not sure when the OS will process your application's code.
    The only time having a quick configuration would be a benefit is if you are constantly reconfiguring in a software loop. But then your are still restrained by OS timing so you will never have true deterministic results unless you go to an RT system.
    The developers of the NI-DAQ driver have had to make many trade-offs when developing such a comprehensive and flexible driver and accommodating every scenario with every user is an impossibility. This particular instance happens to be one of them.
    I would like it to be known though that I have been successful, with the NI-DAQ 7.0 driver, at acquiring continuous pattern input with the PCI-6534 card at 50ns resolutions (20MHz). Obviously, the driver has its benefits!!
    Anyway, I appreciate the chance to discuss this type of situation.
    Ron
    Applications Engineer
    National Instruments

  • Single Point of failure with Administrative Server?

              We are in the process of upgrading from wls 5.1 to 6.1.
              With 5.1 clustering you could run any instance of the cluster and the cluster would
              be up. Further you could bring any of those instances up and down after a failure
              of any node w/o any problem.
              It looks like with 6.1 if you administrative server goes down your cluster is still
              up as long as your managed servers don't go down or get bounced.
              What happens if you need to restart one of your managed servers, while the administrative
              server is out? My guess is you are SOL. Is is true that while the administrative
              server is down you can't restart any of your managed servers?
              If this is the case I think WLS 6.1 clustering took a big step backwards from 5.1
              clustering (fail-over wise at least). With 5.1 if one of your nodes in a cluster
              blew out, you could take as long as you needed to fix it. The other nodes were fully
              functional. Now it looks like if the 'super node' aka administrative server goes
              down, you need to fix it ASAP or you can't relase any new code or restart any servers.
              Am I missing something?
              

              Scott W wrote:
              > We are in the process of upgrading from wls 5.1 to 6.1.
              > With 5.1 clustering you could run any instance of the cluster and the cluster would
              > be up. Further you could bring any of those instances up and down after a failure
              > of any node w/o any problem.
              >
              > It looks like with 6.1 if you administrative server goes down your cluster is still
              > up as long as your managed servers don't go down or get bounced.
              >
              > What happens if you need to restart one of your managed servers, while the administrative
              > server is out? My guess is you are SOL. Is is true that while the administrative
              > server is down you can't restart any of your managed servers?
              >
              Yes.
              But this is solved in 7.0 i.e. Managed Server Independence.
              see http://e-docs.bea.com/wls/docs70//////adminguide/startstop.html#1057374
              Kumar
              > If this is the case I think WLS 6.1 clustering took a big step backwards from 5.1
              > clustering (fail-over wise at least). With 5.1 if one of your nodes in a cluster
              > blew out, you could take as long as you needed to fix it. The other nodes were fully
              > functional. Now it looks like if the 'super node' aka administrative server goes
              > down, you need to fix it ASAP or you can't relase any new code or restart any servers.
              >
              > Am I missing something?
              >
              

  • 24-bit analog output with Audigy Val

    Is it true that the Audigy Value does support 24-bit output only for digital out? Thanks.

    chapas wrote:
    Is it true that the Audigy Value does support 24-bit output only for digital out? Thanks.
    By the
    Comparison chart and
    Audigy 2 Value Specs, not true.
    jiitee

  • Hardware buffered analog output single shot

    Using DAQmx and M-Series hardware i'm trying to fire a single shot analog output buffered waveform.   I need the output hardware timed.  I'm able to output a hardware buffered waveform but can't figure on how to configure it for or stop it after prescribed number of cycle runs.
    Thanks in advance.
    Solved!
    Go to Solution.

    Hi,
    You have a couple of options. You can set your timing to N
    samples and you acquisition will stop when N samples have passed. Or you can
    use a counter to control the clock of the analog output and then the counter
    can be paused whenever you can.  Before
    we go and dig into the specific details of the scheme let me suggest a couple
    excellent reading materials and let me know if they help. M Series Synchronization
    with LabVIEW and NI-DAQmx, Continuous Analog Output
    with Pause Trigger and Programmatic Grounding of Output in DAQmx, NI-DAQmx: Retriggerable
    Analog Output -- LabVIEW and M Series: Analog Trigger
    Source.
    Also don’t forget to take a look at simpler examples like: Cont
    Gen Voltage Wfm-Int Clk-Pause Trigger.vi
    I hope it helps
    Jaime Hoffiz
    National Instruments
    Product Expert
    Digital Multimeters and LCR Meters

  • How can I output several simultaneo​us buffered waveforms with NI-DAQmx

    I am using a PCI 6229 card and NI-DAQmq in LabWindows CVI 7.1. I can not figure out how
    to implement waveform generation in four channels simultaneously. This has to be buffered wavefrom
    generation with internal clock timing.
    Are there any simple examples done without using the daq assistant that I can see to learn how to use the
    NI-DAQmx functions?.
    I need to write a number of periods on four waveforms, while I count digital pulses.
    Many thanks,
    Fundadero.

    Alan,
    Thank you for your help. I did look at that example and played with the number of analog outputs.
    But It was not clear how to modify this example in order to perform buffered analog output
    with updates corresponding to one of the internal clocks. I will output two sinchronous analog waveforms
    and use the other two analog outputs to update their voltage on demand to control y and z positions.
    The two synchronous waveforms, are AO_0 : a voltage staircase, 256 steps increasing from V1 to V2, 2ms duration steps , followed by 256 steps decreasing back from V2 to V1 (controls the x axis position). The second waveform, is a sequence of 256/n smaller staircases, with step durations of n*2ms, spanning a voltage range from 0.0 to 1.0 volts.
    It turns out that I could do this in the traditional NIDAQ but I am struggling to migrate it to the NI-DAQmx platform, and I could not resolve this with the example that you suggested.
    Do you have any more suggestions after I described what I am trying to do?
    I will very much appreciate it.
    Many thanks
    Fundadero

  • Single-point calibration with thermocouples in SignalExpress?

    I have a USB-6251 DAQ that I'm using with SignalExpress to measure some J-type thermocouples.  I'm looking to calibrate them, but it appears that I have to do a multi-point (>2 points) calibration.
    Since the range that I care about is relatively close to 0C and I'm not too worried about a super-precise calibration, I'd just like to do a simple single-point calibration in an ice bath to remove the offset error.  Is this possible?  When I use the calibrate wizard in SignalExpress, it requires at least two points.
    Furthermore, it appears that it won't extrapolate beyond those two points, so even if I just use an ice bath and a bath of water at room temperature (taking the calibration value from another digital thermometer that has been calibrated), it will clip the values to that range.  Very unhelpful.  Can I get around this?
    Thanks,
    Josh

    Duplicate post !

  • Setting sample rate for sinus analog output

    Hello,
    I've been trying to do something very simple : using an analog output of the card PCI 6221 to produce a sinus curve of frequency 50 Hz. For this I used a Vi to create a sinus curve and the different DAQmx VIs. But I have difficulties understanding the principle of virtual channel and I think I'm doing a mistake setting the sample rate and samples number : one time for the sinus vi, second time for "DAQmx - Timing". Should I use the same values for both of these VIs ?
    On my oscilloscope, with frequency=50Hz and sample rate=1kHz, I get a null signal. Then depending on both values, I get differently rated signals. For example with f=1Hz and sr=10kHz, a sinus of frequency 0,7 Hz.
    Solved!
    Go to Solution.
    Attachments:
    Sinus analog output.vi ‏32 KB

    Yes, thanks for your advice. I used the structure given in the example and now it's working fine. I'm still not sure what I did wrong though.
    I would have a second question now (should I create a new topic?):
    I put a continuous sine wave on the analog output. As soon as this is running, (or maybe after a short delay) I want to measure a limited amount of samples on my analog input. How can I be sure, it's not going to start measuring before the output is properly set ?
    I don't think a trigger would solve the problem since I'm going to vary the output Amplitude.

  • Error 10403:AO Buffer Config (i just want to command an analog output)

    just wanna command an analog output with a little program using intermediate vi/but when i execute it an error 10403 appears/need sone to help me

    What type of DAQ device do you have? You can check the KB below about getting this error on certain boards.
    http://digital.ni.com/public.nsf/websearch/6ED30C2CBB5FF447862562C10056D61B?OpenDocument
    You might also try the simple example that ships with LabVIEW. Write N Updates.vi
    Hope this helps.

  • Use soundcard for analog output

    Is it possible to use soundcard for analog output with LabView6?

    nicke wrote:
    > Is it possible to use soundcard for analog output with LabView6?
    Have a look in the examples under Hardware Input and Output|Sound (LV6.1)
    Dunno where it is under 6i, but the files are there.
    Impressed the crap out of some Fortran hackers by showing them how
    easy I could turn my laptop into a spectrum analyser.
    Remove "spamkill." when replying to this message

Maybe you are looking for