The measurement interface is designed to read the generalized coordinates of the mechanical system using two optical shaft encoders and to transmit the data to the main interface through the I2C serial bus on request.
The first optical encoder is attached to the dc motor and provides information about the pivot arm angle. This pivot arm encoder generates 500 pulses/rotation, so each pulse corresponds to 0.72°. The encoder has an integrated signal filter circuit, and a conditioning circuit. Because the upright position of the pendulum is unstable the measurement of the angular displacement must be more accurate to avoid any deviation. For this reason we attached to the inverted pendulum an encoder with 1000 pulses/rotation, which provides a measurement accuracy of 0.36°. The second encoder also contains internally the filter circuit and the conditioning circuit. Knowing the working speed of the encoders we can obtain a 250 kHz maximum frequency of the pulses.
The angular positions of the pendulum and pivot arm are determined by counting the pulses in an interrupt routine generated by the encoder signal and the angular velocities are computed using the pulse-counting method. There can be multiple ways to determine the angular velocity and acceleration for a quadrature encoder. We chose the pulse-counting method because is more appropriate for high speed applications. So, we implemented another routine generated by the internal timer which count the number of encoder pulses in a fixed time interval to estimate the velocity of the encoder.
The four variables are grouped into a package of 8-byte and sent via I2C bus if requested by control interface.