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;

Similar Messages

  • How to get data from pdf file and send contents  of the pdf file to R/3

    Hi, experts,
    Action:
    1. Make a pdf forms (interactive form) with inputfield named “A_inputfield” in the webdynpro application and run the webdynpro application.
    2. In the IE, click the save button in the pdf interactive form and save the pdf to local disk,ex: C disk. Close the IE browser.
    3. Open the pdf interactive form from the local C disk and type "aaa" to the “A_inputfield”.
    4. I want to save the "aaa" to the R/3 system using webdynpro or using other tools . How can I do it?
    First way:
    If I use webdynpro application to save the content of the pdf, I don't find a way mapping or binding the content to a context of a view. So I don't think this way is unadvisable.
    Second way:
    Adding a button "submit" in the pdf forms when create the pdf form. Runing the webdynpro application, save the pdf to local disk,ex: C disk.  Opening the pdf interactive form from the local c disk and typing "aaa" to the “A_inputfield”, click the  "submit" button to save the content. Of course, I need to finish the code for clicking "submit" button. But I don't know how  to write these codes and where to write these codes. Do you give me some advise ?
    Best regards,
    tao

    Hi, Abhimanyu L,
    Thanks a lot for your help. Your answer can give me large developmental.:)
    I find http://help.sap.com/saphelp_erp2005/helpdata/en/67/fae9421dd80121e10000000a155106/content through searching google for CL_WD_ADOBE_SERVICES class. But I don't find any exmples for the class. Do you give me some hint for some exmples for the class?
    Best regards,
    tao
    (You can reply back to me via e-mail if you think we should discuss this internally at [email protected] or [email protected])

  • Simultaneous sound: how to get sound from internal speakers and usb audio adapter

    I have an iMac in my living room. It is hardwired to my home theater system in my family room. Currently, I can listen to audio in one location or the other... but not both. I bought a StarTech.com ICUSB Audio Adapter hoping that it would be a fix... not so much. Downloaded SoundSource... not so much
    How can I get audio to play via my internal speakers and through my home theater system? Hosting a party this Saturday and would like multiple rooms filled with sound.

    First pluging is headphones and then unplugging it. If yu can't get it fully inseted tham may indicate that end of a plug is broken off inside the jack.
    Then if not above problem, try the standard fixes:
    - Reset. Nothing is lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup
    - Restore to factory defaults/new iPod
    If you still have the problem then an appointment at the Genius Bar of an Apple store is in order.

  • How to get users from Organizational Unit and with worker's subgroup

    Hi
    I am looking for a f. module to get the list of users from specific Organizational Unit and with specific worker's subgroup.
    I found f. module SWI_GET_USERS_OF_ORG_UNIT but it seems not working and only returns the users, how can I narrow the selection to get only from specific worker's subgroup?
    Thank you

    Hi,
    Try with FM RH_STRUC_GET with following parameters:
    ACT_OTYPE = O
    ACT_OBJID = worker's subgroup
    ACT_WEGID = SBESX
    Most important is to specify OBJID as the workers's subgroup, values for the others parameters may vary.
    Cheers.

  • How to get value from option box and submit accordingly

    Sorry for posting my question. I have been trying to edit message and repost it and not successful. Hence I am reposting my question. Please let me know.
    I am right now exploring JSF for presentation layer. I am designing a form with <h:outputLabel..> and <h:inputText...> for the user to input his value. I also have a radio button as below. <h:outputLabel..>
    <h:inputText...>
    <h:selectOneRadio id="libraryList" >
                                <f:selectItems value="#{libraryList}"/>
                            </h:selectOneRadio>And I have included the following piece of code in faces-config.xml as below.
    <managed-bean>
            <managed-bean-name>libraryList</managed-bean-name>
            <managed-bean-class>java.util.HashMap</managed-bean-class>
            <managed-bean-scope>application</managed-bean-scope>
            <map-entries>
                <map-entry>
                    <key>Pass</key>
                    <value>Pass</value>
                </map-entry>
                <map-entry>
                    <key>Fail</key>
                    <value>Fail</value>
                </map-entry>
            </map-entries>
        </managed-bean>Hence I get two option box as Pass and Fail.
    I am also bit aware of navigation rules of JSF. Now I want the user to take to the step 2 if he chooses the option Pass and if the user chooses Fail, then I want to reset the values of the above form and display the same form.
    I have not done any Java part of the application yet as I am a newbee and hence started doing JSP pages and config-faces.xml part. Please let me know how to proceed further.

    Create a bean, bind the value to the bean, let the action method return that value and add navigation-case entries for those outcomes.

  • I had a disc of pictures in my imac and tried to update the software to 10.9, after realizing the disc was in there i ejected it and now its stuck on the os x page. any info of how to get away from that screen and onto my normal pages?

    i tried to update my software to 10.9 and forgot i had a disc of pictues in the computer. i stopped the istall as it was trying to go onto the disc of pictures. now its stuck on the os x page and i cant get it to my home screen. can anyone help?

    I'm not really sure what you mean by "the os x page". It sounds like the installation did not complete.
    I would try this:
    hold down the power button until the computer shuts down
    take out the disk with the pictures!
    restart and see if it will boot up
    if it boots up normally, I'd probably try to repair your HD: Boot into your recovery partition (hold down ⌘R at restart until you see the Apple symbol), go to Disk Utility, and repair your hard drive. While you're there, repair permissions too. OSX Tips Using the Recovery HD
    Then I'd try to reboot and run the installer again. I think it's a good idea to do the installation in safe mode : Mac OS X: What is Safe Boot, Safe Mode? .
    if it won't boot up normally, I'd try booting from the recovery partition and repairing your HD.
    if it won't boot into the recovery partition, your options are:
    Try to repair your hard drive with internet recovery: OS X: About OS X Recovery
    If you have access to another (working) Mac and a USB thumb drive, download Recovery Disk Assistant, which you can use to repair your hard drive or reinstall OSX: OS X: About Recovery Disk Assistant
    Try to boot into single user mode and repair your hard drive: Repair Your Hard Disk in Single User Mode | Everything Macintosh

  • How to synchronize analog input and output from two different USB daq boards

    Hi all,
    I have two very differnt USB boards the NI USB 6008, which I am using to acquire the data (Analog Input) and a NI USB 9263, it is an Analog Output only board that I am using to deliver a signal (in this case a square pulse). The reason why I am not using the 6008 Analog Ouputs is because I need to deliver negative voltages and need the full +/-10V range.
    Looking at similar posts I am pretty sure that I can't use an external trigger or a shared clock, I also tried to use the synchronization of timed structures but no cigar.
    I am including a quick vi that I whipped out showing how the signal jitters due to the lack of synchronization. The AO from the 9263 connects to the AI in the 6008 in this example.
    Solved!
    Go to Solution.
    Attachments:
    Test Pulse.vi ‏117 KB

    I talked to a specialist in the phone and tols me that it is not possible.

  • How do I get signal from my Roland Fantom G8 to Logic Studio or GarageBand?

    My computer recently crashed, and since then I have not been able to record any music into either Logic Studio or GarageBand.  I need to get back up and running ASAP, as I'm in the middle of recording music for 5 different projects.  Here's all the gear that I have:
    -1 Roland Fantom G8
    -1 iMac with Logic Studio and GarageBand
    -1 M-Audio Fast Track Ultra
    -2 Rokit KRK Monitors
    -1 USB cable
    -1 midi cable
    -2 1/4-inch cables
    -2 1/4-in to XLR cables
    The 2 1/4-inch cables run from Balanced Outputs 1 and 2 on the back on the Fantom G8 into Inputs 1 and 2 on the back of the Fast Track Ultra.  The 2 1/4-inch to XLR cables run from the back of the 2 KRK monitors into Outputs 1 and 2 on the back of the Fast Track Ultra.  The Fast Track Ultra is powered via USB cable that runs into a USB port on the back of my iMac.  The midi cable runs from the "Computer" port on the back of the Fantom G8 into a USB port on the back of my iMac.  This is the exact set-up I had before my computer crashed, and I was able to record just fine.  When I open up the audio preferences on either Logic Studio or GarageBand now, it recognizes the Fast Track Ultra; however, it does not recognize the Fantom G8.  What I'm trying to do is get signal from my Fantom G8 into both Logic Studio and GarageBand.  I also want that sound to then project through my KRK monitors.  I also want to be able to record audio and midi.  Please help me!!!

    I used the Fantom for several years and did exactly what you want to do. I simply plugged my Fantom into a channel on my mixer, in your case the 003. I ran a firewire out of my mixer (Presonus Studio Live) into my computer using Logic Pro X. Then I just assigned that incoming channel to a channel strip in Logic. As an example I used stero channel 9/10 on my mixer, (plugged in the Fantom here). Then the signal went via my mixer firewire to computer running Logic. I assigned my channel strip input to channel 9/10.
    Does this make sense?
    I just sold my Fantom last week and purchased a new Yamaha Motif XF8. Now I am trying to figure out the same thing on it.

  • I got a new computer and don't know how to get music from ipod touch to itunes library

    I recently got a new computer and don't know how to get music from my ipod touch to show on my itunes library. 

    You need to transfer the iTunes folder from the old computer to the new one.
    iTunes: How to move your music to a new computer (Mac or Windows):
      http://support.apple.com/kb/HT4527

  • I have a new MacAir and don't know how to get info from my USB stick and my SD photo card.  Can anyone help me please?

    I have a new MacBook Air and don't know how to get info from my USB stick and get info from my SD card.  Can anyone help, please?

    Plug the stick and/or card into the appropriate slots on the side of your Air. Do you see icons for the devices appear on the desktop? Click into them to see what files are there.
    Matt

  • I have had Adobe XI for about two years and My harddrive just crashed. My backups were part of the failure so I can't get it back. I purchased it from a third part supplier and it was a download. I need to find out how to get it restored. I can send scree

    I have had Adobe XI for about two years and My harddrive just crashed. My backups were part of the failure so I can't get it back. I purchased it from a third part supplier and it was a download. I need to find out how to get it restored. I can send screen shots of all of the drive location where the drive is still good and I can see my Adobe Acrobat pro information, but the download itself is missing. NEXT STEP?

    If you are talking about Reader (you did post in the Reader forum), then just download http://get.adobe.com/reader/enterprise. However Reader is free not purchasable. You can download a trial then install using your serial number, which if you didn’t register or write down somewhere you will be out of luck to track down.
    Download a free trial or buy Adobe products | Adobe downloads

  • How long does it take to get approval from iTunes Connect and how do I find out if they are working on it?

    How long does it take to get approval from iTunes Connect and how do I find out if they are even working on it? I'm not really sure if my application was even delivered - from the links in IBA. Any suggestions how one might push the right buttons at Apple?
    Also went around in a big circle trying to get beyond the confusion of not having the right Apple ID when I've had it a long time. Confusion abounds and learning this forum also takes a new degree of patience. Humbling to say the least :-)
    Anyone been there done that?

    [email protected]
    [email protected]
    …support phone number call +1 (877) 206-2092.
    Global Phone Support
    We have expanded English-language publisher phone support. To make contacting the iBookstore support even easier, new local phone numbers are now available for Australia, France, Germany, Italy, Netherlands, Spain, and the U.K. Support is available Monday to Friday, from 7 a.m. to 5 p.m. (PT).
    Country
    Phone Number
    Australia
    1300 307 504
    Note that this is a low tariff number.
    France
    0805 540 117
    Germany
    0800 664 5307
    Italy
    800 915 902
    Netherlands
    0800 0201 578
    Spain
    900 812 687
    U.K.
    0800 975 0615
    U.S.
    +1 (877) 206-2092
    Toll-free from U.S. and Canada.

  • When i update my IOS7 i lost my all pic from my IPAD2 how to get back those pic? and i don,t think so i did kept back up before i did that. can anyone help me for this issue?

    When i update my IOS7 i lost my all pic from my IPAD2 can anyone suggest how to get back those pic? and i don,t think so i did kept back up before i update ios7. can anyone help me for this issue?

    The photo's in your camera roll would be in a backup, if you have one (iCloud or iTunes).  If you did not keep a backup somewhere, they are gone.  Sorry, but that is the way of any data - if you don't have a backup of it somewhere, there is nothing to restore it from.
    All other photo's should be on your computer somewhere anyway - whereever you had them to sync to the device originally.

  • How to get data from three tables (A,B,C) having one to many relation between A and B .and having one to many reation between b and c

    i have  three tables A,B,C.  there is one to many relation between A and B. and one to many relation existed between table b and c . how will get data from these three tables

    check if this helps:
    select * --you can always frame your column set
    from tableA a
    left join tableB b on a.aid=b.aid
    left join tableC c on c.bid=b.bid
    This is just a general query. However, we can help you a lot more, if you can post the DDL + sample data and required output.
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • HT1498 Horrible experience and the movie kept stalling through iTunes on appletv. Gave up (after paying for it) and ended up renting it through cable provider. Anyone know how to get $ back from apple?!

    Horrible experience and the movie kept stalling through iTunes on appletv. Gave up (after paying for it) and ended up renting it through cable provider. Anyone know how to get $ back from apple?!

    Issues are usually network related
    What is your internet speed? www.speedtest.net
    6mbps is required for instant HD (you can switch to SD in the settings)
    If on wifi try ethernet and www.istumbler.net to rule out interference
    Make sure you're using your ISP's DNS

Maybe you are looking for

  • Is it possible to have a cFP application that involves more than 8 modules?

    I have an application that is using a cFP-2200 with an 8 slot backplane, but i need to read 9 modules and potentially more, is there a solution to this?  I know with the old field point there were expansion backplanes that you can use. Any response i

  • App.executeCommand(app.findMenuCommandId("Solid...")) doesn't work right?

    Hey guys, I'm tring to use app.executeCommand(app.findMenuCommandId("Solid...")) to add a solid layer to active comp. But it only add a solid layer to the project panel, instead of adding the solid layer to both project panel and active comp. It work

  • Group Left Order By

    Hi, I have a sql which contains an order by clause (order by field1, field2), the query runs fine in SQL*Plus. I tried to create a Group Left report in Reports 10g. (The report contains the Group on field1.) When I run the report, it disregards the o

  • New to Servlet - Existing html doc

    I created a new servlet and have an existing html doc. How do I connect the doc to the servlet so that it will send request to the servlet. In the html file I have the following code. <form action = "/servlet/TEDServicesDatabrowserServlet" method = "

  • Create table from view giving error

    i am trying to creating a table from view it is giving following error. can you please help create table jd as select * from A.ab_v where 1=2; error ORA-01723 zero columns not allowed