Friday, March 26, 2010

LogoChip Challenge #2

For this challenge, Esther and I had to use a toggle program on PicoChips. The toggle program acts like a switch and changes the state of the motor to its opposite state. For example, if the motor is running and then if I press on the toggle program, the motor will stop, and vice and versa. However, when we used the toggle program on the motor, it didn't work all the time. There is something called a switch bounce which makes it unpredictable to what the motor will do. This is an example of how problems occur when working with both a program on a computer and the physical world. There is a 50% chance that the motor will remain in its original state or toggle. Our challenge was to create a program that would avoid the switch bounce and make the motor toggle 100% of the time.

Here is what we came up with:
We put mwait blocks in between certain commands, so that the program would skip over the switch bounces.


No comments:

Post a Comment