Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Rotary encoder help and verification

Hi all.

I have a motor whereby i need to test its torque and its rotation. The basic operation is that when the motor starts running, the torque transducer and encoder starts measuring together, and when the encoder detects a full rev, everything stops.

For the rotary encoder, i need to read its direction and stop acquisition where it completes a full revolution. I do not have any hardware for me to test yet but i would like to start with the programming of LV first due to timing constraints. I've been reading relevant posts here and examples in LV and i've attached the screenshot of my VI and the task setting in MAX. What i've done is that i've created a task that will read the Ch A, Ch B and Ch I from my encoder. Based on what's depicted in MAX, it seems like i can connect A to the PFI8, pin B to PFI10 pin and I to PFI9 pin.

How should i set:
1) Phase for Z index?
(If i got this correctly from the datasheet of the encoder Ch I would be high for every 1/4 of rev, thus for 1 full rev i should get 4 counts at Ch I right? Based on page 2-93 on the encoder datasheet A and B would be low when I is HIGH, but how do i accomplish detecting a full rev?)

2) Clock settings?
(I guessing it should be referenced to the frequency of the A, B and I signals but i can't seem to find these data from the datasheet)

3) Advanced clock settings?

And for the VI, did i set it up right? I realise the output from the DAQmx READ vi is a dbl array, would that be the position of the encoder or angle in degrees?
0 Kudos
Message 1 of 13
(4,861 Views)
I'm using a PCI6221 DAQ card, connected to a SCC-68 connector block (SCC modules is used in other functions)

Message Edited by ATMA on 08-14-2007 10:57 PM

0 Kudos
Message 2 of 13
(4,858 Views)
Have a look at this knowledge base: http://zone.ni.com/devzone/cda/tut/p/id/4623
0 Kudos
Message 3 of 13
(4,843 Views)
 Hi ATMA,

  1. I read the timing diagram as saying that for every 360 degrees of revolution, channel I will be high for 90 degrees. You can see that when
       A & B are low then I is high. The task setting should be A low B low, not A high B high.

  2. Clock rate will be determined in large part by how fast of a position change you expect to see from the encoder. You would want the fastest clock source that you have access to, there
      is a 80 Mhz timebase available on the M-series...

  3. It appears the VI is setup correctly other than the task setting I mentioned above. Also, look at the Counter Measurements examples for more information on
    Quadrature Encoder tasks.. And the link that Brian B. posted is very informative.

Please post back if you have more questions.

 Best regards,

 MatthewW
 Applications Engineer
 National Instruments

 
 
 

0 Kudos
Message 4 of 13
(4,828 Views)
Brian, the link you gave me was great, thanks.


Matthew, i've tried fixing up the encoder with a temporary shaft and made the necessary connections and pull ups. I tried connecting only channal A to my scope and i see pulses when i turn the shaft, which means that it should be working fine. But when i connect it directly to the DAQ card and try testing it with the TEST option in MAX, i don't seem to get any output.

I think it might be the Advanced Clock Settings which is causing the problem because the Clock Type is set to External Clock Source. How do i set this option so that it uses the internal clock? Under the Clock Source section i can only see all the PFI pins, RTSI pins, ai/StartTrigger, ai/ReferenceTrigger and PairedCtrInternalOutput.
0 Kudos
Message 5 of 13
(4,814 Views)
I tried the Measure Angular Position.vi example, can't work also.

If i'm correct i should be getting 0 1 2 3 counting upwards if i turn 1 direction and 3 2 1 so on counting downwards if i turn the other way right?

Am i missing something?
0 Kudos
Message 6 of 13
(4,811 Views)
Hi guys, after i fixed up the GND of the encoder to the D GND of the DAQ card i managed to get an numeric output using the 'Measure Angular Position.vi'. But strangely even i disconnect this gnd connection i still get an output from the VI numeric display, is there a reason for that?

Secondly, how do i extract the Z index data? So that i can recieve an input when the shaft turns 1 rev?
0 Kudos
Message 7 of 13
(4,807 Views)
 
 Hi ATMA,

 Here is a link that shows how to connect the encoder to your counter. I would advise checking your connections one more time and be sure the physical connections are all correct.

 You are correct, the encoder should increment in one direction, decrement in the other direction.

 If you look at the Measure Angular Position example, you'll see that you tell the VI how many pulses per revolution, the phase relationship and the Z-index value.
   The pulses per revolution are used to determine when Z-index should go high.
   The phase relationship determines when to allow Z-index to go high.
   The Z-index value is what value will be loaded with when Z-index goes high.

 Here is another forum posting that re-states these same concepts.

 If you want different behaviour when Z-index pulses, such as using that as a input to your program. You might consider setting up a second counter as a finite pulse train generation, retriggerable. Use the Z-index pulse to fire off a long pulse that you use as a event trigger. Here's a forum post where they discuss this type of concept.

I hope this helps! Have a great afternoon.

 Best regards,

 MatthewW
 Applications Engineer
National Instruments



 

 

 

0 Kudos
Message 8 of 13
(4,788 Views)
Hi guys, sorry for the late reply. I was out for a couple of days.

Thanks Matthew, the links were great. But as i read on i realized maybe for my application i do not need to use the Z input after all. Because my objective is to have the encoder stop counting when it hits 360 and stop all acquisition and motor. I should be able to acheive that by having a Case structure inside the for loop and trigger a STOP when then encoder output hits 360 correct?

Second thing, there are 3 types of decoding methods X1, X2 and X4 and based on what i read X4 is more sensitive to position but susceptible to incorrect measurements. My question is, all these 3 increments and decrements differently, would i still get a 360 or -360 after 1 revolution? What would be a better choice? Because when i try turning the shaft with my hand i seem to get pretty irregular numeric outputs, for example it would be counting up then suddenly would count downward again before resuming upward counting and by then i would have already turned 2 or 3 revs already. Is this because i'm turning this by hand? or the decoding method i've chosen? (the same thing seems to apply to all types)


Message Edited by ATMA on 08-21-2007 10:47 PM

0 Kudos
Message 9 of 13
(4,769 Views)
And just to verify i've got the settings correct. Based on the datasheet page 2-101, since i'm using the HEDS-5540A#06, based on my resolution (cycles/rev) is 500 so i should key in the same value for my Pulse/Rev  in my MAX settings correct?
0 Kudos
Message 10 of 13
(4,764 Views)