# Motor shaking while doing .init

**URL:** https://community.simplefoc.com/t/motor-shaking-while-doing-init/8142
**Category:** hardware support
**Tags:** bldc, esp32, as5600, arduino\_uno
**Created:** [May 19, 2026, 3:40pm UTC](https://community.simplefoc.com/t/motor-shaking-while-doing-init/8142 "2026-05-19T15:40:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cronos](https://community.simplefoc.com/user_avatar/community.simplefoc.com/cronos/32/9873_2.png) [@cronos](https://community.simplefoc.com/u/cronos)
#### Post date: [May 19, 2026, 3:40pm UTC](https://community.simplefoc.com/t/motor-shaking-while-doing-init/8142/1 "2026-05-19T15:40:15Z")

</div>

> I’m using simplefoc mini to control gimbal BLDC motor 2804 100T , encoder AS 5600 I2C (closed loop control example)  
> Motor init shaking (few months ago it’s not working like that)  
> I also checked encoder value no abnormal.  
> I want to ask if there’s no problem with my code, maybe the problem comes from the driver. Thanks!  
> Here is the code I used to test:  
> /\*\*
> 
> \*
> 
> \* Position/angle motion control example
> 
> \* Steps:
> 
> \* 1) Configure the motor and magnetic sensor
> 
> \* 2) Run the code
> 
> \* 3) Set the target angle (in radians) from serial terminal
> 
> \*
> 
> \*/
> 
> #include \<SimpleFOC.h\>
> 
> // magnetic sensor instance - SPI
> 
> //MagneticSensorSPI sensor = MagneticSensorSPI(AS5147\_SPI, 10);
> 
> // magnetic sensor instance - MagneticSensorI2C
> 
> MagneticSensorI2C sensor = MagneticSensorI2C(AS5600\_I2C);
> 
> // magnetic sensor instance - analog output
> 
> // MagneticSensorAnalog sensor = MagneticSensorAnalog(A1, 14, 1020);
> 
> // BLDC motor & driver instance
> 
> BLDCMotor motor = BLDCMotor(7);//BLDC 2804 100T
> 
> BLDCDriver3PWM driver = BLDCDriver3PWM(6, 5, 3, 8);// arduino nano
> 
> // Stepper motor & driver instance
> 
> //StepperMotor motor = StepperMotor(50);
> 
> //StepperDriver4PWM driver = StepperDriver4PWM(9, 5, 10, 6, 8);
> 
> // angle set point variable
> 
> float target\_angle = 0;
> 
> // instantiate the commander
> 
> Commander command = Commander(Serial);
> 
> void doTarget(char\* cmd) { command.scalar(&target\_angle, cmd); }
> 
> void setup() {
> 
> // initialise magnetic sensor hardware
> 
> sensor.init();
> 
> // link the motor to the sensor
> 
> motor.linkSensor(&sensor);
> 
> // driver config
> 
> // power supply voltage [V]
> 
> driver.voltage\_power\_supply = 12;
> 
> driver.init();
> 
> // link the motor and the driver
> 
> motor.linkDriver(&driver);
> 
> // choose FOC modulation (optional)
> 
> motor.foc\_modulation = FOCModulationType::SpaceVectorPWM;
> 
> // set motion control loop to be used
> 
> motor.controller = MotionControlType::angle;
> 
> // contoller configuration
> 
> // default parameters in defaults.h
> 
> // velocity PI controller parameters
> 
> motor.PID\_velocity.P = 0.2f;
> 
> motor.PID\_velocity.I = 20;
> 
> motor.PID\_velocity.D = 0;
> 
> // maximal voltage to be set to the motor
> 
> motor.voltage\_limit = 6;
> 
> // velocity low pass filtering time constant
> 
> // the lower the less filtered
> 
> motor.LPF\_velocity.Tf = 0.01f;
> 
> // angle P controller
> 
> motor.P\_angle.P = 20;
> 
> // maximal velocity of the position control
> 
> motor.velocity\_limit = 20;
> 
> // use monitoring with serial
> 
> Serial.begin(115200);
> 
> // comment out if not needed
> 
> motor.useMonitoring(Serial);
> 
> // initialize motor
> 
> motor.init();
> 
> // align sensor and start FOC
> 
> motor.initFOC();
> 
> // add target command T
> 
> command.add(‘T’, doTarget, “target angle”);
> 
> Serial.println(F(“Motor ready.”));
> 
> Serial.println(F(“Set the target angle using serial terminal:”));
> 
> \_delay(1000);
> 
> }
> 
> void loop() {
> 
> // main FOC algorithm function
> 
> // the faster you run this function the better
> 
> // Arduino UNO loop ~1kHz
> 
> // Bluepill loop ~10kHz
> 
> motor.loopFOC();
> 
> // Motion control function
> 
> // velocity, position or voltage (defined in motor.controller)
> 
> // this function can be run at much lower frequency than loopFOC() function
> 
> // You can also use motor.move() and set the motor.target in the code
> 
> motor.move(target\_angle);
> 
> // function intended to be used with serial plotter to monitor motor variables
> 
> // significantly slowing the execution down!!!
> 
> // motor.monitor();
> 
> // user communication
> 
> command.run();
> 
> }

---

<div class="post-metadata">

### Author: ![Digitalmonk](https://community.simplefoc.com/user_avatar/community.simplefoc.com/digitalmonk/32/9846_2.png) [@Digitalmonk](https://community.simplefoc.com/u/Digitalmonk)
#### Post date: [May 25, 2026, 10:47am UTC](https://community.simplefoc.com/t/motor-shaking-while-doing-init/8142/2 "2026-05-25T10:47:46Z")

</div>

The motor is shaking during `motor.init()` because the voltage and PID values are too high for a gimbal motor. Set `motor.voltage_limit = 1.5` and `motor.P_angle.P = 5` to fix the oscillation. If shaking persists, the SimpleFOC Mini driver may have been damaged over time and needs replacement.
