LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using DAQmx_Val_ChangeDetectionEvent as a sample clock

I'm tryingto use the DAQmx_Val_ChangeDetectionEvent as the sample clock for some Analog Inputs and an Encoder. I believe I can use the event by routing it to the OnboardClock alias via the following code:

    DAQmxExportSignal (
        changeDetectTaskHandle,
        DAQmx_Val_ChangeDetectionEvent,
        "OnboardClock");            

Where the "OnboardClock" is an alias for the terminal within a device where the default source for a clock can be found.

Is this correct or have I totaly lost the plot ? If so then how do I use the ChangeDetectionEvent as a sample clock without having to register a callback and use software reads ? The latter would have serious timing implications on my intended goal.

Many thanks in advance for any help you can offer.

Cheers, Shaun.
0 Kudos
Message 1 of 18
(5,516 Views)
Bump! Coudl anyone perhapps take a couple of seconds to answer the above question ?

Many thanks in advance.
0 Kudos
Message 2 of 18
(5,498 Views)
Hi Shaun,

I don't think that routing DAQmx_Val_ChangeDetectionEvent to the OnboardClock is going to work. The OnboardClock is the default hardware regulated clock and may even be used to generate the DAQmx_Val_ChangeDetectionEvent itself, so we may have to find another solution to your problem.

I you are able to provide a broader description of your application I will endeavour to suggest a suitable solution for you.

Kind Regards,

Ian C.
Applications Engineer
National Instruments UK
0 Kudos
Message 3 of 18
(5,493 Views)
Hi Ian,

Thanks for picking up the gauntlett. I posted a sumamry of our goal in this post: http://forums.ni.com/ni/board/message?board.id=180&message.id=31831 but will present an overview of it here.
1. Connect a Quad Angle Encoder to Counter 0 and configure it for angular position measurement
2. Connect the A and B lines of a Quad Angle Encoder to Digital Input Port 0, lines 0 and 1.
3. Configure the Digital Input task for change detection.
4. Route the ChangeDetectionEvent to a connection where its trailing edge can be used as the sample clock for 6 Analogue Inputs
5. Route the ChangeDetectionEvent to a connection where its trailing edge can be used as the sample clock for Counter 0 (see 1 above)
6. Route the ChangeDetectionEvent to the GATE input of Counter 1 and configure it for Buffered Event Counting with a suitable clock (80Mhz) connected to SOURCE input.

Our goal is to sample the 6 Analog Inputs only on every movement of the angle encoder - hence the use of the ChangeDetectionEvent. The Buffered Event Counter allows us to effectively timestamp these samples. The end result should allow us to obtain angular stamp and time stamp for AI values sampled at every encoder movement.

However, the DAQmx and DAQmx C Ref docs are a bit scantily clad. I therefore need to know how to route the ChangeDetectEvent to achieve points 4, 5 and 6 above.

One other task we would like to achieve is to use the Z-Index of the Encoder to reset the BufferedEventCounter to Zero.

The DAQ card we are using is a PXI-6259 M series.

Thanks in advance for any help you might be able to provide.

Cheers, Shaun.



Message Edited by steorn on 10-18-2007 06:16 AM

0 Kudos
Message 4 of 18
(5,483 Views)

Hi Shaun,

I have nearly finished outlining a solution to your problem. Before I post though, do you want to create a value change event on the falling edge of the A output of the encoder (Port 0, Bit 0), the B output of the encoder (Port 0, Bit 1), or both A & B?

Thanks,

Ian

0 Kudos
Message 5 of 18
(5,475 Views)
Hi Ian,

Thanks for getting back to me so quickly. In the long term we would make this a GUI input choice but for now we would like to run with both A and B rising and falling as I believe thats the only way we can get quad pulses. But hey, if you could even reveal a solution for just A rising then that would surely help.

I've been running some tests here myself but i'm having difficulty configuring the timestamp counter (CTR1). I'm trying to route the Change Detection Event to GATE (PFI4) and 80MHz Internal Timebase to SOURCE (PFI3) but no joy so far 😞

Thanks again for your help on this.

Cheers, Shaun.
0 Kudos
Message 6 of 18
(5,473 Views)
Hi Ian,

Any update on the solution you had in mind ?

Thanks in advance, Shaun.
0 Kudos
Message 7 of 18
(5,439 Views)

Hi Shaun,

Here is an outline of my proposed alternative solution:

  • Hardwire the encoder to Counter 0. Use Counter 0 as a position measurement (as before)
  • Hardwire the encoder to Counter 1. Use Counter 1 at 80MHz to record the time of an encoder pulse by physically wiring the encoder to the counter input (rather than counting an internally routed event)
  • Hardwire the encoder to PFI0 (trigger input). Configure the trigger input as the sample clock for your analogue acquisition.

This would effectively mean:

  • Counter 0 would measure position

  • Counter 1 would record the times that your samples are acquired

  • Your encoder would be acting as an external sample clock for analogue input

Would this satisfy your goal? I am unsure as to your level of experience with LabWindows/CVI so just let me know if you need help implementing this alternative approach.

Kind Regards,

Ian C.

0 Kudos
Message 8 of 18
(5,435 Views)
Hi Ian,

Thanks for outlining your solution, your suggestions do indeed make sense. I do have a couple of questions though, more for learning than anything else:


>>Hardwire the encoder to Counter 1. Use Counter 1 at 80MHz to record the time of an encoder pulse by physically wiring the encoder to the counter input (rather than counting an internally routed event)

Firstly, if the Encoder is wired to Counter 1 then it will be connected as follows:
A: PFI 3
B: PFI 11
Z: PFI 4
So how do I connect the on onboard 80MHz signal and instruct it to count the 80Mhz pulses between each encoder pulse ? I have read so much on the forums regarding this but it still is not clear to me, I have also looked at the sample code that came with CVI but to no avail.

Secondly, is hardwiring better than using the ChangeDetectionEvent ? I mean if I route the ChangeDetectionEvent from Counter 0 to Counter 1 Gate (PFI4) and route the 80MHz clock to Counter 1 Source (PFI3) then surely i'm achieving the same thing (or at least I would be if I could actually route the 80MHz clock to PFI3, unfortunately all attempts to do this throw an error because I believe I'm not doing it correctly).


>>Hardwire the encoder to PFI0 (trigger input). Configure the trigger input as the sample clock for your analogue acquisition.
Do you mean wire A to PFI0/Port0 and B to PFI0/Port1 and then use both rising and falling edge detection to create the sample pulse ?

Again I find the documentation very "vague" in most of these matters and as such cannot see the wood for the trees.

Sorry to have to ask you to spell it out to me 😞

Cheers, Shaun.



0 Kudos
Message 9 of 18
(5,429 Views)

Hi Steve,

Don’t worry I’m more than happy to help as much as you require and I’m here to do so. I’ve elaborated on what I’ve said in the following bullet points. Perform a search in CVI help on any of the following functions that you are unfamiliar with:

·         You can use the DAQmxCreateCIAngEncoderChan function on counter 0 to detect your angle. This doesn’t produce a ChangeDetectionEvent, hence all the hardwiring.

·         You can use the DAQmxCfgChangeDetectionTiming to configure the timing of your analogue input acquisition to acquire upon each rising and or falling edge of whatever triggering inputs you require.

The timing is somewhat trickier, how accurate do you want your time stamping to be? In an earlier post you referred to time stamping.  CNVGetTimestampInfo returns a stamp to the nearest second, but I assume you require millisecond accuracy or greater?

Many Thanks,

Ian

0 Kudos
Message 10 of 18
(5,419 Views)