# Hoverboard motor vibrates but doesn't rotate

**URL:** https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073
**Category:** hardware support
**Tags:** arduino\_uno
**Created:** [November 9, 2023, 5:42pm UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073 "2023-11-09T17:42:35Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 9, 2023, 5:42pm UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/1 "2023-11-09T17:42:35Z")

</div>

#include \<SimpleFOC.h\>  
// software interrupt library  
#include \<PciManager.h\>  
#include \<PciListenerImp.h\>  
// DRV8302 pins connections  
#define INH\_A 9  
#define INH\_B 10  
#define INH\_C 11  
#define EN\_GATE 8  
#define M\_PWM 6  
#define M\_OC 5  
#define OC\_ADJ 7

// set up pins on arduino board  
#define HallA 2 // yellow  
#define HallB 3 // blue  
#define HallC 4// green

// polar pairs  
int pp = 15; // motor has 30 outer magnets  
// motor instance  
BLDCMotor motor = BLDCMotor(pp);

// driver instance  
BLDCDriver3PWM driver = BLDCDriver3PWM(INH\_A, INH\_B, INH\_C, EN\_GATE);

// hall sensor instance  
HallSensor sensor = HallSensor(HallA, HallB, HallC, pp);  
// Interrupt routine intialisation  
// channel A and B callbacks  
void doA(){sensor.handleA();}  
void doB(){sensor.handleB();}  
void doC(){sensor.handleC();}  
// If no available hadware interrupt pins use the software interrupt  
PciListenerImp listenC(sensor.pinC, doC);

// velocity set point variable  
float target\_velocity = 0;  
// instantiate the commander  
Commander command = Commander(Serial);  
void doTarget(char\* cmd) { command.scalar(&target\_velocity, cmd); }

void setup() {  
// initialize Hall sensor hardware  
[//sensor.pullup](https://sensor.pullup) = Pullup::USE\_EXTERN;  
//sensor.velocity\_max = 30;  
// initialize sensor sensor hardware  
sensor.init();  
sensor.enableInterrupts(doA, doB); //, doC);  
// software interrupts  
PciManager.registerListener(&listenC);

// link the motor to the sensor  
motor.linkSensor(&sensor);

// DRV8302 specific code  
// M\_OC - enable over-current protection  
pinMode(M\_OC,OUTPUT);  
digitalWrite(M\_OC,LOW);  
// M\_PWM - enable 3pwm mode  
pinMode(M\_PWM,OUTPUT);  
digitalWrite(M\_PWM,HIGH);  
// OD\_ADJ - set the maximum over-current limit possible  
// Better option would be to use voltage divisor to set exact value  
pinMode(OC\_ADJ,OUTPUT);  
digitalWrite(OC\_ADJ,HIGH);  
//driver.pwm\_frequency = 32000;

// configure driver  
driver.voltage\_power\_supply = 36;  
driver.init();  
motor.linkDriver(&driver);

//motor.velocity\_limit = 1; // [rad/s] cca 50rpm

// aligning voltage [V]  
motor.voltage\_sensor\_align = 3;

// choose FOC modulation  
//motor.foc\_modulation = FOCModulationType::SpaceVectorPWM;

// set control loop type to be used  
motor.controller = MotionControlType::velocity;

// controller configuration based on the control type  
motor.PID\_velocity.P = 0.2;  
motor.PID\_velocity.I = 20;  
motor.PID\_velocity.D = 0;  
// default voltage\_power\_supply  
motor.voltage\_limit = 12;

// jerk control using voltage voltage ramp  
// default value is 300 volts per sec ~ 0.3V per millisecond  
motor.PID\_velocity.output\_ramp = 1000;

// velocity low pass filtering time constant  
motor.LPF\_velocity.Tf = 0.01f;  
// angle loop velocity limit  
// angle loop controller  
//motor.P\_angle.P = 20;

//motor.velocity\_limit = 50;  
// use monitoring with serial  
// default voltage\_power\_supply  
//motor.voltage\_limit = 36;  
Serial.begin(115200);  
// comment out if not needed  
motor.useMonitoring(Serial);  
//motor.monitor\_variables = \_MON\_TARGET | \_MON\_VEL | \_MON\_ANGLE;  
// downsampling  
//motor.monitor\_downsample = 10; // default 10  
// initialize motor  
motor.init();  
// align encoder and start FOC  
motor.initFOC();

// set the initial target value  
[//motor.target](https://motor.target) = 2;

// define the motor id  
command.add(‘T’, doTarget, “target velocity”);  
Serial.println(F(“Motor ready.”));  
Serial.println(F(“Set the target velocity using serial terminal:”));  
\_delay(1000);  
}

void loop() {  
// iterative setting FOC phase voltage  
//sensor.min\_elapsed\_time = 0.0001; // 0.0001 by default  
// update the sensor values  
// sensor.update();  
motor.loopFOC();

// iterative function setting the outer loop target  
// velocity, position or voltage  
// if target not set in parameter uses motor.target variable  
motor.move(target\_velocity);  
// user communication  
command.run();  
}

---

<div class="post-metadata">

### Author: ![o\_lampe](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/o/85e7bf/32.png) [@o\_lampe](https://community.simplefoc.com/u/o_lampe)
#### Post date: [November 10, 2023, 7:55am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/2 "2023-11-10T07:55:18Z")

</div>

Hi,  
During sensor.init it should move back and forth a few degrees. If it doesn’t move the sensor.init fails.  
Did you try to use the /utils/sensor-test.ino first?  
Also test the motor with openloop\_velocity.ino before you combine both.  
It might not want to spin with only 3V target on a 12V system.

---

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 10, 2023, 2:53pm UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/3 "2023-11-10T14:53:21Z")

</div>

Thank you, I have checked and the sensor alignment process is quite ok but when I set the speed the motor only vibrates but it does not rotate.

---

<div class="post-metadata">

### Author: ![o\_lampe](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/o/85e7bf/32.png) [@o\_lampe](https://community.simplefoc.com/u/o_lampe)
#### Post date: [November 12, 2023, 9:03am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/4 "2023-11-12T09:03:41Z")

</div>

Try to reduce the PID values alot, especially “I” is much too high for low resistance hoverboard motors.  
These are my values for a splitboard hoverboard controller. Use it as ballpark numbers, it depends on your MCU-performance, driver voltage a.s.o.

```auto
 // velocity low pass filtering time constant
  motor.PID_velocity.P = 0.3f;
  motor.PID_velocity.I = 0.3f;
  motor.LPF_velocity.Tf = 0.04f; 

```

---

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 12, 2023, 4:37pm UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/5 "2023-11-12T16:37:29Z")

</div>

I tried it but the motor just vibrates and doesn’t rotate. I also changed the PID with small P and I, D = 0 but the result is the same

---

<div class="post-metadata">

### Author: ![VIPQualityPost](https://community.simplefoc.com/user_avatar/community.simplefoc.com/vipqualitypost/32/4420_2.png) [@VIPQualityPost](https://community.simplefoc.com/u/VIPQualityPost)
#### Post date: [November 12, 2023, 5:03pm UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/6 "2023-11-12T17:03:36Z")

</div>

Does open loop work at all?

---

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 13, 2023, 5:03am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/7 "2023-11-13T05:03:42Z")

</div>

Yes, but when I put the hall sensor in, the wheel does not rotate, the motor only vibrates when I set the speed taget but the wheel does not rotate.

---

<div class="post-metadata">

### Author: ![o\_lampe](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/o/85e7bf/32.png) [@o\_lampe](https://community.simplefoc.com/u/o_lampe)
#### Post date: [November 13, 2023, 8:27am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/8 "2023-11-13T08:27:10Z")

</div>

You have to match the hall sensor pins with the right motor pins.  
Usually the phase colors and hall-sensor colors match ( yellow, blue, green)

---

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 13, 2023, 9:01am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/9 "2023-11-13T09:01:53Z")

</div>

I plugged hall into arduino mega2560, hallsensor A, B, pin 21,20. hallsensorB is plugged into pin 4 and I use an interrupt

---

<div class="post-metadata">

### Author: ![runger](https://community.simplefoc.com/user_avatar/community.simplefoc.com/runger/32/395_2.png) [@runger](https://community.simplefoc.com/u/runger)
#### Post date: [November 13, 2023, 9:21am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/10 "2023-11-13T09:21:16Z")

</div>

Is the sensor working normally without closed-loop mode?

i.e. could you try with the HallSensor, but leaving the motor disabled (motor.disable()) and rotate the motor by hand while printing the angles in the main loop.  
We have a sensor test ino in our examples that you can use.

If you do this, do you get ±6.28 radians from the sensor per full revolution of the motor?

---

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 13, 2023, 9:25am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/11 "2023-11-13T09:25:54Z")

</div>

I have tried it and the result is like that

---

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 13, 2023, 9:26am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/12 "2023-11-13T09:26:57Z")

</div>

When I send the speed the motor vibrates very loudly but the wheel does not rotate. Is it because the PID parameters are not correct?

---

<div class="post-metadata">

### Author: ![runger](https://community.simplefoc.com/user_avatar/community.simplefoc.com/runger/32/395_2.png) [@runger](https://community.simplefoc.com/u/runger)
#### Post date: [November 13, 2023, 9:32am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/13 "2023-11-13T09:32:11Z")

</div>

It’s possible that PID parameters are the cause, but usually, unless they are way off, you get some movement.

Non-movement and loud noise is sometimes caused by setting the number of pole-pairs incorrectly, or due to bad commutation signals. But if open loop is working well then it’s probably not the commutation.

Can you try to use open-loop mode, maybe in open-loop position mode, and command the motor to turn itself?  
In the main loop, call sensor.update() and print the angle from the sensor (but only 1-2 times per second or you will overload the serial port). This is to see if the sensor agrees with the open loop position.

---

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 13, 2023, 10:02am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/14 "2023-11-13T10:02:52Z")

</div>

yes, I see it rotates once and the angle is about 6rad. quite okay

---

<div class="post-metadata">

### Author: ![Candas1](https://community.simplefoc.com/user_avatar/community.simplefoc.com/candas1/32/5296_2.png) [@Candas1](https://community.simplefoc.com/u/Candas1)
#### Post date: [November 13, 2023, 10:38am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/15 "2023-11-13T10:38:56Z")

</div>

Can you rephrase the title of the thread lol

---

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 13, 2023, 3:50pm UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/16 "2023-11-13T15:50:49Z")

</div>

Sorry, I just want to make the content clearer

---

<div class="post-metadata">

### Author: ![runger](https://community.simplefoc.com/user_avatar/community.simplefoc.com/runger/32/395_2.png) [@runger](https://community.simplefoc.com/u/runger)
#### Post date: [November 13, 2023, 6:42pm UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/17 "2023-11-13T18:42:54Z")

</div>

Honestly, if all these things are working, and it also works in torque-voltage mode, then it might well be the PID that needs tuning…

Does torque voltage mode work?

---

<div class="post-metadata">

### Author: ![Candas1](https://community.simplefoc.com/user_avatar/community.simplefoc.com/candas1/32/5296_2.png) [@Candas1](https://community.simplefoc.com/u/Candas1)
#### Post date: [November 13, 2023, 8:54pm UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/18 "2023-11-13T20:54:53Z")

</div>

> [@Khoa\_Bach](#):
>
> sensor.enableInterrupts(doA, doB); //, doC);

You enable only 2 interrupts?

---

<div class="post-metadata">

### Author: ![An\_Hoang](https://community.simplefoc.com/user_avatar/community.simplefoc.com/an_hoang/32/5692_2.png) [@An\_Hoang](https://community.simplefoc.com/u/An_Hoang)
#### Post date: [November 14, 2023, 4:38am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/19 "2023-11-14T04:38:20Z")

</div>

They one have 2 spare pins left for interrupt, so they used one with software int.

---

<div class="post-metadata">

### Author: ![Khoa\_Bach](https://community.simplefoc.com/user_avatar/community.simplefoc.com/khoa_bach/32/5623_2.png) [@Khoa\_Bach](https://community.simplefoc.com/u/Khoa_Bach)
#### Post date: [November 14, 2023, 5:31am UTC](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073/20 "2023-11-14T05:31:39Z")

</div>

I tried changing the PID parameters many times without success. Or maybe it’s not right?

[Next page](https://community.simplefoc.com/t/hoverboard-motor-vibrates-but-doesnt-rotate/4073.md?page=2)
