12-05-2005 10:55 AM
12-06-2005 08:43 AM
Two different thoughts for you. I'm not at my LabVIEW pc now and haven't used the DAQ assistant, but do know the 6602 pretty well.
1. For debugging, try setting up the task so that there is no buffering. This may be called something like "on-demand" sampling. Whatever the name, the operation will be that the counter always increments/decrements with encoder position. Each time you call DAQmx Read, you'll get a snapshot of the instantaneous position.
2. When you need to return to continuous sampling, you'll need to create your own sampling clock with one of the other counters. I'm sure you could set this up with DAQ assistant. You may just need to carefully note the PFI pin # for that counter's output so you can use it as the sampling clock when you configure your buffered encoder task.
05-21-2007 01:43 PM
05-22-2007 09:07 AM
1. First understand that counter tasks are fundamentally different than analog or digital sampling tasks. Each counter has a count register that will increment / decrement according to the hardware signals coming in from the encoders. The count register will readily handle encoder pulse rates of 1 MHz.
2. Performing "sampling" is a matter of storing that count register value to RAM so your app can later read it. The sampling rate will likely be much slower than 1 MHz, but that does NOT mean that counts are being missed. The count register happily keeps incrementing and decrementing in between samples so you aren't going to lose track of position.
3. You 'll need to learn a bit about DMA vs. interrupts for data acq because you can only sample 3 encoders with high-speed DMA. The others will need to use interrupts, which will be much slower. (Or, use 2 6602 cards to get a total of 6 encoder tasks using DMA).
4. So far you talk about a software loop that reads values. Maybe that means you don't need the precision of hardware sampling or maybe it means that you just don't yet know how to achieve it. To get hardware sampling, you would generate a pulsetrain with 1 counter and configure your 6 encoder tasks to use that counter's output as their sampling clock. You should be sure to start the 6 encoder tasks *before* you start the pulsetrain to make sure the readings will be sync'ed.
5. Using 1 card with 3 DMA tasks and 3 interrupt tasks, you shouldn't count on achieving sample rates above a few kHz.
Spend some time looking at the shipping examples and the ni.com "Developer Zone" for more examples, tutorials, app notes. There's a bit of a learning curve getting used to encoder and counter measurements.
-Kevin P.
05-22-2007 04:23 PM
05-22-2007 10:34 PM
05-23-2007 08:54 AM - edited 05-23-2007 08:54 AM
Message Edited by josef_slg on 05-23-2007 08:55 AM
Message Edited by josef_slg on 05-23-2007 08:58 AM
05-23-2007 09:16 AM
05-23-2007 10:21 AM
I don't have an LV machine available near my network PC and have only been able to look at the screenshots. To be perfectly frank, I see far too many issues to address and tutor individually with the limited time I have. As friendly advice, I would *strongly* recommend backing up several steps and first make an app that works with 1 encoder. Once you get through that part of the learning curve, *then* add the other encoder channels to your app. Then my prior post about DMA and interrupts will become relevant again.
Other things:
1. I really, *really*, think you've got the wrong idea about how the counters measure encoder signals. You do NOT need to sample at 2x the encoder pulse rate, the Nyquist theorem does NOT apply here. The hardware count register tracks encoder position accurately with your 400 kHz encoder signals. Your app is free to choose how often to sample that count register according to your needs. This may be anywhere from 1 Hz or less to several kHz. It does NOT need to approach 1 MHz and even if you tried, the system is almost certain to be incapable of such a rate.
2. After all the talk about sampling at 1 MHz, you have a software loop that reads 1 single value at a time from each encoder and has a timer to run it only once every 10 msec. There is a *very* fundamental disconnect here. (It also appears that you have optional file writes inside the same loop, another factor that'll slow you down.)
3. The encoder readings are not hardware-sync'ed in time -- the first value read from each represents their positions at different points in time. With such high-precision encoders, I'd think you would need hardware sync on the read times.
Finally, why not give us an overall description of your app's needs? Kind of a big picture description. I know you've told us what you think the problems are, but I'd wager my NI screwdriver that the 1 MHz sampling rate you think is your main problem will turn out not to be relevant.
-Kevin P.
I don't have an LV machine available near my network PC and have only been able to look at the screenshots. To be perfectly frank, I see far too many issues to address and tutor individually with the limited time I have. As friendly advice, I would *strongly* recommend backing up several steps and first make an app that works with 1 encoder. Once you get through that part of the learning curve, *then* add the other encoder channels to your app. Then my prior post about DMA and interrupts will become relevant again.
Other things:
1. I really, *really*, think you've got the wrong idea about how the counters measure encoder signals. You do NOT need to sample at 2x the encoder pulse rate, the Nyquist theorem does NOT apply here. The hardware count register tracks encoder position accurately with your 400 kHz encoder signals. Your app is free to choose how often to sample that count register according to your needs. This may be anywhere from 1 Hz or less to several kHz. It does NOT need to approach 1 MHz and even if you tried, the system is almost certain to be incapable of such a rate.
2. After all the talk about sampling at 1 MHz, you have a software loop that reads 1 single value at a time from each encoder and has a timer to run it only once every 10 msec. There is a *very* fundamental disconnect here. (It also appears that you have optional file writes inside the same loop, another factor that'll slow you down.)
3. The encoder readings are not hardware-sync'ed in time -- the first value read from each represents their positions at different points in time. With such high-precision encoders, I'd think you would need hardware sync on the read times.
Finally, why not give us an overall description of your app's needs? Kind of a big picture description. I know you've told us what you think the problems are, but I'd wager my NI screwdriver that the 1 MHz sampling rate you think is your main problem will turn out not to be relevant.
-Kevin P.
05-23-2007 10:52 AM - edited 05-23-2007 10:52 AM
Message Edited by josef_slg on 05-23-2007 10:57 AM