10-08-2012 08:28 AM - edited 10-08-2012 08:29 AM
Hello World,
after 10 years of LabVIEW experience I'm totally lost.
This is my first project with DAQmx and I don't know how to handle it.
My setup: Windows7; LabVIEW 2012 DevSuite; X-Series USB-6366
My goal: Trigger the encoder value and 2 Analog Inputs
I would like to get one result for the encoder value and each of the two analog inputs for each change of the encoder value (not more!!! I don't want to sort a huge amount of data afterwards)
I've been able to configure it with the Measurement and Automation Explorer, but have no clue how to get this in a LabVIEW configuration.
All examples I could find are reading the analog Inputs and the Encoder with SampleClock. That's not what I'm looking for.
I would greatly appreciate if someone could guide me to my solution.
I've attached the exported confiuration of the Measurement and Automation Explorer.
Thanks in advance, best regards,
Balze
P.S.: Sorry I had to ZIP the *.nce file, because NI doesn't allow to attach *.nce files
Solved! Go to Solution.
10-09-2012 08:57 AM
Hi Balze,
thanks for your good description of your application. A big advantage is the X-Series Card in your case. This card allows retriggering of Analog Input.
Basically you have two options, to measure AI if the encoder value is changing.
1. Selecting external hardware clock for analog input, using Counter Input as clock
So you can use the Counter Source terminal as Hardware clock. Please be aware in DAQmx Timing vi, choose in context menu I/O filtering and allow advanced
terminal, so you are able to choose the Counter Source as terminal
If you select the Encoder Input signal as hardware clock for the analog Input, be aware of Nyquist Theorem. So the clock puls has to be at least 2 times faster than the AI.
2. Trigger source Counter Input
You can use the onboard AI clock as hardware clock for the AI and implement also a trigger.vi. On trigger.vi you have to select digital trigger and using Counter Input as source of the trigger.
Don't forget to use the retriggerable property node.
In general please keep in mind to start the Counter task before the AI task, therefore check the examples of synchronization to get an idea how to synchronize parallel tasks.
Kind regards,
RupiDo,
NIG, AE
10-09-2012 12:06 PM
I'm assuming you have a quad encoder with at least an A & B channel, right?
The best way I know of to do this is to configure a Digital Input task using "Change Detection" for the Sample Clock type. Specify both rising and falling edges for both A & B channels. Set the Digital task to "allow buffer overwrites" so you can just let it run without needing to read digital data from it.
Also configure your AI and Counter tasks to use the Digital task's "Change Detect Event" as their sample clock signal. I would aim to use the *trailing* edge of the change event as the sample clock to be sure that the count value will have incremented/decremented before sampling.
Start the AI and Counter tasks before the DI task so they're both ready for the first detected change. That's about it in a nutshell. Search for variations of "quadrature", "encoder", "change detection" for more threads & maybe examples here on ni.com
-Kevin P.
10-10-2012 03:47 AM
Hi RupiDo, hi Kevin P.
thank you for your effort and your willingness to help me. I aprreciate it!
@ RupiDo:
I'm aware of the DAQmx Timing.vi but where do I find I/O filtering (which context menue?)
DAQmx is a Monster for me. It's for sure felxible and powerfull but how to configure it is not obvious for me. Also the dependencies are unclear to me. I tried things and get an error at run-time that this or that is not supported, reserved, ....
Nyquist Shannon doesn't matter very much for my task. I measure DC voltages with litlle changes. But thank you for pointing this out.
Retriggerable property node?? Where's that? (This maybe not obvious for me, because it's a german LabVIEW I've got to work with)
@ Kevin P.:
Yes, it's a quad-encoder with A,B and Z but Z is still unused (and will be unused for now)
I've got similar problems to setup your solutions.
When I try to configure "Change Detection" I get error messages, that it's not supported. "allow buffer overwrites"??? I seached for it very thoroughly,but without success.
I looked at a lot of examples but always found solutions with buffered aquisition. I'm already willing to use buffered aquisition, but I even can't setup this.
I FEEL SO STUPID Over 10 years LabVIEW experience and the first DAQmx project let's me stumble.
I tried a buffered aquisition based on an NI example. But it only works for one analog input channel. The other brings up en error (-50103). Which one of the two analog channels brings the error is randomly.
Maybe someone could explain me, what leads to this error, that I could start understanding DAQmx.
I've attached the VI (LV2012) and screenshots of the frontpanel and the blockdiagram.
Thanks in advance, best regards
Balze
10-10-2012 09:45 AM
You'll get there, but yeah, very first exposure to DAQmx is probably a bit overwhelming. Here are a few more tips based on your screenshot (I'm on LV2010 & can't open code).
1. "allow buffer overwrites" is a functional description but is not the actual text. It's found under the DAQmx Read Property node and should be configured before starting the task. Here's a snippet:
2. There's usually (if not always) only one timing system available to use for any/all AI channels in a hardware-timed task. As a consequence, all AI channels must be included in a single task. You can easily do this by chaining your two "DAQmx Create Virtual Channel" call via both the task output/input and the error output/input. Because the second call will receive a task refnum as an input, it will configure the 2nd AI channel to be part of the same task.
(It's possible to simply specify multiple channels in a single call, but separate calls gives you the ability to configure different scaling or input ranges.)
3. The "randomness" of which AI task gave you the error is due to the lack of sequencing in your attempts to start the tasks. The question of which one is the lucky successful one that happens to execute first can (and did) vary from run to run. By combining the two AI channels into a single task, this problem will go away, but you still want to be sure that both the AI and Counter tasks are started *before* any clock signals come in at PFI8.
4. "Change Detection" would only be available for Digital Input tasks, not counter tasks. And it's also generally only supported for one digital port worth of bits. The other ports then only support software-timed on-demand data acq. I'm guessing one of these issues is the source of your error.
On the M-series boards I've used, change detection was supported only on port 0 -- I suspect the same will be true for X-series boards. The following snippet ran without error for me using a simulated X-series device. Selecting a different port gave an error.
10-12-2012 02:02 AM
Hello Kevin,
thank you very much for your detailed description.
I've to get familiar with DAQmx, because we are going to use NI hardware in future.
regarding 1.
I'll check what Overwrite is used for and will give it a try.
regarding 2.
That is what i expected, but didn't know how to reach this. (In fact I only used PFI8 for timing)
Using the Output of on virtual channel as Input for the second virtual channel was the "missing link". Now it works as expected.
regarding 3.
Yes, the reason of randomness has been clear to me. (+10 years LabVIEW taught me 🙂 The reason for failing wasn't.
regarding 4.
OK, I understand now. I'll try this later.
Again thank you very much for your effort and support.
Best regards
Balze