Circuit Diagram of Electric Bike Controller for Motor

In this topic we are tried to understand the working of Controller in E-bike. In e-bike it don’t mean that motor and battery that’s all. There is third party involved in this to manage them and they work correctly. This is only possible by somehow programming and hardware skill with the help of controller. Now we are designed controller for this to control the motor of bike. The main or we can say the core feature of this controller is to manage the DC Motor that the run smoothly. Many  motor are controlled by hall sensors that are responsible for the power consumed.

Controller Design:

Now a day we need motor running smooth beside this, we need   throttle , motor, and battery.   If you want this things run perfectly then make sure you are using controller. Now we are designing such type of controller that will responsible of all. This controller  senses the setting of throttle and adjusting the power supply to the motor. For does all this things we are using Pulse-width Modulation technique. We will discuss later. Now we discuss the other functionalities of the controller that we are making such like:

Voltage Cutoff Switch :

We are using cutoff switch that is responsible for the voltage supply from the battery. Cutoff switch cut the connection if voltage drops to the motor. This help to protect the battery from over discharge.

Temperature Cutoff Switch:

This cutoff switch is used for temperature monitoring of field effect power transistors. It will cut the power supply of motor if that FET power Transistors overheated.   

Current overflow cutoff:

This cutoff switch is manage the current supply to motor and the field effect power transistor. In case of the over current is supply to the motor and field effect power transistor, it wil cut the power supply for the protection of motor and field effect transistor.

Supply cutoff switch:

This cutoff switch is help to manage motor and no waste of current. It cut the supply to the motor when you applying brakes. This is only for safety purpose.

Safety note:

This is advanced level project. Do not try to attempt this if you don’t have only experience with electronics devices. In this project we are playing  with current and voltage, it is dangerous and difficult to handle, so plz do under the supervene of experienced persons.

If you are using 48 volt power supply then you have to use 12 volts power supply for the controller. If you are using 12 volts cells pack then simply tap 12 volt from the pack. In my case it is impossible for me, so i am using 12 volts power supply or you can convert DC to DC converter to supply 12 volts power.

The controller that we are making is designed for this e-Bike. We are using IRFP4468 field effect power transistor are rate 195 Amps at 100 volts maximum. This E-bike use very small amount of Amps like 10 Amps at 50 volts. It was tested around about 10 mile every day and this controller is tested and trouble free.

List of item:


all the things are mention there but few of things are used:

  • Prototype Board
  • Heat shrink tubes
  • few screws
  • few insulation padding
  • an enclosure

Assembling section:



assiblingcontroller fettransistor layoutcadcontroller

you can design this layout by cad program.

Schematic drawing:





#  A simple DC motor controller
#  This program implements the following functions:
#   a) startup throttle limit checks
#   b) read the throttle and set the PWM duty cycle
#  It should also check:
#   c) the maximum allowed motor current
#   d) low battery voltage
#   e) low battery voltage
#  but these checks (c,d,e) are not implemented yet.
#  Chip type           : ATmega8-16
#  Clock frequency     : 8.00 MHz

#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/sleep.h>
#include <avr/wdt.h>

#define ADC_VREF_TYPE     0x40

unsigned char pwx;    // pulse width
unsigned char j = 0;  // LED value
unsigned char i = 0;  // loop counter

// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
    ADMUX = adc_input | (ADC_VREF_TYPE & 0xff);
    // Start the AD conversion
    ADCSRA |= 0x40;
    // Wait for the AD conversion to complete
    while ((ADCSRA & 0x10) == 0);
    ADCSRA |= 0x10;
    return ADCW;

// Timer 1 overflow interrupt service routine
    OCR1AL = pwx;  // set the pulse width

int main(void)
    int throttle;

    // Port B initialization (not used)
    // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=Out Func0=Out
    // State7=T State6=T State5=T State4=T State3=T State2=T State1=0 State0=T
    PORTB = 0x00;
    DDRB  = 0x02;

    // Port C initialization (not used)
    // Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
    // State6=T State5=T State4=T State3=T State2=T State1=T State0=T
    PORTC = 0x00;
    DDRC  = 0x00;

    // Port D initialization (used for simple LED toggle)
    // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
    // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
    PORTD = 0x00;
    DDRD  = 0x04;

    // Timer/Counter 0 initialization
    // Clock source: System Clock
    // Clock value: Timer 0 Stopped
    TCCR0 = 0x00;
    TCNT0 = 0x00;

    // Timer/Counter 1 initialization
    // TCCR1A
    // TCCR1B
    // ICNC1  ICES1  ---–   WGM13  WGM12 CS12  CS11  CS10
    // Clock source: System Clock
    // Clock value: 7372.800 kHz
    // Mode: Fast PWM top=03FFh
    // OC1A output: Non-Inv
    // OC1B output: Discon
    // Noise Canceler: Off
    // Input Capture on Falling Edge
    // Timer 1 Overflow Interrupt: On
    // Input Capture Interrupt: Off
    // Compare A Match Interrupt: Off
    // Compare B Match Interrupt: Off
    TCCR1A = 0x82;
    TCCR1B = 0x19;
    TCNT1H = 0x00;
    TCNT1L = 0x00;
    ICR1H  = 0x00;
    ICR1L  = 0x3F;
    OCR1AH = 0x00;
    OCR1AL = 0x00;
    OCR1BH = 0x00;
    OCR1BL = 0x00;

    // Timer/Counter 2 initialization
    // Clock source: System Clock
    // Clock value: Timer 2 Stopped
    // Mode: Normal top=FFh
    // OC2 output: Disconnected
    ASSR  = 0x00;
    TCCR2 = 0x00;
    TCNT2 = 0x00;
    OCR2  = 0x00;

    // External Interrupt(s) initialization
    // INT0: Off
    // INT1: Off
    MCUCR = 0x00;

    // Timer(s)/Counter(s) Interrupt(s) initialization
    TIMSK = 0x04;

    // USART initialization
    // Communication Parameters: 8 Data, 1 Stop, No Parity
    // USART Receiver: On
    // USART Transmitter: On
    // USART Mode: Asynchronous
    // USART Baud rate: 115200 (Double Speed Mode)
    UCSRA = 0x02;
    UCSRB = 0x18;
    UCSRC = 0x86;
    UBRRH = 0x00;
    UBRRL = 0x07;

    // Analog Comparator initialization
    // Analog Comparator: Off
    // Analog Comparator Input Capture by Timer/Counter 1: Off
    ACSR  = 0x80;
    SFIOR = 0x00;

    // ADC initialization
    // ADC Clock frequency: 230.400 kHz
    // ADC Voltage Reference: AVCC pin
    ADMUX  = ADC_VREF_TYPE & 0xff;
    ADCSRA = 0x85;

    // Global enable interrupts

    while (1) {

        // read the throttle position
        throttle = read_adc(0);

        // toggle the LED
        if (i == 255) {
            i = 0;
            j = j ^ 0xff;
            PORTD = j;

        // If the ADC reads out of normal range then assume that the
        // throttle is either disconnected, or not connected properly
        if ((throttle < 100) || (throttle > 1000)) {
            // disable the PWM output
            // and cut the throttle
            TCCR1A = 0x02;
            throttle = 0;
        } else {

            if (throttle < 200) { // disable the PWM output // and cut the throttle TCCR1A = 0x02; throttle = 0; } else { // enable the PWM output // subtract the lower dead zone and then // multiply by 1.5x and then clip TCCR1A = 0x82; throttle -= 180; throttle = throttle + (throttle >> 1);
            if (throttle > 1023) throttle = 1023;
        pwx = throttle >> 4;


Leave a Reply

Your email address will not be published. Required fields are marked *