carlynorama

the blog

Intel Galileo and Bee Mail Part 3: The Object

by Carlyn Maw on February 28, 2014, 5 comments

Bee mounted with pager motor on spring

Bee mounted with pager motor on spring

Most of the other parts of this series will be about the Galileo Board and the software driving the project. This installment is about the object itself, which to me is the most important.

The Bees

The visible parts all come from my work as a Tech Disrupter at the Intel Experience store.

Honey comb pattern from the bottom of a Mitsubishi VCR

Honey comb pattern from the bottom of a Mitsubishi VCR

The idea of doing something bee themed actually came in mid December with the honeycombed bottom of a Mitsubishi VCR. The honeycombing provides strength to the plastic so the manufacturer can use less material.

underside of bee

Spring and washer mounting system for the bees

I began collecting springs as well. Printers were the best source. The vibration motors came from BrushBots left behind from the races. Although I did collect some from mobile phones. A washer below the spring provides a large stable base. The different types of springs used means each bee has its own personality.

Bee in situ with the final wing prototype of plastic and craft paper

Bee with combination wings

The bodies are index card. The best wing configuration turned out to be a combination of brown craft paper and a thin plastic from some discarded packaging. The plastic is about the same weight as overhead transparency sheets and the veining was drawn with sharpies.

Telephone exchange wire soldered onto headers for use with breadboard

Telephone exchange wire soldered onto headers for use with breadboard

Each bee motor has salvaged telephone exchange wire extensions. Each joint is protected with clear heatshrink I bought from Electronic City‘s closing sale. Some of the wire was stranded which necessitated soldering on male header pins for breadboarding.

The Circuit

With the UNO I would have been tempted to drive the pager motors directly, but with the Galileo’s increased delicacy I decided to seek out the correct way of do things. The most thorough but clear explanation of how to hook up a pager motor the right way came from Precision Microdrives. Instead of surface mount mosfets I used PN2222 transistors. Transistors do not require pull down resistors, but they do require current limiting resistors.

Schematic of motor being driven by a microcontroller pin

Schematic of motor being driven by a microcontroller pin, screen shot of layout done on circuits.io because I wanted to test that system.

This is what that circuit looks when multiplied and put into an Arduino protoshield. This is an old shield, but both Adafruit and SparkFun sell good ones.

The circuit (transistors driving 3 pager motors separately)

The circuit (transistors driving 3 pager motors separately)

Using a shield help ease the transfer from the UNO used for preliminary testing and the Galileo. Switching from the UNO lead to the discovery that on the Galileo the I/O pins are pulled up (5V or 3.3V depending) between the Galileo embedded Linux start-up and the Arduino sketch startup. The Bees are angry when woken.

This is ideal for projects using negative logic, but it is kind of a disaster for motor projects using positive logic. I am following this thread about GPIO pins starting high to see if there will be a way to choose.

The Code

This code just tests the bee behavior based on the input of a potentiometer. I’ve also been running into a problem where if the bees have just been left alone for awhile (especially off) the program locks up. When queried on the serial port the identity of the board has switched ports. I have not determined what is happening with that yet, either.

//------------------------------------------------------------ START LICENSE

/*The MIT License (MIT)

Copyright (c) 2014 Carlyn Maw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

// ---------------------------------------------------------------- END LICENSE

//This code is testing code for the circut to make sure all of the
//physical Arduino I/O is working. It checks a potentiometer or other
//sensors on the AO PIN and equates it to the future number of mails
//in the inbox.
//On each pin 9, 10 and 11 are 220 Ohm resistors leading to the bases of
//PN2222A transistors. The collector is attached to the motor and the
//emitter to ground.

//------------------------------------------------- OUTPUTS AND THEIR VARIABLES
//the total number of bees bing controlled
const int beeTotalNumber = 3;

int beePins[beeTotalNumber] = {9, 10, 11 };

//INPUTS AND THEIR VARIABLES
int howManyNewEmails = 0;

//--------------------------------------------------------  GLOBAL BEE SETTINGS

//the number of emails the bees hit maximum freakout.
//ideally it should be divisible by the number of
//beeActivityLevels
int maxBeeVar = 1023;

//how many different states the Bees can be in
const int beeActivityLevels = 16;

//The area that dictates the 16 BeeActivityLevels.
int b[beeActivityLevels][beeTotalNumber] =
{
  { 0, 0, 0 },
  { 0, 0, 50 },
  { 0, 50, 50 },
  { 50, 50, 50 },
  { 50, 50, 100 },
  { 50, 100, 100 },
  { 100, 100, 100 },
  { 100, 100, 150 },
  { 100, 150, 150 },
  { 150, 150, 150 },
  { 150, 150, 200 },
  { 150, 200, 200 },
  { 200, 200, 200 },
  { 200, 200, 250 },
  { 200, 250, 250 },
  { 255, 255, 255 },
};

//---------------------------------------------------------------------- SETUP
void setup() {
   Serial.begin(9600);
}

//----------------------------------------------------------------------- LOOP
void loop() {
  //get the data determining bee behavior
  howManyNewEmails = analogRead(A0);
  //Serial.println(howManyNewEmails);

  //update the bees
  updateBees(howManyNewEmails, maxBeeVar);

  //mini-pause
  delay(10);

}

//---------------------------------------------------------------- updateBees()
void updateBees(int v, int maxVal) {
  //ignore any values of V above maximum freakout level
  // v = min(v, maxVal); does not work in Intel Galileo MacOS IDE

  if (v > maxVal) {
    v = maxVal;
  }

  //map the newly constrained V to the beeActivityLevel array
  //the top value is 1 less than the number than the array size
  //because the an array starts with the index number 0
  int mappedV = map(v, 0, maxVal, 0, beeActivityLevels-1);
  //Serial.println(mappedV);

  //for each bee, get the value it supposed to be and set it there
  for (int i=0; i <= beeTotalNumber-1; i++){
    //Serial.println(b[mappedV][i]);
    analogWrite(beePins[i], b[mappedV][i]);
  }

}

Related Posts

  • Part 1
    • This overview
  • Part 2
    • From Zero to Blink.
    • Creating an SD card image and getting a sketch to persist on the Galileo
    • UPDATE: Blink on an external LED
  • Part 3 (This Post)
    • Creating the bees and getting them to work on an Arduino UNO
  • Part 4
    • Setting up Wifi (very easy, library examples worked immediately)
    • Getting the SD card read & write to work (a missing libraries/symlink problem)
  • Part 5
    • Serial Communication to the Linux Core
    • Troubleshooting Python on the Galileo
  • Part 6
    • Revising the example String to Int code (lack of Null Termination problems)
    • Moving the motors over to the Galileo

carlynorama is Stephen Fry proof thanks to caching by WP Super Cache