Thursday, September 23, 2010

Ducted Fan and Arduino

So I was looking for more of a breeze...




...seems like I've got some good breeze now with the 56mm ducted fan. Be careful, these ducted fans will slice your finger off!


Below is the sketch that works with the Great Planes ESC (adapted from other people's ESC sketches). It arms the ESC, then sweeps the speed up, stop, back to full speed, and sweeps back down to off.

#include <Servo.h>

Servo myservo;

void arm(){
// arm the speed controller, modify as necessary for your ESC
Serial.println("arming");
setSpeed(30);
delay(2000);
setSpeed(90);
delay(2000);
Serial.println("armed");
setSpeed(30);
delay(2000);
}

void setSpeed(int speed){
// speed is from 0 to 100 where 0 is off and 100 is maximum speed
//the following maps speed values of 0-100 to angles from 0-180,
int angle = map(speed, 0, 100, 0, 180);
myservo.write(angle);
}

void setup()
{
Serial.begin(115200);
myservo.attach(9);
arm();
}

void loop()
{
int speed;

Serial.println("Sweeping up");
for(speed = 37; speed <= 90; speed += 1) {
setSpeed(speed);
Serial.println(speed);
delay(100);
}
setSpeed(30);
delay(1000);
Serial.println("Sweeping down");
for(speed = 90; speed > 37; speed -= 1) {
setSpeed(speed);
Serial.println(speed);
delay(100);
}
Serial.println("30 halting...");
setSpeed(30);
delay(5000);
}

Sunday, September 19, 2010

Brushless Motor Test

I hooked up a Great Planes Ammo 20-40-3500 In-Runner Brushless Motor attached to Great Planes Silver Series 25A Brushless ESC 5V/2A BEC powered by Radio Shack 7.2V battery and controlled by Arduino servo library.

This ESC has three control wires. Brown is ground, Red is the ESC "battery eliminator ciruit (BEC)" +5V, and Orange is the servo pulse control. I hooked up the Brown wire to the Arduino ground, and the Orange wire to Arduino pin 9, and left the Red wire not hooked to anything:




Friday, September 17, 2010

Cross-method PHY2PHY?

So I'm all in to physical-to-physical interactions over the Internet (PHY2PHY), but here is an interesting cross-method interaction which is just asking to be extended over the Internet:

Saturday, September 11, 2010

Speeding up Arduino PWM

If you ever need to speed up the Arduino PWM frequency, here is an example. You can manipulate the counter prescalar with TCCR1B, and the amount it counts up each cycle with ICR1:

int i;

void setup()
{

pinMode(2, OUTPUT); // direction pin
digitalWrite(2, LOW); // set direction CW

TCCR1A = 0x00; // sets timer control bits to PWM Phase and Frequency Correct mode
TCCR1B = 0x12; // sets timer control bits to Prescaler N = 8
ICR1 = 500; // Upper Timer Limit

analogWrite(9,1); // for Geckodrive controller you want a very short on pulse

Serial.begin(115200);
Serial.println("Delaying 100...");
delay(100);

}

void loop()

{
for(i=500;i>70;i=i-1){
Serial.println(i);
ICR1=i;
delay(20);
}
for(i=70;i<500;i=i 1){
Serial.println(i);
ICR1=i;
delay(20);
}
}


I believe the prescalar leads to 16 MHz / 8 = 2 MHz, then I count up to 500 meaning about 4 kHz frequency output, then I move it up to a 70 count or 28.5 kHz.

Wednesday, September 08, 2010

Ducted fans!

When you are starting a new tech art project, you are engaging in a search for the best way to implement your idea.

As soon as you make a large purchase, you immediately will find an even better solution!

I've had lots of fun with the servomotors, but now I am wondering about ducted fans and from the R/C hobby world for breath-over-IP, it sure would be a BLAST!

They appear to have electronic speed control, but I wonder how fast they can speed up/slow down. Also I'd need a 34A @ 11V power supply, not hard for a big battery, but tougher for a 120V based system.

These R/C electric airplane motors are much faster than industrial servomotors (8-20 kRPM versus 3-4 kRPM), so I suspect their props are probably more efficient (more lift, less drag). Apparently you can get the motor and esc together or a ducted fan motor/prop/esc together well. But you better put some mesh on it or you will slice off someone's finger!

Saturday, September 04, 2010

Geckodrive accuracy test



I hooked up the quadrature encoder outputs from one Tohoko Ricoh Type 7K00011 servomotor into an Arduino. I am using the input pull-up trick of doing a digitalWrite(HIGH) on the quadrature input pins. The quadrature A and B inputs are translated by the Arduino program into the step and direction signals into Geckodrive 320X controller attached to a second 7K00011 servomotor.

One thing I found is that to ensure accuracy, the pulses going to the Geckodrive 320X must have a very short high time. I started with a 500 uS high time, but the second motor was not tracking the first one very closely. I ended up with 10 uS high time for the pulse, and that seemed to keep the two motor shafts perfectly synchronized. The Geckodrive is rated for Step Pulse "1" Time down to 1.5 uS.

A second thing I found is that for every one quadrature step on the first motor, I needed to send four pulses to the Geckodrive. There is something in the spec sheet that says "Feedback Resolution: X4 Encoder Line Count", so maybe that explains it.

Here is the code for this example (which can help you with quadrature encoder decoding in general as well):

//
// Use quadrature sensors in one unpowered motor to
// drive other powered motor in synchronized fashion
//

int a=0; // current quadrature A
int b=0; // current quadrature B
int al=0; // last quadrature A
int bl=0; // last quadrature B

void setup() {
pinMode(2, OUTPUT); // step to Geckodrive
pinMode(3,OUTPUT); // direction to Geckodrive
digitalWrite(3,LOW);
pinMode(6, INPUT); // A quadrature input
pinMode(7, INPUT); // B quadrature input
digitalWrite(6,HIGH); // pull-up A input
digitalWrite(7,HIGH); // pull-up B input
}

void pulse(int direction)
// perform one pulse
{
unsigned long wait=0;
digitalWrite(3,direction); // signal direction
for(int i=0;i<4; i){
wait=micros();
digitalWrite(2,HIGH);
while(micros()-wait<10); // high for 10 uS
digitalWrite(2,LOW);
wait=micros();
while(micros()-wait<15); // low for at least 15 uS
}
}

void loop()
{
a=digitalRead(6); // read quadrature A
b=digitalRead(7); // read quadrature B

// decode quadrature input
// and pulse in proper direction

if((al != a) || (bl != b)){
if((al == 0) && (bl == 0)){
if((a==0)&&(b==1)){
pulse(LOW);
}else if((a==1)&&(b==0)){
pulse(HIGH);
}
}
if((al=0)&&(bl=1)){
if((a==1)&&(b==1)){
pulse(LOW);
}else if((a==0)&&(b==0)){
pulse(HIGH);
}
}
if((al==1)&&(bl==1)){
if((a==1)&&(b==0)){
pulse(LOW);
}else if((a==0)&&(b==0)){
pulse(HIGH);
}
}
if((al==1)&&(bl==0)){
if((a==0)&&(b==0)){
pulse(LOW);
}else if((a==1)&&(b==1)){
pulse(HIGH);
}
}
}
// record history of last quadrature state
al=a;
bl=b;
}

Friday, September 03, 2010

Linux SBCs with Ethernet - too many!

Finally, the affordable (~$100) Linux SBC with Ethernet is here.

The Chumby Board is now available for $89. Add USB Ethernet connector for $15, and you've got yourself a $104 Ethernet-enabled Linux SBC with:
  • Freescale iMX.233 processor running at 454 MHZ
  • 64 MB onboard RAM
  • Comes with 512MB uSD card with 100 MB Linux installation all ready to go
  • 3 USB ports (2 after you add Ethernet)
  • Built-in Lithium Ion/Polymer battery charger and 5V boost converter for portable projects
  • 1.9W mono speaker amplifier into 4ohm (0.1" JST onboard connector)
  • Microphone input (0.05" JST onboard connector)
  • LCD controller with 2mm output port
  • 3.5mm A/V output jack with stereo audio and NTSC/PAL composite video
  • Quadrature encoder connections onboard
  • 5-way joystick on-board
  • MMA7455 3-axis +-2G to +-8G accelerometer on-board
Very interesting, and great competition to the Mini2440 board, which is $89 with Ethernet, with the same amount of RAM and 128MB of flash RAM on board (can be as big as 1GB for more money). The Mini2440 doesn't have the NTSC/PAL video, accelerometer, or battery charger.

I am having some trouble getting DHCP to work on the Mini2440 with the base Linux/Qtopia load (based on Busybox, it evidently uses udhcpc which requires me to write a not-well-documented script).

Meanwhile my SheevaPlug finally showed up ($99, but with 120VAC supply):


SheevaPlug

Not much time to play with it the SheevaPlug yet. I am intending to use it for an Ethernet-to-serial application (using a USB-to-serial converter).

The GPIO lines are pretty much hidden in the SheevaPlug, whereas the Mini2440 and Chumby Board have them easily available.

On the other hand, SheevaPlug ships with Python, so development on it is a breeze!

Thursday, September 02, 2010

Geckodrive is awesome

I am very impressed with the Geckodrive 320x. It works very well with the Tohoko Ricoh Type 7K00011 Servo Motor. I used an Arduino as the pulse source to control the speed:




As you hook up the Geckodrive 320X, follow the instructions step by step, and don't forget to hook Terminal 5 (ERR/RES) to Terminal 7 (Encoder +5VDC), or else the controller won't work. Also for the Tohoko Ricoh Type 7K00011 Servo Motor, you should set switch SW6 (HEDS) to "ON" to provide an active pullup for the encoder.

And the 320X didn't even get very warm - great heat engineering!

The Geckodrive is a highly precise device. You drive it with pulses. Each pulse means the motor is to move ahead on pulse on the encoder. Of course, motors can just speed up and slow down infinitely fast, so if you change the input pulse rate, there is a brief period of error where the Geckodrive applies a higher duty cycle PWM to the motor to catch up. However if the error is too much (configurable by DIP switches on the Geckodrive), the controller assumes there is a fault, stops for a second, accepts the new position as "good" and starts again.

At the end of the video above, I am probably trying to drive the motor faster than it can actually go, thus the controller faults out.

Also you can't just start the motor at its highest speed. You might have to start it at a slightly lower pulse rate and ramp it up to a higher speed, or else the controller might fault out. I am going to experiment with increasing the 256 count following error limit to the 2048 count following error limit and see how that changes the ability to do a cold start to a high speed.

Also I may try a sneaky thing where I hook up the encoder from a second motor to an Arduino, read the quadrature input to generate a pulse and direction signal, and send that into the Geckodrive to see if my twisting of the rotor on the undriven motor is reflected in the driven motor.

I think the Geckodrive and Tohoko Ricoh Type 7K00011 Servo Motor may work not only for "Breath 2 - the proportional version" but also for Ouija board over IP. I have to put a fan on the motor and see if I get a good breeze from it.