Electric cars are the future, and are beginning to take off today. However, they are still pretty expensive. A 3 phase AC motor is the absolute standard for car companies when they make an electric vehicle. The Tesla Roadster, Nissan Leaf, etc... All of the big boys use AC. It has a number of advantages over DC. An AC motor can last almost forever. You get regenerative braking for free, so that the energy you used to get your car moving can be captured and put back into your battery pack. This also makes the brakes last almost forever! There are almost no parts that get any wear in an AC motor except for the ball bearings, which are typically very durable.
The market is literally flooded with 3 phase industrial AC motors, so you can get them CHEAP if they are used. Yet, almost all DIY electric vehicle conversions are done using a DC motor. Why is that? One big reason is that the motor controller is typically very expensive. For example, a 211kW Brusa AC motor controller for use in an electic car will run you $21,000:
I'm going to walk you through the process of building your own 200kW (268 HP!!) AC motor controller for around $1000. It can be less than that if you get a few good deals on Ebay, or are content with less power.
I wrote the field oriented control software that goes on the dsPIC30F4011 microcontroller, and am making it freely available to do with as you please. If you want to modify it, MPLab is free:
Also, I made the PCB used for the control and driver section, and am making the schematic and pcb artwork available for you to modify to your heart's content. They were made in DesignSpark, which is also completely free to download:
So, if you want to modify the board, you can, and then can get your own board made at the PCB manufacturer of your choice.
Soldering skills are helpful for the PCB. There will be some aluminum drilling required, but it can be done with a hand drill if we get creative. Let's get started!
Step 1: Gather the parts
Here's a list of parts you will need:
1. 12" x 15" x 3/8" aluminum plate:
1a) Instead of an aluminum plate, you could use this heat sink. You would need it to be 15" long. But then you would have to drill AND tap the holes:
2. 20.5" x 15" x 0.063" aluminum sheet for the enclosure:
3. 5 feet of 2 gauge welding cable, and 10 #2 lugs with 1/4" or 5/16" eye holes.
4. 12" x 24" x 16 mil copper sheet:
5. 12" x 12" x 20 mil Nomex sheet for insulating the 2 copper sheets. The link below is enough for 6 controllers, but it's the smallest piece I could find. It's part number NMX4102001:
6. 5 feet x 1" x 1mil of Kapton tape (Ebay has a ton of this. It doesn't have to be 1" wide). Even electrical tape would probably be OK.
7. Screws & mounting hardware. Note: The links below are just for reference. They generally come in packs of 100, but you will only need a few of most of these. So, maybe a trip to the local hardware store would be cheaper. Also, instead of the 12mm x M4 nylon, 20mm x M4 zinc, and 30mm nylon standoffs, you can use #8 x 1/2" nylon, #8 x 3/4" zinc, and a #8 x 1.25" threaded nylon standoff. It's just that ebay had the metric versions cheaper:
http://www.tacomascrew.com/s.nl/it.A/id.21078/.f 1/4" x 3/4" flat head x24
http://www.tacomascrew.com/s.nl/it.A/id.22534/.f #8 x 1/2" nylon pan head x4
http://www.tacomascrew.com/Products/Machine-Screws... #8 x 3/4" zinc flat head x8
http://www.ebay.com/itm/Metric-Thread-M3-M4-M5-M6-... 12mm x M4 pan head nylon machine screws x4
http://www.tacomascrew.com/s.nl/it.A/id.23078/.f 20mm x M4 flat head zinc machine screws x4
http://www.ebay.com/itm/10pcs-30mm-1-18-Black-Nylo... 30mm x M4 nylon threaded standoffs x4
http://www.tacomascrew.com/Products/Flat-Washers/0... 3/16" flat washers x24
http://www.tacomascrew.com/s.nl/it.A/id.7193/.f M5 x 8mm hex head machine screws x16
http://www.tacomascrew.com/s.nl/it.A/id.22695/.f M3 x 6mm pan head machine screws x2
8. Control/Driver board:
9. Bill of Materials for the the control/driver board:
10. Power Capacitor (there are a number of fine choices for this. The link below is for the one I used, and is the best in the world, by a factor of 10. It eliminates the need for snubber capacitors):
11. Three IGBT half bridges. There are a bunch of types that would work fine. I just list 2 options below. You can often find very good deals for these on Ebay:
http://www.mouser.com/ProductDetail/Littelfuse/MG0... (this would allow for 100kW)
http://theelectrostore.com/shopsite_sc/store/html/... (This would allow for 200kW)
12. Three current sensors (you really only need 2, but the 3rd is for extra safety if you want it):
13. 5 feet of 20 gauge red, black, white, and yellow wire. Make sure it's rated for at least 300v. (It doesn't have to be those colors)
14. Thermal paste (there are millions of choices. Just about anything would be fine):
15: 0.11" female quick disconnect noninsulated x12. This goes on the PCB, but isn't a standard PCB part, so I'm not listing it in the bill of materials. It also works if you get insulated ones, and just pull off the insulation:
16. 600 grit sand paper:
Step 2: Drill and sand the base plate
Get the 15" x 12" x 3/8" aluminum plate ready.
The IGBT hole locations are based on the assumption that you are using one of these types of IGBTs:
http://www.pwrx.com/Product/CM600DY-12NF or http://www.pwrx.com/Product/CM600DY-24S
If you use smaller 400amp (or less) IGBTs, the IGBT mounting holes will need to be adjusted:
All hole locations on the picture are given relative to the upper left corner of the base plate. You will need a 3/16" drill bit, a 1/8" drill bit, a 1/4" drill bit, and a 1/2" countersinking bit. If you have a way to precisely drill the holes, go drill them and move on to the next step! If you don't have a super fancy mill, don't lose heart. It can still be done. These next steps are for those who only have a hand drill...
The base plate is officially drilled! Now, flip it back over and sand the area where the IGBTs get mounted, using 600 or 800 grit very fine sand paper. Notice in the picture of the base plate above how it's nice and smooth where it was sanded? Now, make sure there are no shards of aluminum raised up around the holes on the top and bottom side. If there are any, lightly drill the hole with the countersink bit to knock off the raised aluminum.
Step 3: Drill The Enclosure Holes
For those with a precise way to drill holes based on (x,y) coordinates, see the picture for notes on all the coordinates and diameters of the holes, and drill all of them!
For the rest of us, with only a lowly hand drill:
Step 4: Drill The Copper And Nomex Sheets
For those of you who have the ability to drill precise holes based on (x,y) coordinates, these 2 steps are for you!:
For the B+ sheet, the holes are pretty close together, so it's a little awkward to add the notes in the picture to indicate the coordinates. I'll just list them here:
For those who only have a hand drill:
Step 5: Solder The Control/Driver Board
First, let's talk a little about what the control/driver board is. It has all of the safety circuits, as well as the brains for controlling the motor. There's a dsPIC30F4011 microcontroller, which simultaneously samples 2 of the 3 phase currents, throttle position, and base plate temperature, and then based on that information, sets 6 pulse width modulation duties, which control the 6 IGBTs. Those 6 IGBTs power the 3 phases of the motor. The board also has several comparators, and some NAND and AND gates. So, if any current measured from the current sensors goes out of bounds, or the 24v or 5v power supply voltages go out of bounds, the controller shuts down the IGBTs in about 2 millionths of a second.
Each IGBT has it's own dedicated 24v power supply, as well as it's own driver to turn it on and off FAST. That helps to keep the IGBTs cool.
Let's start soldering! Solder the surface mount capacitors and resistors first. The easiest way to do that is to get solder paste:
and put some on each capacitor and resistor surface mount pad. The surface mount pads are the ones that have no holes through the board. And they are labeled Cxxx and Rxxx, where xxx is a number. For example, C21 or R15. Once the pads have a little dollop of solder paste on it, place the components on the pads. The paste should hold them in place. If you have a hot air soldering rework station, just hit them all with some hot air, and they will all solder into place nicely. Otherwise, hold each part down with a toothpick, and touch each pad with a soldering iron until it's good to go. These surface mount parts are very big as far as surface mount parts go (1206 and 1210 packages), so it shouldn't be too bad.
Next, solder all of the through-hole resistors and capacitors. YouTube has tons of soldering tutorials if it's new for you. The resistors have no polarity. The only 2 capacitors on the board with a polarity are the electrolytic "can" type.
Next, add all the diodes. Those parts on the board start with a D. For example, D5. Pay careful attention to the band on the diode! Make sure it is put in with the same orientation as the picture on the board (called "silkscreen").
Now, go ahead and do the SOIC parts (part number FOD8316). There are good videos on youtube for explaining how to solder SOIC parts. It's not too bad.
Now solder all of the other components. Make sure you have grounded yourself before touching all of the things that came in the static shielding bags. Basically, don't walk around dragging your feet on carpet before touching those components. I have a piece of sheet metal that's by my soldering station. The sheet metal is connected to the ground outside through a wire. I touch the sheet metal before I touch the static sensitive components. That way, any potential zapping that I would do is drained away to the earth. Be sure to program the ATTiny25 before soldering it in! It can be found here:
Also, the hex file is called DC-DC-Converter.hex, and is attached to this step. You will need an AVRISP MK2 to program it, or some sort of avr programmer. Also, you will need something like AVR Studio, which is free.
Debug the control board before proceeding!! If you have a bench supply, try giving it 23.5v-24.0v at the 24v supply (see picture above). Program the microcontroller with this debugging code, and measure the voltage between each pair of the 0.11" female quick disconnects. See the picture above for the notes on this:
Step 6: Bending The B+, B-, and Nomex Sheets
Bend the 3 sheets where the half drill holes are along the edge (remember when you kept half of the perimeter drill holes when you cut the sheets out?!). You can use a piece of wood and just fold the copper and nomex down. It should look like the pictures above when you are done. Also, with the B+ sheet, you need to solder 3 wires to it as you can see in the picture. It will take a heavy duty soldering gun. Only do the soldering on B+ while the nomex isn't right next to it. The PCB needs the B+ voltage, and this is how I did it. You could run wires from where the IGBTs bolt to the B+ sheet if you are unable to solder the wires to the B+ sheet like this.
Put all 3 sheets together like in the picture, with the nomex sandwiched in the middle. In the picture, it shows the holes already drilled in the 3 sheets. (Notice that the nomex in the picture has rectangular holes. That was annoying to do. Don't bother! Circular holes work just fine.) If you already have your holes drilled, move on to the next step. You are done here! But for the poor people with only a hand drill, stick around. This next part is for you:
If you are using a hand drill, once you have made your nomex sandwich, flip the sandwich so that the B+ sheet is facing up. Tuck the lip of it under a piece of plywood, so that the sandwich can lay flat without squashing the 2 right angle bends. Lay the lexan sheet with the capacitor holes on top of the sandwich. Sort of try to place the holes like they look in the picture above, but it's not important to be very close. Now, using the lexan holes as your guide, drill all 16 holes through all 3 sheets at the same time, using the 7/32 inch drill bit. Now, pull the 3 sheets apart, and go back to the "Drill The Copper And Nomex Sheets" step. Pay attention to the correct size of each of the capacitor holes, depending on which sheet you are working with. Using the 7/32 inch holes as pilot holes, drill the correct size capacitor holes where they need to be in each of the 3 sheets.
Step 7: Attach the Sandwich to the Capacitor
Put some kapton tape on the B- tabs of the capacitor as is shown in the picture above. Make sure you cut a 5/8 inch circle out of each piece of tape, so you will still get good contact between the tabs and the B- sheet. You need to add that tape so as to prevent the B+ sheet from shorting to the B- tabs. Attach "the sandwich" to the capacitor. Add the 3 pieces of kapton tape as shown in the 4th picture above. That prevents the IGBT B+ bolts from getting too close to the B- sheet.
Step 8: Bolt on the IGBTs and Current Sensors
First attach the thermistor (the temperature probe). Then, add a very very thin layer of thermal paste to both the base plate and the 3 IGBTs. A credit card works well for this. Then, bolt them down using the 1" x 0.25" flat head machine screws, a lock washer, and a nut for each hole. Torque them at diagonals. For example, if the corners were labeled clockwise as 1, 2, 3, 4, torque them down as 1, 3, 2, 4. Make sure the 4 quick disconnect tabs on each of the IGBTs are facing down like in the picture.
For the people who already drilled their IGBT mounting holes because they had access to a mill or whatever, you are done with this step! Move on!
For those people using a hand drill, I just want to say I am sorry for what you are about to have to do:
Now that the IGBTs are locked down forever, you can use an unused portion of that lexan sheet to mark the hole positions for the 3 B+ and the 3 B- tabs. Drill some 0.25 inch diameter holes in the lexan at the spots where you marked your B+ and B- holes. Now, transfer those 6 holes to the 3 sheets that are still bolted on to the capacitor. CAREFULLY drill the 6 holes with the capacitor still attached. Then, (you are going to hate me) take the capacitor off, unbend the B- sheet (sorry) and enlarge the 3 B+ holes to a diameter of 1.25 inches. See the "Drill The Copper And Nomex Sheets" step if you are confused about which 3 holes to enlarge on the B- sheet. Now, rebend the B- sheet as before, put the sandwich back together, reattach the capacitor, and we are ready to go! Don't you wish you owned a CNC mill now? haha.
Step 9: Add the Three Phase Cables
You will first have to build your cables. That will require a way to crimp the lugs onto the cable. We're using 2 gauge cable, which BARELY fits through the current sensor window if you squash it down first. Notice the picture of it slightly flattened. You could use 2 pieces of wood and a vice to flatten it a bit (or 2 pieces of wood and a hammer?) It will take some bending to get the lug to mount right at the IGBT tab. Use a lug with a 0.25" or 5/16" eye. Add the heatshrink tubing AFTER you squashed the cable down. Otherwise, you will smash the heck out of the heatshrink and it will get damaged.
Step 10: Attach the Control/Driver Board to the IGBTs
OK, this step might take a bit of cajoling, but it should go on. Don't try to force it all the way down. If the tabs are pressed in pretty well, so that you know there is good contact, then that's OK! Enough is as good as a feast, as my mom used to say. Feel free to bend the tabs a bit if you need to so they all go in to the female connectors.
Once the PCB is attached to the IGBTs, for each of the 4 PCB mounting holes, add the M4 x 12mm metal screw through the bottom, then a #8 washer or 2 over the metal screw, and then the M4 x 30mm threaded nylon spacer, and then the nylon M4 x 12mm screw that clamps the PCB down against the spacer.
Go ahead and plug in the temperature sensor, as well as the 3 current sensors to the control board. See page 3 of the attached current sensor datasheet for the pinout of the current sensors. You will only need 3 of the 4 pins from each current sensor (Vref is unused), which means you need to build the cables using 3 wires. I usually use shielded 3 wire cable, but you could also twist 3 wires together. Make sure the cable is either shielded or twisted! This is a high noise environment.
Step 11: Attach the Capacitor and 3 Sheets to the IGBTs
To attach the capacitor/nomex sandwich to the IGBTs, you will have to bend the sheets a bit. Once you get the screws in the IGBT holes, things go pretty smoothly. If for some reason things don't line up, just enlarge the problem IGBT mounting hole a bit.on the copper sheet.
Once the capacitor is mounted, plug the 3 wires that were soldered onto the B+ sheet into the 3 orange wires on the control board. It may not be a bad idea to glue down the wires so they don't flap all over the place, and not make them so stinking long, like I did. haha.
Step 12: Add the B+ and B- Cables
One way to attach the B+ and B- cables is see the above picture. Notice that the B- cable attaches at one corner, and the B+ attaches at the other corner.
Step 13: Bend the Enclosure, and Attach It
I use a sheet metal brake for bending aluminum, but if you don't have that, you can make one cheap! Just do a search for cheap sheet metal bender on youtube, and you will get lots of ideas.
OK, get your 20.5 inch x 15 inch x 0.063 inch piece of aluminum ready to go. See the attached picture for directions on the bends. Now, mount the enclosure to the controller. The capacitor BASE is going to mount to the enclosure upside down. If you had the holes drilled already, just screw in the capacitor base to the enclosure. Also wire the DC-DC up and attach it to the enclosure, but first read the notes on the DC-DC picture above. You professional people are done! Go to the next step!
Hand drilling people: Bolt the edges of the enclosure to the base plate. Then, lift the capacitor inside until it bumps against the enclosure. Now, mark the 4 capacitor mounting holes on the enclosure with some paint, or a marker, or a pencil. Remove the enclosure, and drill the 4 holes.
Also, lay the DC-DC converter against the inside of the enclosure and mark the 2 mounting holes. See the notes on the DC-DC converter picture above. Before bolting the DC-DC permanently on the enclosure, make sure the capacitor is attached, and make sure the DC-DC is wired.
Step 14: Making the End Plates
We can't leave it open on both ends like that! I don't have any pictures of it, as I never add end plates (I'm always in the testing phase, and leave it to my beta testers to seal it up), but what they have told me is to cut out ABS in the shape of each end of the controller, and use ABS cement and a heat gun, and form a lip all the way around the ABS end plate. Then, just glue both ends to the enclosure, after cutting holes for the wires to come through, of course. Something like this has worked well:
Step 15: Hooking up the Low Voltage Wiring on the Controller
See the notes in the picture for the pin-out of the low voltage section
The 5 pin encoder cable also needs to plug into the encoder, which will be attached to the motor. It is critical in the field oriented control code to have access to the motor's RPM. The microcontroller counts pulses from the encoder, and can deduce the motor RPM from them.
Here's an example of an encoder that I have used:
And here's a specific part number that I picked:
512 ticks per revolution, 1 inch diameter motor post, no index pulse (that's only useful for permanent magnet AC motors), and single ended, which means no hole in the encoder for the motor post to stick through. This is good when you have a short post at the back of the motor barely protruding out. It's a good clean way to keep out dust. It's no big deal if you have to get one where the motor post goes all the way through the encoder case though. The adhesive back option also was selected, so that the encoder just glues onto the back face of the motor. Also, I selected a centering tool, spacer tool, and a hex wrench to be included. They also sell the shielded 5 wire cable already built for the encoder connector.
You can either use a hall effect throttle or a potentiometer throttle. The controller is programmable through the serial port. Here's an example of a hall effect throttle that I've used:
You will most likely need a USB to serial adapter for the serial communications (unless your computer's nickname is Methusela):
Step 16: Hooking up the High Voltage Section
Connecting the motor is the easy part. You just hook up the 3 phase cables that passed through the 3 current sensors to the 3 leads of the motor. If the motor is spinning the wrong way, just swap any 2 of the 3 motor leads. Here are the rest of the connections:
Battery Pack POSITIVE ------ Precharge Resistor ------- Precharge Relay --------- B+ sheet on controller.
Battery Pack POSITIVE -------------- FUSE -------------- CONTACTOR #1 ------------ B+ sheet on controller.
Battery Pack NEGATIVE ------------ CONTACTOR #2 ---------------- B- sheet on controller.
This is a good choice for an inexpensive contactor. You don't have to use 2. It's just safer (I never did! haha):
This is a good precharge resistor:
The precharge relay must be able to handle a few DC amps at hundreds of DC volts! Do not use an automotive relay!! I've used this in the past, and it works fine. It says it's a 6v coil, but there are 2 coils, so you just wire them in series to make a 12v coil:
Step 17: Software and Testing
This assumes that you have debugged the control/driver board already. OK, let's use a 48v bus voltage for this process. If you have a means to lock your rotor, please do so. That just means to make it so the motor post cannot spin. This is not critical, but is a good idea. For example, if the motor is already installed in a car, put the car in gear, and put the E-brake on.
WARNING: Here comes a little theory first! We are about to tune a couple PI loops. With field oriented control, the goal is to be able to command torque with the throttle. There are 2 DC quantities, Id and Iq, called the direct and quadrature currents. With a permanent magnet AC motor, you want to command Id to be 0, because Id causes the field current. But you already have a field from the permanent magnets! So, let's not waste power for no reason. Then, you command Iq to be proportional to the throttle position. For an AC induction motor, it works well to command both Id and Iq to be proportional to the throttle position. But before we can command Id and Iq to be anything, we have to tune both of their PI loops. See the attached pictures for what you want to see when tuning your PI loop.
Let's talk about tuning the PI loop for Iq. For tuning the PI loop, when connected through the serial port, you are searching for just the right values for "kp-iq" and "ki-iq". So you would do something like this in a program like realterm:
"run-pi-test" will run the motor for less than 1/20 sec, and then output a list of numbers that shows IqRef - Iq. You want this list of numbers to go to zero! IqRef is set to 10amps by default when you run a pi test. You keep adjusting kp-iq until you get something like the first graph. Then, gradually increase ki-iq until you get a graph similar to the 2nd picture above. For graphing the data, you can use this:
Once you have the PI loop tuned for Iq, you can use those same values for kp-id and ki-id. So, kp-id would be the same as kp-iq, and ki-id would be the same as ki-iq.
If you are using an AC INDUCTION motor, do the following additional procedure:
Getting a 3 phase motor to run with field oriented control requires that you know some obscure facts about the motor that are not available on the name plate. For example, you need the rotor time constant, which requires the rotor resistance and rotor inductance. Of course none of these things will be available! So, instead we are going to do a trick to find it. Now that you have tuned the PI loops above at zero rpm (ideally with a locked rotor, but it's not a big deal), you can get this code for finding the rotor flux angle:
It will hunt for the ideal rotor time constant. The best guess for the rotor time constant is the one that causes the motor to accelerate the quickest. So, the software makes a guess at the time constant, accelerates the unloaded motor for about 1 second using that time constant, saves the maximum RPM achieved in an array, waits until it gets back to zero RPM (you can help it go back to zero RPM if you want), increments the guess at the rotor time constant, speeds up the motor for 1 second, ... etc... One of the RPMs will be the biggest. The time constant that produced the biggest RPM will be what we'll use for the rotor time constant for the rest of eternity. It's a programmable variable through the serial port in the AC induction controller software, so you would just set that once it's known for your motor. Here's where you can get the AC controller software for an induction motor:
And here's where you can get the software for a permanent magnet AC motor:
Step 18: Driving an AC Motor
I have tested the controller and software on both an AC induction motor and a permanent magnet AC motor. Here's a video of a quick test with a permanent magnet AC motor. This test was with a 48v DC bus:
And here's a video of a test with an AC induction motor. This was with a 6.6kW motor rated for 480VAC. The test was done with a 72v DC bus, which works out to about 51VAC:
Here's an example of using the serial communications:
I have 2 beta testers. The first controller will be tested in Canada. He will really put it through the paces. There will be high voltage and high current tests of both regen and non-regen. The 2nd controller is going to a friend in Australia. That's the one I assembled for this instructable.