Tuesday, 8 March 2016

SciBorg Part 1

SciBorg Part 1
Goals:
* Learn how to make functions as given in the SOS code, instead of typing codes over and over.
* Get familiar with a Sci-borg and change its behavior (rather that of its two motors)

1) Making functions:
We copied the given code; made a simple circuit connecting an LED and a resistor to the Arduino hardware; and ran Morse's code.

After some confusion about whether a pin provides the voltage needed or we need to connect the LED to the 5 V output directly, we figured the pins are also power outputs.

The product of this practice was an SOS pattern with dot, dot, dot; dash, dash, dash; dot, dot, dot.

Where,
dot : a blink
dash: a longer blink taking three times as long as the dot



Next, we worked with a sci-borg:

1) We set up the Arduino board and the shield on top of the car as shown below:

sharp turn 

                                        

When connecting the shield to the Arduino board, we aligned the shield's pins to the corresponding holes in the Arduino board and pushed them in carefully. Using NXT cables, we connected the motors to the motor ports on the shield. Following the instructions, this was a very straightforward process. 


2) We ran one of the motors according to the following code:
The wheel connected to the said motor (motor #1) rotated back and forth according to the loop command. 


The Arduino program displayed messages like:


The display was reading gibberish at first because we forgot to set the bits per second to 115200 baud to match the code. Once we adjusted the bits per second, the reading matched the behavior of the wheels. 

3) We ran both motors at once after adjusting the code as displayed below:

Since there are only two motors, we copied the code instead of creating a function. With a more repetitive code, a function would be more efficient. 


4) We adjusted the code and played with the speed until we could find the slowest speed at which the sci-borg can travel:

We used the following code:


Notice we didn't use a delay () command so that the car would run nonstop. 

On a table surface, it moved without stuttering starting at 85 mm/s. The friction on the floor was too high for it to move without stopping at this same speed.

The result is shown in the following video:



5) We modified the sketch further to make the car take a hard turn. 
This almost looked like the car was pivoting on one wheel. 





We adjusted one wheel to be much faster than the other, to accomplish this. This makes the car turn to the side with lower speed. 

While this was a pretty sharp turn, it wasn't the absolute extreme. So we set the wheels at the maximum speed but in opposite directions as shown in the following and got the car to make a hard turn (the maximum it can).




6) We modified the relative speeds of the motors (made the difference smaller) so that the car can take a gentler turn. 




7) We timed the sci-borg as it covered 9 ft on the surface of two tables and adjusted its run time so it stops at exactly the time it took to travel 9 ft. 
This was the most challenging task of this lesson because regardless of our efforts to adjust the relative speeds of the wheels to keep the car moving straight, it kept going on a bent path in a very unpredictable manner. So the time measured as well as the distance traveled at any given setting of motor speeds had some uncertainty. 

Based on physics, a = (vf - vi)/ t , where a = acceleration; vf = final velocity; vi = initial velocity, and t = time elapsed between final and initial velocity (during acceleration). So the car cannot come to stop immediately at the finish mark because it would have some reaction time. Other wise, if t = 0, acceleration = infinity. Using this logic, we expected the sci-borg to pass the finish line and stop. 

However, since the measured time and length were both significantly affected by the unexpected turns, the car stopped about 15 cm before its finish line. We were looking at the back wheels to mark the beginning and end of the journey. So when the back wheels were at the start line, t = 0, displacement =0, and when the back wheels pass the finish line, the car is considered to travel 9 ft. 

Here is a video that shows our sci-borg travel 9 ft with some difficulty in keeping a straight path, but more smoothly so than it did on the floor. 


To get this result, we used the following code:



Notice motor 1 is faster than 2 because we wanted to correct for an initial condition when the car was turning slightly towards wheel #1 when the motors were set to travel at the same speed.



And, of course, by now we were attached to our sci-borg and named him Daniel! 



Thank you for your time.

Meba



1 comment:

  1. I really liked the videos! They tied everything in your blogs together.

    ReplyDelete