Thursday, April 9, 2015

Adventures with Arduino, pt 3

Throughout our time with the arduinos, we used three sensors. The first was the touch switch (which was in part 2), and next we turned to using motor encoder before finally using our ultrasonic sensor. Welcome to the wonderful world of feedback and control.

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. 


Guest Speaker: Robert Wood

Our class attended at talk by Robert Wood on Robotic Insects, or more specifically named Bio-inspired mechanisms for inclined locomotion in a legged insect-scale robot. The talk itself was, admittedly, at a higher level that I could completely understand. Nonetheless, his videos and photos about the insects were beautiful and impressive.

His work is extremely interdisciplinary, as he must question the physics of how insects move to build his robots, and come up with new and innovative ways to design and engineer his micro-robots. As a result of their small size, the design is tedious and the designs can't be quite as daring. He uses pop-up assembly to build his robots. This requires consuming and meticulous design, perfect pin alignment before a final release into the final form of the insect. One limitation of this process is that there are no curved edges-- yet.

He also talked about some of the challenges in the actual movement of the insects. They are working on body torque control, including rolls, pitches, and yaws, which are done by altering the frequency at which the wings flap. The robots are fairly power-efficient although the batteries that they must carry tend to be the heaviest component of the insect.

In his paper, Wood spends a section talking about various adhesives that have been used to attach the insects to walls, including gecko-like dry adhesives, electroadhesion, and micro-spine adhesion. In his paper, he addresses the various pros and cons of each method.

In conclusion, the diversity of backgrounds in the lab are making the flies extremely versatile and beautiful. There is only a but of concern about the applications of the flies. Most likely, the project is funded by the military and the flies will end up serving some sort of military purpose although I think that it would be amazing if the flies could be used to help the environment, doing things suck as pollination, fertilization, and destroying invasive plants.

A video of one fly's flight:


Adventures with Arduino, pt 2

We received a partially built sciborg. We began by soldering wire to our battery pack and screwing down the pack and attaching the arduino and protoboards to the sciborg (which I will file under skills that I don't have but really probably should). We were introduced to the bricktronics Lego NXT shield which allowed the arduino board to talk to the lego motors that moved the sciborg. In the end, our sciborg looked like this:


We opened up a sample 'single motor' code and edited the code to work with both motors. We discovered that the minimum code that the motors needed to move was about 20. We made a sketch that experimented with hard and gentler turns by changing the difference between the speeds of the two motors. 


We wrote a sketch that made the sciborg travel 10 feet then stop (and played with the individual motor spped in order to make it drive as straight as we could):


We used currentMillis to get as close to the 10 foot mark as we could.

We also installed a touch sensor, which we used to tell the sciborg when it ran into something and wrote a sketch so that our sciborg traveled forward, stopped when it hit a wall, backed up a bit, turned a bit, and went on its way (it reminded me of the iRobot vacuum). 

And our video of the sciborg in action:


We also played with the touch sensor and LED so that when we touched the sensor, the LED would light up (the following video is the result after we edited the code so the LED would turn off after we released the touch sensor instead of staying on forever):


Part three included my partner and I diving deeper into the endless abilities of the sciborg.

Wednesday, April 8, 2015

Adventures with Arduino, pt 1

Day 0:

Today was an introduction to the Arduinos. We were given an Arduino kit and asked to begin to work on a blink program. Following simple diagrams and reading through functions, we eventually completed simple tasks, such as making a LED light blink.

We were introduced to the various output pins and setting up our board using this function:

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

We wrote this function to turn the light on and off in an infinite loop:
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(2000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(500);              // wait for a second

}



We experimented with different delays in order to make different patterns. 


Day 1:

We began to work through an assignment sheet the went more into learning about functions and the variations of the blink LED program. One such program was blink without delay, which used a millisecond counter to determine when to blink:

This program used currentMillis to tell the LED when to blink through the Arduino pin. 

We also worked with a servo, which we controlled using a potentiometer. We first controlled the position of the servo directly with the potentiometer (when we twisted the knob on the potentiometer, the servo would move in direct relation to the turn), and in the code below both the blink rate and servo position were controlled by the potentiometer.

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

void setup()
{
  pinMode(8, OUTPUT);
}

void loop() 
  
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
 // val = map(val, 0, 1023, 0, 500);     // scale it to use it with the servo (value between 0 and 180) 
  digitalWrite(8, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(val);              // wait for a second
  digitalWrite(8, LOW);    // turn the LED off by making the voltage LOW
  delay(val);   // sets the servo position according to the scaled value 

We also worked with a photocell which we used to control the position of the servo and the blink rate of the LED. Below is a test code where we were using the photocell readings to control the two:


An initial experimentation with just the LED and photocell:




After several attempts, here is our final code for the combination of the photocell, LED, and servo.

And photos and videos of our final setup:




This task proved to be especially difficult, and we spent a lot of time trying to figure out what each line of the code meant.

Day 2: 

We began with an introduction to functions by working with a morse code loop that used functions dot and dash to turn on the LED for different amounts of time in order to eventually convey a message. 




Next, we began to work with the sciborgs which takes us to part two. 

Sunday, April 5, 2015

Final Project Ideas

I first wanted to identify problems in the center. Many mentioned by the instructors were basic fixes. They included:

  • The toilet flushing too loudly
  • The bathroom doors: they can be locked but the latches are old so sometimes they are hard for the kids to unlock
  • In the downstairs classroom, the kids can't see out the window
  • Physical risk: an important part of childhood, allowing kids some risky play without chance of causing them any real danger
  • Feedback and control-specific:
    • Notice when they are spilling sand or water out of the sensory table (pictured below) - possibly a visual/audio signal

    • When they take too many paper towels
    • Remembering to wash hands for long enough, flush
  • Kid-specific office supplies
Ideas:
  • Some type of rope structure (risky play)
  • Something that helps the kids to keep track of weather/know what to wear when they go outside
  • Sensory table - cause and effect system, signal shows when water/sand level goes too low
  • Volume tracker - traffic light
  • Check-in/check-out system for parents
  • Reusable science experiment:
    • circuit teaching
    • ramps
    • bubbles
  • Simple boombox that kids can use easily
  • Fun, different, multi-function musical instruments
  • Some type of organization/tracking system for supplies
Notes:
  • Don't want the kids to be over-simulated
  • Teacher doesn't want too much technology in classroom (no more than the cashier they have) - want kids to feel powerful in their environment
  • Positive reinforcement works best when correcting behavior
  • Children are in charge of their play
  • I would love to try to incorporate 3D printing in some way