Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Use DAQmx counter or trigger?

Solved!
Go to solution

Hello,

I'm newbie with NI products and I'm triyng to get some result with a DAQ USB-6008 and the ANSI C API

My aim is to detect pulses (about 1.4V during about 10 ms) and calculate time between rising edges (should be between 0.5s and 2s).

As it is square pulse, I connected the cables to the Digital GND and PFI0 lines.

 

Firstly I tried to use the trigger functions but I failed.

So, I'm now trying to use the counter functions, but I still have an error and I don't know how to fix it.

 

Here is the code:

 

 int32 error=0;

TaskHandle taskHandle=0;

char errBuff[2048]={'\0'};

 

printf("=> DAQmxCreateTask... ");

DAQmxErrChk(DAQmxCreateTask("",&taskHandle));

printf("OK\n");

 

printf("=> DAQmxCreateCICountEdgesChan... ");

DAQmxErrChk(DAQmxCreateCICountEdgesChan(taskHandle, "Dev1/ctr0", "", DAQmx_Val_Falling, 0, DAQmx_Val_CountUp));

printf("OK\n");

 

printf("=> DAQmxCfgSampClkTiming... ");

DAQmxErrChk(DAQmxCfgSampClkTiming (taskHandle, "/Dev1/PFIO", 1000, DAQmx_Val_Falling, DAQmx_Val_ContSamps, 1000));

printf("OK\n");

 

printf("=> DAQmxStartTask... ");

DAQmxErrChk(DAQmxStartTask(taskHandle));

printf("OK\n");

 

I got the following result:

 

=> DAQmxCreateTask... OK
=> DAQmxCreateCICountEdgesChan... OK
=> DAQmxCfgSampClkTiming...
DAQmx Error: Measurements: Requested value is not a supported value for this property.
Property: DAQmx_SampTimingType
You Have Requested: DAQmx_Val_SampClk
You Can Select: DAQmx_Val_OnDemand

Task Name: _unnamedTask<0>

Status Code: -200077

 

Anybody can tell me how to fix it?

Also, if you think there is a better way to implement my requirement, don't hesitate to tell me.

 

Thanks in advance

Mobill

0 Kudos
Message 1 of 6
(4,448 Views)

Hello,

HOOUUUUHOUUUUU

Is there anybody in the forum?

Nobody wants to spend time for a newbie?

Is there something shocking in my question?

 

I really need your help.

Thanks

Mobill

Message Edité par Mobill le 11-28-2008 03:26 AM
0 Kudos
Message 2 of 6
(4,429 Views)

Bonjour,

 

Je pense que l'erreur 200077 vient du paramètre " DAQmx_Val_ContSamps ".

Au niveau du mode d'acquisition sur un 6008 pour la fonctionnalité compteur, on mettra plutot "1 sample (On demand)".

 

Mais sachant qu'au niveau d'un tache compteur la fréquence d'échantillonage ne peut être modifiée, je pense qu'il n'y a pas d'intérêt à appeler la fonction " DAQmxCfgSampClkTiming ".

 

Le flux de données serait donc le suivant:

 

1. Create empty task
2. Create a Counter Input channel to Count Events. The Edge parameter must be set to increment on falling edges.
3. Call the Start function to arm the counter and begin counting. The counter will be preloaded with the Initial Count.
4. The counter will be continually polled until the Stop button is pressed on the front panel. This will give both counter readings as well as approximate frequency readings.

(DAQmx read in a while loop)

5. Stop the task
6. Call the Clear Task function to clear the Task.

Une piste pour vous serait de télécharger la version d'évaluation de LabWindow/CVI ( https://lumen.ni.com/nicif/f/evalcvi/content.xhtml ) et de consulter les exemples qui sont fournis avec.

 

 Cordialement,

Thomas B. | CLAD
National Instruments France

0 Kudos
Message 3 of 6
(4,421 Views)

Bonjour Thomas,

Et merci beaucoup pour votre réponse.

Je vais regarder ça cette semaine.

Cordialement

Laurent (Mobill)

0 Kudos
Message 4 of 6
(4,411 Views)

Bonjour,

 

J'ai suivi le conseil de Thomas et j'ai installé la version d'évaluation de LabWindow/CVI.

J'y ai trouvé un exemple qui pourrait m'aider à comprendre le fonctionnement: DigGraphDAQmx.

 

Mais quand je l'ouvre, j'ai un message d'erreur car il n'arrive pas à trouver le fichier daqmxioctrl.fp (et .c et .h?)

Le fichier n'est effectivement nulle part sur mon disque.

 

Est-ce une erreur de l'installer?

Est-ce parce que je n'ai pas sélectionné le bon module lors de l'installation? (lequel?)

Est-ce parce que j'utilise la version d'évaluation? 

 

Comment faire pour le récupérer et pour pouvoir compiler? 

 

Merci

Laurent (Mobill)

0 Kudos
Message 5 of 6
(4,379 Views)
Solution
Accepted by topic author Mobill

Hello,

 

Finally, I succeeded in getting the pulse with the following commands:

 

DAQmxErrChk(DAQmxCreateTask("",&taskHandle));

DAQmxErrChk(DAQmxCreateCICountEdgesChan(taskHandle, "Dev1/ctr0", "", DAQmx_Val_Falling, 0, DAQmx_Val_CountUp));

 

DAQmxErrChk(DAQmxStartTask(taskHandle));

 

while (cVal == 0) {

DAQmxErrChk(DAQmxReadCounterScalarU32(taskHandle, 10, &cVal, 0));

}

 

Thank you Thomas for your help.

Best regards

Laurent

0 Kudos
Message 6 of 6
(4,361 Views)