Why is my encoder causing my pendulum angle to drift?

  • Thread starter jgeating
  • Start date
In summary, the conversation discusses the use of a rotary encoder through an arduino for a pneumatic inverted pendulum project. The person has noticed that after running for several seconds, the angle of the pendulum drifts and even shaking it with their hand causes further drift. They have tried different arduinos and encoders, but the problem persists. Someone suggested that the pulses from the encoder may be too high for the arduino, but a previous student did the same project without issues. The person is now considering using an external counter to compare the number of interrupts and simplifying their program to keep an accurate count.
  • #1
jgeating
36
0
So I am reading a rotary encoder through an an arduino using interrupt pins for the quadrature output. I'm not an expert, but the system seems to work fine, i.e. gives correct output readings. It is for a pneumatic inverted pendulum, which can jitter, and change the cart velocity very suddenly. I have noticed that after running for several seconds, the angle drifts. When I realign the pendulum with gravity, the angle has drifted several degrees. Even shaking it with my hand (pneumatics turned off) causes the angle to drift.

Encoder is a S1-1250 by US Digital. 1250 counts per revolution, with standard, ground, power, ChA, and ChB outputs. (Unused index channel). Have tried an arduino mega as well as duemilanove, and two separate encoders (same model number). Someone recommended getting an "encoder counter" because the pulses are probably too high for the arduino.

However, a previous student did the exact same project without problems. The only differences are that my rail friction is much lower (3X lower), and my pendulum is a carbon fiber rod with a weight on the end, while his was just an aluminum shaft.
See http://dasl.mem.drexel.edu/~jiyueHe/pneumatic_inverted_pendulum/ for the tutorial I'm following

Thanks,
-Josh
 
Last edited by a moderator:
Engineering news on Phys.org
  • #2
I would place a small bet on missing interrupts. If the drift is always in the same direction you might have asymmetric processing times on one input.

You could try an external counter to compare the number of interrupts you get, or simplify your program somehow to keep an accurate count.
 
  • #3
Drift is in both directions, but usually CW. The program is simplified to the point where only the encoder related code is present. I also directly downloaded a simple encoder program from the arduino website and the problem still remains. I also eliminated serial output and used an LED to indicate where the supposed 0 point is. It always still drifts when I shake it about.
 

1. What is an Arduino and how does it work?

An Arduino is a small programmable microcontroller board that allows you to control electronic components and devices by writing and uploading code to it. It has input and output pins that can be connected to sensors, motors, and other electronic components, allowing you to create interactive projects.

2. What is an encoder and what is its function in an Arduino?

An encoder is an electromechanical device that converts mechanical motion into electrical signals. It is used in an Arduino to measure the speed, direction, and position of a rotating shaft or motor. It does this by generating pulses that are counted by the Arduino and translated into the desired output.

3. How do I connect an encoder to an Arduino?

To connect an encoder to an Arduino, you will need to identify the encoder's output pins, which are usually labeled A, B, and C. Then, connect one of the pins to a digital input pin on the Arduino and another pin to the ground pin. You can also connect the C pin to a digital pin and use it as a button to reset the encoder's count.

4. What are some common applications of using an encoder with an Arduino?

Encoders with Arduinos are commonly used in robotics, CNC machines, and other projects that require precise control of motors and other mechanical components. They are also used in speed and position monitoring systems, as well as in feedback control loops.

5. Can I use multiple encoders with one Arduino?

Yes, you can use multiple encoders with one Arduino. You will need to connect each encoder to different digital input pins and use separate interrupt routines to read the pulses from each encoder. Alternatively, you can use a multiplexer or a dedicated encoder interface IC to connect and read multiple encoders with fewer pins on the Arduino.

Similar threads

Replies
2
Views
2K
Back
Top