03-20-2007 03:12 AM
m_task = std::auto_ptr<CNiDAQmxTask>(
new CNiDAQmxTask());m_task->COChannels.CreatePulseChannelFrequency(cDAQ1Mod5/ctr0, _T("channel1"), DAQmxCOPulseFrequencyUnitsHertz, DAQmxCOPulseIdleStateLow, 0.0, 1.0, 0.5);
m_task->COChannels.CreatePulseChannelFrequency(cDAQ1Mod5/ctr1, _T("channel2"), DAQmxCOPulseFrequencyUnitsHertz, DAQmxCOPulseIdleStateLow, 0.25, 1.0, 0.5);
m_task->Timing.ConfigureImplicit(
DAQmxSampleQuantityModeContinuousSamples, 1000);// Create a timer
SetTimer(1, 5, NULL);
///////////////////////
...::OnTimer(..)
{
.....
// I want to count de pulses of the generated trains but this does not work, I obtain strange numbers..
unsigned int a,b;a = m_task->COChannels[_T(
"channel1")].Count;b = m_task->COChannels[_T(
"channel2")].Count;}
m_task->Start();03-21-2007 12:03 PM
Hi Lei,
You arereading the value that is on the register of the counter but does do not work properly coz u dont now what was on that registry before...
There are 2 things u can do:
1. Why u do not create a finite number of pulses instead of a continous PWM? That is... u can indicate how many pulses u want to take out, and that's all.
2. If u still wanna do a continous pulse train output just use another free counter to count the edges of the first one,
Hope that helps,
03-23-2007 04:09 AM
03-23-2007 05:17 AM
Hi Leire,
I believe there is no other chance that using another counter to verify that.
If you make the connection you can do it directly and u do not need to export the terminal u just need to say which terminal is your source for counter 1. Is not the export function, can u try this one:
int32 __CFUNC DAQmxSetCICountEdgesTerm(TaskHandle taskHandle, const char channel[], const char *data);
But do not insert "Ctr1/Out" say the PFI line (i dont know exactly for your device but u can look for it at documentation) for example "Dev1/PFI4". That should work.
You cannot change the frequency on the fly. You should stop the task and start a new one if u want to do that.
You can use an analog input for counting edges if your pulse generation has not a high speed (high frequency) if you program it properly.
Hope that helps,
03-23-2007 07:04 AM
04-13-2007 06:14 AM
Hola,
Puedes usar las salidas digitales, ya que se pueden clockear ahora ... eso sería una solución viable.
Mi pregunta es... te has planteado una tarjeta de contadores?
Busca algún ejemplo dentro de labview de Digital I/O con timing o sino busca alguno que ponga correlated I/O.
Saludos,