48v bldc self balancing controller design

I am from India, Myself Raju Patel, I Started planning to build a custom self balancing wheel.

The problem which I am facing is that, the controller I bought is not compatible or faulty, So I ordered another one which is working fine but has missing some essential functions. and as you know the controller is the brain of my Project, which will control Forward, Backward, Speed, Stability and many other functions

I have 48v lithium battery and want to run 36v 500watt BLDC motor, for self balancing Wheel project, I almost done with my frame welding and all stuff, But stuck in controller, I tried with 48v 350watt Bldc controller, it works with 36v 500w motor but it do not support reverse function so, I brought same controller again and connect both simultaneously and one of them with reverse configuration connection, So it worked to rotate two direction but it need motor completely stop to change the direction of motor and that is the problem for self balancing scooter. because for self balancing, motor need to stop or slow down quickly and should run reverse as quickly as possible.

#include <MPU6050_tockn.h>
#include <Wire.h>

MPU6050 mpu6050(Wire);

float elapsedTime, time, timePrev;

float rad_to_deg = 180 / 3.141592654;

float PID, pwmLeft, pwmRight, error, previous_error;
float pid_p = 0;
float pid_i = 0;
float pid_d = 0;
/////////////////PID CONSTANTS/////////////////
double kp = 3.55; //3.55
double ki = 0.005; //0.003
double kd = 2.05; //2.05

double throttle = 1000; //initial value of throttle to the motors
float desired_angle = 0; //This is the angle in which we whant the
//balance to stay steady

void setup() {
  time = millis();

void loop() {
  /////////////////////////////I M U/////////////////////////////////////
  timePrev = time;  // the previous time is stored before the actual time read
  time = millis();  // actual time read
  elapsedTime = (time - timePrev) / 1000;

  //Serial.print("angleX : ");

  error = mpu6050.getAngleX() - desired_angle;

  pid_p = kp * error;

  if (-3 < error < 3)
    pid_i = pid_i + (ki * error);
  pid_d = kd * ((error - previous_error) / elapsedTime);

  PID = pid_p + pid_i + pid_d;

  if (PID < -1000)
    PID = -1000;
  if (PID > 1000)
    PID = 1000;
  pwmLeft = throttle + PID;
  pwmRight = throttle - PID;

  if (pwmRight < 1000)
    pwmRight = 1000;
  if (pwmRight > 2000)
    pwmRight = 2000;
  if (pwmLeft < 1000)
    pwmLeft = 1000;
  if (pwmLeft > 2000)
    pwmLeft = 2000;

  pwmRight = map(pwmRight, 1000, 2000, 0, 255);
  analogWrite(10, pwmRight);

  pwmLeft = map(pwmLeft, 1000, 2000, 0, 255);
  analogWrite(11, pwmLeft);

  previous_error = error; //Remember to store the previous error.

And one more problem was... i used arduino UNO for PWM signals to run both controllers, but they starts at 30% PWM signal with high speed directly (i need smooth start for self balancing scooter) , which is again controller's fault. both are chinese controllers, i don't know it's hardware or driver configuration.

So, I Thought to make a custom one for my project, But I am not having any expertise or prior knowledge about making a new custom tailored controller, where to put required value of capacitor resistor transistor (I opened one old BLDC controller but didn't get it anything why this big capacitors and small resistors are there, where they are connected and all that), I tried reaching out Google but it shows to buy very much costly controllers.

As my project was based on Arduino so I posted these request on Arduino Forum.
For balancing with MPU sensor, arduino forum already helped me a lot, thank you so much for that.

Could please anyone pcb circuit designer help me out, In big trouble ?

Seriously It would be great help if you help me out

Thank you again.

Lots of text.
Plenty of people have built self balancing robots and lots of topics ought to show up when searching. From those topics You ought to find what hardware they used to make the robot work.

Please read the first topic telling how to use this forum.
Your posting lacks code, schematics, links to drivers, motors etc.

And forget about Your Email address. The idea is that Your question and the replies will be available for other members. This is not a private doctors clinic.

So you have two controllers with the outputs strapped together? They will fight and destroy each other.

You really need a controller designed for driving a servomotor, not only with reverse but with bidirectional torque control. Rapid reversal of torque is needed, not just the ability to change direction as might be designed for standard motor control as self-balancing is a servomotor application.

1 Like

I've notified the moderators and proposed to move this to a Paid Gigs forum or something like that since it seems to be a "please do this for me" question instead of a "a need your thoughts on this" question.

Yes i am using two controllers together but i have write code that type only one controller generate output at a time and by the time other controller will give 0% PWM output. ( I have checked by printing tilt angle, pwmleft and pwmright on serial port. that worked properly).

I don't know about bidirectional torque control (but i will google it),
is there any chance for BLDC motor for self balancing ?
because i already spend 230 dollars for the motor.

Outputs are outputs, you never connect two together. (Unless you want to explode MOSFETs violently...)

So i am thinking to make new BLDC controller that will work with arduino, but as i told i don't know how to make it a need your thoughts on this, sir.

Are you willing to pay for help with this project ?

If so, then I will move it to the appropriate forum section

how much i have to pay for it ?

It is up to you to negotiate that

How much are you prepared to pay ?

Note that I am not offering to write the code

Depends on who wants to help and how much they'd charge you - or if you look at it from your perspective, how much you're willing to pay.

The reason it's asked is that you indicate to have little knowledge about this part of the engineering effort and want someone to help with it. You can then do two things:
1: Learn how to do it. I predict this will be a painful exercise and will take a long time and meet a lot of frustration along the way. Designing a high-power driver for this application is specialist work; if you've never done any serious electronical engineering, it's going to take you a lot of time and effort to master it.
2: Get someone else to do it, but obviously, most people don't work for free. It's a quicker route to success, but more costly financially.

where i can find these people who will help me for it ?

In the appropriate sub-forum. That's why the question is asked. If you say 'yes', your post will be moved to that sub-forum and anyone who's interested in picking up this challenge and negotiating with you can respond.


Ok, I've asked the moderators to move your post! Good luck with your project; it looks and sounds nice.

This guy had the problem same as i have, can you tell me how to reach this guy ?
I am new at the arduino forum.