NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
chemph
Posts: 45
0 Kudos

saving counter and voltage signals

I am searching for an alternative to save measured signals with a high sample rate (~10 kHz). For example, I have one Analog input signal and one Quadrature Encoder signal. Until now, I have for both signals an own threadfunction if n samples are aquired. For both signal types i wirte with fprintf an own file and after stopping the measurement, I bring both files together.

 

This method works but I think this is not really the best one. Can you say me what's the better method?

Member
Gerryli
Posts: 79

回复: saving counter and voltage signals

Hi, chemph

 

if i understand correctly, you want to write both signal to same file , right ?

 

if so, i think you can save the data first in buffer than use function arraytofile  and choose attribute append.

 

ArrayToFile ("", , VAL_DOUBLE, 0, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS, VAL_CONST_WIDTH, 10, VAL_ASCII, VAL_TRUNCATE);

 

hope can help!

 

B.R

Gerry

Member
chemph
Posts: 45
0 Kudos

saving counter and voltage signals

Hi,

 

the problem is now the number of read samples in both tasks is not always the same. In the most time it is but sometimes, there are in one task samples more tahn in the other.

 

    DAQmxCfgSampClkTiming (ni_ai, "OnboardClock", 10000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 10000);
    DAQmxCfgSampClkTiming (ni_ctr0, "/Dev1/ai/SampleClock", 10000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 10000);
    
    DAQmxRegisterEveryNSamplesEvent (ni_ai, DAQmx_Val_Acquired_Into_Buffer, AFTERNS, 0, CF_ai, NULL); with AFTERNS=1000
    DAQmxRegisterEveryNSamplesEvent (ni_ctr0, DAQmx_Val_Acquired_Into_Buffer, AFTERNS, 0, CF_ctr0, NULL); with AFTERNS=1000

 

I can imagine, the samples read in buffer until I do DAQmxStopTask(...) are not read after stopping mesuring.I need a solution to stop tasks (in both tasks should now the same amount of samples) that no more samples will me measured but read all data.

Member
chemph
Posts: 45
0 Kudos

Re: saving counter and voltage signals

Does anybody has sample code to meas analog voltage and quadrature encoder signal synchron and write in one file?

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page