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
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.
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!
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; }
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):
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!
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.
There is pretty much no heat sink on the Pololu Jrk 21v3 USB Motor Controller with Feedback. So basically that means if you try to do any kind of serious control of start/stop/speed of a real motor (say 24V / 0.3A), you will end up melting it. There isn't much in the manual about how to even mount a heat sink, the thing is so small and there is plenty of exposed solder blobs that it would be tough to do. Having made other motor controllers get seriously hot in the past using PWM control, I guess I'm not surprised.
I'm moving up to the Geckodrive G320X. The whole bottom of it is a heat sink.