Saturday, April 3, 2010

Challenge #7- 7.2

For this part of the challenge, we had to create a program that would take in account the "net" count, counting up as the motor rotates one way and counting down as the motor rotates the other way. In order to do this, we used the oscilloscope to see if there was a difference in the signals as we turned the motor in one way and in the other. We used the channel 2 to detect the edges of S2. Channel 1 was yellow and Channel 2 was blue. As we turned the motor clockwise, the yellow signal appeared first, indicating that the edge 1 came before edge 2. As we turned the motor counter-clockwise, the blue signal appeared first, indicating that edge 2 came before edge 1. This is a picture of what we saw on the oscilloscope:


We noticed that when the motor was rotating clockwise, edge 1 came first and edge 2 was still present. While when the motor was rotating counterclockwise, edge 2 came first and when edge 1 appeared, edge 2 was no longer there. We used this information in our program to get a sense of the motion of the motor. We created a forever loop that detected these different edges. We first checked the state of the first sensor (detect the edge 1) and then checked the state of sensor 2. If the program detected sensor 2 then this meant that the motor was rotating clockwise and if the program didn't detect sensor 2, the motor was rotating counterclockwise. The oscilloscope was extremely helpful in distinguishing these two motions and helped us come up with a pretty clever program.

This is the program that we came up with:
We made the program so that if sensor 2 was detected (motor going clockwise), the count would go up and if sensor 2 was not detected (motor going counterclockwise), the count would go down.

No comments:

Post a Comment