08-30-2007 08:52 PM
09-04-2007 09:43 AM
09-05-2007 01:02 PM
Hello Matt,
I am not reading the data as fast as its being acquired. There has to be a way or DAQmx property to somehow tell it to wait a certain number of time before it fills it again. The other problem I have is in the analog task and I am getting error -200019. My gate4 to Gate 7 ratio is 360:1. Each reading with Gate4 represents a rev (once every 360 edges). Here is the code I am using, I also varied the Acq rate to see if it makes a difference as well as the BufferSize, but none solved the problem.
Thanks for Your help.
DAQmxErrChk (DAQmxCreateTask(
"Pressure Task",&taskHandle[0]));DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle[0],
"Dev1/ai0:1","Pressure Channels",DAQmx_Val_RSE,m_MinVoltVal,m_MaxVoltVal,DAQmx_Val_Volts,NULL));DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle[0],
"/Dev1/PFI7",20000,DAQmx_Val_Falling,DAQmx_Val_ContSamps,100000)); // Analog channel timing// DAQmxErrChk(DAQmxSetAIConvRate(taskHandle[0],125000));
DAQmxErrChk (DAQmxStartTask(taskHandle[0]));
DAQmxErrChk (DAQmxReadBinaryI16 (taskHandle[0],BufferSize/NumberOfChannels, TimeOut, DAQmx_Val_GroupByChannel,HoldBuffer,BufferSize,&NumRead, NULL));
// Time CounterDAQmxErrChk (DAQmxCreateTask(
"Counter Task1",&taskHandle[1]));DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandle[1],
"Dev1/ctr0","Counter1",DAQmx_Val_Falling,0,DAQmx_Val_CountUp)); // Counter 0DAQmxErrChk (DAQmxSetCICountEdgesTerm(taskHandle[1],
"Dev1/Ctr0","/Dev1/20MHzTimebase")); // Sets 20MHz as source clockDAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle[1],
"/Dev1/PFI7",50000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,100000)); // using PFI7 as gateDAQmxErrChk (DAQmxStartTask(taskHandle[1]));
DAQmxErrChk (DAQmxReadCounterU32(taskHandle[1],BufferSize/NumberOfChannels,-1,TimeBuffer,(BufferSize*2),&NumberReadOnTimeCounter,NULL));
// Once Per Rev CounterDAQmxErrChk (DAQmxCreateTask(
"Counter Task 2",&taskHandle[2]));DAQmxErrChk (DAQmxCreateCICountEdgesChan(taskHandle[2],"Dev1/ctr1","Counter2",DAQmx_Val_Falling,0,DAQmx_Val_CountUp)); // Counter 1
DAQmxErrChk (DAQmxSetCICountEdgesTerm(taskHandle[2],
"Dev1/Ctr1","/Dev1/20MHzTimebase")); // Sets 20MHz as source clockDAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle[2],
"/Dev1/PFI4",50000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,100000)); // using PFI4 as gateDAQmxErrChk (DAQmxStartTask(taskHandle[2]));
DAQmxErrChk (DAQmxReadCounterU32(taskHandle[2],100,-1,OncePerRevBuffer,BufferSize,&NumberReadOnOncePerRevCounter,NULL));
09-06-2007 08:26 PM - edited 09-06-2007 08:26 PM
@NewBe wrote:
Hello Matt,
I am not reading the data as fast as its being acquired. There has to be a way or DAQmx property to somehow tell it to wait a certain number of time before it fills it again...
Message Edited by Matt A on 09-06-2007 08:27 PM
09-07-2007 08:52 AM
Hello Matt,
Thanks for your reply. I do have the task functios grouped correctly not as posted. As a matter of fact my counters are configured before my AI task, because I need my analog readings to be gated. I have already ran into error 200078 which I can't seem to get around, I can't use interrupts and I can't put my AI task first, and I am not sure how to switch ctr0 and ctr1 or if that helps anyways, I did switch them in the application, but the application started to choke. To answer your question, I am getting the message with & (without) the line commented out. Also I specified "" for the source for AI task, it didn't seem to help either. I am wondering if there is a way to get around this problem with still setting gates(ctr) before AI as i need my AI readings to be gated.
Thanks
09-10-2007 11:52 PM
You can specify the return value of this function in seconds or ticks; either way you could determine RPM by counting the time for one complete revolution. That is, with a "two-stroke" encoder, you could use a continuous period measurement task to count the number of seconds for 360 periods. This would give you seconds/revolution; you could calculate revolutions/minute by inverting this measurement and then multiplying by 60:DAQmxCreateCIPeriodChan
int32 DAQmxCreateCIPeriodChan (TaskHandle taskHandle, const char counter[], const char nameToAssignToChannel[], float64 minVal, float64 maxVal, int32 units, int32 edge, int32 measMethod, float64 measTime, uInt32 divisor, const char customScaleName[]);
Purpose
Creates a channel to measure the period of a digital signal and adds the channel to the task you specify with taskHandle. You can create only one counter input channel at a time with this function because a task can include only one counter input channel. To read from multiple counters simultaneously, use a separate task for each counter. Connect the input signal to the default input terminal of the counter unless you select a different input terminal.
09-11-2007 07:46 AM
09-12-2007 03:32 PM