Magnetic encoder and brushless gimbal controller

- from my blog hobbyuav,com.

For the techpod 2.0, I want to have a high precision camera gimbal capable of continuous rotation in two axis. I have always likes the brushless gimbals that are so popular today. The control and drive systems are very nice but are not setup for continuous 360 degree rotation. furthermore the IMU algorithm is very CPU intensive and prone to needing the gyros calibrated frequently etc.

I decided to replace the IMU with a AS5048B  rotary magnetic  encoder for position feedback.  The  AS5048B outputs the 14 bit absolute position of a magnet rotated near the IC. After you include noise, it is good for about 0.06 degrees of accuracy.  Here is a short video of it going from 90.5 degrees to -90.5 degrees every 10 seconds.

Here is a quick hack of the brushless gimbal software.


E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • Hey Wayne and others.
    Did you find any motors that has encoder and is allowing to use slip ring?


  • Hi wayne,

    i'm interested in your application of encoder instead of usin IMU. i've 2 questions:

    1) how do you control the motor;

    2) how can i improve your work adding 2 axis

    TY for your attention

  • 100KM


     thanks, this is just a small part of a greater system I am building. This will make you think differently about your autopilot and camera setup. It could also lead to some interesting setups not utilized. setups such as mounting the autopilot to the camera while using the angle difference to estimate the aircraft attitude. you could use the autopilot to control the camera instead of having 2 IMUs on board. You can hard mount it to something stable like a bench and use it for aiming a camera or aiming an antenna.


    point taken, however these problems can be eliminated by mounting the AP and camera on the same vibration isolated mount. The possibility of using only a gyro strapped to the camera to dampen vibrations etc becomes apparent, eliminating the need for a full IMU sensor and algorithm.



    TY! mostly I crammed this into the code right before the PID is calculated.


    //read encoder
    Wire.beginTransmission(ADDRESS); //starts communication with cmps03
    Wire.write(255); //Sends the register we wish to read

    Wire.requestFrom(ADDRESS, 2); //requests high byte
    while(Wire.available() < 2); //while there is a byte to receive
    highByte= Wire.read(); //reads the byte as an integer
    lowByte = Wire.read();
    byte lowBytemask = lowByte & B00111111;
    //lowByte = lowBytemask;
    unsigned int bearing = (highByte<<6)+lowByte;
    angle[PITCH] = (((float)bearing * 0.02197265625)-180.0)* 1000;


    I over wrote the variable " angle[PITCH] " with the encoder angle. after it was working I then could start commenting out the IMU related code. Now thats a hack ;-)


    Its connected to the IMU port on the BruGIAOI board. connected 5v, ground, SDA and SCL. It goes through a level translator first then to the encoder. more pictures will be coming as i develop the gimbal further. 


    There is a close up at the end of the video. I will be publishing the CAD files for 3D printing your own when i am more settled on the design. As for needing an IMU, there is no reason you cant put this in a normal RC aircraft and have your self a look around without an IMU. If you want to stabilize, you can use gyro + encoder, full blown IMU not needed. If you want stabilization and SPOI you would need full IMU + GPS (autopilot). Also if it is mounted to a bench or a known position.


     you could utilize an SPI or I2C connection between AP and camera control. Heck you could even marry the two on a single board. IMUs have many drawbacks, given the choice between an IMU and an encoder to measure the relative angle of two planes, the choice is simple.


     There are obvious drawbacks to IMUs.  One basic guiding principle in robotics is the more sensors the better. Biologics enjoy a plurality of sensors, why not our creations? (IMU + encoder) > (IMU) == 1.

  • Yes, because it helps to make the gimbal correct for any mechanical slop in the gimbal structure, as well as movement in the vibration damping system.

  • The autopilot already has an IMU. The encoder provides the position relative to the autopilot. Would using an IMU on the camera provide better control and smoother operation?

  • Moderator

    I agree with Robert about the need of IMU ,too ... 

  • Really interesting work Wayne.  Can you show the mechanics of the encoder hookup?  I'm curious to see what you did.

    You must still be using an IMU on the camera mount plate, no?  I think the encoder will definitely help the control systme design, but I'm pretty sure you need an IMU still.

  • Hello How do you Connect it ?
    Any more picture?
  • Moderator

    Hi Wayne , 

    great job , but where in the code there is your implementation ? I don't found the patch in the zip code in the link.



This reply was deleted.