08-23-2010 01:02 PM
HI, I am connecting quadrature encoder to USB 6229 DAQ, I am connecting CH A to PFI 0/P1.0 or pin 73 and PFI 0/p1.1 or pin 74 and I am setting them up as a counter read or counter in. The DAQ USB6229 is not reading these signals as a counter. How would I read the the counts of a quadrature encoder using DAQ 6229.
Regads;
JH
Solved! Go to Solution.
08-24-2010 01:49 PM
You mention two different tasks here. The first is a simple count edges task, which will simply increment a counter every time it receives a pulse. It will not take into consideration that you have quadrature encoder, and that it could go backwards and countdown. It also only counts one line (ctr0 source, pfi 8, pin 81).
For an example of this, look in the example finder (Help » Find Examples) and browse to
Hardware Input and Output » DAQmx » Counter Measurements » Count Digital Events » Count Digital Events.vi
However, I believe what you actually want is position from your quadrature encoder. For this we don't want to do an Count Edges task, but rather an Angular (or linear) Position task. It will still return the position in number of ticks, but the number of quadrature ticks, not just one channel, and will also decrement if going backwards.
An example program for this is also found in the example finder under:
Hardware Input and Output » DAQmx » Counter Measurements » Position » Measure Angular Position.vi
You will have to have your A channel connected to PFI 8, pin 81 (ctr0 Source) and channel B connected to PFI 10, pin 85(ctr0 Aux)
The correlation is found for the USB-6229 in the M Series User Manual on page A-53, A-52 has the pinouts.
We know that for an Angular Position Task, we want ch A in the Source and ch B to be in the Aux from the NI-DAQmx Help File. Browse in the Contents tab to NI-DAQmx Device Considerations»Conters»Counter Signal Connections»68-Pin M Series
Which specifies A goes to PFI 8, B goes to PFI 10, and Z, if you use it, goes to PFI 9.
08-24-2010 08:55 PM
Thanks Eric,
I did run >>Measure Angular Position.vi>>, it is reading from the counter in both direction. It is reading too fast or big numbers. I would like to read one revolution, my counter has 256 counts per one revolution. How would I read 256 counts per revolution. Also my counter has two channels A and B only, no Z.
Regards;
JH
08-25-2010 04:26 PM
You set the number of pulses per revolution on the front panel of that example program. There is a numeric control on the front labeled "Pulses per Revolution" - place 256 in that box. The fact your encoder does not have a Z is fine, just keep the "Z Index Enable" button off.
What do you mean it's reading too fast / big numbers and that you want it to read one revolution?
08-25-2010 05:48 PM
Thanks Eric,
the count is big or fast, I meant it reads fast and big numbers in thousands and millions.
I did set the Pulses per revolution to 256. What does that tell me. If the real count of the counter is 300 counts, how would I know that this is a bad encoder. My assignment is to verify if the encoder is outputing 256 counts per revolution and would like Labview VI to read the actual count of the encoder and to displays it. This way, the person who tests the encoder can verify if the encoder is good or bad depending on the acutal count of the encoder. We had some cases where we were sent wrong encoders or encoder that has wrong wiring between CH A and CH B.
Regards;
JH
08-26-2010 11:30 AM
The fact that it's reading in the thousands and millions usually means there's noise on the signal that's being picked up as counts when it really should not be. To correct this we have to enable digital filtering:
See the example:
Use the Counter Digital Debounce Filter
and page 7-32 to 7-33 of the M Series User Manual for the more details of what a digital filter is and the different settings available for the 6229.
Enabling the filter will get rid of the very high frequency noise on the digital line and should get rid of the extremely high values and instead give a correct 256 counts / rev.
08-27-2010 02:23 PM
Thanks Eric, the encoder reading worked fine.
I only need to add one more function to it. To show me that if next reading is higher than first reading that means the counter is counting CW and if the next reading less than the previous reading that means it is going CCW.
Thanks again.
JH
08-30-2010 10:04 AM
Cool JH, glad to hear it's working!
08-30-2010 12:35 PM
Thanks Eric,,
do you have any idea how to wire up the VI so it saves initial reading or the initial rotation of the encoder, when I rotate the encoder CW it tells me that I did rotate it CW and if I rotate the encoder CCW it will tell me that I did rotate CCW. It basically setting up two shift registers on the while loop, it should save the first reading in the first shift register, then next reading update on the second shift register, I am not sure how to connect my shift registers to the output reading.
Jamal
08-31-2010 05:18 PM
Yep, here's I think what you're looking for, or at least one way to implement it. I simulated an encoder reading here (not very well), but replace the single frame sequence structure with your DAQmx read and you should be good to go. The boolean shift register is used only in the simulation of the encoder, so you don't need that in the final version either. The main aspect is using the bottom shift register to keep track of the encoder readings, compare the new reading to the old reading to see if it is greater than, less than, or equal to the previous measurement.