We used the ultrasonic sensor next. An ultrasonic sensor is an in air, non-contact object detection and ranging sensors. They provided us with readings about the distance of the sensor from other objects, which we used to control the motors. We did find them to be a bit unreliable, although reliability could be increased with a more open space away from objects to interfere with the readings.
We wired the sensor to the arduino and ran the ultrasonic sensor code, noticing interference and getting a sense of its scale and accuracy. Using a board, we controlled the speed of the motors so if the value of the sensor was greater than 15, it would run at full speed otherwise, the sciborg would stop. This meant that it would always stop before it ran into any walls or boards. We experimented with this so it would stop after going 10 feet (and running into a board at the end of the track).
In the Lego motors are encoders, which communicate with the arduino and count how many times the shaft has rotated. We first used bang-bang control and the encoder to make the sciborg stop after 10 feet, and were able get fairly close (within a few inches) of the line, although how close it got also depended on the wheeels and how straight the sciborg was running.
We measured the number of rotations of the shaft to be about 10300, and the sciborg would stop after that. We checked this periodically by keeping the USB plugged into the computer and printing its current position.
And here is a video of us using the encoder:
Next, we used proportional control. The motor received less power as it got closer to the 10 foot line. The sciborg got much closer to the finish line when it was on a smoother surface (not the rug outside the room). Using proportional control, we tended to undershoot by quite a bit, where it was reasonably close but never quite reached.
To solve this, we introduced a nudge function where we turned on the motor for just a few second so our sciborg inched its way the last distance to the finish line.
(the code continued below)
We than used the ultrasonic sensor again to follow something (for example a board or anoth sciborg) in front of it. We used bang-bang control for this.






Your explanations of ultrasonic sensors and the encoders are great! I think some more videos in your blog would be helpful for us to see what the code is actually doing!
ReplyDeleteGreat job explaining everything step by step, this post shows a really clear progression of what we did. Keep it up!
ReplyDeleteHmm, is it the format of the blog that allows the videos to rewind like that at a certain part? It was the same for Tiffany's blog and I thought it was interesting...
ReplyDeleteI like how you had a brief description at the to describe the sensors/instruments we used with the SciBorg. And it was interesting reading your nudge function...I definitely thought about creating the nudge function a different way, and didn't know that you could just put stop to have the SciBorg nudge.