EasyManua.ls Logo

AMS AS5600 - Reading out the AS5600 sensor

AMS AS5600
14 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
AS5600 Adapter Board
ams Eval Kit Manual, Confidential
Page 8
[v1-0] 2015-Jan-21
Document Feedback
3.2.2 Reading out the AS5600 sensor
Source code examples are also available for download on the ams webpage.
Following source code shows an easy example of reading out the sensor:
/*------------------------------------------------------
FILE: AS5600
Author: Mark A. Hoferitza, Field Application Engineer, ams AG
www.ams.com
Date: 27 May 2014
Description: Development of sketches for AS5600 "Potuino"
Read Raw Angle and Angle.
Single Value, no averaging.
-------------------------------------------------------*/
#include <Wire.h>
int AS5600_ADR = 0x36;
const int raw_ang_hi = 0x0c;
const int raw_ang_lo = 0x0d;
const int ang_hi = 0x0e;
const int ang_lo = 0x0f;
const int stat = 0x0b;
const int agc = 0x1a;
const int mag_hi = 0x1b;
const int mag_lo = 0x1c;
void setup(){
Serial.begin(9600);
Wire.begin();
}
void startup(){
}
void loop(){
// Wire.beginTransmission(AS5600_ADR);
// Wire.write(0x);
// Wire.write(0x00);
// Wire.endTransmission();
//***************************************************************
// Read Raw Angle Low Byte
Wire.beginTransmission(AS5600_ADR);
Wire.write(raw_ang_lo);
Wire.endTransmission();
Wire.requestFrom(AS5600_ADR, 1);
while(Wire.available() == 0);
int lo_raw = Wire.read();
// Read Raw Angle High Byte
Wire.beginTransmission(AS5600_ADR);
Wire.write(raw_ang_hi);
Wire.endTransmission();
Wire.requestFrom(AS5600_ADR, 1);
while(Wire.available() == 0);
word hi_raw = Wire.read();
hi_raw = hi_raw << 8; //shift raw angle hi 8 left
hi_raw = hi_raw | lo_raw; //AND high and low raw angle value
//**********************************************************
// Read Angle Low Byte

Other manuals for AMS AS5600