Wednesday, April 13, 2011

How to make magic blue smoke

Trying to drive an old hdd motor I cooked my arduino's microcontroller. Luckily they're only $5, but shipping and waiting will suck. It sucks because I had that bitch kickin' over. I wrote a simple little sketch that pulsed the pins at 90 milliseconds then slowly incremented the pulses faster and faster. I had it going dammit! It wasn't until I plugged in an 18V power supply from an old laptop that I got to see the magic smoke. I had it wired right but something wasn't right so grounded the the arduino with the ground from power supply and poof. Anyway, here's what I had. I didn't get a chance to take video of it going because I killed it.




You can see from the pics I was just using the 5v from the uno to push the motor at this point. It did work, just no torque. I'll throw up some pics of the abortion that I have now whenever my new microcontroller gets here. Here's the sketch.
/* BLDC Driver
*/
int drivePin1 = 9; //set the pin numbers for coils
int drivePin2 = 10;
int drivePin3 = 11;

int delayTime = 90; //Pulse timing will replace with adjustable pwm

void setup(){

pinMode(drivePin1, OUTPUT);
pinMode(drivePin2, OUTPUT);
pinMode(drivePin3, OUTPUT);
}

void loop(){
for (int delayTime = 90; delayTime > 40; delayTime = delayTime - 1){
digitalWrite(drivePin1, HIGH);
digitalWrite(drivePin3, LOW);
delay(delayTime);
digitalWrite(drivePin2, HIGH);
digitalWrite(drivePin1, LOW);
delay(delayTime);
digitalWrite(drivePin3, HIGH);
digitalWrite(drivePin2, LOW);
delay(delayTime);
}
while (delayTime = 40){
digitalWrite(drivePin1, HIGH);
digitalWrite(drivePin3, LOW);
delay(delayTime);
digitalWrite(drivePin2, HIGH);
digitalWrite(drivePin1, LOW);
delay(delayTime);
digitalWrite(drivePin3, HIGH);
digitalWrite(drivePin2, LOW);
delay(delayTime);
}}

No comments:

Post a Comment