-
Source Code
02/20/2016 at 22:44 • 0 commentsThis is the first prototype version, but still here's the source code if you are interested in how it's done:
#include <Servo.h> Servo servos[2]; void move(int position) { static int current = -1; if (position == current) { return; } current = position; servos[0].attach(9); // right servos[1].attach(10); // left switch (position) { case 0: // Perk up. servos[0].writeMicroseconds(1500 + 300); servos[1].writeMicroseconds(1500 - 300); Serial.println("perk"); break; case 1: // Droop down servos[0].writeMicroseconds(1500 - 300); servos[1].writeMicroseconds(1500 + 300); Serial.println("droop"); break; case 2: servos[0].writeMicroseconds(1500 + 300); servos[1].writeMicroseconds(1500 + 300); Serial.println("left"); break; case 3: servos[0].writeMicroseconds(1500 - 300); servos[1].writeMicroseconds(1500 - 300); Serial.println("right"); break; default: Serial.println("unknown"); } } void rest() { servos[0].detach(); servos[1].detach(); } void setup() { Serial.begin(115200); move(0); } void loop() { int z = analogRead(A0) - 490; int y = analogRead(A1) - 490; int x = analogRead(A2) - 490; Serial.print(x); Serial.print(", "); Serial.print(y); Serial.print(", "); Serial.print(z); Serial.println(); if (x > -10) { if (y > 10) { move(2); } else if (y < -10) { move(3); } else { move(0); } } else { move(1); } delay(600); rest(); }
-
First Prototype Working
02/20/2016 at 22:03 • 0 commentsI got the first version to work. Here's the demo video:
There are several things there. I have the control board with the battery and accelerometer sitting at the top of my head -- this is obviously suboptimal, especially during rain. I suppose I can hide most of the electronics and the battery inside the ears themselves -- there is enough room for that. But the accelerometer has to stay. Or I could move the whole thing to the side, making it look like a bluetooth headset or something -- I would just need to switch the accelerometer axes then. I need to sleep on that.
Second thing, the range of movement is really limited. Those tiny servos don't really have enough strength to squash the material of the ears enough to flatten or perk them completely. I used those little guys, because I was afraid about space, but turns out that there is a lot of room inside those ears, so I might try with 9g servos next.
Third, they make noise. Since constant buzzing would be annoying and would drain the battery fast, I'm actually switching the servos off (by disabling PWM signal) when they are not changing the ears position. I only enable them for 600 milliseconds when they need to move. It would be much cooler to have them move fluently all the time, but not with those servos.
Fourth, I guess I could attach them to a hat -- then there would be no problem with hiding the electronics, and I could even have a larger battery.
Fifth, right now they only react to the head position. I need to experiment with tracking how fast I'm moving, and make them move based on that too -- make them droop when I'm not moving, and perk up when I make a sudden move with my head. Also, twitch them randomly when they are perked up.
-
Movement Test
02/20/2016 at 18:43 • 2 commentsI have the mechanical part ready, and I did a small test of the ears movement. They move so slow because that's what the test does, not because they are so slow -- in fact, they can move into a new position quite fast.
On the control side, I gave up on the Pololu IMU, and instead went with a simple GY-61 analog accelerometer. This should be more than enough, since I only need to react to movements, and this is much simpler to interface.
-
Installing Servomechanisms
02/20/2016 at 12:49 • 0 commentsOf course I don't want the mechanisms to show, so I have to put most of it inside the ears themselves. The servomechanisms are simple -- I made some longer levels from servo horns connected with small screws. Then I inserted that into the ear through a small hole that was helpfully left in it:
I initially planned to secure them by sewing, but I couldn't be bothered to find my needle, so I just secured the servo horns with more of the small screws:
I might remove them later and replace with some stitches after all.
Next, programming. I found a Pololu Mini IMU 9 in a drawer, so I guess that's what I'm going to use for the accelerometer. I found some example programs in the documentation, and I'm trying them now. More in the next log.