Connect with us

atmega8 based three phase control

Discussion in 'Microcontrollers, Programming and IoT' started by jupiter, May 21, 2013.

Scroll to continue with content
  1. jupiter


    May 13, 2013
    Hi everyone,
    My name is Mike friends. New Zealand,

    I am looking to build an open source three phase variable speed drive for an electric car and was wondering if any of you can help?

    I have a few atmel atmega 8 chips amongst my arduino bits that I am looking to use as a base.
    My idea is to have a single pwm input, as model brushless esc,'s do and to recieve three hi an lo outputs on the other side of the chip to supply a driver ic...can anyone help here? I have decided to stick with atmel as it is something I am used to and I can use an arduino board as a programmer as this project is low budget. ...

    Thanks in advance for any help you offer!

  2. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    Jan 21, 2010
    You would probably be better off asking on an electric vehicle forum.

    What voltages and currents are involved? Be prepared for me to bow out as soon as you mention them :D
  3. jupiter


    May 13, 2013
    thank you for the reply,
    voltage and current is not a problem right now as I am merely designing the control system itself .
    the circuit I am designing will only be between 3.3 and 5 volts the, 400 volts needed to run The motor will only be present in and around the igbts

  4. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    Jan 21, 2010
    Yeah, it is the high current and voltage stuff around the IGBT's that I'm talking about. The rest of the stuff is a lot easier.

    Depending on the speed of switching you require, and whether you want PWM control of the IGBT's to simulate a sine wave drive to the motors, the ATMega8 should be fast enough to do what you want.

    It sounds like you don't want a sine wave driving your motor, so the arduino could possibly have 6 outputs to the half-bridges, with their inputs being logically ANDed with the PWM signal -- the gate drivers themselves may do that via an inhibit input or similar.
  5. jupiter


    May 13, 2013
    thanks alot,

    i am unsure about the voltages and current required but it would be desirable to have about 60kw, due to it being an automotive application, the lower the voltage the better, however there are severe limitations...

    i am an electrician by trade so am not scared of this kind of energy as i deal with it on a daily basis and still have most of my fingers left...the hard bit will be designing the motor and obtaining the batteries without having to sell my soul to do so!

    my plan is to build a sealed controller attached, or close the motor to reduce wiring and make the system more modular, so there is only the main dc supply and required sensor and control wires running to it.

    a sine wave would be nice,but i am unsure if having a sine wave would contribute anything to efficiency or performance....perhaps you could advise there?

    i am unsure about frequency, but something above 20khz or under 300hz would be good as it will not be harmful to the ear, but the upside to having audible frequency is that pedestrians can hear the vehicle coming...

    here is a sketch i am working on for the controller, as you can see i have merely allocated the pins and borrowed someone elses arduino sketch for a three phase vsd and modified it to get my feet wet...
    let me know if you can help me in assigning the input pwm pin as a torque reference to the motor output pulses?

    thanks in advance,


    int val; //value for motor speed
    int inputpulsePin = 0; //primary controller pwm input

    int redphasecheckPin = 1; //phase failure system inputs
    int yellowphasecheckPin = 2;
    int bluephasecheckPin = 4;
    int phaseokPin = 7; //phase ok output to master controller
    int runledPin = 13; //motor run output to master controller

    int redhi = 255; //initialise one high and one low output per phase
    int redlo = 0;
    int yellowhi = 0;
    int yellowlo = 85;
    int bluehi = 0;
    int bluelo = 85;

    int x1 = 1; //Set the directions of travel
    int x2 = 0;
    int x3 = 0;
    int y1 = 0;
    int y2 =-1;
    int y3 = 1;

    int redhiPin = 3; // allocate phase outputs to atmega pwm outputs
    int redloPin = 5;
    int yellowhiPin = 6;
    int yellowloPin = 9;
    int bluehiPin = 10;
    int blueloPin = 11;

    void setup()

    void loop(){
    int val = digitalRead(inputpulsePin); //digital pwm from primary controller
    inputpulsePin.write(val); //send pwm info to motor
    analogWrite(redhiPin, redhi); //assign integers
    analogWrite(redloPin, redlo);
    analogWrite(yellowhiPin, yellowhi);
    analogWrite(yellowloPin, yellowlo);
    analogWrite(bluehiPin, bluehi);
    analogWrite(blueloPin, bluelo);

    if ((redhi == 255) & (x1 == 1)) { x1 = -1; } //phase position checker
    if ((redhi == 0) & (x1 == -1)) { x1 = 0; y1 = +1; } if ((yellowhi == 255) & (x2 == 1)) { x2 = -1; }
    if ((yellowhi == 0) & (x2 == -1)) { x2 = 0; y2 = + 1; } if ((bluehi == 255) & (x3 == 1)) { x3 = -1; }
    if ((bluehi == 0) & (x3 == -1)) { x3 = 0; y3 = +1; } if ((redlo == 255) & (y1 == 1)) { y1 = -1; }
    if ((redlo == 0) & (y1 == -1)) { y1 = 0; x1 = 1; } if ((yellowlo == 255) & (y2 == 1)) { y2 = -1; }
    if ((yellowlo == 0) & (y2 == -1)) { y2 = 0; x2 = 1; } if ((bluelo == 255) & (y3 == 1)) { y3 = -1; }
    if ((bluelo == 0) & (y3 == -1)) { y3 = 0; x3 = 1; }

    redhi = redhi + x1; //postitive/negative flip flop to ensure the waves
    yellowhi = yellowhi + x2; //travel in the right direction
    bluehi = bluehi + x3;
    redlo = redlo + y1;
    yellowlo = yellowlo + y2;
    bluelo = bluelo + y3;


Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day