Skip to content

Latest commit

 

History

History

AMT25

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

AMT25

Arduino library for SPI based AMT25 series rotary encoder.

Description

Experimental

Warning: This library is not tested with hardware yet. So use with care, feedback welcome.

AMT25 is a library for the AMT253D-V and compatible rotation encoders. This devices decodes 360.0° in 4096 (12 bits) or 16384 steps (14 bits) which implies an accuracy of about 0.088° or even 0.022°.

TODO elaborate.

Compatibles

Families of AMT2x series rotary encoder devices with other interfaces.

device protocol compat notes
AMT21 RS485 x
AMT22 SPI YYY
AMT23 3-Wire ? Simpler, SPI alike, investigate
AMT24 RS485 x
AMT25 SPI YYY

So far the AMT22 family looks compatible and the AMT23 family might. TODO investigate.

Please note that from the AMT25xy-V there are 8 variations. See datasheet for all details:

  • x = Orientation: 2 = Radial (right angle), 3 = Axial (straight)
  • y = Absolute Resolution:
    • A = 12-bit single-turn, B = 14-bit single-turn
    • C = 12-bit multi-turn, D = 14-bit multi-turn

Not all variations are tested.

Hardware

Hardware SPI connections UNO based upon AMT22

PIN Uno Pin AMT color1 color2 Notes
+5V 5V 1 White Green
SCLK 13 2 Blue White
MOSI 11 3 White Blue
GND GND 4 Green White
MISO 12 5 Orange White
CS 2 6 White Orange Chip Select can be any free pin.

Related

Angle math

Decoders

Please report your experiences.

If you have a AMT25 device, please let me know your experiences with the sensor and this (or other) library.

Interface

#include "AMT25.h"

Constructor

  • AMT25(uint8_t select, SPI_CLASS * mySPI = &SPI) HARDWARE SPI
  • AMT25(uint8_t select, uint8_t dataIn, uint8_t dataOut, uint8_t clock) SOFTWARE SPI
  • bool begin(uint8_t bits = 14) initializes the communication, set number of bits.

AMT22 and AMT23 derived classes have same constructors.

Read

  • uint16_t getRawValue() returns a value from 0..16383
  • float getAngle() returns an absolute angle from 0..360.0°, optional with offset correction.
  • void setOffset(float offset = 0) set an offset in degrees for the angle.
  • float getOffset() returns the current offset in degrees.
  • uint16_t setZero() set current position as zero.
  • uint16_t getTurns() get number of turns.
  • uint32_t lastRead() timestamp in microseconds since start. Note this wraps every ~70 minutes however for RPM measurements one need to read the device far more often.

SPI

  • void setSPIspeed(uint32_t speed) idem, clipped to max 2 MHz.
  • uint32_t getSPIspeed() idem.
  • bool usesHWSPI() idem.

Future

Must

  • improve documentation
  • test with hardware

Should

  • test compatibility ANT22 / AMT23

Could

  • add examples
  • add convenience getter for steps / bits

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,