Loop in combination with Analog output

Hi
I have modified the script thats translate a value in to a static analog output voltage. The value comes from another online running application. The analog output value must remain static until a new value arise. I'm using VB6 and DAQmx 8.5 on a XP computer. The DA converter is NI USB-6211. I have tried to play around with the Start/Stop and clear commands but my script still makes the program highly unstabile.
So am I using the commands correctly?. And have I setup the write commands correctly too. Can anyone allso explain how to use the command Doevent correctly
  Dim taskHandle As Long
    Dim clockEdge As Long
    Dim sampsPerCycle As Double
    Dim desiredSampleClockRate As Double
    Dim resultingFrequency As Double
    Dim amplitude As Double
    Dim numSampsPerChannel As Long
    Dim numChannels As Long
    Dim errorCode As Long
    Dim errorString As String
    Dim sampsPerChanWritten As Long
    Dim XICVolt As Double
 '  Create the DAQmx task.
    Call DAQmxCreateTask("", taskHandle)
    '  Add an analog output channel to the task and check to see whether there is only ONE task.
    Call DAQmxCreateAOVoltageChan(taskHandle, "Dev2/ao0", "aoChannel", "-10", "10", DAQmx_Val_VoltageUnits2_Volts, "")
    Call DAQmxGetTaskNumChans(taskHandle, numChannels)
    If numChannels > 1 Then
        errorCode = -1
        errorString = "Please specify only one channel."
        Err.Raise errorCode, , errorString
    End If
Data_is_recorded:
    If Actualcycles = expectedcycles Then
    GoTo end_script
    Else
    If Actualcycles > lastcycles Then
    DoEvents
     Call DataPoint.GetDataPoint(thenumberOfDataPoint, theXvalue, theYvalue)
        XICVolt = (theYvalue / 10000000#)
    '  Write to the desired channel(s).
    Call DAQmxWriteAnalogF64(taskHandle, 1, True, 10#, _
        DAQmx_Val_GroupByScanNumber, XICVolt, sampsPerChanWritten, ByVal 0&
    Else
     lastcycles = theWF.GetActualNumberOfCycles(sampleIndex, 0)
     End If
    GoTo Data_is_recorded
end_script:
End If
call DAQmx.stopTask(Taskhandle)
call DAQmx.clearTask(taskhandle)
Best regards
Peter

David Weber wrote:
thanks lot for all the great feedback. That's really helpful. I think I'll go for the NO_MERGE hint. A first test with this looks good.Keep in mind, only undocumented hint MATERIALIZE along with subquery factoring clause WITH (for which this hint was created) will work in real queries:
SQL> select my_id as id
  2       , my_id as same_id
  3  from (select /*+ NO_MERGE */ xxx_test_pkg.get_id(1) as my_id from dual),emp where rownum < 6;
        ID    SAME_ID
        20         20
        21         21
        21         21
        21         21
        21         21
SQL> select my_id as id
  2       , my_id as same_id
  3  from (select xxx_test_pkg.get_id(1) as my_id from dual where rownum=1),emp where rownum < 6;
        ID    SAME_ID
        22         22
        23         23
        23         23
        23         23
        23         23
SQL> select my_id as id
  2       , my_id as same_id
  3  from (select /*+ MATERIALIZE */ xxx_test_pkg.get_id(1) as my_id from dual),emp where rownum < 6;
        ID    SAME_ID
        24         25
        26         27
        28         29
        30         31
        32         33
SQL> with t as (select /*+ MATERIALIZE */ xxx_test_pkg.get_id(1) as my_id from dual)
  2  select my_id as id
  3       , my_id as same_id
  4  from t,emp where rownum < 6;
        ID    SAME_ID
        34         34
        34         34
        34         34
        34         34
        34         34
SQL> SY.

Similar Messages

  • What is the best way to Sync Digital Output(TTL) with Analog Output?

    I am trying to generate Analog waveform that synchronize the rising edge of a digital signal(TTL). The ttl will be used as trigger for camera. The board I have is USB-6343X. In my draft,  I used a clock as ttl so I can tune frequency easily. Could any one tell me what's the best way to accomplish such task? My draft seems working, but I hope there's more neat way. Thanks in advance for any help!
    Kind regards,
    Eric

    Hi Econg,
    You should be able to trigger your TTL output with the analog output by using the ao/StartTrigger as your trigger source on the counter task. You wouldn't have to have the extra Get Full Terminal Name.vi in your analog output task.
    Here is an example using your modified code. You will have to change the cDAQ1/ao/StartTigger to *your device*/ao/StartTrigger, but it should then trigger the counter output at the exact time when the analog output starts.

  • Buffered analog output puts out additional sample on aborting or stopping task

    I'm using DAQmx and LV 8.2
    I'm doing a buffered analog output operation where the sample clock is driven by pulses from ctr0 on the same device (PXI-6070E).  When I end the analog output task, either with the DAQmx stop task or DAQmx control task (abort option selected), the AO puts out one additional point from the buffer.  (I have checked by setting breakpoints and stepping through the code that the additional point is definitely generated when the analog ouput task is aborted)
    I need the output to remain where it was before the stop task command is issued.  How do I fix this?
    Thanks,
    Marc

    I'm watching to see if there hasn't been a sample output in a certain length of time, then terminating the task if there hasn't been.  Specifically, I have ctr0 outputting pulses to drive the task based on input from the AnalogComparisonEvent terminal.  I'm using a counter on a different PXI device to count the number of pulses and monitoring this count to determine if another sample has been output.  I'm outputting the ctr0 pulse to PFI3 as well, and I'm monitoring both the ctr0 output (which drives the ao clock) and the analog output itself on an oscilloscope.
    Basically I'm sitting in a while loop waiting for the monitoring counter to fail to increment.  Then I terminate the while loop and stop the analog output task.  I can watch the analog output on the oscilloscope while I step through the program.  Immediately before the daqmx control task - abort (or daqmx stop if I don't abort first, or daqmx clear, if I don't abort or stop) vi runs, the analog output remains outputting the last sample.  Immediately after the abort, stop, or clear, the analog output advances one sample in the buffer. 
    During this time, ctr0 does not output another pulse, so the scan clock should not advance.
    Thanks,
    Marc

  • Producer consumer with analog and digital inputs and outputs

    Hi everyone,
    I am working on a control system program for some practical test work. Currently I am working on the data acuisition component of the Labview program. My architecture is produced-consumer loops with a que. My system will have analog inputs, analog outputs, digital inputs and digital outputs. It's not a time critical sytem, but I would like all of the data acquisition to be synchronised. I have attached my program as it is at the moment. I am having trouble getting all of the data into the que since I have two data types. Also, I'm not sure if i've synchronised the four read/write sequences correctly. I would greatly appreciate if somebody could take a look at my program and give me some advice. Thanks in advance.
    Solved!
    Go to Solution.
    Attachments:
    control_v2_DAQ loop.vi ‏46 KB

    Robert, the specific error that I get is:
    Error -200462 occurred at DAQmx Start Task.vi:6
    Possible reason(s):
    Generation cannot be started because the output buffer is empty. 
    Write data before starting a buffered generation. The following actions can empty the buffer: changing the size of the buffer, unreserving a task, setting the Regeneration Mode property, changing the Sample Mode, or configuring retriggering.
    Task Name: Heater testing lab digital outputs
    This error occurs at the 'DAQmx write.vi' function. I just want to sent one sample per second, for each channel. I would like the producer and consumer loops to each run once every second.
    I have attached part of my code with just the data acquisition and writing. Any help would be greatly appreciated.
    Attachments:
    control_v2_ML_simple.vi ‏83 KB

  • 2 analog output channels with different frequencies

    Hi,
    hope that somebody can help me:
    I created two physical tasks, analog output channels.
    I should give signals (triangle signals) to a scanner. The problem ist that I need these triangle signals with two different frequencies.
    I can create the signal with each of the task, but not together. Can I solve this problem somehow?
    Ah, and of course the 2 tasks should start together...
    Thanks for your help!!
    Telly

    You didn't mention the type of device you're using, so I'll assume it's a standard MIO. A typical MIO only has one AO timing engine, so you'll have to create one task for both channels and use a single update rate for the task. You will have to make the output frequencies different by passing different data for both channels.
    For example, let's say your update rate is 1KHz. The data for channel 0 is 1000 data points of a single cycle of a triangle wave. The data for channel 1 is 1000 data point of two cycles of a triangle wave. When you run the task, you will get a 1Hz triangle wave on channel 0 and a 2Hz triangle wave on channel 1.
    Good luck,
    Joe

  • 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

  • PICe-6259 with DasyLAB 9 - How to do Analog Output

    Hi,
    I'm trying to get a small project working in DasyLAB 9.0.2 and I need some serious help.
    I'm working with a PCIe-6259 and NiDAQmx 8 is installed.  I simply want to create a program that uses a slider to adjust the analog output on 4 channels and read the slider value on a meter.  This is a fresh installation of DasyLAB.
    Here's the program that I setup and the errors that I get.
    I select:  Modules -> Input/Output -> NIDAQ -> Analog Output.
    I adjust the properties of the DAC module to include channels 0,1,2,3 and select OK.  (I don't adjust any of the other properties)
    I then select: Modules -> Control -> Slider
    I adjust the properties of the slider to include the same channels as above.
    I then select: Modules -> Display -> Analog Meter
    I adjust the properties of the meter to include the same channes.
    The meters and Analog output are wired in parallel.
    I get the following errors:
    NI-DAQmx: Error Message
    Driver: Task DA00, Version: 0.15
    Possibly Reason:
    -> The module can process the number of "values to be written".
    File: ProcessData_KONTINUIERLICH.H, Line: 39
    When I press OK I get:
    NI-DAQmx: Error Message
    Driver: Task DA00, Version: 0.15
    Possibly Reason:
    -> The driver does not use all NI-DAQmx task channel names. This is not valid, reconfigure the module to use all task channels.
    Note: A NI-DAQmx task for analog / digital / frequency output must not have more than 16 channels. If you need more than 16 channels for the output, you must use more NI-DAQmx tasks.
    File: MODUL_DA.C, Line: 2131
    Any help to point me in the right direction would be greatly appreciated.
    The next part of my program will include acquiring data from the analog channels, but I need to get the AO working first.  I've run into some issues with Analog Input as well, but I thought I should start with AO first.
    Thanks in advance!
    Chris

    Here's what I did using the NI-DAQmx simulation mode:
        - create two tasks
                Analog Output - 4 channels, 1k output rate, 100 samples to write, Continuous
                Analog Input - 4 channels, 1k input rate, 100 samples to read, Continuous
        Save them. Start up or synchronize DASYLab (Under Measurement Boards Settings - NI-DAQmx - Synchronize with... in earlier versions, it's under Hardware Setup)
        - Create Slider. Open Slider properties, click on Options, Synchronize to the AO task that you created. This step is really important - it ensures that the data rate matches what NI-DAQmx is expecting.
        - Connect Slider to NI-DAQmx AO module, configured for 4 channels.
        - Create AI module. Connect to the AI task that you created.
        Press Start. It should run. I can't verify absolute accuracy in simulation mode, but, I received no errors.
        Your first error is probably the result of the timing being wrong - the Slider defaults to the "Driver" timebase. The rest of the errors seem to be a cascade off the first.
        Note - my simulation did not work without the Analog Input. It generated no data. That may be an artifact of the simulator, but, once I put an Analog Input on the worksheet, it ran okay.
        I hope this helps.
    - cj
    Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.

  • Using analog outputs in labview with

    I have recently started using the USB personal measurement device PMD1208-LS from measurement computing with labview. I am having problems with using the analog outputs in labview i keep getting error message 41 "This function can not be used with this board" The outputs are working fine when tested with the supplied software but not when using the Aout vi in labview. has anybody else had problems with this and know how to resolve them? I have the analog inputs all working fine in labview.
    Thanks

    I have used the PMD12208FS and I used this vi to use the analog outputs for it.  I obtained it from Measurment Computing ftp site.  The data value is in mV.  Hope this helps.
    Attachments:
    PMD1208FS_AOut_lv61.vi ‏17 KB

  • How to change the update rate of an Analog output in a loop

    I have to generate a ramp at a decreasing frequency. I use a shift register in a "for" loop to decrease the rate of the analog output. Unfortunately, the loop or the analog output initialisation take a too long time delay..
    How can I solve this problem?
    Any help is greatly appreciated
    Thank you

    Hello;
    I'm attaching an example VI that shows how to change the output rate on the fly.
    Hope this helps.
    Filipe
    Applications Engineer
    National Instruments
    Attachments:
    aochangeonthefly.zip ‏47 KB

  • Hi, iam facing proble in synchronizing 4 ni 4472 cards input with pxi -6052e analog output. please help me out to sort out this problem

    hi, iam facing problem in synchronizing 4 ni 4472 cards input with pxi -6052e analog output. please help me out to sort out this problem

    Hi achyuth,
    Thank you for posting on the National Instruments forum.
    I am not sure what you are trying to do.  Are you trying to input and output at the
    same time?  Are you just trying to
    synchronize all of your inputs?  Do you
    want them to run off the same clock?  If
    you could, give me some more information so I can understand your problem
    better.
    In the meantime, this might help you:
    PXI Timing,
    Triggering, and Synchronization Capabilities of E-Series Multifunction Data
    Acquisition ...
    PXI Timing and Synchronization
    Thank You,
    Nick F.
    Applications Engineer

  • 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 combine the analog input and analog output vi's

    Hi !
    I have a perfectly running triggered analog input acquisition vi. I have a seperate vi for analog output that's running perfectly too. Can someone tell me how to combine these two operations so that I could get a vi that does simulataneous AI and AO without missing triggers. I have tried all the different kinds of configurations suggested by NI support but nothing seems to work. Can someone help ?
    thanks,
    Shiva
    Attachments:
    dac_good.vi ‏77 KB
    adc_good_fw.vi ‏124 KB

    Shiva;
    I'm attaching a good Application Notes that shows how to synchronize multiple DAQ tasks, in Labview.
    Hope this helps.
    Filipe
    Attachments:
    Advanced_Sync_Techniques_for_DAQ.zip ‏166 KB

  • NI board with 4 analog output

    Hello,
    I'm looking for the cheapest national instrument with this specifications:
    Ethernet communication
    1 channel Analog input
    1 Digital input
    4 channel Analog output
    All I found was the Ni sbrio board but the problem that I don't need 80% for its features.
    Thank you for your help

    Hi,
    Before recommending a particular product, it would be beneficial to understand some the requirements you need for the analog inputs, analog outputs, and digital inputs. What signals are you reading and how fast do you need to sample the signals? Also, what is the general application? Are you going to be logging data or providing control?
    Answering the above questions will help us better determine the correct device for your application.
    Tannerite
    National Instruments

  • Combine Analog outputs for higher current drive

    I'm using a cRIO 9263 analog output module.  The current output specification is 1 mA.  If I need 1.2 mA of current, can I use two outputs in parallel?
    SteveA
    CLD
    FPGA/RT/PDA/TP/DSC

    I am not familiar with that device, but, in general when paralleling voltage output devices which were not specifically designed to be paralleled you need to include some ballast resistors. They allow for slight differences in the output voltages of the two (or more) devices and promote current sharing.
    Put one resistor in series with each output. Connect the other ends of the resistors together and connect this to the load. The value of the resistors depends on the amount of current, the voltage difference between the two outputs when given the same digital code, how much voltage drop in the resistors can be allowed, and perhaps other factors such as how fast the output must change.
    I can help with the calculations if you are not familiar with them, but I will need more information about the voltages and loads.
    Lynn

  • Userdefined Type combined with AssociativeArray as Output Parameter

    Hello,
    Does anybody get a workin solution for this combination of Techs?
    "Userdefined Type combined with AssociativeArray as Output Parameter".
    I don't get in my solution.
    I can also post my example, if this is helpfull.
    cheers
    Holger

    Hi Holger,
    PL/SQL Associative Arrays of UDTs is not supported by ODP.NET. There is a bug/enhancement request for this issue which will be addressed in a future release.
    Please take a look at Mark's post in the following thread:
    Re: timestamps with associative arrays
    As a workaround, can you use VARRAY or Nested Table of UDTs?
    -Naveen

Maybe you are looking for