On this page
Position sensors
The library currently supports the following types of position sensors:
- Encoder
- Magnetic sensor.
- Hall sensors
- IMU (in development)
Encoders
Encoders are by far the most popular position sensors, both in industry and in the hobby community. The main benefits are the precision, standardization and very low noise level. The SimpleFOClibrary supports just about any type of encoder you can find. Here is a 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 between encoder precision and execution efficiency, therefore it very is important to find a suitable encoder to your application.
Examples | Description | Link | Price |
---|---|---|---|
Optical encoder 2400cpr | Ebay | 10$ | |
Optical encoder AMT103 configurable cpr 48-8192 | Mouser | 20$ | |
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 a max velocity of 120rpm - 2 rotations/second
Magnetic sensors
Magnetic position sensors have many benefits over 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 than 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)
- 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:
Examples | Description | Link | Price |
---|---|---|---|
AS5047 SPI/ABI/PWM/UVW 14bit | Mouser | 15$ | |
AS5048A SPI/PWM absolute 14bit | Ebay | 10$ | |
AS5600 I2C/PWM 12bit | Ebay | 5$ |
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. Motors are usually fitted with 3 hall sensors which read the rotor magnet position and can determine electrical angle of the motor with a resolution of 60 degrees.
Sector | Electrical angle | Hall A | Hall B | Hall C |
---|---|---|---|---|
1 | 0-60 | 1 | 0 | 1 |
2 | 60-120 | 1 | 0 | 0 |
3 | 120-180 | 1 | 1 | 0 |
4 | 180-240 | 0 | 1 | 0 |
5 | 240-300 | 0 | 1 | 1 |
3 | 300-360 | 0 | 0 | 1 |
The main benefit of these sensors is that they are really cheap and they can be added on just about any BLDC motor. But nowadays, with the 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 sensors are electrical motors in all kinds of transportation vehicles. Their motors are often very high-power and relying on any kind of communication (I2C, SPI, SSI … ) with such high currents and magnetic fieds is just not an option. Another reason to 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.
You can find hall sensor ICs at any electronics supplier, all the way from Ebay and Aliexpress to Mouser and Digikey but also in most local electronics shops.
Examples | Description | Link | Price |
---|---|---|---|
49E Hall Sensor (10x) | Aliexpress | 1$ |
You can also consider buying a BLDC motor with integrated Hall effect sensors if this suits your application.
Examples | Description | Link | Price |
---|---|---|---|
BLDC motor hall sensors integrated 100W | Aliexpress | 40$ | |
BLDC motor hall sensors integrated 30W | Aliexpress | 25$ |
Motor choice
Make sure to read supported motor docs before you buy your BLDC motor.