DVR8302 closed loop AS5048B

After successfully tested the open loop, I’m back trying to make it work with a sensor.
My setup is
Prodrive 35-36 800kv <0.1 Ohm

im using the example I found in the lib, after correctly run the initialization the motor starts wobbling really fast until I type the C in the terminal to display the Velocity control set.

Moving to angle or velocity is not producing any difference, the motor is not moving at all.

the voltage is limited to 0.5 (motor_limit) , input source 12V, 2A.

reading the forum I’ve already tested :
. magnet alignment (is centered and with a gap of less tan 1 mm)
. magnet is diametric polarized
. magnet is producing the correct output using the GetAngle function.

This is the terminal output
MOT: Monitor enabled!
MOT: Initialise variables.
MOT: Enable driver.
MOT: Align sensor.
MOT: natural_direction==CCW
MOT: Absolute zero align.
MOT: Success!

Any other things I can check ?

My approach to tuning is

  1. Test sensor alone - and ensure your angle is 2*PI for a 360 rotation (done?)
  2. Test velocity_openloop mode - smooth movement in both directions. Get a feel for sensible voltage_limit (done)
  3. Test voltage mode - this is simpler than velocity mode as it requires no PID tuning. In this mode motor.mode(target) (in this mode target is voltage_q - so start at 0.1 and move slowly to + or - 0.5)
    Once voltage mode is working you know you’ve got good sensor alignment. The rest is typically easy
  4. Test velocity mode - set
motor.PID_velocity.P = 0.1; // and increase slowly to 1.0
motor.PID_velocity.I = 0.0; // and increase slowly to 10
motor.LPF_velocity.Tf = 0.01 //and adjust between 0.2 and 0.0001 (higher is required for noisy sensors
  1. Test angle mode - this is usually easier to tune
motor.P_angle.P = 10; // and increase or decrease (also experiment with voltage_limit)

Maybe show us your code.


  1. sensor works fine, I got 6.30 -ish for one turn.
  2. working good , not that super smooth, especially on slow speed. ( I got a value of 25 before it stalls)
  3. this one in not working, I 've tried to ramp up the value (0.1, 0.2 …) but I got only a tiny tiny movement forward, that are going backwards if I decrease the value. I don’t get the continuous speed I would expect.

During the n3 test Im outputting the angle value and looks stable and steady .

The code is a copy and paste from the voltage_control.ino example.

Weird… what happens if you take out the serial control and/or serial monitoring?

Did you put pull-ups on your I2C lines?

Nice motor.

A lot of people seem to have a problem with this step, I think we miss some documentation about this :smiley:

But I am really not sure what is the issue. If you’ve got open loop working well that means it will work in closed loop as well.

Did you change the pole pair number to 7?

never tried to not initialize the serial monitor, but with motor.monitor commented I got no changes, i2c has pull ups,

the pole number is 12 for that motor, I will run the pole. number finder example to be sure.
this is how is moving on open loop

Try running the open loop angle control.
If your motor does exactly one turn when you input 6.28 you have a right pola pair number.

I just quickly searched on the internet and told you 7 pole pairs, it can be easily wrong. :slight_smile:

12 pp is not a common number. Are you sure it’s not 11 or 7? If the motor says 24n22p that means 24 slots and 22 poles which means 11 pole pairs.

ok sorry for the delay guys,
Yes you both right and im an idiot.
I’ve removed the cage of the motor to find out I have 14 magnets and not 12. and figure it out later that simple for is using Pole PAIRS so I have to divide it by 2.
the motor is running, not that smooth on very slow velocity but I’ve tune it a bit and is better.
sorry again.

1 Like