Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx - trigger based on AB encoder ??

Hello all,

I need to generate a pulse to trig a camera every 2° rotation of a motor. I have Rotative AB encoder (16000 pulses for 360°).

Can someone tell me how to setup a trigger to generate continuous pulses based on every 89 encoder pulses. I am using the quadrature input instead of the simple pulse with edge counting to eliminate any issue of vibrations causing the encoder to move backwards a few ticks.

Thanks for help

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 1 of 16
(5,353 Views)
TiTou,

Sorry for the delay in posting... I've been meaning to test this out with hardware before I suggested it. The only way the DAQmx driver exposes the functionality to do what you want is to use an angular encoder task (or a linear encoder, i guess) with Z index enabled. If you preload the value of the initial angle and set the Z index value intelligently, you can put the count register within a certain number of binary values of the terminal count. Use the CI.Count DAQmx Channel property node to verify the value of the count register - the Counter Read will return scaled data. Then, you'll need to set the internal output of the counter to pulse on the terminal count. You can then feed this signal back (either internally or externally) to the Z index input of the counter. This way, the counter will begin counting (with quadrature inputs) until it reaches the terminal count. Upon the terminal count pulse, you will reset the value of the count register and begin the process again. It is the counter output signal that you will use as your trigger. Of course, if your counter starts counting down instead of up, it will be a long time before you get that pulse. This will also depend on the details of your encoder (as to how to set your Z index phase). You also wont be able to get valid values from your counter read - you'll have to use another counter if you want to do that. Anyway, please let us know your results! Also, let me know if you have any questions about the process.

Regards,

Message Edited by Voltage Viper [DE] on 03-21-2006 05:03 PM

Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
Message 2 of 16
(5,301 Views)

Hello Voltage Viper [DE],

I have a related question. I'm using a counter of a PCI-6229 configured as an angular encoder with X4 mode. I would like to trig an AI measurement on every change of this position counter. Is there a way to route this "virtual output signal" of the counter to a PFI line or to use it internally ?

Many thanks in advance

0 Kudos
Message 3 of 16
(5,286 Views)
Hello Ryan,

I also apologize for the delay in replying.

I've been trying to "put your solution into code" with no success. The point is that I don't really understand the idea of your solution and also I am not familiar to the DAQmx vocabulary... this results in a total mess in my mind.

I pointed the parts that are not clear for me...

Voltage Viper [DE] a écrit:

If you preload the value of the initial angle and set the Z index value intelligently, you can put the count register within a certain number of binary values of the terminal count. Use the CI.Count DAQmx Channel property node to verify the value of the count register - the Counter Read will return scaled data. Then, you'll need to set the internal output of the counter to pulse on the terminal count. You can then feed this signal back (either internally or externally) to the Z index input of the counter. This way, the counter will begin counting (with quadrature inputs) until it reaches the terminal count. Upon the terminal count pulse, you will reset the value of the count register and begin the process again.


I now understand that your idea is to enable the Z index and feed it with a signal that counts input pulses, but the way to code that is not clear for me. Some code would really help me to go passed this issue.

I really appriciate your help.



We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 4 of 16
(5,270 Views)
JB,

After scratching my head a bit, I can't think of a single way to do what you want. You may be limited to only sampling on one of the edges of one of your phases. Of course, this would give you only a quarter of the resolution of sampling on both rising and falling edges of both phases. Adding a single external IC to perform an XOR of your A and B signals could double this resolution. And I suppose you could add more circuitry to pulse on both the rising and falling edges of this XORed signal, giving you the resolution you desire. Would this be an option? If you get something working, please let us know!

Hope this helps,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
Message 5 of 16
(5,258 Views)
JB,

I just thought of something... You could wire the same signals into your M Series' digital lines and run a change detection task. You could then route the change detection event to your AI sample clock. This should give you the behavior you desire. Please post back if you need help implementing this.

Regards,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
Message 6 of 16
(5,255 Views)
TiTou,

I have not checked this in hardware, but this should be about what you want. It should theoretically pulse the output line every N full periods of A and B. You'll have to change it up a bit if you want better resolution than that. Some of the constants may be a bit off due to the details of the coercion of the encoder angle to actual counter values. I would set up your hardware and play with it. You should be able to monitor the value of the count register and the state of the counter output with the indicators on the front panel. Please let me know if you have any questions.

Regards,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
Message 7 of 16
(5,262 Views)
Thanks a lor for the code, that makes things clearer for me.

I will try it out and let you know.

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 8 of 16
(5,255 Views)
Ryan,

In the end we chose to make it a bit different. The AB encoder signal goes to the DAQ board, a simple divisor in DAQmx sends the triggers to the IMAQ board to trig the camera. That makes the settings easier for us since we can visualize  the signal on a scope a every stage.
Meanwhile I will keep the code+ideas you kindly sent for the futur because I really have to develop my skills in DAQmx.

Thanks again for your help.

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 9 of 16
(5,227 Views)
TiTou,

Could you elaborate a bit on how you were able to implement a divisor in DAQmx? Was this software-timed? Did you maintain quadrature inputs?

Thanks!
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 10 of 16
(5,217 Views)