05-04-2010 08:51 AM
Hello!
We have some NI-DAQ cards (PCI-6221, 6251 and 6036E) but none of them seems to be capable of the following measurement.
There is a digital pulse train which must be received (practicaly with a counter). We have to measure the VOLTAGE on an AI channel when an impulse is received. The frequency of the impulses can be 1 KHz so generating events at every pulse for the PC is not viable. We also have to know the TIME when the impulse occured (something like the card should have its own clock and should be able to put its value next to the measured voltage).
Furthermore the card should give an output sign (impulse or line change) of 1. the number of impulses reaches a given amount or 2. the voltage drops below or goes above a given value on an AI channel. If an automatic output is not available at least we need an event to the PC.
Is there any card for solving this problem? Actually the card has to have two counters at least since we have two digital pulse train, but only one is active at a measurement. Thank you for your suggestions!
Solved! Go to Solution.
05-04-2010 11:17 AM
OK, some more specs needed:
Voltage ac or more DC ?
Timing requirements for the output pulses .... response in ns, µs ms???
Max and min pulse repetition.
If a hardware solution is prefered look at the FPGA cards
05-04-2010 12:03 PM
Thx for the fast answer! The voltage we measure is DC. The preciseness of the time measurements should be ms, and the response for the output pulse also should be not more than 1 ms. What do u mean by the min and max pulse repetition? There is only 1 impulse to output (this will cause the machine to stop).
I haven't thougth for FPGA-s, but it might be a good solution.
05-04-2010 01:06 PM
Could you please clarify "we have two digital pulse train, but only one is active at a measurement". Are you checking for a certain number of pulses on more than one line? Do you have more than one channel of Analog Input?
Ignoring the requirement for the 2nd digital pulse train for now, from my understanding of the application the 6251 could do what you need:
1. The AI signal must be connected to the 6251, since it is the only board of the three that supports analog triggering.
You will need to configure an Analog Reference Trigger to enable the on-board comparator. You can use the AI line if you are just sampling a single channel (or an APFI line if you are sampling multiple channels). Exporting the Analog Comparison Event will tell you when the signal is outside of a certain threshhold (the graph shows "Entering Window" but you can select "Leaving Window" instead):
2. Connect the digital pulse train to one of the PFI lines on the 6251. It will be the sample clock for your AI Task.
4. Use the same PFI line as the source for a Counter Output Task (single pulse). Set the initial delay so that when the desired number of pulses have been counted you will output a pulse on the counter output.
5. You would now have one line telling you when N pulses have been reached (from step 4), and one line telling you when AI is outside of a window (from step 1).
6. If you want to timestamp the pulses using the board's on-board counter, then you would need to use the 2nd counter as a buffered edge count task with the external pulse signal as your sample clock. This will give you a very accurate timestamp of your external pulses (relative to the start of the task).
If you need to timestamp pulses on more than one line you could look into configuring a DI Change Detection task on the 6251, and using the change detection event as the sample clock for the counter task. You would need to implement some logic in SW to determine which line generated the actual event.
You also have 4 other counters to play with on your other two DAQ devices, so depending on what you want to do you should have quite a bit of flexibility.
Best Regards,
05-05-2010 10:07 AM
Thank you for the detailed answer!
Answering your question, we have two digital lines but only one is active at a time (so probably it can be solved to read both digital impulse train on the same line.) Using the delayed counter output is actually what is good for here, so thanks for the idea!
But I dont understand that how will I measure the time using another counter? If the impulse train will be the sample clock of the 2nd counter as well it will always store how many impulses have already come, but it will not have any information about the time. If I understand well...
05-05-2010 10:52 AM
The second counter would be an edge count task.
-The source (what you are counting) would be one of the on-board timebases--either 100 kHz, 20 MHz, or 80 MHz (M Series only).
-The gate (the sample clock) would be the external pulse train
So, every time the external signal pulses you would latch in the number of ticks that have been counted from the internal timebase. Each tick would correspond to 10 us, 50 ns, or 12.5 ns depending on the timebase. You could use this to give an accurate relative timestamp to the external pulses. The end result would be an array of timestamps (in the form of timebase ticks), with each value latched in by the external signal.
05-12-2010 03:39 AM
Thank you very much! I didn't know a counter can be used in such way. It seems you actually solved our problem!
05-21-2010 05:09 AM
Dear John,
I am trying to set up the analog triggering, but it seems that it's not going to work for some reason. Could you please clarify for me what this sample program should do? (I cut this few lines from an example project called 'VC_ContAcq_IntClk_AnlgStart'.)
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
DAQmxErrChk (DAQmxCfgAnlgEdgeStartTrig(taskHandle,"APFI0",DAQmx_Val_Rising,0.0));
DAQmxErrChk (DAQmxSetAnlgEdgeStartTrigHyst(taskHandle, 1.0));
DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
In my understanding this program should start continous acquisiton on ai0 when the voltage increases above 1.0V on the APFI0 line (channel number 20), is that right? Also, can the "APFI0" string be replaced with -for example - "Dev1/ai0" in the 'DAQmxCfgAnlgEdgeStartTrig' call? (To set the trigger source to ai0.) I tried quite a lot of things, but unfortunately the acquisition does not want to start. (If I delete the 'DAQmxCfgAnlgEdgeStartTrig' and 'DAQmxSetAnlgEdgeStartTrigHyst' lines the acquisition starts immediately.)
Thank you for any help!
Zsolt Selmeczi
05-25-2010 08:53 AM
Dear John,
By-passing the AI trigger example above, how can I export the 'Analog Comparison Event' you mentioned in step 1.?
05-25-2010 11:05 AM
Hi Zsolt,
Sorry for the delay, I've been out of the office on vacation the past few days. Did you manage to get the acquisition to trigger property? I believe the original problem came from a misunderstanding about the relationship between hysteresis and trigger level:
So, the way you had the trigger configured in your post from 5-21, it would trigger when crossing 0V, but only after going below -1 V. From the original post, it sounded like you actually wanted an Analog Window Trigger (instead of Analog Edge): "the voltage drops below or goes above a given value on an AI channel".
You may use "Dev1/ai0" in place of the APFI lines in order to trigger your signal with the following restrictions:
1. If using an analog start trigger, the ai channel to trigger off of must be the first in your scan list.
2. If using an analog reference trigger, the ai channel to trigger off of must be the only channel in your scan list.
To export the signal as you have it configured now, call DAQmxExportSignal(taskhandle, DAQmx_Val_StartTrigger, <output terminal>).
I had suggested a reference trigger originally since it sounded like you might want to acquire the data before the trigger is sent--if using a Start Trigger this wouldn't be possible.
Best Regards,