Urgent: continous recorders of NIDAQmx and other instruments with multi-threaded vc ++

I'm working on a software with vc ++ to control several instruments including a NO-DAQmx6289. For example, the features of the software.

1. communicate with data acquisition card (card data acquisition) and continuously acquire data from several channels at a frequency of 1 kHz.

2. connect with function via port RS232 1 generator, sending triggered bursts to the real-time features generator change state Ultrasound (G_usstatus) variable.

3. connect with optical switch via RS232 2 port, send signals to switch between the two input channels (0,1) and six output channels (2,3,4,5,6,7) to the specified user to sequence and time interval (default: 150 ms), real-time change the channel connection variable (G_optchannel).

4. in real-time, record data and the corresponding ultrasound status and connection status of optical channel in a specified file use for later analysis.

I use multiple threads to make data acquisition (1-wire), control of the function (2 wire) generator and optical switch (3 wire).  I also need save data acquisition of data and the corresponding ultrasound status and use the connection status of optical channel in a specified file for later analysis. I use the following codes to read data continuously.

Sub DataCollectionWin::ConnectDAQ()
{DAQmxErrChk (DAQmxCreateTask ("", & taskHandle));}
DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0,Dev1/ai1,Dev1/ai2,Dev1/ai3,Dev1/ai4,Dev1/ai5,Dev1/ai16,Dev1/ai17,Dev1/ai18,Dev1/ai19,Dev1/ai20,Dev1/ai21,Dev1/ai6,Dev1/ai7,Dev1/ai22","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,60000));

DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent (taskHandle, DAQmx_Val_Acquired_Into_Buffer, 50, 0, EveryNCallback, NULL));
DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,));

DAQmxErrChk (DAQmxStartTask (taskHandle));

Error:
If (DAQmxFailed (error))
{
DAQmxGetExtendedErrorInfo (errBuff, 2048);
MessageBox (errBuff);
DAQmxStopTask (taskHandle);
DAQmxClearTask (taskHandle);
return;
}

}

Int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
{
char l_optstatus_s [1] l_optstatus_e [1];
char l_usstatus_s [1] l_usstatus_e [1];

/*********************************************/
Reading DAQmx code
/*********************************************/
If (! m_bStopTracking)
{
l_usstatus_s [0] = g_usstatus [0];
l_optstatus_s [0] = g_optstatus [0]; Switching State optical before reading the data of 50 * 15

DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,50,10.0,DAQmx_Val_GroupByScanNumber,data,50*15,&read,));

SetEvent (hEvent);
l_usstatus_e [0] = g_usstatus [0];
l_optstatus_e [0] = g_optstatus [0]; Status of the ///optical at the end of the reading of the data of 50 * 15

If (read > 0) / / / save data in an exl file specified by "datafile".
{

Indicator = 1;

for (i = 0; i<>
{(/ / fprintf(datafile,"%d\t",i);}
fprintf(datafile,"%c\t",l_usstatus_s[0]);
fprintf(datafile,"%c\t",l_usstatus_e[0]);
fprintf(datafile,"%c\t",l_optstatus_s[0]);
fprintf(datafile,"%c\t",l_optstatus_e[0]);
fprintf(datafile,"%.2f\t",data[15*i]);
fprintf(datafile,"%.2f\t",data[15*i+1]);
fprintf(datafile,"%.2f\t",data[15*i+2]);
fprintf(datafile,"%.2f\t",data[15*i+3]);
fprintf(datafile,"%.2f\t",data[15*i+4]);
fprintf(datafile,"%.2f\t",data[15*i+5]);
fprintf(datafile,"%.2f\t",data[15*i+6]);
fprintf(datafile,"%.2f\t",data[15*i+7]);
fprintf(datafile,"%.2f\t",data[15*i+8]);
fprintf(datafile,"%.2f\t",data[15*i+9]);
fprintf(datafile,"%.2f\t",data[15*i+10]);
fprintf(datafile,"%.2f\t",data[15*i+11]);
fprintf(datafile,"%.2f\t",data[15*i+12]*5);
fprintf(datafile,"%.2f\t",data[15*i+13]*5);
fprintf(datafile,"%.2f\n",data[15*i+14]*5);
       
}
  
fflush (stdout);
  
}
}
}

Now the problem is the data acquired with daq card does not match the corresponding registered swtich optical status (G_optchannel, which specifies the light connecting channels). High readings expected certain status really appeared in any other situation.  It seems that there is a misalignment of the multi-thread data. Because the optical switching State passes to 150ms, so I put DAQmxRegisterEveryNSamplesEvent to be trigued each 50samples, which means 50ms with 1 kHz sampling to avoid missing the changes. I also check if there is any change of status during the DAQmxReadAnalogF64, by registering l_optstatus_s and l_optstatus_e, which are actually the same. I wonder if this is because the data are first registered in the buffer. When the software starts reading, at that time, optical swtich status no longer reflects the State when the data was recorded first. Is it possible to fix this?  Thank you very much!

kGy,

I'm glad to hear that you are progressing with your project.  Timestamp data are always a bit tricky, because the process of querying a counter on the CPU is done asynchronously with the acquisition of your DAQ hardware.  However, your equipment will ensure that the relative chronology between samples is consistent (in your case, the data will be sampled every 1 ms).  And since you have changed your program as you are now all samples acquired reading, you know that each sample follows the previous 1ms.  So, if I were to implement this I think that I take an initial horodotage when I started the task and to calculate the timestamp for all samples following this timestamp (timestamp SampleN = (*.001s + horodotage initial N) or timestamp SampleN = timestamp SampleN 1 +. 001 s).

I would go to do that, rather than the timestamp of the end of the reading for the following reason.  As I mentioned previously, the reminder of your reading will run when the OS is planning.  Therefore, it is possible that it gets delayed or does not exactly in phase with the acquisition of hardware, and make adjustments to your code to handle this problem.  However, when you're timestamping there is another thing to pay attention to.  It's the fact that your hardware has a FIFO where sampled data can accumulate before getting transferred to the memory buffer that reading from (for example if the bus PCI were busy when the sample was acquired).  Now assume that the stars aligned against us and get the following:

(1) the operating system is busy with other things, and our reminder read gets delayed a few ms.

(2) at the same time, another device connects the PCI bus (or part of the data path between your device and the memory used for the buffer).

(3) one or more samples is momentarily blocked in FIFO of the device.

If you were to read data timestamp at the moment, your timestamp would reflect the data in the buffer as well as data that was flying in the FIFO of your device.  However, you can only read data in the buffer.  Thus, time stamp applied to data that you just read would be a millisecond or two later they should be.  Suppose that on the next read reminder, this condition has cleared up itself.  This timestamp taken here would be accurate, however, you will need to return some additional samples (those who were stuck in the FIFO last time).  If you backcalculation your timestamp at this stage, I think that the timestamp calculated for these ecaple timestamps calculated on the previous reading.  It wouldn't be ideal, nor would it reflect when the data has been actually sampled.

One of the remaining challenges is how exactly the start of time stamp feature.  To do this, I would like to add a call to DAQmxTaskControl (taskHandle, DAQmx_Val_Task_Commit) before calling DAQmxStartTask.  This step will advance the State template DAQmx as far as possible without actually starting the task.  This will help to DAQmxStartTask as soon as possible.  Now, before the appellant beginning or immediately after, I would take my initial horodotage (perhaps timestamp before and after and take the average).  Then I would use this original time stamp and my sampling rate known to calculate timestamps for all the rest of my samples.

That got a bit long, but I hope it has been helpful.

Dan

Tags: NI Hardware

Similar Questions

  • Sound and other issues with Qosmio x 300-11

    Hello

    I purchased a Qosmio x 300-11s there are a little over 2 months. I have usually more than 1 audio application on at a time, for example radio game world of warcraft, but since today if I try to run more than 1 sound application or a program like world of warcraft which runs to several sound channels at once I get nothing. The sound stops completely right, I can also hear the fan hitting the basis if I up the laptop a little on the side. In games and other things, that he also got a little slow, Warcraft as much as the drop in 50-15 FPS, but which could also be a problem in game. Did I do the fix try the sound and the fps of the laptop or is it an internal problem maybe

    The game slows down could be related to the problem I have with temperatures on my 300 x 11 s. You can download a temperature monitoring tool like HWmonitor [http://www.cpuid.com/hwmonitor.php] and [http://www.ozone3d.net/benchmarks/fur/] Furmark to measure the temperature of the gpu, then all running stability test mode non-plein screen and post back with the gpu reported max temperature.

    Mine will reach close to 100 c while performing this test and I bought it 3 weeks ago. I hate the idea of what it will be like when a little dust deposits on the fan

  • Hotmail never send emails asking for password and other details with the warning that the account will be susepended if the information is not given?

    I get messages in English and French attention that my account hotmail will be suspended if I don't provide the information. I guess it's phishing and delete the emails. Is my account at risk of being suspended?

    Thank you

    It is a common phishing scam as you can imagine - Hotmail and other organizations do not request this type of information. Do not answer, mark the email as spam and delete it

  • After Effects and other CC with this record? / After Effects u otros CC con estas efforts?

    Hey, I'm getting a computer, but my budget is low (computer subscription and only 'cheap' cc), and my main option is:

    -i5 4460

    -NVIDIA GTX 750 ti (seems sufficient)

    -8 GB of ram (16 in the future)

    I want to know if I can run After Effects and other programs of the suite CC with decent fluidity with a processor Intel Core i5 4460 or I need to upgrade to i5 4690 (not i7), render times are not important in my case, the use of After Effects will be 720 / 1080 p, no use 'very professional '.

    I insist, I want only performance OK. If anyone wants more information, I give it.

    Thank you!

    -------------------------------------

    Hola, estoy serve UN ordenador, pero mi presupuesto're bajo (solo a 'barato' ordenador y suscripcion a CC), y mi opcion are key:

    -i5 4460

    -Nvidia GTX 750 Ti (parece suficiente)

    -8 GB of ram (16 in el futuro)

    Me gustaria saber puedo usar After Effects if y otros programas of more CC con una fluidez decent cogiendo UN i5 4460 o tengo that undergo a UN 4690 (i7 no), los tiempos renderizado don't me important in e caso, el uso of After Effects will be of para 720 / 1080 p, no will be a uso "ultra-profesional.

    Saw, solo quiero UN performance OK. If someone needs more information, is the perfectly doy.

    Gracias!

    Hi Albert,

    Please see the document:

    System requirements | Creative cloud

    If your system is compatible with creative Cloud Applications. It will work.

    Hope this will help you.

    Kind regards

    Megha Rawat

  • Cannot access Yahoo, Gmail and other accounts with password in Firefox, but can in Chrome. I type the passwords in myself - not registered.

    Started happening today (22/07/2015) - after the re-opening Firefox this afternoon, I couldn't connect to Yahoo, G-mail accounts, as well as other protected by password. Fortunately, I could access these accounts in Chrome. I don't have browsers save the passwords. I always type them in manually. How can I access these accounts in Chrome and not Firefox? JavaScript or what? The whole Flash issue is also boring. I use more other browsers. Please fix, or I forget quite using Firefox.

    Safe mode is a troubleshooting mode that turns off temporarily
    hardware acceleration, restores some settings and disables
    -Add-ons (extensions and themes). If the problem disappears,
    that tells us something. If it is not the case, this tells us something else.

    • Step 1

    Type of topic: preferences #advanced< enter > in the address bar.

    Under Advanced, select General.
    Find and stop using hardware acceleration.

    Restart Firefox. Is always the problem?

    • Step 2

    It could be the work of one of your modules.
    Type of topic: addons< enter > in the address bar to open your add-ons Manager.
    Access key; < Control >(Mac: < command >)< shift > has)

    In the Manager of Add-ons, on the left, select Extensions.
    Disable some add-ons, then restart Firefox.

    Some added addons toolbar and anti-virus are known to cause
    Firefox issues. Disable all of them.

    If the problem persists, disable some more (restarting FF). Continue until the
    the problem disappeared. After, you know which group is the origin of the problem.
    Reactivate the last group ONE AT A TIME (reboot FF) until the problem reports.

    Once you think you have found the issue, that disable and reactivate all the
    others, then restart. Let us know who the suspect is detective.

  • I can watch more videos on YouTube and other sites with Firefox is (IE and Chrome work well) someone can suggest a solution for this?

    This week, after the automatic updates, Firefox no longer plays videos on YouTube or other sites. I tried using a very old version of Firefox and it was OK, but I'm afraid too many glitches with this older version.

    This can be caused by a recent update of Flash 11.3.

    See:

  • I get phone calls from the center of support of "Microsoft Windows" supposed to have detected viruses and other problems with my computer.

    They seem to want to let me have online access to my PC to 'fix '.

    This unsolicited approach is likely to be authentic?

    Friday, January 11, 2013 15:01:10 + 0000, BarryTrewern wrote:

    They seem to want to let me have online access to my PC to 'fix '.

    This unsolicited approach is likely to be authentic?

    No!
    It's a scam and with all the names and phone numbers, one who has
    become very frequent lately. See
    http://www.troyhunt.com/2012/08/virus-scams-social-engineering-victims.html

    In addition to their money get on your part to do anything of any value,
    If you leave them in your computer, which knows what losses they did are
    where confidential information they stole.

    So if you have done so, I highly recommend that you do both of the following
    immediately:

    1 do a clean reinstall of Windows.

    2. change all of your passwords, especially banks or other
    financial sites.

    Ken Blake, Microsoft MVP

  • Why CS6 turning headlights and other sources with plain red light?

    I am a railroad photographer and I came the other night of an exit from the House and began editing photos. However, I couldn't use an any of them, because of the CS6, turning the train lights in clear red spots. It worked perfectly as a few days before. No parameters have been adjusted at all, and does so for all RAW photos on my computer, including those I have already edited by Adobe RAW.

    It looks like this:

    http://i.imgur.com/fgRhjBE.jpg

    Any help would be appreciated.

    It is the indicator of cliping of climax. Click on the small triangle at the top right of the histogram to turn it off.

  • Sound and other issues with Satellite P100-277

    Hello dear...

    My English is not long but I hope you understand me...

    I have a laptop toshiba satellite P100-227 & Windows XP operating system.
    When I login to windows, the message on laptop display "cannot Access Volume Control!"
    I have no sound on my laptop. I reinstall my OS system, but I have the same problems.
    Please see this link, my screen of the device menager

    http://images29.fotosik.pl/163/6a31918c1b8998b1.jpg

    (kontroler sieci = network controller)

    I do not know how to install this 'network controller' and 'PCI device', and what is the problem with the sound?

    I was install all drivers for my laptop, the TOSHIBA Web page and when I install the audio drivers
    (sound-20071106151533) I get the message like "device setup error, no device found for this driver."

    Please tell me what is the problem? Help me

    Thank you

    Hello

    How long the problem exists? I mean, is that the sound worked before? And if so, what did he stop? Immediately or after you´ve installed software?
    Have you had Windows Vista installed first on your machine?

    A lot of questions for now: I need some answers. ;)

    Would appreciate to hear something from you, maybe we can solve your problem...

    Greetings

  • installed xp pro sound and Wireless does not have tried uddates Lenova micro updates and other participant with vista not XP pro

    After installing XP pro wirelwss features audio years stop working on microsoft Lenova 3000 C200 No. or lenova updates have proven to help the old compuier new problem

    Hello denebrennan,

    I recommend to download the latest drivers and software on Lenovo's site:

    http://support.lenovo.com/en_US/downloads/default.page?

    Best regards

    Matthew_Ha

  • How to install windows 7 Firefox without 'Ask search' and other software?

    I would like to install Firefox pure, lean without other complementary software, such as "Ask search. Please download from the home page of Mozilla. Thank you for helping.

    I moved cela Firefox Support Forum.

    You have two options.
    (1) uninstall the Ask toolbar to page addons (menu button of Firefox (upper right corner)-> Add-ons or Ctrl + Shift + A
    (2) uninstall Firefox and then re - install from Mozilla directly

    Yahoo!, Ask, and other companies to combine their toolbars and other nonsense with Firefox it is therefore preferable to get it directly from Mozilla to avoid any "bloat-ware".

  • Fan control with 5750G and other machines problems

    Lets start with stating that the 5750 G (and other models with same design cases) has lots of GPU and overheating problems:

    As well as the mysterious GPU problems:

    This problem is happing on computers between 12 and 20 old frames. Although the user

    • Using a fresh install of windows.
    • Uses the latest GPU driver.
    • Use the BIOS more recent (1.21 for my 5750G).
    • A cleaned the dust from heatsink and fan.

    So that's the problem! Thermal and non-functioning fan control past!

    So it goes like this:

    End of one your PC starts to slow down: This is because the heat past at low price, acer puts on their laptop begins to degrade. This means that even if the fan trying to cool the CPU and the GPU. The heat generated by the CPU and the GPU may be transferred on the radiator. Thus the CPU and the GPU lower their performance so that the computer does not so hot that it cannot work. And damage the CPU and the GPU.

    After a bit more time the PC begins to close when you use more intense programs / games:
    This is because that which has degraded the heat past so that the computer becomes so hot than its cutting himself to avoid damaging himself.

    So what's the problem?: I mean that acer can not simply replace past heat each contact? So what can they DO?

    Here's what Acer should do: Do a BIOS 1.22 WITH CUSTOM FAN CONTROL!
    It would be easy! While the main problem is the thermal past. There is another problem:

    Fan will not go 100%: when my 5750 hits 95 degrees Celsius. It is still running the fan speed of ~ 60-70%!
    When it hit 103 degrees Celsius. Just 2 degrees, far from extinguished to prevent critical damage. She is STILL going to ~ 60-70%! Acer... I know that the fan can be turned to a higher speed. Because when I turn on my 5750G after he himself has just cut off due to overheating. He rotates extremely fast fan! But just for a few seconds. Then he goes back to the being to slow to cool enough.

    Acer... Why not do that? ! : Come on Acer! Do it! Make a new BIOS, I would be happy. And I know that Acer is not a * beep * ty company. But actually listens to their customers! If your worried that some people would go in the BIOS and the fan settings so that they broke the laptop. Then just have a big WARNING: "Guarantee will be woid entering this option" or a "to activate this option go to Acer.com/XXXX and type the code. Follow-up of the caveat "the guarantee will be void.

    Please Acer. Give people who know what they make of the option to do so!

    Im going to this ends with a quote from another post on your forum:

    «I look a little, but have not found anything to give a bit more power the fan...»
    Acer could not just add a few adjustments of fan to the bios?

    Quote this post: http://community.acer.com/t5/Acer-Notebooks-Netbooks/Entire-CPU-Overheating/m-p/12211/highlight/fals...

    Hello

    Today I can finally post what you are waiting for. The fan controller tool was developed in a public place.
    Anyone who decides to install this tool, please take note once more:

    • Acer does not support this tool on systems from laptops Aspire 5750 G / 5755G.

    • Acer does not support this tool on Acer OEM Software (your laptop comes with Windows 7 installation).

    • Users with other portable model should not use this tool. This will be entirely at your own risk.

    • Other OS can run this tool, but Acer does not test or review it. Acer is not responsible for any bad consequences when using the tool in that mentioned other environments.

    Official statements made, here are the goodies. Be sure to download the PDF file as well, if you want to check the installation process:
    FTP://ftp2.Acer-euro.com/notebook/aspire_5750G/fan/FanController_V1.0.0.3.zip
    FTP://ftp2.Acer-euro.com/notebook/aspire_5750G/fan/SOP_AS5750G_Fan_Control_Utility.PDF

    Feel free to have a discussion open after this post on the results. I tell you what I'll be less frequent in this topic, though.

    Anyone who still has problems when running this tool is advised to contact Acer support and get their laptop repaired.

    We thank all for your patience, hope that this helps out you.

    Kind regards

    Rolf

  • Unable to open gmail and other google account services. Need urgent help. Firefox version is 29.0.1. Erasedeverythingcache/history + reset without addons.

    Unable to open gmail and other google account services. Need urgent help. Firefox version is 29.0.1. Deleted all cache and history + wiped without addons. Urgent help please. Same problem in other browsers ie opera/IE. Other Internet sites without problem.

    Personally, I've never had problems with ABP, but questions about ABP would be better answered in the AdBlock Plus forum where there are people more suited to respond as we only deal with technical support from Mozilla (e.. g the Fx of Firefox, Thunderbird, for Android)

  • Why when I click with the left button of the mouse on the unique tool, you open the window with the other instruments?

    When I click with the left button of the mouse on the unique tool, open the window with the other instruments


    Mohito Hi, this morning, I solved the problem by trying to support. I realized that the problem was in mice, because the click rate is at its highest level, and then click the instruments was like if he did 2. I will now set the minimum speed of the clicks.

    Thank you

  • Are automatically shared Contacts with the members of the family of a device for all devices of the family? One device uses IOS9 and others are using IOS10.

    Members of the family can share Contacts?  A member of the family is on IOS9 and others are on IOS10. Our calendars are sharing but not our contacts?

    No, sharing of family does not share Contacts. He shares:

    Purchases

    (If you are registered) Apple's music

    Family Photo album

    Family calendar

    Location sharing

    Find my iPhone

    Apple - iCloud - family sharing

    See you soon,.

    GB

Maybe you are looking for