Tuesday, January 6, 2009

3 phase sin wave

I've managed to generate a 3 phase sin wave on the sanguino. Its just pulsing LEDs at this point, but I am able to modulate the frequency and the amplitude. Still have lots of work to do as this current code uses the analogWrite command which does PWM at about 490 Hz. I'm going to need this to work a lot faster. Also I've used a delay command to change the frequency. I'd like to come up with a way to not use any delays in the program. Here it is if anyone is interested:

// 3 phase sin wave output
// by Swamijake

int sinarray [] = {0,0,87,0,0,87,3,0,85,0,0,88,7,0,83,0,0,90,10,0,81,0,0,91,14,0,79,0,0,93,17,0,77,0,0,94,21,0,74,0,0,95,24,0,72,0,0,96,28,0,69,0,0,97,31,0,67,0,0,98,34,0,64,0,0,98,37,0,62,0,0,99,41,0,59,0,0,99,44,0,56,0,0,100,47,0,53,0,0,100,50,0,50,0,0,100,53,0,47,0,0,100,56,0,44,0,0,100,59,0,41,0,0,99,62,0,37,0,0,99,64,0,34,0,0,98,67,0,31,0,0,98,69,0,28,0,0,97,72,0,24,0,0,96,74,0,21,0,0,95,77,0,17,0,0,94,79,0,14,0,0,93,81,0,10,0,0,91,83,0,7,0,0,90,85,0,3,0,0,88,87,0,0,0,0,87,88,0,0,3,0,85,90,0,0,7,0,83,91,0,0,10,0,81,93,0,0,14,0,79,94,0,0,17,0,77,95,0,0,21,0,74,96,0,0,24,0,72,97,0,0,28,0,69,98,0,0,31,0,67,98,0,0,34,0,64,99,0,0,37,0,62,99,0,0,41,0,59,100,0,0,44,0,56,100,0,0,47,0,53,100,0,0,50,0,50,100,0,0,53,0,47,100,0,0,56,0,44,99,0,0,59,0,41,99,0,0,62,0,37,98,0,0,64,0,34,98,0,0,67,0,31,97,0,0,69,0,28,96,0,0,72,0,24,95,0,0,74,0,21,94,0,0,77,0,17,93,0,0,79,0,14,91,0,0,81,0,10,90,0,0,83,0,7,88,0,0,85,0,3,87,0,0,87,0,0,85,0,0,88,3,0,83,0,0,90,7,0,81,0,0,91,10,0,79,0,0,93,14,0,77,0,0,94,17,0,74,0,0,95,21,0,72,0,0,96,24,0,69,0,0,97,28,0,67,0,0,98,31,0,64,0,0,98,34,0,62,0,0,99,37,0,59,0,0,99,41,0,56,0,0,100,44,0,53,0,0,100,47,0,50,0,0,100,50,0,47,0,0,100,53,0,44,0,0,100,56,0,41,0,0,99,59,0,37,0,0,99,62,0,34,0,0,98,64,0,31,0,0,98,67,0,28,0,0,97,69,0,24,0,0,96,72,0,21,0,0,95,74,0,17,0,0,94,77,0,14,0,0,93,79,0,10,0,0,91,81,0,7,0,0,90,83,0,3,0,0,88,85,0,0,0,0,87,87,0,0,3,0,85,88,0,0,7,0,83,90,0,0,10,0,81,91,0,0,14,0,79,93,0,0,17,0,77,94,0,0,21,0,74,95,0,0,24,0,72,96,0,0,28,0,69,97,0,0,31,0,67,98,0,0,34,0,64,98,0,0,37,0,62,99,0,0,41,0,59,99,0,0,44,0,56,100,0,0,47,0,53,100,0,0,50,0,50,100,0,0,53,0,47,100,0,0,56,0,44,100,0,0,59,0,41,99,0,0,62,0,37,99,0,0,64,0,34,98,0,0,67,0,31,98,0,0,69,0,28,97,0,0,72,0,24,96,0,0,74,0,21,95,0,0,77,0,17,94,0,0,79,0,14,93,0,0,81,0,10,91,0,0,83,0,7,90,0,0,85,0,3,88,0,0,87,0,0,87,0,0,88,3,0,85,0,0,90,7,0,83,0,0,91,10,0,81,0,0,93,14,0,79,0,0,94,17,0,77,0,0,95,21,0,74,0,0,96,24,0,72,0,0,97,28,0,69,0,0,98,31,0,67,0,0,98,34,0,64,0,0,99,37,0,62,0,0,99,41,0,59,0,0,100,44,0,56,0,0,100,47,0,53,0,0,100,50,0,50,0,0,100,53,0,47,0,0,100,56,0,44,0,0,99,59,0,41,0,0,99,62,0,37,0,0,98,64,0,34,0,0,98,67,0,31,0,0,97,69,0,28,0,0,96,72,0,24,0,0,95,74,0,21,0,0,94,77,0,17,0,0,93,79,0,14,0,0,91,81,0,10,0,0,90,83,0,7,0,0,88,85,0,3,0,0,87,87,0,0,0,0,85,88,0,0,3,0,83,90,0,0,7,0,81,91,0,0,10,0,79,93,0,0,14,0,77,94,0,0,17,0,74,95,0,0,21,0,72,96,0,0,24,0,69,97,0,0,28,0,67,98,0,0,31,0,64,98,0,0,34,0,62,99,0,0,37,0,59,99,0,0,41,0,56,100,0,0,44,0,53,100,0,0,47,0,50,100,0,0,50,0,47,100,0,0,53,0,44,100,0,0,56,0,41,99,0,0,59,0,37,99,0,0,62,0,34,98,0,0,64,0,31,98,0,0,67,0,28,97,0,0,69,0,24,96,0,0,72,0,21,95,0,0,74,0,17,94,0,0,77,0,14,93,0,0,79,0,10,91,0,0,81,0,7,90,0,0,83,0,3,88,0,0,85};

// generated the array in excel, it is 6 outputs (one positive and one negative for each phase) times 180 bins for 2 degree resolution

int pot_value = 0; // input for the potentiometer used to control frequency
int analog_pin = 0; // input pin for pot

int max_volts = 0; // controls amplitude of the sin wave
int analog_volt = 1;

int value_pwm_1 = 0; // variable to keep the actual value_pwm_1
int ledpin_1 = 3; // light connected to digital pin 3
int array_tag_1 = 0; // where to get first value for phase 1 positive from array, first value in array is tagged at 0

int value_pwm_2 = 0; // variable to keep the actual value_pwm_2
int ledpin_2 = 4; // light connected to digital pin 4
int array_tag_2 = 1; // where to get first value for phase 1 negative from array

int value_pwm_3 = 0; // variable to keep the actual value_pwm_2
int ledpin_3 = 12; // light connected to digital pin 12
int array_tag_3 = 2; // where to get first value for phase 2 positive from array

int value_pwm_4 = 0; // variable to keep the actual value_pwm_2
int ledpin_4 = 13; // light connected to digital pin 13
int array_tag_4 = 3; // where to get first value for phase 2 negative from array

int value_pwm_5 = 0; // variable to keep the actual value_pwm_2
int ledpin_5 = 14; // light connected to digital pin 14
int array_tag_5 = 4; // where to get first value for phase 3 positive from array

int value_pwm_6 = 0; // variable to keep the actual value_pwm_2
int ledpin_6 = 15; // light connected to digital pin 15
int array_tag_6 = 5; // where to get first value for phase 3 negative from array

void setup()
{
pinMode(7, OUTPUT); // using an LED on pin 7 to indicate the completion of one complete cycle on phase 1
}

void loop()
{
pot_value = analogRead(analog_pin) / 100; // using a pot to control the frequency
max_volts = analogRead(analog_volt) / 4; // changes the max voltage based on the second pot

analogWrite(ledpin_1, (sinarray[array_tag_1] * max_volts / 100)); // sets the value_pwm_1 picked from the array
analogWrite(ledpin_2, (sinarray[array_tag_2] * max_volts / 100)); // sets the value_pwm_2 picked from the array
analogWrite(ledpin_3, (sinarray[array_tag_3] * max_volts / 100)); // sets the value_pwm_3
analogWrite(ledpin_4, (sinarray[array_tag_4] * max_volts / 100)); // sets the value_pwm_4
analogWrite(ledpin_5, (sinarray[array_tag_5] * max_volts / 100)); // sets the value_pwm_5
analogWrite(ledpin_6, (sinarray[array_tag_6] * max_volts / 100)); // sets the value_pwm_6

if (array_tag_1 < 1074) { // 1074 is the last the last array tag for phase 1 postive, so below that we add 6 to each tag to get to the next spot for each phase in the array

array_tag_1 = array_tag_1 + 6;
array_tag_2 = array_tag_2 + 6;
array_tag_3 = array_tag_3 + 6;
array_tag_4 = array_tag_4 + 6;
array_tag_5 = array_tag_5 + 6;
array_tag_6 = array_tag_6 + 6;


}

else { // after 1074 we reset all the array tags to their original value

digitalWrite (7,HIGH); // I flash an LED to see the completion of each cycle

array_tag_1 = 0; // this resets the array counters back to zero
array_tag_2 = 1;
array_tag_3 = 2;
array_tag_4 = 3;
array_tag_5 = 4;
array_tag_6 = 5;

}

delay(pot_value); // delays and reruns the whole thing after going through each full cycle. I need to be able to due this without delays and with faster PWM

digitalWrite (7,LOW);




}

Wednesday, December 31, 2008

Thoughts on batteries

So the idea about recycling packs from old power tools is essentially dead. I did some calculations and figure that such a pack would weigh more than a given lead pack. yikes. There are a few lithium options that would be great but still very expensive, likely 10-12 thousand for a decent pack. Another option is the very cool sounding molten salt nickel or Zebra battery being manufactured by Cebi in Switzerland. No idea on the current cost as they are only selling to OEMs, but in the long run should be much cheaper than a lithium pack.

IGBT's on the way

I won an ebay auction for 3 Fuji 1200 V 200 amp IGBT's. They should be here in a few weeks. woot!

Tuesday, December 23, 2008

Shopping List

So here is the list of parts I'm trying to scavenge. Any help would be greatly appreciated.

  1. Motor, 30 to 40 Hp 1800 or 3600 RPM TEFC, any frame size. Burnt out is okay as I will likely have to rewind it anyway.
  2. IGBTs. Need 3. Looking for at least 600V, 200 to 300 amp. I'll likely find these on Ebay.
  3. Firing Cards. The sanguino only outputs 5V at low current, so will need to step this up to fire the IGBTs. I'll likely buy the PWM cards from the Reprap store.
  4. Current Shunt. I need to measure somewhere up to 200 to 300 amps. These are available pretty cheap on Ebay.
  5. Encoder - already have one from BEI coming from Ebay. I've used these with great success in industrial applications. However the unit I won is a 1000 pulse per revolution, which may be too many pulses per second.
  6. Busbar - This stuff is expensive, but I will try and find some from my favorite used electrical guys at ACNelson. If not I will flatten some copper pipe.
  7. Fuses - I'd like to include low voltage control fuses and a high voltage high amp high speed semiconductor fuse on the DC bus. I think this might be one place I buy new.
  8. DC Contactors - I'd like to use two or three single pole contactors in series in the pack such that when the car is off, or any thing bad happens, all the contactors drop out, reducing the total voltage anywhere in the pack. And one big two pole contactor for the main contactor. Not sure where I am going to find these.
  9. Circuit Breaker - I need a 400V 200A breaker. Still looking for a solution.
  10. Throttle - need a beefy industrial potentiometer to be used for the throttle. Will be doing some sort of regen as well, but not yet sure if I will do this off the brake pedal.
That's it to start.

Request for Batteries

I have an idea for the battery pack. There are lots of dead cordless power tools floating around. When these packs go bad, it is usually just one or two cells that are toast. I'm thinking I could pull apart dead packs, and scavenge the remaining good cells to build the pack. It would be a lot of futzing around, but it would be free.

So, if anyone has dead tool packs you'd like to recycle, send me an email at "jake (at) jakegray (dot) ca" and I'll give you my address.

Issues I had with the sanguino

I bought the kit from the Rep Rap Store, and they are great. It came very fast, and was well packaged and complete. The online instructions are easy to follow, and though the soldering pads are quite small, I had no problems with the assembly.

I had a bit of a challenge getting my first program to upload. The instructions didn't mention getting a driver for the USB to TTL cable that is required for programming the sanguino. Once the drivers were downloaded and installed, it worked great.

Changing the Purpose of this Blog.

As the election is long passed, and I'm back to the regular part of my life, I'm going to start using this to document my attempt to build an electric car. I'll be kluging together all the parts I can scrounge, and recycling or upcylcing at every opportunity. This will be the ultimate cheap skate ride.

Here is the basic idea:

Find an old small light car to convert. I have a friend with a '68 VW beetle who may be interested in donating it to the cause. It's a bit rusty, but I'm a decent welder and the replacement steel is cheap.

Ditch the engine/gas tank and anything else no longer needed, hopefully selling the engine for the cost of the steel repairs.

Find a burnt out 30 to 40 hp squirrel cage AC motor for scrap value. Grind off the cooling fins, weld on a water jacket, fabricate an adapter to the transmission, replace the bearings, and rewind with high quality windings.

Make my own VFD for controlling the motor. I'm going to use a sanguino which I have already bought and built. I'm having to learn how to program it which is very fun. I've bought an encoder off ebay and will be trying to implement some kind of vector control. I like full torque at 0 rpm.

Highish voltage pack. Somewhere around 400V DC. Still trying to figure out what batteries to use. If I can find a sponsor I will try and use lithium. I have no problem plastering the car with some companies logo if it means we can afford a juicy highpower pack. Only issue is lithium needs a much more complex pack controller, and the fact lithium is about 4 times the price of lead. Looking for about a 17 kwh pack which should make for at least an 80km range. More to follow.

Homebuilt progammable charger. I'll likely use a microcontroller, a big IGBT and a welding power supply.

Woot.