Archive for the arduino Category

Shoes work again!

Posted in arduino, giant, Hot glue is the best thing in the universe. Deal with it., LED on May 27, 2010 by raphaelabrams

The giant baby shoes work again. They blink on each footstep.

Advertisements

Boards are in!

Posted in arduino, electronics on May 27, 2010 by raphaelabrams

We got our custom circuit boards! You’ll probably want to change them around for your own purposes but here and here are the EAGLE CAD files. What we have is essentially an Arduino with a whole mess of servo headers and a couple of analog filters. The servo headers have unregulated battery voltage and the rest of the circuit is on a 5V regulator. The filters are envelope followers with a buffer stage to feed the A/D inputs on the AVR.

Here it is with parts soldered in:

Japanese readers: Just be glad I’m practicing my calligraphy, OK?

Autoblink

Posted in arduino, servos, Uncategorized on May 14, 2010 by raphaelabrams

The eyes now blink automatically. They will flit closed semi-randomly with minimum and maximum time spans between blinks. When the puppeteer wants to take over, they can be switched to manual mode.

How about some code!

unsigned long last_time = millis();
unsigned long time = millis();
unsigned long autoblinkdelay=1000;
unsigned int blinkingnow=0;
void loop(){

//do some other things in the loop here//

//now, the blinking stuff:

  time = millis();  //get the current time in milliseconds
  if ((time-autoblinkdelay)>last_time){
    blinkingnow=autoblink_duration;  //fill up the blinking timer, when it reaches zero the eye will open back up
    autoblinkdelay=random(autoblink_mintime,autoblink_maxtime);  //randomly select how long until the next blink
    last_time=time; //holder for comparing times in the next iteration of the loop
  }
  if(blinkingnow){  //is "blinkingnow" empty? if not, keep eye closed
    blinkingnow--;
    eyes_output=eyes_servo_closed;
    soft_servo(EYES_SERVO,eyes_servo_closed);
  }
  else{  //open the eye!
    eyes_output=eyes_servo_open;
    soft_servo(EYES_SERVO,eyes_servo_open);
  }
  delay(4); //delay to let the servo have time to get where it goes
}

Servo Library Seems Unreliable

Posted in arduino, servos on May 1, 2010 by raphaelabrams

I’m not sure why, but it seems like the Arduino servo library has some sort of periodic twitch to it. Every few seconds or so it gives a pulse that’s too long, which makes the servo try to get all the way over to one side for a split second. Not a problem with cheap servos that have a slow response, but the fancy-pants ones that we’re using are giving an annoying flicking movement to everything. So I decided to just use a simple loop instead:

#define MINIMUMPULSE 550    // Minimum servo position
#define MAXIMUMPULSE 2400   // Maximum servo position

void soft_servo(char pin, int angle){
  angle=constrain(angle, MINIMUMPULSE, MAXIMUMPULSE); //keep it within a safe range
  digitalWrite(pin, HIGH); //start the pulse
  delayMicroseconds(angle);       // Length of the pulse sets the motor position
  digitalWrite(pin, LOW);  //end the pulse
}

void loop(void){
  do this;
  do that;
  soft_servo(whichservo,whatangle);
  delay(10); //give things a bit of time to settle. Something between 1ms and 40ms
}

Advantage: no more funny pulses. Interrupts† and timers are free for other uses.

Disadvantage: has to be called every few milliseconds or else the servo goes slack. Maybe there’s a way to program a modern digital servo to hold a position indefinitely with one command pulse? That would be handy!

In practice I haven’t had any trouble running a servo refresh in my main loop. 10mS is an eternity in which to calculate the math and gather sensor data.

†Disable interrupts during the pulse or else it may get elongated and send the servo into unknown territory!

Wiggly minions, I bring you LIFE!

Posted in analog, arduino, robotics, servos, sound, Uncategorized, update on April 26, 2010 by raphaelabrams

Hi folks! This is Raphael Abrams here! I’m an artist living in Brooklyn, doing all kinds of odd skilled labor to make a living. I teach electronics at NYC Resistor (I’m a co-founder), design open source electronic kits, do contract electrical engineering and when I get the chance I try to make art.

This blog will serve as a record of my new adventures in animatronics and puppetry. I’ll be sharing what I learn, and I hope you might be able to find something useful!