Skip to content

Repository files navigation

MagAlpha library

Compile Examples

Arduino library for the MPS MagAlpha magnetic angle sensor.

About

MagAlpha sensor detects the absolute angular position of a permanent magnet, typically a diametrically magnetized cylinder on the rotating shaft.

For more information on the MagAlpha sensor family:

Supported sensors

Supports all 3rd, 4th, 6th, 7th, 8th generation MagAlpha magnetic angle sensors from Monolithic Power Systems.

ApplicationsPart Numbers
Turning knob applications (potentiometer replacement)MA800, MA820, MA850
Rotary encoders (optical encoder replacement, Servo motors, ...)MA702, MA704, MA710, MA730
Position controlled motor drivers (FOC, ...)MA302, MA310, MA600
Motor commutation (hall switches replacement)MA102

License

Written by Mathieu Kaelin for Monolithic Power Systems. MIT license, all text above must be included in any redistribution.

Connections

Power supply

ArduinoMagAlpha
GNDGND
+3.3V (Not 5V)VDD
Warning
Unlike most Arduino & Genuino boards, the MagAlpha runs at 3.3V. Even if the I/O can tolerate 5V, check that the voltage applied to VDD is at 3.3V. Applying a voltages higher than 3.3V to the VDD pin could damage the sensor.

Serial communication

All MagAlpha have a SPI communication interface. Some sensors like the MA702 also have an additional SSI (2-wire) interface. MagAlpha gen8 possess an I2C interface.

SPI (4-wire interface)

ArduinoMagAlpha
MOSIMOSI
MISOMISO
SCKSCLK
any available digital pin (default: pin 0)CS

SSI (2-wire interface)

ArduinoMagAlpha
MISOSSD
SCKSSCK

I2C (2-wire interface)

ArduinoMagAlpha
SCLSCL
SDASDA

Arduino SPI pin mapping

Arduino / Genuino BoardMOSIMISOSCKCSVoltage Level
ZeroICSP-4ICSP-1ICSP-3defined by the user, any digital pin (default: pin 0)+3.3V
MKRZero8109defined by the user, any digital pin (default: pin 0)+3.3V
MKR10008109defined by the user, any digital pin (default: pin 0)+3.3V
10111 or ICSP-412 or ICSP-113 or ICSP-3defined by the user, any digital pin (default: pin 0)+3.3V
DueICSP-4ICSP-1ICSP-3defined by the user, any digital pin (default: pin 0)+3.3V
Uno or Duemilanove11 or ICSP-412 or ICSP-113 or ICSP-3defined by the user, any digital pin. Default pin must be changed because pin 0 is also used by the Serial port. (use pin 7 for example)+5V
Mega1280 or Mega256051 or ICSP-450 or ICSP-152 or ICSP-3defined by the user, any digital pin (default: pin 0)+5V
LeonardoICSP-4ICSP-1ICSP-3defined by the user, any digital pin (default: pin 0)+5V

Check Arduino SPI library reference page for more information on the SPI signal connections.

Setup

Install the library directly from within the Arduino IDE by using the Library Manager (Sketch => Include Library => Manage Libraries...).

It is also possible to import the library Zip file (check release tab) from the Arduino IDE (Sketch => Include Library => Add .ZIP Library...).

The library can also be manually installed by copying the MagAlpha library folder in your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE to see the library.

Check this tutorial on Arduino library installation for more information:

About

Arduino library for the MPS MagAlpha magnetic angle sensor.

Topics

Resources

Stars

23 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages