Cant get good data from sensor/can't turn the motor


just got my shield and wanted to try something out, I got a AS5600 via I2C but I can’t get the pole pair script to run. It looks like my values of my AS5600 are too low. With the sensor test script the angle data is between 0.00 - about 7.00 when turned a full resolution.
It also always adds up for the angle - I would have guessed the angle function gives back an actual angle of the sensor. Is there something wrong on my side?

The motor just tries to move and clicks but I guess its getting prevented by wrong sensor data. The pairs calculation script looks like it always fails with such low numbers

I played around with the search_voltage and changed around the motor wires but I guess its the sensor data.

Do you have any tips? What does correct sensor data look like?

Edit: And its a diametrical magnet - just a guess could it be not strong enough? I bought some 6x2 I think and they feel quite strong but - don’t know.


Hey @breef

The angle of the sensor is in radians, so it should be from 0 to 2PI (6.28) for the full rotation.
So 0-7 looks ok.

The finding pole pairs actually doesn’t use the sensor much. It moves the motor in the open loop and then just reads the angle that the sensor has read at the end.

Here are some questions that will help us debug :smiley:
Is your motor moving when you run the code?
What is the pole pairs number that is being calculated?
What is the output of the sketch ?

I think the magnet is fine for now, if you get good angle read (0-6.28 rad per rotation) it should be fine.

P.S. the library is making the sensor angle continuous, it saves the number of rotations internally. Primarily for position control, so you can ask for more than one rotation.

Hey @Antun_Skuric,

Ah that makes sense! Then the sensor is good I think, my problem is somewhere else :slight_smile:

  • The motor is not turning when running the script, well lets say barely. Just a tiny bit. I thought it gets prevented by the sensor but it might be the setup.

The motor which was advertised for like 36V I think but I thought just to test everything thats fine for now. I tested with 12V and it moved a bit. Then I changed to like 20V and changed the voltage_power_supply to 20 to get more movement but with 20V the motor won’t turn at all. The script always gets = inf

With 12V the script outputs everything between -2000 to +x00 - it doesn’t lock on a number.

I will search for another motor right now and will test it later with a smaller one.
And will move around the motors cables again, I thought I did all possible combinations haha.

I see. Sometimes I get Inf value if I forget to uncomment the code for the SPI sensor. But I am doing a lot of switching in between sensors so things like this happen.

Is the driver getting hot, what is the resistance of the motor?

If the motor doesn’t move that probably means that there is a problem in hardware connections. But this pole pair search algorithm is not at all bulletproof. :smiley:
So it will more likely work statistically good, it will not make it each time. I would say 7 out of 10 times it will work.

I had a problem before with the Arudino UNO memory, can you please tell me the amount of memory the sketch is using. Arudino IDE will display it for you once when it is uploading. Beacause so many Serial prints. Ardunio UNO’s memoty is full and some wired (completely unrealeted) execution problems occur.

I have tested the code few minutes ago and it works for my setup, here is a quick video, maybe it helps somehow.

Let me know how it goes.

Thanks for the video! I see now what it should look like!

  • The driver is getting real hot especially with 20V. I was getting concerned with that too forgot to mention it sorry!

The motor is basically a skateboard motor. I just searched for the specifications, I can measure it later what the actual resistance is. I read the shield is for low motors like gimbals, I have a DR3802 coming but that will take a while and wanted to try it with the shield :slight_smile:

KV (rpm/volt) : 270
Power (W) : 1820
Wire Winds : 9
Resistance (Kv) : 42
Idle Current (A) : 1.5
ESC (A) : 80
Cell NiMH/NiCD : 9-24
Cell LiPo : 3-8

I thought at least I might get it going - is there any way to use the shield with a motor like this?

  • About the UNO memory I guess you are right. It uses 1994/2048 bytes 97% - which already warning me for low memory available. I might try it on a ESP - is this already working on there? The documentation mentiones with modifications or something but haven’t found much about it but haven’t tried either yet.

I think there is a small bug in the find_pole_pairs_example.ino.

Can you try to change the while loop to:

  while(motor_angle <= pp_search_angle){
    motor_angle += 0.01;
    encoder.getAngle();  // <- ADD THIS LINE
    motor.setPhaseVoltage(pp_search_voltage, motor_angle);

What I believe was happening was that because nothing was calling encode.getAngle() then the encoder doesn’t get a chance to notice a 'rollover) (where 4096 goes back to zero). I found that sometimes you get lucky, sometimes you don’t. But if you add the getAngle() in the loop, its good.


Hey @Owen_Williams,
I put that in but did not change a thing for me. Might help in the future but I guess my motor won’t work :slight_smile:

I’m not sure what the real units are for “resistance”. But if you’ve bought a big outrunner motor then it could have a resistance of 42milli ohms (yes really!!). If you compare that to my small gimbal motor - which has a resistance of 10ohms that is a massive difference. You could be drawing massive current!

1 Like

Here is (perhaps) a similar motor that has resistance of 25mOhms.
What do you want to use the motor for? Are you building an electric skateboard?

@Owen_Williams oh wow yeah thats quite a difference.

Yes the motor is about that size like in that thread, its basically an outrunner if I gathered that name correct. I found another I think RC-plane/boat - same style - 5-12V motor. I tried the shield with that one and its just a little bit more movement I guess the resistance with such motors is much higher than the small gimbal motors.

I guess the shield is not able to drive this motor and there is no modification I can do or is there? I have a DR3802 coming - but I think that one is able to drive motors like that?

What I want to with it is currently move something on a rail but also some robotics applications - I just had this motor laying around from another project.

I recommend always measuing the motor’s resistance before connecting it to a driver. I don’t have a shield just yet, but I believe you should be able to run your motor by setting a voltage limit to something small like 1V, you definitely want to draw no more than 5A with the shield.

With the DRV8302 you will be able to spin the motor, but you will have to limit the voltage too to something really small so that the motor doesn’t draw extreme currents.

As well as running with a voltage limit, I’d suggest trying to run it in voltage mode first. Velocity and position modes require more configuration. I think voltage mode should even work without an encodet/sensor.
Voltage control = simple config
Velocity control = medium config complexity
Position control = harder config complexity (more tuning).
Baby steps!

1 Like

Hi @breef,
such a motor needs a bunch of amps to start. Also the sine commutation at low RPM needs a lot of amps because of the cogging. The usual controller for such a motor is i.e. a VESC 50. Regular commutation starts at about 500 RPM. Below there is just open loop control. Hence, it is hard to run the sensor alignment or pole pair count calculation at low speed.
Motors like this are not designed to operate in position control. It is possible, but hard.
As long as SimpleFOC has no current control loop (what is on the agenda, i guess) you have to be very careful with the tiny controllers. 1V at 50 mOhm leads to 20 amps at the first moment. Most of them have no over current protection.

Regarding the sensors I can tell that I tried AS5600 via I²C and AS5048A via SPI this weekend. Both with stable operation and good precision on a STM32 Nucleo. On a ATmega there are some trouble with the speed.

1 Like

Do you mean DRV8302? I presume the board you have on order have 6 mosfets on board? Or are you adding those? How much weight/resistance are you moving along your rail? Perhaps you should be looking at a smaller motor (compatible with shield).
Here is a random gimbal motor from ebay that I’m guessing would be fine with your shield:

Note: I haven’t checked how easy it would be to add an encoder or sensor to it.
Or you could use a nema 17 stepper.
1 Like

@Owen_Williams thanks for all the info!

Yes I meant the DRV8302, the development board with mosfets linked here somewhere in the project :slight_smile: I guess to really use my motor which could draw up to 80A I need a board (maybe with a 8302) with mosfets able to handle that draw? Or more calculate with the resistance of the motor and the planned voltage? Thanks @Juxo thats more context for motor controllers. Is there more things to a driver for skateboard motors like mine? VESC50 goes more in a category like odrive isn’t it? Are there just bigger mosfets on there? And they use current control loop but this project might get that too in the future

I want to move just something light, a stepper could do it but I want to use some BLDCs just to use them :slight_smile: I bought the shield just to get started faster and contribute to the project. I was kinda confused which data is actually important for the motors and controllers and the resistance wasn’t really talked about and which sizes go with what motors. (not on here, just my previous research about BLDCs) But I have a better plan now I think :slight_smile: thanks!

But a question about motors:
I researched all the gimble options and those used in here and thought I will just buy the 4108 you linked or from iPower but what makes the difference to this one?

This should work too right? This one has no load current specified like the 4108 just a “Cunnrent (A):0.09” I think that means current, but just 0.09A - thats a little low? But should work fine with the shield?

Are you aware of what 4108 and 5208 means? The first motor has a diameter of 41mm and a depth of 8mm (excluding housing). The second is 52mm x 8mm. The wider diameter motors tend to have more torque. So if you select a 5208 over a 4108 then you can expect it to be able to overcome more angular holding force. Gimbals have lots of winding turns and use thin wire. This, I understand, lowers the KV. A lower KV will typically run slower but have more torque. In many circumstances the torque can be high enough to not require mechanical gears. Looking at that skateboard motor, it has a lot more depth - probably has a tenth of the turns and uses super thick wire (hence the milliohm resistance). It also has higher cogging. When you turn a motor when its disconnected you’ll notice it prefers certain positions. This is due to the permanent magnets holding the rotor. Low cogging is desirable if you want to do position control or very low velocity control. For normal/high velocity control applications e.g. skateboards or balance boards having higher cogging isn’t a massive problem.

Hey, @Owen_Williams ahh thanks! Yeah I got the dimensions from the numbers but I didn’t know what to do with it thanks! My motor has indeed more depth and the wire which is in mine quite thick hence the lower resistance I guess - Bascially what I needed was meant the depth of a mother vs its thickness - Well I want then the thicker motors :slight_smile: and my motors have just much depth hence the wrong motors for this.

I just wanted to know the difference between 4108 and 5208 to know if the bigger one still can be used with the shield or is it already “too big” - but I think its still in the specs of the board isn’t it? Or at least what I can tell from the specs of the motor which are kinda misformatted

Edit: Doesn’t matter, I just bought both - then I will test the difference and try the SimpleFOClibrary again with them :slight_smile:

@breef, You totally can move a low resistive motor with the DRV8302 board. You just need to be careful with the voltage you apply. I agree with @Owen_Williams, try to do voltage mode first and start with 0.1V and keep going until you think you reached a nice limit (current wise). That will be the voltage limit that should be set with the library as:

motor.PI_velocity.voltage_limit = yourVoltageLimit;

My robot (Five Bar Parallel Robot) uses two motors with internal resistance of mohms and I use a board based on the drv8305. I don’t worry a lot about overcurrent because if it’s detected the controller will raise a fault flag and turn off.

This is not the case with the shield, so you have to be really careful in order to not damage it with low resistive motors. Did you ever measure if the voltage dropped when you tried to spin the motor with the pole pair script?

1 Like

I’m sure they’ll both work fine with the shield. They both have a reistance > 10ohms. I reckon, due to that high resistance, that it won’t be possible to take them over 2.5A peak even at full torque (i.e. at max voltage of 20V). That doesn’t account for thermal, they’ll probably need to be kept under 0.5A continuous or the motor or driver may get too hot. The SimpleFOC shield uses the L6234D driver which can take 5A peak. I’m testing with a 2802 gimbal but am going to also try it with a hoverboard motor (~1 ohm).

1 Like

@David_Gonzalez thanks for the input! I wanted to test again and have now measured my smaller 2836 motor and it has 0.5Ohm! Okay - I think I might have burned the chip then and before with the bigger motor or I’m doing something wrong. I btw found for anyone stumbling on here with these questions - which answers all my questions and I can’t believe I didn’t see it - kinda remember it maybe a few weeks ago.

@Owen_Williams, @David_Gonzalez I tested the voltage_limit but I’m not sure - from the documentation it reads like motor.PI_velocity.voltage_limit is only in the examples of position and motion/angle control and the diagram pictures only have the limiter in these modes?

But I tried it with Voltage mode and ::voltage (basically the pole pair script) with the limit at 1V and 0.1V inserted just before motor init - and it also felt like it did nothing. I think I burned the driver - even though I had it always running just for a couple of seconds it now just tries to move the motor a little bit but pulls 10A @12V (which doesn’t look that good)

Do you think the chip is burned with this behavior? Or am I just using the voltage_limit wrong?