Giter Site home page Giter Site logo

as5045's Introduction

AS5045

Dash's AS5045 library for Arduino

This library is successfully tested using AS5045 with the official magnet under the recommended assembly position, see more details on AMS's website here.

AS5045 Rotary Sensor Library for Arduino

Introduction

This package contains the AS5045 rotary sensor library for Arduino. The absolute angle measurement provides instant indication of the magnet’s angular position with a resolution of 0.0879° = 4096 positions per revolution. This digital data is available as a serial bit stream and as a PWM signal(PWM is disabled by default).

The sensor driver package includes AS5045.cpp, AS5045.h and keywords.txt files.

Integration details

Include the AS5045.h file in your code like below.

#include <AS5045.h>

File information

  • AS5045.cpp : This source file contains the definitions of the sensor driver APIs.
  • AS5045.h : This header file has the constants, macros and datatype declarations.
  • keywords.txt : This keywords file contains the library specified syntax highlight.

Supported sensor interfaces

  • Input : SSI
  • Output : PWM, serial bit stream

Usage guide

Initializing the sensor

To initialize the sensor, user need to create a device instance. At least the following parameters need to be provided when creating said instance.

  • CS pin : Chip Select, active low
  • CLK pin : Clock Input of Synchronous Serial Interface
  • DO pin : Data Output of Synchronous Serial Interface

Example

#define CSpin   2
#define CLKpin  3
#define DOpin   4

AS5045 enc (CSpin, CLKpin, DOpin);

Zero Position Programming

An one time offset during a programming cycle. Personally not recommended usless you want no one else to modify the OTP afterwards.

OTP register contents

  • CCW : increase in clockwise(ccw=0), counter clockwise(ccw=1)
  • Z[11:0] : Programmable Zero Position
  • PWM dis : disable PWM output
  • MagCompEn : When set, activates LIN alarm both when magnetic field is too high and too low
  • PWMHalfEn : When set, PWM frequency is 122Hz or 2μs / step (when PWMhalfEN = 0, PWM frequency is 244Hz, 1μs / step)

Default value for all OTP bits is 0. You can modify the OTP register value using either of the functions below directly, for detailed explaination of each bit please ref to this datasheet:

boolean progOTP (byte mode);
boolean progOTP (byte mode, boolean reverse, unsigned int offset);

Credit

Mark's AS5040 library for Arduino https://github.com/MarkTillotson/AS5040.git

as5045's People

Contributors

dashzhang avatar marktillotson avatar valkjsaaa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.