top of page

Code Development

We started with an online library that read feedback directly from the accelerometer and converted it into degrees.

Screenshot 2023-04-20 172227.png

Next the program takes the calculated angle (xaxisangle) and calculates the PID errors.

Screenshot 2023-04-20 172454.png

Finally the controller uses the errors to output a PWM and direction signal to the motor controllers

Screenshot 2023-04-20 172739.png

For the reaction wheel, when the feedback method was changed to a potentiometer, the feedback was measured in steps by the Arduino depending on the variable voltage. These steps were between 0-1023. This number was converted to an angle number which could be compared to a known zero point to let the controller what it needs to do.

Untitled3.png

Finally, for the reaction wheel, it was determined that the setpoint needed to be constantly updated to avoid the reaction wheel endlessly traveling in one direction. This change was made on a KL25Z controller.

Untitled.png

This code dynamically adjusts the target angle when the measure angle overshoots. In this way it can allow the pendulum to oscillate between to points and the wheel doesn't endlessly ramp.

Untitled.png
bottom of page