After connecting everything, we tested out various procedures on the motor. In order for the motor to turn a certain way, we had to set one output to high and the other to low, and in the reverse order for the motor to turn the opposite way. However, this did not work. Esther and I were confused because we didn't know what those simple procedure didn't make the motor move. We double checked our breadboard and everything was at its right place. We then figured out that we had to set output 3 (which is connected to the enable pin on the motor driver) to high. After figuring that out, we were able to make the motor go in both direction, stop, and coast.
These are the programs that make the motor perform this procedures:
Then we had to construct a program that uses feedback from the shaft encoders to make the motors spin exactly 10 revolutions one way, stop, and spin back to exactly where it was.
We first to find a "unit conversion" for how many clicks were in one revolution. So we used our previous "counter" program from challenge 6 and we found that there were 180 clicks in 1 revolution- 1800 clicks in 10 revolutions. However, a problem arose when we saw that the number of clicks in one revolution differed when the motor was running (because previously we manually turned the motor) and when the motor turned in the opposite way. This was very problematic, but we ended up adjusting ourselves the number of clicks that the program needed to count both clockwise and counterclockwise.
When making this program, we split up the first part (moving that way) and the second part (moving the other way). In each part, we included the "counter" program that we created in challenge 6. For the first part, we told the program that once the number of clicks had surpassed1038, the program should stop. For the second part, we told the program that once the number of clicks had gone passed -855, the program should stop.
These are the two programs:
We then combined these two programs and put a wait in between them, so that the stop would be more pronounced.
This program took us a lot of time to figure out because we had to both count the clicks and tell the motor for a certain amount of time all in the same program. This is why we split the two motion, because we wouldn't be able to perform all this procedures in a single thread.
This is a video of us performing the simple procedures:
No comments:
Post a Comment