We also talked about open- and closed-loop controls. So, all controls use some input to make decisions about some output. Open-loops do not factor in the current state of output to make decisions about future output. Some examples of open-loop controllers include the waffle-makers in our dining halls which only rely on time as input and the laundry machine in our dorms which also only rely on time as input. Closed-loops factor in the current state of the output to make decisions about future output. Some examples of closed-loop controllers include a hot water heater for tea which heats up water based a function of time and current temperature of the water and a thermostat which heats/cools a room based on the desired temperature and the current temperature in the room.
Then we... made another robot. This robot tried to stay a constant distance away from a light source. We built a robot that had a light sensor on the front and a light on the back.
Our robot |
Our code. Note: ports A and C run our wheels and port B runs our light. We could have left port B out of the loop, but we forgot to. |
Then we... made another robot! This robot used what we learned in control theory to roll up a ramp. Now, a casual observer might think that this is trivial, but we do not live in a perfect world. Our motors do not necessarily rotate the same amount, even when given the same instructions. So, we had to control for the potential arbitrary unevenness with our two motors.
Our code |
- 42 just happened to be the optimal speed for both motors. It was not just arbitrarily picked, even though most of the times this particular number is used, it is.
- We used a closed-loop control for this. The difference in rotation is multiplied by a constant and added to 42 to control one motor. This way if there is zero difference between rotation, then each motor goes the same speed. If the motor A has rotated more than motor C, then C goes slightly faster than A. If C has rotated more than A, then C goes slightly slower than A.
- The constant .1 we also found through iteration. Higher and it over-corrected and moved off the ramp quickly. Lower and it under-corrected and moved off the ramp in the quickly.
Our robot - we had to add a giant weight in front so that when going up the ramp, it does not flip over like a dead cockroach. |
A clip of our robot successfully going up the ramp