Link

Position sensors

The library currently supports (releases ) types of position sensors:

Encoders

Encoders are by far most popular position sensors, both in industry and in hobby community. The main benefits are the precision, standardization and very low noise level. The SimpleFOClibrary support just about any type of encoder you can find. Here is nice short video which explains the main working principles of encoders: YouTube video

The encoder position tracking (pulse counting) algorithm code efficiency, and especially its implementation on Arduino devices, is one of the main limitations for both performance and smoothness of the FOC algorithm. There is a clear tradeoff in between encoder precision and execution efficiency, therefore it very is important to find a suitable encoder to your application.

ExamplesDescriptionLinkPrice
Optical encoder
2400cpr
Ebay10$
Optical encoder
AMT103
configurable cpr 48-8192
Mouser20$
Margetic encoder
AS5047U
16384cpr
Mouser
Youtube demo
15$

Encoder CPR: Rule of thumb for Arduino UNO

For Arduino UNO, the maximum number of pulses/second should not exceed 20,000. After this value it start to have execution issues. Please take this in consideration when choosing the encoder and especially if using more than one motor.

Example

If your CPR value is 10000, you will be able to spin your motor with max velocity 120rpm - 2 rotations/second

Magnetic sensors

Magnetic position sensor has many benefits over the encoders:

  • Very efficient position calculation ( no counting )
  • Time of execution doesn’t depend on velocity or number of sensors
  • No need for interrupt hardware
  • Absolute position value
  • Lower price then encoders
  • Simple to mount

Magnetic sensors usually come with several different communication protocols:

  • ABI (✔️ supported) - exactly the same as the encoder interface
  • SPI (✔️ supported)
  • I2C (✔️ supported)
  • Analog (✔️ supported)
  • UVW (✔️ supported) - exactly the same as the Hall sensor interface
  • PWM
  • SSI

PWM and SSI protocol will be tested for their performance and implemented in following steps. Please let us know if you would be interested in having some other communication implemented!

Here are some of the supported magnetic sensors:

ExamplesDescriptionLinkPrice
AS5047
SPI/ABI/PWM/UVW
14bit
Mouser15$
AS5048A
SPI/PWM
absolute
14bit
Ebay10$
AS5600
I2C/PWM
12bit
Ebay5$

BEWARE: I2C Pull-ups

Not all the I2C buses need pull-ups. But in some cases they might be necessary. Especially when using STM32 boards. In those cases, you will not be able to communicate with the sensor. To enable communication usually 4.7kOhm resistors will be needed in between 5V/3.3V and SCL and SDA channels. Here is a good stack overflow question about this issue : link .
In the future versions of the SimpleFOCShield I will try to include those pullups as well.

BEWARE: UVW interface

If you desire to use UVW interface of the magnetic sensor please be sure to configure your magnetic sensor to have the same pole pair number as the motor. Also beware that the alignment of the magnetic sensor and the motor phases is very important and will probably take some time to achieve.

Hall sensors

Hall sensors for FOC control used to be very common in past due to their commutation simplicity. Motor is usually fitted with 3 hall sensors which read the rotor magnet position and can determine electrical angle of the motor with the resolution of 60 degrees.

SectorElectrical angleHall AHall BHall C
10-60101
260-120100
3120-180110
4180-240010
5240-300011
3300-360001

The main benefit of these sensors is that they are really cheap and they can be added on just about any BLDC motor. But nowdays, with emergence of magnetic sensors they are less and less used. One of the main disadvantages of these sensors is that the low speed operation is not smooth due to the relatively high quantization of the angle measurement.

The main area of application of these senors are electrical motors in all kinds of transportation vehicles. Their motors are often very high-power and relaying on any kind of communication (I2C, SPI, SSI … ) with such high currents and magnetic fieds is just not an option. Another reason why use hall sensors is if you cannot access the shaft of the motor, or if you cannot mount the sensor coaxial to the motor shaft. Hall sensors are mounted around the motor rotor, which makes them very non-intrusive and easy to integrate.

Hall sensors ICs you can find at any electronics supplier, all the way from Ebay and Aliexpress to Mouser and Digikey but also in most of local electronics shops.

ExamplesDescriptionLinkPrice
49E Hall Sensor (10x)Aliexpress1$

You can also consider buying a BLDC motor with integrated Hall effect sensors if this suites your application.

ExamplesDescriptionLinkPrice
BLDC motor
hall sensors integrated
100W
Aliexpress40$
BLDC motor
hall sensors integrated
30W
Aliexpress25$

Motor choice

Make sure to read supported motor docs before you buy your BLDC motor.