The library currently supports (releases ) types of position sensors:
- Magnetic sensor.
- Hall sensors
- IMU (in development)
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.
configurable cpr 48-8192
|Margetic encoder |
Encoder CPR: Rule of thumb for Arduino UNOFor 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.
ExampleIf your CPR value is 10000, you will be able to spin your motor with max velocity 120rpm - 2 rotations/second
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 (✔️ supported)
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:
BEWARE: I2C Pull-upsNot 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 interfaceIf 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 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.
|Sector||Electrical angle||Hall A||Hall B||Hall C|
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.
|49E Hall Sensor (10x)||Aliexpress||1$|
You can also consider buying a BLDC motor with integrated Hall effect sensors if this suites your application.
|BLDC motor |
hall sensors integrated
|BLDC motor |
hall sensors integrated
Motor choiceMake sure to read supported motor docs before you buy your BLDC motor.