Photo

Photo

Monday, March 7, 2016

SciBorgs

For Friday's class, we began exploring an application for arduinos – sciborgs! YAY!
But first, we had to learn about functions, but that's okay because functions are pretty great too! My partner for this assignment is Amy.

Functions:

In order to learn about functions, we were given an SOS code to look at and run. Functions are very useful for repetitive actions because, as you can see in the SOS code, it allows the coder to do less typing. YAY!

How Functions Work:

Functions are created outside the infinite loop and when the function is called, the computer jumps to the function and performs the task listed. When the computer has done what is listed inside the function, it jumps back to where it was in the infinite loop. If the function is called again, the computer will jump back to the function, run through the code, and jump back to the main loop, over and over again, for as many times as the code calls for, until the program ends.





Setting up our sciborg:


This is the part that I was really excited for – putting our Arduino knowledge to use! Here's a picture of our SciBorg





Singlemotor:

In this code, we tested out a single motor. This was pretty straightforward, as we were given the code.



Reset/Blank Code:

We also created a blank code whose sole function is to turn of the SciBorg when it isn't being used in order to preserve the batteries.





BothMotors:

Now, since we want our SciBorg to take full advance of both its motors, we turned both of them on by coding in the motion of its second motor. We used our previous single motor code as a template.








Bareminimum:

For this exercise, we spent some time tweaking with the motor speeds in order to get a better idea of what numerical speed correlated to what kind of visual speed. We then were able to discover that on the tables in the lab, the minimum power required for the SciBorg to move at all is at 80.










Hardturns:

To get the SciBorg to turn, the motors have to be set at different speeds from one another. No surprise there. In these next two exercises, by experimenting with values, we learned a bit more about the speed relations that would get us the different types of turns. To get a hard turn, or a very sharp turn, all you have to do is set one motor as the negative speed of the other. In our case, we had one motor at 255 and the other at -255.











Softturns:

In order to create a softer turn than in the above code, we decided to make the speed of one motor slower than the other (basically nonexistent, since we discovered that the minimum speed is 75). The smaller the difference between the motors, the softer the turn until the SciBorg is just going straight. How soft is too soft, or how soft is soft enough, depends on the course and scenario.













Traveling 10 Feet:

In order to get our SciBorg to travel 10 feet and stop, Amy and I decided to use a stopwatch to record the time it took for the SciBorg to travel the desired distance. Once we had our data, we set the run time of the SciBorg to 12300 ms or 12.3seconds. After the 12300ms, the SciBorg's motors were set to 0.

During our first run, we initially set both motors to maximum speed, however the SciBorg started veering to the side. To fix this, we kept one motor at 255, but lowered the right motor to 245 because the SciBorg had been veering to the left. This did a pretty good job at fixing our veering problem, but the SciBorg still ended up stopping 8 inches short of the 10 feet mark.






















A video of our SciBorg running the above code


No comments:

Post a Comment