Help getting started / basics!

My goal is to create a gimbal to hold a sensor array that is looking at/tracking an object. Pan up/down, spin left/right. I am new to FOC, but not electrical engineering. My MCU will be the ESP32-S3, the sensor array will be ~120g (with one of the gimbal motors inside it).

I am going for smooth, slow motion.
I do not need it to be very strong/high torque (I think).

I have been looking at 2804 sized gimbal motors. Also some 2208 ones. I intend to do a closed loop setup (two INA240 current sensors per gimbal) with encoders.

Things I am confused on that I hope someone can point me in the right direction:

  • Encoders, they seem to vary in price a lot.
    • Drivers, the SparkFun board I got uses the TMC6300 vs the TI DRV8313, I am going for a lower power system (2S Lipo battery ~7.4v), any concerns with the TMC?
    • AS5600 vs AS5048a, again a price difference, some accuracy (12bit vs 14bit) I am not sure that is super important in my application. (and one is I2c and one is SPI)
      • Also the SparkFun board uses TMAG5273 Hall effect sensor, but I have seen negative thoughts on this for a gimbal, not sure why tho.
    • I2C vs SPI vs PWM - Most off the shelf gimbal motors + encoders seem to use the above two chips but in PWM mode. In practice is this fine? crappy?
  • Heat - Ideally I want this to be slow and smooth, the sensor array will be balanced, I am thinking just low current should be fine here, if something pushes back I just want it to give up.
  • ESP32-S3, does it generally work well if it is multitasking a bit? I can make dedicated thread for it.
  • Is it worth using an off the shelf gimbal + encoder or should I just make my own encoder board setup? I am assuming most do not have the magnet needed so I will need to add that in the shaft.
  • Lastly any advice on gimbal size / kV / turns? I have seen some small low kV, various turns, I feel this is all a balance I am not yet understanding.

Appreciate any guidance or pointing me in the right direction to find it!!

Ryan

Hi Ryan, a lot of questions, i will try to answer most of them, but I am also kinda new to this so don’t take everything I say at face value.

I dont have experience with the drivers you mentioned, maybe someone else can help you there.

I have used the AS5600 and the AS5048a, the resolution can be calculated like this: 360° / 2^bit. The important difference to me between these two sensors was the communication protocol. The AS5048a can measure way faster, which leads to a higher Loopfrequency, which leads to a smoother Motion and a higher possible speed. But if you are just going for slow Motion (<20rad/s) you can probably just use the AS5600.

Hall effect sensors are only usefull for speed control, not position control, because of their limited resolution.

If possible avoid PWM because it is slower, for the AS5600 and the AS5048a use the implementations of the simplefoc library (for example: MagneticSensorSPI sensor = MagneticSensorSPI(AS5048_SPI,5)), these deliver the best performance.

You can try to limit the current if you want to avoid overheating.

You should be able to Multitask with the esp32, you can even dedicate a core to the motor loop. I haven’t tried this yet, but it sounds interesting.

I made my own motor+encoder setup, it was pretty doable, you just have to experiment a bit.

I haven´t experimented with gimbal motors so far, so no advice there.

As a general tip, use the documentation and examples, they are incredibly useful.

Gregor

One of the things that you need to keep in mind is that motors have a “motor constant”. Usually expressed as “KV”, voltage-constant, in RPM/Volt.

Motors with a high KV will run many RPMs for “manageable” voltages. This is useful if you want to run a small 100 thousand RPM mini prop from a 3V battery. (i.e. a 30000 RPM/V motor required). (that’s the most extreme I’ve seen).

The downside of a high KV is however that you get very little torque for each Amp of current through the motor. In fact the Torque per Amp is another motor-constant and it is mathematically equal to 1/ (the KV constant when in the proper units). (torque in Nm, KV in rad/sec/V).

So when you give a rat’s ass about the top speed, you want the lowest possible KV. 10 RPM/V would be ideal. You can reach 120RPM at 12V, and you can do two full revolutions in a second. Do you need more???

Making a high-KV motor is easy. Making a low-KV motor is hard.

10 RPM/V motors are difficult to get. I’d be surprised if you can find one that has 100KV. So on 12V you’ll be able to do 20 revs per second, but have only 0.1 of the would-have-been-possible torque for each amp that you have available. (i.e. with simplefoc mini, and say 2A max motor current, you get about 0.1 NM/A or .2Nm at 2A. ). (Rotations per minute = 2pi / 60s = 0.105 rad/s).

0.2Nm if you can achieve that, would be plenty.

Anyway… the motors you suggest are the “cheap chinese easy-to-make” and High-KV motors. If you get a motor for gimbal purposes, they use thinner wires, more turns, lower KV and better for your application. And about 2x more expensive, at least…

  1. I’m have little experience in projects with FOC but maybe I can help adding some information
    1. I didnt work with the drivers that you cited, so for now I’ll try to see the datasheet and if I see something to note, I’ll come back
    2. About the encoders, if you need more accuracy in tracking the object and need more reliability, the AS5048A can be a better option. Not only the resolution is bigger but the SPI communication is the fattest one between I2C and PWM. For projects that have higher speeds, like drones for example, the AS5048 is also a good option. If you don’t need so much, the AS5600 is great (btw I’m using the AS5600 in my project for a omnidirectional robot). PWM is the easiest one because uses less hardware (only 3 wires) and you don’t need a lot more than knowing the GPIO of your board, but it is much slower than the others. However, if you don’t need so much speed, it’s okay to use.
    3. About the ESP32-S3, I saw a lot of people using for multitasking and it works well. Also depends on how much you want to do. You can estimate how much of memory and CPU your tasks will consume and compare it to the specifications’s board. I don’t know a good tutorial ou another material to help you estimate this but I believe that you can search and find it with little difficulties
    4. The encoder’s readings are greatly influenced by the magnet position. The magnet have to be centralized in the axis motor to a good reading and the distance between the magnet and the encoder also influences too. I strongly recommend using a shelf to minimize errors due to bad positioning (if I confused what you mean by shelf, I’m sorry, english isnt my first language but I will not change that you need to support you magnet very well !!). Some motors have the magnet included so you just need to secure the encoders position

Thank you both, very helpful!!

@Gregor Yeah, you are getting what I have been trying to understand which is how “fast” do I need the feedback loop for a relatively slow moving gimbal. I have seen some projects that use PWM and seem to accomplish the job but your point about smoothness is interesting. It seemed generally smooth but after rewatching some of the videos maybe not. Granted that could be the recognition algorithm too.

Example video: https://www.youtube.com/watch?v=1gW-QTQxuLY They do use the AS5048 encoders, but I have seen the wiring it is PWM.

@rew Most of the gimbals I am finding are over 200Kv. To understand better, do more turns generally lower the Kv? or is it a combination of wire thickness and more turns? I do not think I need a large amount of torque I can balance my setup quite well and it will be stationary.

Thank you @nanaEuah as well! I may just need to try the various connection types (PWM, I2C and SPI) and see what is adequate. Most of the ready made gimbal BLDC motors with encoders come pre-wired with just PWM. That is the easier path, but I can explore doing it myself or a custom order as well.

I’m a bit of a theory-man. So when I say 100Kv would be ideal, that doesn’t mean that you can find them. :slight_smile: You’ll have to compromise with having “as low as possible” and getting “more RPM that needed”. So they don’t make them any better than 200kV. Sounds plausible.

Lower KV is more turns. The wire thickness doesn’t matter. If you can fit more AWG10 wires on your motor, that’s great, but generally speaking the amount of space for wires is limited so you’ll have to go to thinner wires to get more turns.

In general, the power specs stay “about the same” when you put more turns of a thinner wire on a motor. It is just that you get different voltage and AMP ratings when the motor runs optimally.

So in theory, if you have a 400kV motor, you can use two times thinner wire to get two times more turns on it. Now you’ve halved the KV, doubled the voltages and halved the amps!

The other way around it is slightly more obvious that you end up with exactly the same motor, but different voltages and currents. Suppose I have a 200kV motor. Now I cut each of the windings in half and instead of putting the two halves in series (like they were), I put them in parallel. Now you need double the current and half the voltage for exactly the same magnetic and mechanical effect.

So I don’t really understand why a motor would be rated for XXX W in the 400kV version and YYY W in the 800kV version. In practice they might have issues with fitting the theoretical number of tunrs on a motor with a practically available wire thickness.

Just as a comment to this excellent thread: it’s no problem to find 100KV, and even some lower KV motors if you look for “gimbal motor”.

Pancake style gimbal motors in the larger sizes can have very low KVs, companies like iFlight RC and T-Motor have models that aren’t too expensive:

KV on that looks like around 27 RPM/V