AMS AS5600 Podręcznik - Strona 8

Przeglądaj online lub pobierz pdf Podręcznik dla Jednostka sterująca AMS AS5600. AMS AS5600 14 stron. 12-bit programmable contactless potentiometer
Również dla AMS AS5600: Instrukcja obsługi (12 strony), Podręcznik użytkownika (13 strony), Instrukcja obsługi (10 strony)

AMS AS5600 Podręcznik
AS5600 Adapter Board

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;
hi_raw = hi_raw | lo_raw;
//**********************************************************
// Read Angle Low Byte
ams Eval Kit Manual, Confidential
[v1-0] 2015-Jan-21
//shift raw angle hi 8 left
//AND high and low raw angle value
Page 8
Document Feedback