Friday, April 23, 2010

LogoChip [Challenge 8-1,2,3]

[Challenge 8-1]
Here we built the base of our MotorCar!



[Challenge 8-2]
To control our MotorCar, we devised multiple codes: forward, backward, coast, brake, spin right, spin left, bear right and bear left.



[Challenge 8-3]
We implemented the 'init' program from which we can use 'count+' and 'count-' system to detect the rotation on on the motor. It was a bit confusing wiring up the motors so that counta increases as left motor goes forward and countb increases as the right motor goes forward. After wiring up the motors correct, we tested out our code below so that the wheels move forward until the count count-a is 1000 and backward until count-a is back to zero. The number printed out at the bottom is count-a after the code is taken place. It is a less than one rotation backward (one rotation = 180) because the wheels have moved backward just a little bit after the brake.


Monday, April 19, 2010

LogoChip [Challenge 7-1,2,3]

[Challenge 7-1]
To sense the rotation of our two wheels, we implemented the "shaft encoders." Because we were not sure if it was sensing the rotation, we connected it to the oscilloscope and tried to capture the motion on the wheel (it is in the video below).





[Challenge 7-2]
To keep the direction in which the wheel spins, we modified our solution code for challenge 7-1. If the wheel is spinning forward, then the sensor will detect a positive number and vice versa. The if statement that we added in the code will keep track of the count by adding or subtracting 1 to it. If the detected number from sensor 2 is positive, then it suggests that the wheel is going forward and so our count will increase by one. If is detects a negative number, then it suggests that the wheel is going backward so our count will decrease by one.



[Challenge 7-3]
Following the instruction, we have implemented the idea of H-Bridge and wired up L293D motor. To have the motor spin exactly 10 revolutions one way, stop and then back to its original position, we counted the number of counts in one revolution, which we found to be 180. Keeping record of the count, we devised the code below named "10rotate" that rotates one way and when the 'rotate' count equals 10 it rotates the other way until the count is 20.

LogoChip [Challenge 5, 6]

[Challenge 5]
To detect shadows, we implemented a photocell, which detects the amount of light coming in. We used a lantern over the photocell for better accuracy. When a shadow was over the photocell, the reading was in between 910 and 940. Therefore, to count the edges of shadows, we had the count wait until the number from reading goes below and then back up above the threshold. The video below shows detecting shadow of four fingers crossing over the photocell under the lantern for two times.





[Challenge 6]
In challenge 6, we learned to use the "second wand" and applied this method to our code below in the picture. We were able to turn on and off the two LEDs separately.





LogoChip [Challenge 3, 4]

[Challenge 3]
For this challenge we applied the method we used to fix the toggle method to detect the switch better and, therefore, to get a reliable result. We realized that the set "count" has to be initialized outside of the forever loop since having it inside the loop will just set it equal to zero every time.



[Challenge 4]
For challenge 4, we implemented our transistor, which I find exciting! Using "setpower" operation, we were able to bring up the motor power to its maximum (10000) and back to zero by repeating the code ten times, slowly incrementing and then decrementing by 1000 each time.


LogoChip [Challenge 1, 2]

[Challenge 1]
For challenge 1, my partner and I just followed the instructions and set up the Lego chip as the picture below shows.


[Challenge 2]
Every time we tried to "toggle," we got an unreliable result back. The system was going over the code too quick to detect the switch. To fix this, we added the wait property after the switch.