While the stick does perpetually move towards equilibrium, it will still fall if left completely on its own. Our system works in theory, but we will need additional time to further tune our variables and make the system fully functional. Currently, when you have your hand on the top of the stick to help it balance, you can feel the reaction wheels responding to the changes in position and actively pushing the stick back to equilibrium, but unfortunately the PID values still cause the wheels to overcorrect. Below are some videos that demonstrate this; further below we describe a series of tests conducted in order to better understand the behavior of our system.
Video 1: Both wheels spinning continuously does not generate the torque needed to correct the change in angle.
Video 2: PID = 0.8, 0.8, 0.01
The torque generated was enough to move the stick on its own, but the motion was too erratic.
Video 3: PID = 0.4, 0.8, 0.01
The motion of the stick was slightly smoother but still not enough to correct itself.
Video 4: The stick was responding to roll and pitch. However, it tended to yaw. We assume this is due to the constant movement of the wheel in one axis.
Video 5: The calculated PWM seemed inaccurate. We believe that this is either due to inaccurate IMU readings or our mathematical model was incorrect.
Video 6: Again we see that the torque generated was enough to move the stick on its own.
These videos exhibit some of the countless nights we spent tuning the PID values. Without a simulation, we were somewhat blindly guessing our PID values. At each sample, we needed to measure the IMU data and determine the PWM value necessary to bring the stick to equilibrium. The logic of this problem is different that the problem introduce in Lab 7 when we needed to move the Baxter arm. At each set PWM value, it was necessary to account for the momentum of the wheel. For example, if we rotated the motors and stopped when the stick reaches a deadzone, the momentum of the reaction wheels would throw the stick out of equilibrium. What we needed to do instead was to provide a necessary and accurate impulse PWM value to the motors: this value should bring our stick to equilibrium while accounting for the momentum of the wheel.
Since motors do not behave linearly, we performed experiments to characterize the two Nidec 24H brushless DC motors.
Purpose: We want to determine how linearly the velocities change relative to a sweeping range of PWM values.
Set up: Sweep PWM values from low to high to low and graph the set PWM and encoder velocities.
Variable: time_delay determines the amount of delay before we change the PWM value
Note: 255 corresponds to the lowest velocity while 0 corresponds to the high velocity.
(Legend: Green = Encoder velocity values; Blue = Linearly sweeping PWM outputs to motors)
Figure 1a: 100 ms
Figure 1b: 10 ms
We discovered as we decrease the time_delay (increase the sweeping frequency), more noise is introduced into our graph. In figure 1a, we see that the shape of the graph is very clear while figure 1c shows a very fuzzy graph. We also discovered that all graphs contain a spike in the beginning. We believe that this is due to the “jolt” in current that is required to start the motors. In all graphs, we see nonlinear behavior from 2500 to 6000 m/s on the y-axis. Then from 6000 to 9000 m/s, we see a very linear behavior.
We learned that at 100 ms, the encoder velocities were rather stable compared to 10 ms. This is expected since noise in the readings would occur when we decrease the time_delay between updating PWM values. Also note that in all cases, we experience nonlinear behaviors at low velocities and linear behavior at high velocities. This is interesting because this means that we have to account for nonlinear behavior since we are working at low velocities. This can be corrected using our PID values.
We want to determine how well our motors track our set PWM. This helps us understand our system when it is operating at high frequencies.
Hypothesis: The two motors may have different operating points.
Set up: Quickly change the set PWM from 255 -> 0 -> 255 -> … depending on the time_delay.
Variable: time_delay determines the amount of delay before we switch the PWM value
Note: 255 corresponds to the lowest velocity while 0 corresponds to the high velocity. The number of iterations per test is not exactly the same between all of the tests, which is not ideal but we can work with it.
By looking at the side by side comparison between our motor 1 and motor 2, it is apparent that motor 2’s amplitude is much higher than motor 1’s amplitude when mapped to the same PWM. This means that motor 2 operates at a higher velocity than motor 1 – reinforcing our assumption that the two motors are not perfect in design.
In both motors, we saw very good tracking at 500 and 250 ms in time_delay. Once we get to 100 - 10 ms, our motors no longer do a good job of tracking the set PWM. In all cases, as we decrease the time_delay (increase the oscillation frequency), the amplitude of our motors also increases. This begins to be apparent from 500 ms to 250 ms.
By conducting this experiment, we confirmed our hypothesis that our two motors are not completely identical. This adds a layer of complexity to our system that we must address by tuning our PID values.