# Limits to motor movement at startup

I’m studying the FOC init procedure (in `initFOC()`) and how well it plays with my constraints.

I know the motor characteristics, including the `sensor_direction`, so I guess I can skip the natural direction detection phase. Anyone ever saw `sensor_direction` changing across motors of the same model?

What I still need to measure for each motor/sensor, though, is the `zero_electric_angle`.

The issue is that my device imposes limits to the possible movements of my motor. It can only have a 30° angular range. After reading this page, my understanding is that setPhaseVoltage(voltage_align, 0, _3PI_2) might require, in the worst case scenario, a 180° rotation. Am I right?

How many pole pairs, and what kind of sensor? The zero angle move is in electrical degrees, so the jump depends on pole count, but probably still too much in your case.

You’ll probably have to write a custom calibration routine to find a cogging step inbetween the mechanical limits and figure the zero angle from that.

There are 6 cogging steps per electrical revolution. I’m fairly sure _3PI_2 is one of them, so the others should be in steps of _PI_3 from there. So call setPhaseVoltage with those angles, and if it fails to move, you can guess you’re at one of the mechanical limits. Try to find a step that’s definitely clear in both directions. Average the sensor reading you get when jumping to it from both directions, and then adjust according to how many steps you are from _3PI_2.

You’ll actually get a more accurate zero angle that way than with the built in calibration routine, which only approaches from one direction.

1 Like

Thanks @dekutree64 . My motor has 6 pole pairs.

The sensor direction will change if you switch any of the phase wires. So in order to be able to assume a sensor direction you have to:

1. know or assume that the factory applies the windings in a fixed order and then brings those windings out of the motor and to the connector/exterior wires in a fixed order.
2. when making the connection to your board, you always connect the wires in that fixed order to your boards phases.
3. If the MCU is seperate, the connections between MCU and your driver also have to follow the same order.

If all this is given you can rely on a pre-defined sensor direction for a newly assembled unit. If not, you’d better calibrate the direction.

30° rotor angle on a 6PP motor translates into 180° electrical angle, not even a full electrical revolution…
It’s actually a very bad situation because in reality the motor’s 6 electrical zeros can all be completely outside your available range of motion.
So I fear you won’t be able to use our normal calibration routine and will have to come up with your own. Either that, or calibrate the motors before final assembly constrains their motion.

1 Like

Make sure you can get one to work at all before worrying about multiple motors. 9N12P outrunners usually have strong cogging in my experience. I’ve never managed to get one to hold position between steps. If it’s an inrunner it might be different.

1 Like

Thank you, this is really helpful. Sounds like I’d better calibrate the direction, as I don’t have a deep enough working relationship with the motor provider.

Let’s suppose that I can alleviate my constraint and allow for a 60° range. In that situation, am I sure that one electrical zero is always accessible? In that case, could I use the SimpleFOC normal calibration routine?

This is what I initially had in mind, but avoiding a calibration step during production would be nice.

They seem to work well. It’s the SteadyWin GB1105 (12mm in diameter).

It’s a good question. I fear it would not be reliable:

60° in this case is exactly one electrical revolution. If we imagine the different situations that can occur with this setup, considering the initial rotor position and the position of the electrical zeros I think there would be situations where it would work well, but there would be others where the rotor would be pulled towards one of the end-stops, and come to rest there instead of the actual zero (which would be just a little beyond the end in this example).

1 Like

Thanks @runger.

I’m new to this, so pardon me if the following is naive or even totally wrong.

Would you please confirm the following?

• With 3 phases, there exists 12 phase combinations to align a pole to a known angle (the 12 steps of the trapezoidal 150 control).
• If a motor is allowed a rotation range of only 60°, then two of these phase combinations are actually reachable (3 being an edge case).
• On a 6 PP motor, a mechanical rotation range of 60° corresponds to one full electrical revolution (60x6=360), so any one of those 12 phase combinations are actually reachable and are separated by a mechanical angle of 60/12=5°.

If the above is true, what about the following calibration routine?:

1. Try each of the 12 phase combinations, in rotation order, and record the corresponding sensor angle.
Only two (or three) consecutive records should be separated by a 30° sensor value. Those are the reachable phase combinations mentioned above. Both can be used to find the zero electric angles, the other ones cannot.
2. Consecutive records should be separated by a 5° sensor value. If they aren’t, it means the motor has been stopped by a limit. The ones that are separated by a 5° sensor value can be used to find the zero electric angles.

How does it sound?

– EDIT: first version was half wrong.

This sounds pretty good!

I’m honestly not sure which angles correspond to the other stable points (deku was calling them “cogging steps”, I don’t know what the official term would be if there is one).
Your description sounds quite convincing but I haven’t thought about it deeply.

Your method however sounds like a good one, once you know the corresponding angle values to use.

I definitely agree with deku’s suggestion to do it going in both directions and take the average.

1 Like

@dekutree64 , would you please explain why you said there are 6 “cogging steps” per electrical revolution? What’s wrong with my reasoning that there are 12? My understanding comes from the 6 steps described here for a half-revolution.

If you turn the unplugged motor by hand you can feel the preferred positions, and there should be 6 x pole pairs (3 x number of rotor magnets). Trapezoid150 mode does have 12 steps per electrical revolution, but I think it’s like microstepping a stepper motor, holding half way between the step positions. Your motors probably can do it, but for calibrating, the full step positions should be more accurate. My motors just oscillate back and forth if the angle setpoint is between step positions.

By the way, how do you buy from SteadyWin? Their web site doesn’t seem to have a store, and I couldn’t find the GB1806 on aliexpress. It looks like a good fit for my 3D printer extruder project.

That’s not easy.

They only accept direct initial contact if you speak Chinese and if you sound like you’ll purchase many motors. You also need a WeChat account, which is no trivial thing either. That being said, I can act as a middleman if you order enough motors (>=10).

Another option is to find the motor you’re looking for on Aliexpress or TaoBao (if you are lucky enough to be in TaoBao’s delivery country list).

Notice that many resellers won’t mention SteadyWin as the manufacturer and will apply their own brand name. Some will even change the model name. So you need to compare the motor’s characteristics with SteadyWin’s website to identify the right motor.

For example, here is your motor on TaoBao. Its name has been changed to PM1806, but the datasheet says… GB1806.

1 Like

Thanks, but I’ll pass. Too much trouble, and too expensive judging by the price on that TaoBao page.

Yeah but they also sell on AliExpress. In my experience if you write to sellers they’ll create an AliExpress listing for whatever you agree on with them. You can pay via AliExpress by credit card or PayPal.
Or if you have sufficient trust in the seller they can also just send you a quotation and you pay by PayPal.
I’ve not done this with SteadyWin but it’s worked without problems several times now for other things.
Since SteadyWin explicitly mentions Custom Support (just contact them) and factory direct sales in their listings I think it will work out.

For those landing here, please also see the following topic, as it presents methods to compute the `zero_electrical_angle` even when the motor has limits: