Sometimes a rotary potentiometer is inaccurate and sticky, and full encoders are bulky and costly. neoPLC has a solution in this touch-free Hall Effect Encoder board. By attaching a small magnet on any rotating shaft or body nearby, this IC will measure the angle of the magnet with 12-bit precision and with no friction nor drag. Ideal for feedback control of everything from feedback control demo projects (like inverted pendulums) to full robotic systems and creating your own servo motor from a low-cost stepper. Small disk magnet included. Fits nicely on the back of a NEMA8 stepper motor.
- 12-bit hall effect rotary encoder, requires diametrically magnetized disk magnet in close-proximity to the bottom of the board, with rotation centered on, and perpendicular to, the board
- Sensor reads from 0-360 degrees with 0.09 deg precision, 1.5 LSB RMS noise in internal tests
- Not appropriate for high speed applications since effective sample rate using i2c is limited to 2 kHz depending on filter settings
- Note: this IC does not allow address shifting so it is not recommended for projects where multiple encoders are needed on a single i2c bus
HAL Quickstart Code
// ~~~ HAL ~~~ // include the neoPLC-HAL library #include <neoHAL.h> // create an instance of the BAT board neoHAL hal = neoHAL(); // --- SETUP --- // initialize the HAL sensor board void hal.begin(); // set the origin to the current position void hal.setOrigin(); // --- METHODS --- // read the raw angle (0-4095) relative to user set origin uint16_t angle = hal.readAngle(); // read the sensor status. returns 0 for Magnet OK, // 1 for Magnet Missing, // 2 for Magnet Too Strong, // 3 for Magnet Too Weak uint8_t status = hal.status(); // --- VARIABLES --- uint16_t hal.angle; // current angle in raw format (0-4095) float hal.degrees; // current angle in degrees float hal.rad; // current angle in radians uint16_t hal.origin; // origin (reference) angle in raw format (0-4095)