04-05-2011 05:44 AM
Hello,
following a long search on this forum, I have decided to start this thread for dotNet developper.
I have a PCI-6602 with a quadrature encoder (A,B,Z). The pulse frequency is average (10kHz).
I am only using A and B channels.
The function I have to implement is to generate an output every N pulses in the forward direction. N being an integer and ranging from 1 to let say 100.
I have no constraint on the output. I am it can be a bit toggling or a pulse generation.
What functions shall I call in MeasurementStudio.Net to implement this ?
How many counters should I use ?
On the register basis, my guess is that I have to pre-load a value in the register.
Then when downcounting the counter reaches 0 this in turn does 2 things:
Thanks for any help you may bring
NOTEs FOR NI guys:
---------------------------------
By the way, in the NI samples, quadrature doesn't work all the way. I nthe sample "CountDigEvents" with CountDirection set to "Externally controlled", backward motion is never displayed. This is because the counter is read as a UInt32.
Solved! Go to Solution.
04-12-2011 10:45 AM - last edited on 11-05-2014 10:27 AM by dcarva
Hi,
Your first ideas are pretty good, it should be a good way to implement a solution for your problematic.
I am not used to work with MeasurementStudio, but this is few links which you could use or which could help you with theoretical points:
http://zone.ni.com/devzone/cda/tut/p/id/3167
<link no longer exists>
http://zone.ni.com/devzone/cda/epd/p/id/2999#0requirements
Hope it could help
Mathieu B
National Instruments France
04-12-2011 11:07 AM
Hi anthony75fr,
Although it does not have support for A, B, and Z inputs, the behavior you are looking for is essentially how a counter output tasks works. Would it be sufficient to generate an output on every N pulses of your A signal (ignoring B and Z)?
If so, you can configure this with a single counter by making a simple change to the GenDigPulseTrain_Continuous example. The basic shipping example uses the CreatePulseChannelFrequency method. You would want to use the CreatePulseChannelTicks method instead to specify your high and low times in terms of ticks of the external signal (whichever PFI line the A output of your encoder is connected to). By default, the counter output will toggle between high and low in a manner corresponding to the number of high ticks and low ticks that you specify (e.g. you could configure the counter to output high for 2 ticks, and low for 98 ticks, giving a pulse every 100 ticks--2 is the minimum value for high or low ticks).
Best Regards,
04-12-2011 02:05 PM
Indeed , both your answers solved my problem.
So here follows a source code that works under Visual Basic 2005 (DotNet 2.0) on a PCI-6601 and 6602.
counter 0 does quadrature mesurement
counter 3 does décimation of encoder channel A - its output is used to trigger output waveforms.
counter 1 is a pulse for triggering a camera (camera input have a typical trigger latency of 50us, so pulse begins straight after counter 0 rises)
counter 2 is a pulse for triggering a strobe (because of camera's latency, the strobe is pulse 50us after counter 0 rises)
The sample code allows to adjust the decimation and also to simulate the encoder (counter 3 set to 2hz, 50hz and 120hz).
Tested on DAQ 8.0 and 9.0.17, WinXP pro and Windows 7
Unfortunately some part of the code is written in french.