06-19-2006 03:59 AM
06-19-2006 09:35 AM
Can the motor's direction change? If so, what behavior would you want when the motor goes 18 steps in one direction, then 22 more in the other direction:
1. Generate "event" every 10 steps regardless of direction. This places events at positions 10, 16, 6, and -4.
2. Generate "event" at absolute positions that are multiples of 10. This places events at positions 10, 10, and 0. The # of steps between events would be 10, 16, 10.
If behavior #1 is acceptable, you could simply set up a counter to generate a continuous pulsetrain. Use the step signal as an external Source (timebase) signal with a total pulse period (low time plus high time) set to 10 Ticks. All this will happen in hardware so you don't need to worry about software polling, etc.
Method #2 probably can't be done in hardware with your board.
Method #1 should also be fine if direction doesn't need to change.
-Kevin P.
06-20-2006 03:42 AM - edited 06-20-2006 03:42 AM
Message Edited by anhd on 06-20-2006 03:43 AM
06-20-2006 09:50 AM
Is there any better way to do this acquistion without running it in a while loop with all the start-task und stop-task vi's?
But I don't know how to "sample" the counter-value at 10 MS/s giving me an array of 10 million counter-values...
1. Yes, there is definitely a better way. The classic approach that lets the hardware do the work is to configure and start the task 1 time before entering the loop and stop and clear the task 1 time after exiting the loop. Inside the loop, I prefer an approach a little different than what most of NI's examples show.
The NI examples will call DAQmx Read asking for some fairly large # of samples. The loop must then stop and wait for that # of samples to accumulate. If they don't accumulate within the specified timeout period, you'll get a timeout error which is often wired to cause the loop to terminate.
I prefer to first query a DAQmx Read property node for the # of samples available. This will return a value immediately with no risk of a timeout error. My code can then easily decide whether to read them or wait a bit longer for more samples to accumulate. There are some other methods too such as specifying # to read == -1. This returns all available samples, whatever the # happens to be.
2. Counter values can definitely be sampled in sync with analog acquisition, but not in the MHz range. The available speed is system-dependent, but seems to top out in the 100's of kHz. The main reason is simply that the data acq board's hardware data buffer for counters is very very small while the one for analog acq is relatively large. While trying to transfer data across the PCI bus, the counter tasks have very little tolerance for missed opportunities.
Also, I *think* that perhaps you're mixing up the meaning of "trigger" and "sampling clock". If you want to take a sample of 1+ analog channel EVERY 2 msec based on a ~500 Hz pulse train, you need to treat that pulse train as a "sampling clock" not a "trigger." There are shipping examples that use the abbreviation "Ext Clk" or similar to denote that the sampling clock is an external signal.
-Kevin P.
06-21-2006 03:02 AM - edited 06-21-2006 03:02 AM
@nope, i need the signal as some kind of trigger, as i don't want a single sample every 2 msescs, but to start sampling 50 samples @ 2,5 MS/s every 2 msecs.
@Kevin Price wrote:Also, I *think* that perhaps you're mixing up the meaning of "trigger" and "sampling clock". If you want to take a sample of 1+ analog channel EVERY 2 msec based on a ~500 Hz pulse train, you need to treat that pulse train as a "sampling clock" not a "trigger." There are shipping examples that use the abbreviation "Ext Clk" or similar to denote that the sampling clock is an external signal.
-Kevin P.
Thanks for your time again.
Message Edited by anhd on 06-21-2006 03:09 AM
06-21-2006 10:09 AM