05-01-2007 10:11 AM
05-02-2007 05:39 PM - edited 05-02-2007 05:39 PM
Hi Chris,
If you want ticks you could set up your encoder task like so:
myTask.CIChannels.CreateAngularEncoderChannel(counterComboBox.Text, _
"", encoderType, zIndexEnable, zIndexValue, encoderPhase, pulsePerRev, _0.0, CIAngularEncoderUnits.Ticks)If you use degrees, it will take the 20,000 as the pulse per revolution and calulate that each tick is 360/20000, and return the resulting degrees. If you want the counter readings to be correlated with your AI samples, you're going to need to find a way to share some timing signals between the AI card (6052e) and the counter (6602). If you're in a PXI system, you can just share over the backplane. If you're in a PC, you'll need a RTSI cable, or a trigger to start both acquisitions off of. There are a few options.
With PXI/RTSI, you can use the AI sample clock from the 6052E as the sample clock source for the angular position measurement. For each AI sample, you will get the position. You may not be able to do buffered event counting at 333 kHz - the counter input has a tiny buffer and probably will not be able to run at that rate. You may have to tweak the acquistion rate.
Depending on how tight of synchronization you need, instead of using a RTSI connector you could use a start trigger and start both acquistions (AI and CI). For the counter, you would want to use an arm start trigger -
myTask.Triggers.ArmStartTrigger.ConfigureDigitalEdgeTrigger(source, DigitalEdgeArmStartTriggerEdge.Rising);
For the AI you would just use a start trigger - check out the ContAcqVoltageSamples_ExtClkDigStart example, but specify the onboard clock (for some reason we dont have an internal clock example). This would start both acquisitions at the same time. This would give you the advantage of being able to control the Counter's clock independent of the AI sample clock. You could use another counter to generate a pulse train at a divide down of the AI sample clock - so for every 10th or 4th ai samples you would get a position measurement. This would be good synchronization, but the trigger delays could introduce a little bit of constant delay.Hope this helps,
Andrew S
Message Edited by stilly32 on 05-02-2007 05:42 PM
05-04-2007 02:36 PM
05-07-2007 06:39 PM - edited 05-07-2007 06:39 PM
Hi,
In resonse to some of your questions:
"...I wasn't getting the values back out of the Counter Input that match my 20000 ppr. So I didn't trust the reading." - what kind of reading were you getting? If you use the Angular position example clocked with the pulse train generation example and move your encoder half a turn, what value do you read? One thing to note, if you're using X4 encoding and read in ticks, the reading will be 4 times what you would expect.
"I am not sure I understand how to set up the counter channel to generate a pulse that will syncronize up everything so that I can determine what is happening at a specific point in time." - You just need to generate a continuous pulse train. This pulse train will be used as a clock, for both your AI and your counter reads. One thing to note, you should start both the AI task and the Counter Input Task before you start the counter generation task (clock). That way, both tasks are waiting on the clocking signal before they start acquiring. If you use a shared clocking signal like this, you don't need to worry about triggers - both will wait on the clock so this will simplify your code.
Please try this and post back.
Andrew S
Message Edited by stilly32 on 05-07-2007 06:40 PM
05-08-2007 06:28 PM
05-10-2007 03:34 PM
myTask.COChannels.All.PulseFrequency = 5000
05-10-2007 05:11 PM
05-11-2007 03:06 PM
Hi,
For error 200251, check out this KB - Error -200251, No DMA Channels Available, When Using Multiple Counters. You can find this by searching for "200251" from www.ni.com.
For the rest of these:
When I finish a test, should I stop the tasks, before I stop the pulse generator, does it matter? - You'll want to stop the acquisitions before your clock, otherwise you'll stop latching in values, which can result in error 200284.
Should I be using continioussamples as the sample quality mode? - If you don't know how many samples you want to acquire, you'll want to use continuous. If you have a predetermined set amount of samples you want, finite would be easiest.
If I configre an analog task and don't set the timing, I am assuming that it is using its internal clock, is that correct? Is that sycronized in any way to the counter card (I have a RTSI cable connecting the two cards and I can that both devices are connected in the max display). - If you don't configure timing at all, I believe it defaults to a 1 Khz rate with an internal clock. If you use the configure timing, set the rate and don't specify a source it will use the internal AI Sample clock.
For your starting postion, this should just be in terms of ticks. If your encoder has a Z index, you could also make use of that.
If I change the freq of the pulse generation, do I need to modify the timing rate of the other analog and counter input channels that also have the previous timing configuration? If not will I start missing samples? - You don't need to change the rate and you won't miss samples. When using an external clock (a clock other than the AI sample clock) you are effectivly onlt influencing the Buffer size. Check out the "How is Buffer Size Determined" section of the DAQmx Help for more info on this.
Yes, I like to know how to divide it properly - doesn't seem like I get get much faster than 1000 freq and 1000 samples per second otherwise.
The easiest way to do this is to use the AI sample clock for the AI task. For the counter task, use a divide down of the AI Sample clock as the clock for the Counter input. The Divide down is generated from another counter output task. For example, from the counter generation example that we've been using, create a ticks channel instead of a frequency channel:
myTask.COChannels.CreatePulseChannelTicks()
and use the AI Sample clock as the "Source Terminal" - this will get automatically routed across the RTSI line. The Ticks will control how large the divide down is.Hope this helps,
Andrew S
05-14-2007 12:01 PM
05-17-2007 02:29 PM - edited 05-17-2007 02:29 PM
Hi,
You can change the transfer method to IRQ in .NET - check out some of the links in the KB I referenced.
Signals are not synchronized across the RTSI cable unless you explicitly route them - ie use AI sample Clock from your MIO card as the source on a counter task on your 6601.
Z channel will give you the zero point on your encoder. If you specify the "initialAngle" in your create counter task, the units should be in the units you specify (ticks or degrees). So I have a 24 ppr encoder. I give it an initial angle of 12, and my units are in ticks. Any movement on the encoder counts up/down from that position. What behavior are you seeing?
You would need to use a counter to divide down your AI sample clock, just as you are using a counter to generate a clock for both right now.
Andrew S
Message Edited by stilly32 on 05-17-2007 02:30 PM