Pages

Friday, March 20, 2015

Arduinos: Day 3

Class this Friday was a continuation of working with Arduinos for our new unit: Feedback and Control. Today we learned how to use an Arduino to control the movement of a servo motor as well as another method of controlling LEDs. 

Arduinos and Photocells


A photocell is a sensor device that is used to detect levels of light. Today we modified a program that translates the light the photocell detects into several reading levels;  "Dark", "Dim", "Light", "Bright" or "Very Bright." The original code shown below was modified such that a servo motor moves and an LED light blinks in accordance to the photocell readings.

Original Code:



Calibrated Photocell, LED, and Motor:

In order to use the original code above, the photocell needed to be calibrated such that it could adjust its sensor reading levels to match the relative intensity of the in light in its surroundings. In order to do this, we programmed the Arduino to allow the user to manually calibrate the sensor's minimum and maximum readings each time the code is implemented. 

We also added a section in the void loop of the code that would proportionally control the blink rate of an LED based on the reading levels of the photocell, as well as an additional section similiarly controlling the movement of a servo motor. 


End Result:



Arduinos and S.O.S. Functions


An S.O.S. type function applies a morse code like strategy that is useful for shortening long codes that repeat a lot of the same functions. This is achieved by initially defining a function as something short such as "dot()" or "dash()," and then thereafter using the shorter abbreviation in the code. Below is a S.O.S function that we practiced on. This code was able to cause an LED to blink in a morse code pattern (SOS).



Setting up the Sciborg


In order to move on to the Bricktronics unit of our Arduino work, my partner and I needed to finish setting up a Sciborg provided by our instructor. Setup included:
  • Assembling a battery pack by soldering its wires and attaching it to the cyborg using screws.
  • Attaching an Arduino to the top of the Sciborg
  • Attaching a Breadboard to the top of the Sciborg
  • Attaching a Bricktronics shield to the top of the Arduino 




Sciborg: Single Motor


Our first task with the Sciborgs was to run and understand an example code for moving only one of the two motors on the Sciborg. After attaching both of the motors to the Arduino, my partner and I ran the sample program shown below. The program results in one of the wheels on the Sciborg moving forward at a speed of 75 and then 255, and then backwards at a speed of 75 and then 255.





Sciborg: Double Motor/Drive Straight


Using the single motor code, we created a new one that could control the movement of two motors simultaneously. The program below runs both motors at the same speed, allowing the Sciborg to travel in a straight line.




Sciborg: Minimum Motor Speed


Our net task was to find the minimum speed at which the sciborg could move. We already knew that the maximum speed of the Sciborg was 255, so we started at a speed of 100 and incrementally decreased the speed down until the device couldn't move, and then increased the speed until the Sciborg could move again. We determined the minimum speed to be 50.






Sciborg: Hard Turn


In order to make the Sciborg take a sharp turn we modified the two motor code such that one mother was turning at full speed in one direction, while the other was turning at full speed in the other direction. This resulted in the sciborg turning in place.





Sciborg: Gentle Turn


To make a more gentle turn we modified the above code in two ways. First we decreased the speed. We also made it so both wheels were turning in the same direction with one wheel slightly faster than the other.




Sciborg: Travel 10ft and Stop


The next task was to create a program that would allow the Sciborg to travel exactly 10ft and then stop. In order to do this, we first found the amount of time it took for the Sciborg to travel 10 ft at a certain speed (255) (9 seconds). After determining this time,  we programed the motors to stop after this time period (9 seconds) had elapsed. In our testing, the sciborg traveled the 10 feet exactly almost every time save for several times it was 2-3 cm short of the line.







Touch Switch


A touch switch is a type of sensor that can be operated by touch to induce a variety of responses. The Sciborgs we used in class have a touch switch on the front, as well as a detachable touch switch that can both be programmed using an Arduino.

Initially we were given the sample code below that turns on the LED at pin 9 once the touch switch is pressed. Thereafter, the LED stays on unless the code is reimplemented as there are no conditions specified for when the button is released.




Controlling LED

Part of our task for this section was to figure out how to modify the above code such that the LED at pin 9 would only turn on only while the touch switch was pressed, and otherwise be off. This was achieved  by defining the conditions of the LED when the button was not pressed as off. 





Sciborg: Motor Button


The final project today was to program a touch sensor on the Sciborg that allows it to back up, turn, and then go forward again when it hits an obstacle.


In order to program this, we used the touch switch codes from the previous days as a basis for the new one. First we modified one of our older codes such that the Sciborg motors turn on when the touch sensor button is not pressed, but turns off when the button is pressed. Then we added an additional component that makes the Sciborg change directions after the button has been pressed. The result can be seen below.




For our final code, however, we wanted the Sciborg to be able to move regardless of whether the button is pressed, and rather change directions instantaneously. In order to achieve this, we set the Sciborg's default movement to forwards and straight. Only when the touch switch gets activated does the Sciborg briefly move backward, turn, and then continue forward,






Reflection

Today I had a lot of fun working with the Sciborgs and LEDs. I felt it was very useful to have visual feedback from our devices as we modified our codes. 

Thursday, March 12, 2015

Rob Wood Talk

Today I had the opportunity to attend a Physics and Engineering seminar given by Professor Robert Wood from the Harvard School of Engineering and Applied Sciences. Professor Wood is the founder of the Harvard Microrobotics Lab, and his work involves developing biologically-inspired robots with feature sizes on the micrometer to centimeter scale. In today's lecture, he focused on his lab's work involving the creation of flying robotic "insects." 

What I found particularly interesting about the work he discussed today was the process by which his flying insect devices were assembled. In the past, these tiny devices were laboriously put together by tweezers one piece at a time. Rob Wood's lab, however, developed a "pop-up folding" method to assemble the whole device, and others like it in one go. There is an exponential amount of planning put into assembling devices in this way, which makes the end process truly astounding to watch. A more detailed description of this method can be found in the video below. 



It was also interesting to see how his lab tackled the issue of making these tine robotic devices fly independently. While I did not understand much of the mechanics mentioned, the process Professor Wood described reminded me of a lot of the feedback and control troubleshooting we've been doing in class. 

For anyone interested in learning more about Professor Wood's work and the information discussed in the lecture, below is a similar talk he did for National Geographic. 




Sunday, March 8, 2015

Arduinos: Day 3


Class this Friday was a continuation of working with Arduinos for our new unit: Feedback and Control. Today we learned how to use an Arduino to control the movement of a servo motor as well as another method of controlling LEDs. 

Arduinos and Servo Motors


-Using an Arduino and Sweep Program to control movement of servo motor-
Sweep is a public program that makes the motor move back and forth 180 degrees in steps of 1 degree every 15 milliseconds. As part of class today we sought to understand, and then modify this program. Our modified program, whose code can be seen below, makes the motor go from 0 to 90 degrees  in steps of 1 degree every 15 milliseconds, and then from 90 to 0 degrees  in steps of 1 degree every 15 milliseconds.





-Using an Arduino and Knob Program to control movement of servo motor-
We also learned how to use set up the Arduino so that a potentiometer could be used to control the movement of the motor. For this method we used a knob program that linked the movement of the knob on the potentiometer to that of the motor so that turning the knob 1023 degrees would result in the motor turning 180 degrees.




Arduinos and LEDs

On Friday we also learned how to use a potentiometer and the knob program to control the blink rate of an LED light. The below program is a modified version of the Knob program that links the blink rate of the LED at pin 8 to the position of the knob on the potentiometer. 

Our circuit was set up as below:



Reflection

When setting up and running an Arduino circuit, it is important to make sure that both the circuit board and code are properly set up. Today we learned a lot about troubleshooting small errors within our codes such as placement of semicolons and parenthesis, as well as the placement of wires within our breadboard. Overall we did not have any issues with controlling the movement of the motor. We did, however, need to research how map, as well as other functions in our code, worked. 

Arduinos: Day 1

In class this past Tuesday we started our new unit: Feedback and Control. For this unit I will be working with Sarah Barden on whose blog you can also follow for our progress. 

A main component of this unit will be working with Arduinos. To become more familiar with how they work, today we practiced using them to control LEDs. 

Arduinos and "Blink" Program

Using the Blink we first learned how to run and modify a program. We started with the example Blink program provided on Arduino (seen below), and then proceeded to modify the delay between when the LED located on the Arduino board turned on and off. 


Once we understood how the Blink program worked, we then learned how to set up a circuit board by attaching an additional LED and including it in the above code. Our new LED was connected to Pin 12 and grounded through a resistor connected back to the Arduino board. After playing with a couple different delay patterns between LED 12 and 13 we settled on the one seen below. This pattern has LED 13 blinking once for 500ms, then LED 12 blinking once for 500ms, and then three more times quickly before LED 13 turns on again. 




We also practiced using the Blink program using four LEDs attached to the circuit board. The modified program we created below causes the first light (LED 2) to turn on and off, followed by the second one (LED 4), then the third one (LED 7), and finally the fourth one (LED 12) before traveling back down the line.


Arduinos and "Blink Without Delay" Program

The Blink Without Delay program (code seen below) allows the arduino to do two or more things at once. In the context of using LEDs, this program turns on the LED on and then makes note of the time to then check and see if the desired blink time has passed before turning it on or off again. 

  
The last part of what we did today was understanding this program and use it to create a pattern with the 4 LEDs we had set up earlier. In the program we used else if statements to control when each individual LED would turn on and off so that only one LED was off at a time. What we came up with can be seen below.

                


Reflection

Today as my first formal experience with coding. I think it is very handy that the Arduinos have so many well annotated example codes. It made it much easier to understand what the original codes were doing before altering them. It was still challenging, however, to use the blink without delay program, as we had to take into account the LEDs relationship to each other within the code. 

Sunday, March 1, 2015

Lego Racer

For this assignment I worked with Izzy King to design a lego vehicle that is propelled by one PicoCricket motor. The vehicle had to be able to carry a 1 kg weight as fast as possible on a 4 meter straight, carpeted track.

Design Process

Practice
Before we got done to actually building our race car we spent sometime learning about how the materials and motor we were using actually worked. To do this my partner and I created several lego gear trains with various gear ratios and numbers. Building these trains helped us to understand the mathematics behind gear ratios/gear reductions. In class we learned that higher the gear ratios allowed for more torque, but often led to less speed. Lower gear rations, on the other hand, allowed for more speed at the expense of having a lower torque. Due to this tradeoff, one must think carefully about the intended use and possible strain that their motor powered creation will be put under when designing its gear layout. 

The image below is of our final gear train which has four gear pairs and a gear reduction of 27:1. We determined the ratio of this gear train by multiplying the gear ratios together.



Brainstorming
Once we had some understanding of how to work with the gears and motors, Izzy and I started to think about how we might want the overall design of our car to look. To keep the car as light as possible we decided to only use 3 wheels in our design. Less wheels would also decrease the friction between the car and the carpet.  For the actual shape of the car we chose to create a wedge design with lateral axes for the wheels. The angled body of the car would would help to take weight off of the two back wheels that would be connected to the motor, allowing them to turn faster. The lone front wheel would not be connected to the gear train and would primarily be there to provide balance.


Based on our practice with gear trains we decided to use a 15:1 gear reduction (seen below minus the gear attached to the motor). The gear train consisted of an 8 toothed gear attached directly on the motor, which then connected to a 40 toothed gear, which then connected to a 24 toothed gear. This 24 toothed gear controlled the spin speed of a 8 toothed gear connected to a 24 toothed gear, which was then connected to a 40 toothed gear that controlled the speed of the back wheels.  With this gear reduction our motor did not stall, and was able to turn the final gear, where the wheels would be attached, relatively fast.


Building/Testing

After making a gear train that did not stall when attached to the PicoCricket motor, we began to figure out how to build the rest of the car. The challenge was being able to fit the three parts of the motor, the wheels, and the 1kg weight without having them interfere with the movement of the gear train and back wheels wheels. This was a trial and error process in which we had take apart and resemble the car multiple times.

Our first concern was how we would attach the front wheel on. We settled with the design below.


In the image above one can see that the front wheel is attached to a platform located on top of the PicoCricket motor. This allows it to turn freely as the car is propelled forward by the back wheels. Originally we had planned to use a smaller wheel for the front wheel, but chose to keep all three wheels the same for several reasons including to keep the gear train from touching the ground. 

Once we had this structure sorted out, we began building upwards to accommodate the other two parts of the motor, as well as the 1kg wight. Once we had a structure that held everything, we tested our car out on the track.



Something surprising that happened with our first test run was that our car went backwards! Instead of the lone front wheel leading the car, the two motor propelled back wheels took the lead. We tried switching the direction of the motor to what we expected it would be, but found that having the back wheels leading the car was actually more favorable. So, we decided to keep that element of the design.

Regardless of the car's direction, though, our first test run went pretty well with our car's race at about 10 seconds. We wanted our car to go faster, though, so we went back and  cleaned up our design; adding structural supports as needed and rooming any needed weight. In one of our tests the gears went out of alignment, so the car did not move. To fix this we made sure that the bushings holding them in place were secure and numerous. Our final design can be seen below.

Dissected view of car
Height: ~13 cm
Length: ~24 cm
With Weight


The Race


Engineering Analysis

For this assignment we wanted to design a car that would be as fast as possible while still being able to carry a 1kg weight. This meant that we had to take into account both the rotational speed and torque of the gears we were using. The relationship between these two variables can be seen below.



The motor we were using for the car was the PicoCricket motor. This motor is known for having a higher speed, but very little torque. This is why we had to design a gear train with a large enough reduction that it would give just as much torque as needed without reducing the speed too much. The gear train we ended up using had a 15:1 reduction which ended up being very favorable for our car during the race. (Gear ratio in train order: 8:40, 40:24, 8:24, 24:40) 

There were several other facets of our design that contributed to its success. In class we discussed that things such as wheel diameter, material strength, and friction played a large role in the car's speed. 

For our car we chose the largest wheels available, which had a diameter of 8cm. While this choice was primarily to prevent the gear train from touching the ground, we learned that having larger wheels increases their linear output from the angular velocity they receive from the gears. This can be understood through the equation:  (Angular velocity)(wheel radius) = Linear Velocity. 

Material strength also played a factor in how much friction the car experienced. The axles use for the wheels were made of relatively thin plastic, and thus would bend if put under significant weight. This would in turn cause the wheels to sit at an angle, which would reduce their speed. To prevent this we positioned our wheels as close to the car as possible.

We also tried to increase the car's speed by limiting the amount of static friction it would experience. This was achieved by lessening it's weight and only using three wheels. 

Reflection

Over the course of this project I have learned a lot about how gears and motors work. I had not previously know about the relationship between torque and speed and how it relates to linking multiple gears together. I had also never fully considered all the thought and work put into making sure that the gears of larger machinery ran smoothly. Especially when one has to take into account the friction between gears as well. 

As we learned in the process of making our car, so many variables need to be considered when designing a piece of machinery. We had to make many adjustments to not only our gear train, but the placement of our wheels and supports as well. All this was to ensure that the friction experience by the gears in the car and the wheels on the floor was as low as possible.

We could try to improve the speed of our car by testing different support structures to lessen the weight, and thus experienced friction. This, however, is unnecessary as it is time to move on to our next project!

Thanks for stopping by!