Control analog output based on analog input

Dear forumers,
I am pretty new to the labview programming so excuse me if this was posted before.
I use: Labview 8.5 + PCI 6229
I want to create a real time feedback: to control analog output based on analog input. The task is very simple - if the ai1 (analog input 1) voltage is larger than a constant, then decrease the voltage of the ao1 (analog output 1) by a constant. Otherwise increase the voltage of ao1 by the same constant.
All should work for 10 seconds.
I have tried to implement this using 2 daq asistants and various methods. The problem is that I get the whole signal recorded from the ai1 ( 10 seconds) and then modified and released to the output (another 10 seconds). The execution takes 20 seconds instead of 10 and it is not realtime at all.
Is it a must to make vi in "run continuous" mode to make it work ?
Please help :}.
I am attaching 2 examples.
1. Main idea what I am trying to accomplish
2. Very simple example that still does not work in real time simultaneously.
Attachments:
example-main.vi ‏180 KB
example-simple.vi ‏147 KB

nooto wrote:
Thank you for your suggestion.
I understand the simple arithmetic you are talking about. However I do not understand why it takes 20 seconds instead of 10 to complete the task. In other way to say - why it reads the whole input first (10 seconds) then write the output ( 10 seconds).
Why doesn't ir read and write simultaneously?
If I use Elapsed Time function - what feedback response time can I expect ? Is it good to use Elapsed Time if i need fast response time? In my application i would I need about 1 milisecond response time. Currently in the example the rate is 50 Hz, later I would like to change the rate to 1000.
You simply don't understand the underlying paradigm of LabVIEW -
dataflow. You have a dependency between the first DAQ Assistant and the
second. The second simply will not start until the first finishes. There
is no way around that given your condition that the output depends on
what you read.
If you want 1 millisecond response time then you will have to swithc to a real-time OS. Windows does not have that kind of resolution and there is way to much jitter.

Similar Messages

  • Controlling report output based on current user

    Hi all,
    I am building a small app with APEX for a sales team.
    We have the site and app hosted by another company.
    I have built a report showing sales summary for the company. The problem is that the report is showing all sales for all sales people.
    What I want is for the report to show data based on the user that is logged in, so that the user only sees his items.
    In fact, this would be a useful thing to learn for me, because I could use this functionality on several other pager, so this will be a good example for other situations.
    So far I have:
    I have a database table that keeps track of the sales reps.
    Each sales rep in that table is assigned a unique EMP_id, which is an autonumber column of that table, and is also the primary key.
    The table also contains a column named: "User login Name" which is their login ID (the one they use to log into the application.
    Possible solution (I think):
    when user logs into APEX, retrieve their EMP_id from the EMP table based on their login name,
    Hold the EMP_id in a variable for the duration of the session,
    pass the variable to the SQL query for the report in the where clause.
    Is this a good solution? or is there a better way to do this?
    Can anyone advise on how to get this done please,
    Thank you.

    Hi,
    Sorry - I guess I should have said where to create the function!
    You can keep those steps or keep with your own method as both should return the value you need. I usually store the result of that value in G_USER - similar to Tyson's method - when the user logs in and then use :G_USER wherever I want to use it in filters etc. However, if I need to create SQL Views, I have to use the GETCURRENTUSERID() function instead.
    Andy
    ps - I used MIN() in the function to ensure that I only get one value returned. The method SELECT .... INTO .... only allows us to set a variable to one value and, sometimes, more than one value is returned by the SELECT statement and this would generate an error. Of course, there should be just the one value that matches the current user, but I always assume the worst! The statementS:
    SELECT MIN(EMP_ID) into user_id FROM S_USERS WHERE UPPER(LOGIN_ID) = UPPER(v('APP_USER'));
    user_id := CASE WHEN user_id IS NULL THEN 9999999999 ELSE user_id END;could also be written as:
    SELECT EMP_ID into user_id FROM S_USERS WHERE UPPER(LOGIN_ID) = UPPER(v('APP_USER')) AND ROWNUM = 1;
    user_id := CASE WHEN user_id IS NULL THEN 9999999999 ELSE user_id END;or
    SELECT NVL(MIN(EMP_ID), 9999999999) into user_id FROM S_USERS WHERE UPPER(LOGIN_ID) = UPPER(v('APP_USER'));

  • Analog output digital start trigger c api

    Hi, I am attempting to start analog output based off a digital trigger (either PFIO, or a PXI line)  I can do this easy in LabVIEW.  However with the C API (through Python wrappers), the problem isthat when I call DAQmxBaseWriteAnalogF64, the write will always timeout as the acquisition has not been triggered.   However, I cannot call this after the trigger occurs, as obviously that will be too late.
    I cannot find any C API examples where analog output is triggered off a digital trigger.  I can find them for analog input, but that is fundamentally different as you can performan read anytime after the trigger occurs.
    Python code as follows (the functions are equivalent ot C API, though you do not need ot pass the task handle as it maintained as part of the Task object)
    # create analog output task
    analog_output = Task()
    analog_output.CreateAOVoltageChan("Dev1/ao0","",-10.0,10.0, DAQmx_Val_Volts, None)
    analog_output.CfgSampClkTiming("",outputRate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, numSamples)
    analog_output.CfgDigEdgeStartTrig("/Dev1/PFI0", DAQmx_Val_Rising)
    analog_output.StartTask()
    analog_output.WriteAnalogF64(numSampsPerChan=numSamples, autoStart=False,timeout=1.0, dataLayout=DAQmx_Val_GroupByChannel, writeArray=data, reserved=None, sampsPerChanWritten=byref(samplesWritten))
    print("Analog output: Wrote %d samples" % samplesWritten.value)
    # create digital trigger
    dig_out = Task()
    dig_out.CreateDOChan("Dev1/port0", "", DAQmx_Val_ChanForAllLines)
    # create digital trigger function
    highSamples = 1000
    numpts = 3 * highSamples
    doData = np.zeros((numpts,), dtype=np.uint32)
    doData[highSamples:2*highSamples] = 2**32 - 1
    # send digital trigger
    doSamplesWritten = c_int32()
    dig_out.WriteDigitalU32(numSampsPerChan=numpts, autoStart=True, timeout=1.0, dataLayout=DAQmx_Val_GroupByChannel, writeArray=doData, reserved=None, sampsPerChanWritten=byref(doSamplesWritten))
    print("Digital output: Wrote %d samples" % doSamplesWritten.value)
     

    Hi PatrickR,
    You can review some of the text based NI DAQmx (ANSI C) code examples on generating an analog output using a digital start trigger. If you included/checked text-based support dusing your NI DAQmx driver installation, you can navigate to Windows Start>All Programs>National Instruments>NI DAQ>Teaxt-Based Code Support>ANSI C Examples>Analog Out>Generate Voltage>Mult Volt Updates-Int Clk-Dig Start. If you have any questions/concerns regarding the NI hardware.

  • Generating sawtooth in Analog Output

    Dear Mr.
    I am programinning in labview and I would like to generate from my DaqPad 6020E sawtooth signal. I have a problem becouse I can generate virtually but not in Analog Output. Please verify my program which is attached to the mail. If you can please write your simple program which generate sawtooth signal in analog Output. I was checked programs (examles) in ni.com but i can generate one. I know that AO works becouse i checked it sending sin (as trigonomethry sig) and there was no problem.
    Best regards
    Tomasz Olszewski
    PS. If You speak Polish we can talk in Polish language.
    Attachments:
    ct03.vi ‏124 KB

    Have you verified output in the Test Panels of the Measurement & Automation Explorer (MAX)? Simply wire analog output 0 to analog input 0. In the test panels, generate a sine wave on the analog output pin. If you can read in the signal on the Analog Input tab, then the board is operational and something is wrong in the code. Check the code to make sure you are referencing the correct device # and channels. Have a great day!

  • How to trigger a TTL output with an analog input

    Hello,
    I have an apparatus for measuring the flame speed of various hydrocarbon/air mixtures.  The chamber uses central ignition as the means for igniting the mixture.  My goal is to film the ignition process with a high speed Phantom video camera.  I control the ignition with an analog output signal from a SCC-68 DAQ.  I would like to trigger the camera with the same signal that triggers the ignition sequence.  The camera is triggered with one TTL pulse so ideally I would connect the output analog voltage signal to an input analog voltage port that would be used to trigger a counter output that generates one pulse.
    I have a sample VI that triggers a digital pulse each time the analog trigger level is met and it works for what I am trying to do but I do not understand how the two channels are connected. I also can't figure out how to make the VI end after just one pulse.  In the VI the digital counter is supposedly triggered using the /Dev1/ai/StartTrigger slot on the DAQ but nothing is connected to this slot.
    I need to first figure out how to make the output_pulses_on_sine_wave.vi terminate after a single pulse is generated. Then I can try to incorporate it into the VI that I use to control the ignition and measure the temperature and pressure once the mixture is ignited.
    John
    Attachments:
    output_pulses_on_sine_wave.vi ‏27 KB

    I am using the USB-6259, sorry for the confusion.  I would be nice if I could trigger with an analog signal to the ignition system but it is controlled with a high voltage relay that operates when 12 volts are supplied to it. It really isn't a trigger as much as powering on the high voltage relay. To control it, I have a 12 V supply line that is switched closed using a SCC-RLY module.  Could I somehow connect the 12 V supply to one of the buses and use a digital trigger to supply the 12V on command to the high voltage relay?
    Thanks for the quick response. 

  • When using the analog inputs and analog outputs of the PCI-7344, what is the conversion between the voltage entering the card to counts? Similarly, what is the conversion between counts to voltage at the output of the card?

    I am using the PCI-7344 to control my system. The analog inputs are connected to the output of my system while the analog outputs serve as feedback to the system. The system is a servo. I want to know what is the conversion between the voltage read at the input, to card counts, and finally to the voltage output to the system.

    Carole,
    If you are trying to do analog feedback with a servo motor, Chapter 14 of the manual talks about how to set up the torque feedback. Also linked below is a LabVIEW example of analog feedback.
    Chapter 14
    NI-Motion User Manual
    Automatic Analog Feedback with FlexMotion example
    A. Talley
    National Instruments

  • How to get signal from analog input and send it to analog output (real-time​)

    Hi everyone,
    I am doing simple task in Visual C++ and I am using PCI-6221(37 pin).
    Basically, I want to send same signal from 'analog input' to 'analog output'
    at the same time (almost), to make it real-time application.
    Can someone please provide me sample program. 
    I would appreciate if you could provide me with the good tutorial which explains
    step by step everything about programing NI-DAQmx for C/C++.
    Best Regards,
    Khassan
    Solved!
    Go to Solution.

    This is my code in C++, you can optimize it if it looks too messy. This code reads signal from analog input and outputs it through analog output. 
    To make this code work additional  include directories and library directories must be added from NI.
    I hope it helps someone.
    #include <stdio.h>
    #include <conio.h>
    #include "NIDAQmx.h"
    #include <math.h>
    #define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
    int main(int argc, char *argv[])
    int32 error=0;
    TaskHandle taskHandleRead=0,taskHandleWrite=0;
    int32 read=0;
    float64 dataRead[1000];
    char errBuffRead[2048]={'\0'};
    char errBuffWrite[2048]={'\0'};
    bool32 done=0;
    int32 written;
    DAQmxErrChk (DAQmxCreateTask("",&taskHandleRead));
    DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandleRead,"Dev1/ai0​","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Vo​lts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleRead,"",100.0,DAQ​mx_Val_Rising,DAQmx_Val_ContSamps,0));
    DAQmxErrChk (DAQmxCreateTask("",&taskHandleWrite));
    DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandleWrite,"Dev1/ao​0","",-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleWrite,"ai/SampleC​lock",100.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1​000));
    DAQmxErrChk (DAQmxStartTask(taskHandleRead));
    DAQmxErrChk (DAQmxStartTask(taskHandleWrite));
    while( !done && !_kbhit() )
    DAQmxErrChk (DAQmxReadAnalogF64(taskHandleRead,1,10,DAQmx_Val_​GroupByScanNumber,dataRead,1000,&read,NULL));
    DAQmxErrChk (DAQmxWriteAnalogF64(taskHandleWrite,read,0,10.0,D​AQmx_Val_GroupByChannel,dataRead,&written,NULL));
    _getch();
    Error:
    if( DAQmxFailed(error) )
    DAQmxGetExtendedErrorInfo(errBuffRead,2048);
    DAQmxGetExtendedErrorInfo(errBuffWrite,2048);
    if( taskHandleRead!=0 )
    DAQmxStopTask(taskHandleRead);
    DAQmxClearTask(taskHandleRead);
    if( taskHandleWrite!=0 )
    DAQmxStopTask(taskHandleWrite);
    DAQmxClearTask(taskHandleWrite);
    if( DAQmxFailed(error) ){
    printf("DAQmx Error: %s\n",errBuffRead);
    printf("DAQmx Error: %s\n",errBuffWrite);
    printf("End of program, press Enter key to quit\n");
    getchar();
    return 0;

  • Synchronizing Analog Output to Counter Input

    Hi!
    I'm really new to LabView. Pls help!
    I'm trying to obtain a set of stimulus signal and response signal from my motor for system identification.
    The stimulus signal will be generated by the Ao0 channel and response signal (quad encoder linear position) will be read into counter0.
    How can I synchronize the stimulus signal and response signal so that the sampling (n samples) for both stimulus and response starts at the same time?
    e.g.
    t=0, stimulus sample 1, response sample 1
    t=1, stimulus sample 2, response sample 2
    t=2000, stimulus sample 2000, response sample 2000 
    I've attached my VI.
    Thanks. 
    Regards,
    Student
    Attachments:
    Acquiring Linear Encoder Samples.vi ‏44 KB

    Hello Htp,
    What do you mean by synchronize? Do you want to start the analog and counter outputs at the same time? If you do, you should have both outputs start with the same digital trigger. For the analog output, you can set up the triggering in the DAQ Assistant in the Task Triggering tab. For the counter output, look at Gen Dig Pulse Train-Continuous-Dig Start.vi found in the Example Finder (Help Menu>>Find Examples). Browse Hardware Input and Output>>DAQmx>>Generating Digital Pulses. Please let me know if you have any questions. Have a great day!
    Sincerely,
    Marni S.

  • 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 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

  • How can i synchronize analog output and analog input timings to generate and measure voltage at the same time.

    how can i synchronize analog output and analog input timings to generate and measure voltage at the same time.

    Read this Tutorial
    http://zone.ni.com/devzone/cda/tut/p/id/3615#toc3
    And also refer to this link where You have repeated this question.
    PS: Please stick to one thread. That way, its easier to keep track of your query and answers

  • Processing counter input into an analog output

    Greetings to all --
    I've set up a PCI6070E card to do digital input through its "counter 0" channel and output through its "AO 0" channel.
    I'm brand-new to Labview, however, and having trouble figuring out how to design my program.  In short, this is what I want to do:
    1. Count the number of pulses, let's call it P, that arrive at the counter in a given time increment.  (Ideally, this time will be adjustable from 1 microsec to 1 sec.  In reality, I may have to settle for some number of milliseconds or more, as Labview doesn't seem to like to do loops at more than 1khz.  But that's an issue for another day.)
    2. Perfrom a mathematical operation to turn P number of counts into some number N between -10 and 10
    3. Set the analog output to read N volts
    4. Reset counter to zero and start over at (1.) again.
    I can make labview count pulses in, and I can send voltage signals out, and I can use the front panel to get the inputs I need from the user for the mathematical operation,  However, I'm having trouble with counting how mant pulses hit in a given time increment, and then resetting my digital counter to zero.
    Can anyone point me at the right function names or help files, or suggest a rough program flow?  I appreciate it.
    Chad
    [email protected]

    Chad,
    The only way you can perform this type of operation with your device is in software.  See the knowledge base entries below for more details. 
    HW resetting Counter on an STC Device:
    http://digital.ni.com/public.nsf/websearch/55AF6CA​DD87F6F7786256B89005B8AFD?OpenDocument
    How To Reset in Software:
    http://ae.natinst.com/operations/ae/public.nsf/web​/searchinternal/65e3dbc715998c3286256e900075b7f8?O​...
    Regards,
    L. Allen

  • Usb 6009 continuous analog output

    Hi
    I'm pretty new to Labview, so you may have to bear with me. I have a USB-6009 and I want to generate a continuos analog output voltage. I've got the example you have posted 'Gen Mult Volt Updates-SW Timed_LV7.1 (0 to 4).vi' working and it outputs a continuous sine wave.
    In a similar manner I need to generate:
    1. Ramp up voltage (and ramp down voltage): starting with a continuos constant voltage, which after a period of time linearly increases to another constant voltage, and which allows me to specify the 3 time intervals and the rate of increase.
    2. Pulsations: whereby I can specify the amplitude and time interval of each pulsation
    This is so that I can control voltage to a valve which regulates my pipe flow. In the example I have (one stated above), I do not understand specifically:
    i. Why I need both a 'Software Loop Time (ms)' as well as 'Timeout'
    ii. The 'Sinusoidal Pattern' input which seems to generate data for a sine wave- I can't get a description of that and there are no similar VIs for other waveforms; and what is the function of the two numbers it has?
    iv. How do I change amplitude and time period for the wave?
    iii. What does 'Index Array' do?
    thank you

    Hi there,
    I'm guessing the VI you are using is the one from this KB:
    http://digital.ni.com/public.nsf/allkb/6F2C2B49A89D685C8625711D007BDD64
    i. The software timed loop control is to control the rate at which you change the voltage output.  The timeout on the DAQmx Write VI is the maximum time in seconds the VI will wait to output a sample (eg. if the write buffer is full, the Write VI will wait for it to become available for 'timeout' seconds before outputting an error).
    ii. The sine pattern is just an array constant of doubles that make up the sine wave voltage values, and the for loop adds an offset (of two volts) to every single one of those values. You might want to replace that entire array constant and for loop with a Simulate Signal Express VI (just search for Simulate Sig or look in the Functions >> Input palette) and convert the dynamic data output to an array of doubles.  You can configure the type of waveform, amplitude, and time period from that express VI as well.
    iii.  Refer to previous answer.
    iv.  Index array returns an element of an array based on the index input.  You can turn on the context help and move your mouse over functions to get more help on them.
    I hope that helps!
    Way S.
    NI UK Applications Engineer

  • 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

  • Questions regarding analog output

    I want to build a LabVIEW file to generate analog output signal. Basically, if a variable (say, temperature) is between 250 and 500, voltage will be applied to a valve and open the valve. The attached is my first try using LabVIEW. But there is an error:
    Error -200077 occurred at Property Node DAQmx Timing (arg 1) in DAQmx Timing (Sample Clock).vi:1->pulse based valve control.vi
    Possible reason(s): Requested value is not a supported value for this property.
    Property: SampTimingType
    You Have Requested: Sample Clock
    You Can Select: On Demand
    Task Name: _unnamedTask<2>
    The DAQ device I used is USB-6009. I tried different sample modes, but nothing worked. How can I fix this problem?
    Also, for the next step, I will use AI (temperature) and AO (voltage) in the same LabVIEW file. Here are some other questions.
    1. Is it necessary to set sample rates for the AI and AO channels?
    2. Is it necessary to synchronize the sample clocks for AI and AO channels?
    Thanks,
    Bei

    Hi Qifu,
    If you are new to LabVIEW and DAQmx, I would suggest reading
    this tutorial. The shipping examples are also a wealth of knowledge.  (Help >> Find Examples >>
    Hardware Input and Output >> DAQmx >> Synchronization >>
    Multi-
    Function)
    You did not specify how fast you will be acquiring
    data.  I will assume that you will be
    acquiring and generating at a slow rate since you are measuring
    temperature.  Yes, you should set the
    sampling rate and sample clocks the same for both the AI and AO.  I would refer to the example (Multi-Function-Synch
    AI-AO) in the example finder on how to accomplish this.
    Respectfully,
    Rob F
    Test Engineer
    Condition Measurements
    National Instruments

Maybe you are looking for

  • How to setup multiple content servers on one host

    Hi, We have setup 2 ECC 6.0 systems on one host ECC DEV and ECC QAS. Windows 2003 Server 64bit We want to setup 2 standalone Content Servers (MaxDB). One contentserver pointing to ECC DEV and one to ECC QAS. Containing its own content. Problem is tha

  • Error 106 when Installing Photoshop 7?

    Hello, I don't know much about computers and my english is not perfect, so please bear with me! I just bought a netbook with Windows 7 Starter OS, and since my new netbook doesn't have a CD drive, and I was trying to install Photoshop 7 on here throu

  • M92p SFF: Possible to add a 2.5" SSD boot drive in the 3.5" external card reader bay?

    I recently bought a M92p Small Form Factor with model number 2988-A5U.  Is it possible to to add an additional 2.5" SSD as a boot drive while retaining the 3.5" 1TB SATA as the data drive? I have searched many posts and datasheets on the internet but

  • Error in price change

    Hello, I keep getting this error when tying to change material price using MR21: "Account 7201013 requires an assignment to a CO object." Help is appreciated. Regards

  • Mistakenly erased iphoto how to recover

    I have mistakenly erased the iphoto even from thrash. How to recover the iphoto application?