AMS AS5030 User manual

austriamicrosystems AG
is now
ams AG
The technical content of this austriamicrosystems application note is still valid.
Contact information:
Headquarters:
ams AG
Tobelbaderstrasse 30
8141 Unterpremstaetten, Austria
Tel: +43 (0) 3136 500 0
e-Mail: ams_sales@ams.com
Please visit our website at www.ams.com

AS5030 8-bit Programmable Magnetic Rotary Encoder
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 1 of 10
1General Description
The AS5030 is a contactless magnetic rotary encoder for
accurate angular measurement over a full turn of 360°.
It is a system-on-chip, combining integrated Hall elements,
analog front end and digital signal processing in a single
device.
To measure the angle, only a simple two-pole magnet,
rotating over the center of the chip is required.
The absolute angle measurement provides instant indication
of the magnet’s angular position with a resolution of 8 bit =
256 positions per revolution. This digital data is available as a
serial bit stream and as a PWM signal.
In addition to the angle information, the strength of the
magnetic field is also available as a 6-bit code.
Data transmission can be configured for 1-wire (PWM), 2-
wires (CLK, DIO) or 3-wires (CLK, DIO, CS).
A software programmable (OTP) zero position simplifies
assembly as the zero position of the magnet does not need
to be mechanically aligned.
A Power Down Mode together with fast startup- and
measurement cycles allows for very low average power
consumption and makes the AS5030 also suitable for battery
operated equipment.
2The AS5030 Adapterboard
2.1 Board description
The AS5030 adapter board is a simple circuit allowing to test and evaluate the AS5030 rotary encoder quickly without having to build
a test fixture or PCB.
The PCB can be used as standalone unit or attached to a microcontroller.
The standalone operation requires only a 5V power supply, the magnet’s angle can be read on the PWM or analog output.
Figure 1: AS5030 Adapterboard
AS5030-AB-2.0 Adapterboard
OPERATION MANUAL
AS5030
8 bit Programmable Magnetic Rotary Encoder
JP1 connector
(Alarm, PWM, analog,
p
ower su
pp
l
y)
JP2 connector
(serial IO, power supply)
4 x 2.6mm mounting
holes
P2 solder bridge
Close (default): 3 wire serial mode
Open: 2 wire serial mode
P1 solder bridge
Close (default): Sin/Cos output disabled
Open: Sin/Cos output enabled
AS5030 encoder
A
nalog Sin/Cos outputs
(P1 must be opened)
ams AG
Technical content still valid

AS5030 8-bit Programmable Magnetic Rotary Encoder
Adapterboard Operation Manual
2.2 Mounting the AS5030 adapter board
Bearing
M2~M2.5 Screw + nut
Casing
Figure 2: AS5030 adapter board mounting and dimension
A 6x2.5mm diametral magnet must be placed over on under the AS5030, and should be centered on the middle of the package with
a tolerance of 0.5mm.
The airgap between the magnet and the AS5030 casing should be maintained in the range 0.5mm~2mm.
The magnet holder must not be ferromagnetic. Materials as brass, copper, aluminum, stainless steel are the best choices to make
this part.
Rotating shaft and magnet holder
Not ferromagnetic (plastic, brass, copper,
stainless steel, aluminum…)
Spacer
AS5030-AB PCB
JP2 connector, 3 pin
(Analog out, 5V, GND)
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 2 of 10
ams AG
Technical content still valid

AS5030 8-bit Programmable Magnetic Rotary Encoder
Adapterboard Operation Manual
3AS5030 and adapter board pinout
AS5030
GNDGND Mag PWM DX 5V
GNDProg DI DIO CS CLK 5V
Ana
COSGND SINn SIN COSn
P1
P2
AS5030-AB-2.0
Figure 3: AS5030 adapter board connectors and encoder pinout
Pin#
Board
Pin#
AS5030 Symbol Type Description
JP1 - 1 3 GND S Supply ground
JP1 - 2 13 5V S Positive supply voltage, 4.5V to 5.5V
JP1 - 3 10 CLK DI_ST Clock Input of Synchronous Serial Interface; Schmitt-Trigger input
JP1 - 4 11 CS DI_ST Chip Select for serial data transmission, active high; Schmitt-Trigger input,
external pull-down resistor (~50kΩ) required in read-only mode
JP1 - 5 12 DIO DIO Data output / command input for digital serial interface
JP1 - 6 - DI DI Command input for digital serial interface. Connect to GND if not used.
JP1 - 7 2 PROG S OTP Programming voltage supply pin. Leave open or connect to VDD if not used
JP2 - 1 3 GND S Supply ground
JP2 - 2 13 5V S Positive supply voltage, 4.5V to 5.5V
JP2 - 3 - Analog - 0~5V analog output. Generated by the PWM output and filtered.
JP2 - 4 9 DX DO Digital output for 2-wire operation and Daisy Chain mode
JP2 - 5 16 PWM DO Pulse Width Modulation output, 2.26µs pulse width per step (2.26µs ~ 512µs)
JP2 - 6 1 MagRNG DO_T Push-Pull output. Is HIGH when the magnetic field strength is too weak, e.g. due to missing
magnet
JP2 - 7 3 GND S Supply ground
JP3 - 1 7 COS - Must be left unconnected for normal operation. COS output in SIN/COS mode (P1 open)
JP3 - 2 6 COSn - Must be left unconnected for normal operation. COSn output in SIN/COS mode (P1 open)
JP3 - 3 5 SIN - Must be left unconnected for normal operation. SIN output in SIN/COS mode (P1 open)
JP3 - 4 4 SINn - Must be left unconnected for normal operation. SINn output in SIN/COS mode (P1 open)
JP3 - 5 3 GND S Supply ground
P1
bridge 14 C1 DI
Configuration input for Sin/Cos output:
-Connect to VSS for normal operation (P1 closed, by default)
-High level (P1 open) to enable Sin/Cos outputs
This pin is scanned at power-on-reset and at wakeup from one of the Ultra Low Power Modes
P2
bridge 15 C2 DI
Configuration input for serial wire mode:
-Connect to VSS for 3-wire operation (P2 closed, by default)
-High level (P2 open) for 2-wire operation
This pin is scanned at power-on-reset and at wakeup from one of the Ultra Low Power Modes
Table 1: Pin description
Pin types: S: supply pin DO: digital output
DI_ST: digital input / Schmitt-Trigger DO_T: digital output / tri-state
DIO: bi-directional digital pin DI: digital input (standard CMOS; no pull-up or pull-down)
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 3 of 10
ams AG
Technical content still valid

AS5030 8-bit Programmable Magnetic Rotary Encoder
Adapterboard Operation Manual
4Operation use cases
4.1 Standalone Analog output mode
Figure 4: Using the analog output with the adapter board
The simplest setup to test the AS5030 is to use the
adapter board in standalone mode. A 3-pin header
connector is present on JP2.
A header connector is present on JP2 on pin 1, 2, 3.
Connect a regulated power supply on 5V (pin #2) and
GND (pin #1).
The “Ana” (pin #3) is an analog output, which is an RC
filtered signal of the PWM output of the AS5030. The
external device (AD converter, voltmeter…) connected on
the “Ana” pin should have an input impedance >470kΩ,
otherwise it should be buffered with an op. amp.
By rotating the magnet, a progressive analog voltage
from 0 to 5V can be measured on the “Ana” pin (JP2 #3).
Rotating the magnet clock wise (AS5030 chip on the top
side) increases the Ana voltage, and counter clockwise
will decrease the voltage.
Because of the RC filter, the response time of a jump
359°Æ0° (5VÆ0V) and 0°Æ359° (0VÆ5V) is 100ms.
4.2 Standalone PWM output mode
Figure 5: Using the PWM output with the adapter board
Instead of getting a proportional analog voltage
increasing with the magnet’s angle on the “Ana” output, a
PWM signal (JP2 pin #5) with a period of 581us, 2.26us
step and 5V pulse voltage can be connected to the
capture/timer input of a microcontroller in order to decode
the angle value.
Figure 6: PWM duty cycle depending on magnet position
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 4 of 10
ams AG
Technical content still valid

AS5030 8-bit Programmable Magnetic Rotary Encoder
Adapterboard Operation Manual
5Using the serial interface with MCU
The most complete and accurate solution for a MCU to read the angle of a magnet is the serial interface.
The 8 bit value of the angle will be directly read, and some other indicators as AGC value or alarm bits can be read at the
same time.
Serial commands can be sent to the AS5030 as well, like the low power mode, lock AGC or reset.
Note: The MCU must have 5V I/O connected to the AS5030 adapter board, the AS5030 is a 5V device.
The connection between the MCU and the adapter board can be made with 2, 3 or 4 wires.
5.1 2-wire serial interface
Jumper configuration: P1 close, P2 open.
Figure 7: Bidirectional serial connection (2 wire)
By opening P2, the AS5030 is configured to 2-wire data
transmission mode.
Only Clock (CLK) and Data (DIO) signals are required. A
Chip Select (CS) signal is automatically generated by the
DX output, when a time-out of CLK occurs (typ. 20μs).
See AS5030 datasheet chapter 4.15.
5.2 3-wire serial interface
Jumper configuration: P1 and P2 close.
Figure 8: Bidirectional serial connection (3 wire)
The MCU GPIO used for the DIO data signal should be
bi-directional: the MCU sends a 5 bit command first then
receives a 16 bit value on the same line. The DI input of
the adapter board must be connected to GND in this
mode.
The C source code for reading an angle with this
hardware configuration is described in Chapter 7.
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 5 of 10
ams AG
Technical content still valid

AS5030 8-bit Programmable Magnetic Rotary Encoder
Adapterboard Operation Manual
5.3 4-wire serial interface
Jumper configuration: P1 and P2 close.
Figure 9: Bidirectional serial connection (4 wire)
The command line and data line are separated:
The command line is a MCU output connected to DI, the
data line is an input of the MCU connected to DIO.
With this configuration, synchronous blocks like SPI can
be easily used to receive the 16 bit data value from the
AS5030. This communication method simplifies the
firmware code as well.
5.4 Serial daisy chain mode
Jumper configuration: P1 and P2 close.
Figure 10: Daisy chain setup (3 wire)
The Daisy Chain mode allows connection of more than
one AS5030 to the same MCU.
Independent of the number of connected devices, the
interface to the controller remains the same with only
three signals: CSn, CLK and DO.
In Daisy Chain mode, the data from the second and
subsequent devices is appended to the data of the first
device.
See AS5030 datasheet chapter 4.21.
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 6 of 10
ams AG
Technical content still valid

AS5030 8-bit Programmable Magnetic Rotary Encoder
Adapterboard Operation Manual
6AS5030 adapterboard hardware
6.1 AS5030-AB-2.0 schematics
MagRNGn
1
PROG
2
VSS
3
Test3
4
Test2
5
Test1
6
Test0
7
TC
8DX 9
CLK 10
CS 11
DIO 12
VDD 13
C1 14
C2 15
PWM 16
U1
AS5030
C2
nc C1
2.2u/10V
1
2
3
4
5
6
7
JP1
Header 7
1
2
3
4
5
6
7
JP2
Header 7
DIO
CS
CLK
MagRNGn
MagRNGn
PWM
PWM
DIO
CLK
CS
C1
Analog
C2
DX
DX
GND
GND GND
5V
GND
5V
PROG
PROG
1
2
3
4
5
JP3
Header 5
SINn
SIN
COSn
COS
P1
Solder_Bridge
GND
C1
SERIAL I/O OPTIONAL I/O
Analog SIN/COS output
Closed: SinCos output disabled (default)
(C2=HIGH)
5V
GND
P2
Solder_Bridge
GND
C2
Closed: 3 wire mode (Default)
Open: SinCos output enabled
Open: 2 wire mode
R1
100k
5V
R2
100k
5V
R3
15k C3
2.2u/10V
GND
Analog
GND
DI
DI
R4
100k
5V
GND
Q1
BSS138
Figure 11: AS5030-AB-2.0 adapterboard schematics
6.2 AS5030-AB-2.0 PCB layout
Figure 12: AS5030-AB-2.0 adapterboard layout
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 7 of 10
ams AG
Technical content still valid

AS5030 8-bit Programmable Magnetic Rotary Encoder
Adapterboard Operation Manual
7C-Source code, simple AGC & Angle read
void main() // This program reads the angle and AGC value from AS5030
{
short SSI_Stream; // 16-bit value where the serial result will be saved
byte angle_value, agc_value; // 8-bit results: Angle and AGC
float angle_degree; // Angle in degree
SSI_Stream = SerialRead (0); // Send command “READ” (command ‘00000’)
// and reads the 16-bit result from AS5030
angle_value = (byte)(SSI_Stream & 0x00FF); // Extract the angle value (8 bit)
agc_value = (byte)((SSI_Stream >> 8) & 0x3F); // Extract the AGC value (6 bit)
angle_degree = (float)value * (360/256);// Convert the 8-bit angle to degrees (0-360°)
}
short SerialRead(unsigned char command) // This function writes the command
{ // and receives the result from the AS5030
short RX_buffer;
SET_CS(); // CS pin = ‘1’, AS5030 selected
delay_us(Delay_Serial);
SSIwrite(command); // Send the command (exemple “READ” command ‘00000’)
DIO_HIGH_IMP(); // DIO output high impedance (input mode), ready to read
RX_buffer = SSIread(); // Receive the 16bit result from the AS5030
delay_us(Delay_Serial);
CLEAR_CS(); // CS pin = ‘0’
return RX_buffer;
}
short void SSIread() // This function reads the 16-bit value from the AS5030 DIO pin
{
xdata unsigned char current_bit;
short result;
result = 0; // Is the shift buffer for the 16 bit data receive
for (current_bit = 16; current_bit; current_bit--) // 16 steps loop (16 bit data)
{
result <<= 1; // Shift buffer value left 1 step (first time doesn’t count)
delay_us(Delay_Serial); // Small delay to be get the correct level on DIO
result += (VAL_DIO) ? 1 : 0; // If ‘1’ on DIO, store ‘1’ on the LSB else ‘0’
SET_CLK(); // Generate a CLK pulse to shift the data on DIO
delay_us(Delay_Serial);
CLEAR_CLK();
}
return result;
}
void SSIwrite(unsigned char command) // This function writes the 5-bit command to
{ // the AS5030 DIO pin
unsigned char current_bit;
unsigned char this_bit
for (current_bit = 5; current_bit; current_bit--) // 5 steps loop (5 bit command)
{
this_bit = (command >> (current_bit-1)) & 0x01; // Value of bit 5, then
//
bit 4, …, bit 0
// If the current command bit is ‘1’:
if (this_bit) SET_DIO(); // then send ‘1’ on DIO (push-pull output)
else CLEAR_DIO(); // Otherwise send ‘0’ on DIO (push-pull output)
if (current_bit == 1) // If Last Bit has been written
{
delay_us(Delay_Serial);
SET_CLK(); // Set Clock
delay_us(Delay_Serial);
DIO_HIGH_IMP(); // And DIO output of CPU in input mode
delay_us(Delay_Serial);
CLEAR_CLK(); // Clear Clock (datasheet timings)
}
else // Else generate a CLK pulse to shift the data on DIO
{
delay_us(Delay_Serial);
SET_CLK();
delay_us(Delay_Serial);
CLEAR_CLK();
}
}
}
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 8 of 10
ams AG
Technical content still valid

AS5030 8-bit Programmable Magnetic Rotary Encoder
Adapterboard Operation Manual
Table of contents
1General Description........................................................................................................................................................... 1
2The AS5030 Adapterboard................................................................................................................................................ 1
2.1 Board description...................................................................................................................................................... 1
2.2 Mounting the AS5030 adapter board........................................................................................................................ 2
3AS5030 and adapter board pinout..................................................................................................................................... 3
4Operation use cases.......................................................................................................................................................... 4
4.1 Standalone Analog output mode .............................................................................................................................. 4
4.2 Standalone PWM output mode................................................................................................................................. 4
5Using the serial interface with MCU .................................................................................................................................. 5
5.1 2-wire serial interface................................................................................................................................................ 5
5.2 3-wire serial interface................................................................................................................................................ 5
5.3 4-wire serial interface................................................................................................................................................ 6
5.4 Serial daisy chain mode............................................................................................................................................ 6
6AS5030 adapterboard hardware ....................................................................................................................................... 7
6.1 AS5030-AB-2.0 schematics...................................................................................................................................... 7
6.2 AS5030-AB-2.0 PCB layout...................................................................................................................................... 7
7C-Source code, simple AGC & Angle read........................................................................................................................ 8
Table of contents........................................................................................................................................................................ 9
Copyrights ................................................................................................................................................................................ 10
Disclaimer................................................................................................................................................................................. 10
Contact Information .................................................................................................................................................................. 10
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 9 of 10
ams AG
Technical content still valid

AS5030 8-bit Programmable Magnetic Rotary Encoder
Adapterboard Operation Manual
Copyrights
Copyright © 1997-2009, austriamicrosystems AG, Schloss Premstaetten, 8141 Unterpremstaetten, Austria-Europe.
Trademarks Registered ®. All rights reserved. The material herein may not be reproduced, adapted, merged, translated,
stored, or used without the prior written consent of the copyright owner.
All products and companies mentioned are trademarks or registered trademarks of their respective companies.
Disclaimer
Devices sold by austriamicrosystems AG are covered by the warranty and patent indemnification provisions appearing in its
Term of Sale. austriamicrosystems AG makes no warranty, express, statutory, implied, or by description regarding the
information set forth herein or regarding the freedom of the described devices from patent infringement. austriamicrosystems
AG reserves the right to change specifications and prices at any time and without notice. Therefore, prior to designing this
product into a system, it is necessary to check with austriamicrosystems AG for current information. This product is intended
for use in normal commercial applications. Applications requiring extended temperature range, unusual environmental
requirements, or high reliability applications, such as military, medical life-support or lifesustaining equipment are specifically
not recommended without additional processing by austriamicrosystems AG for each application.
The information furnished here by austriamicrosystems AG is believed to be correct and accurate. However,
austriamicrosystems AG shall not be liable to recipient or any third party for any damages, including but not limited to
personal injury, property damage, loss of profits, loss of use, interruption of business or indirect, special, incidental or
consequential damages, of any kind, in connection with or arising out of the furnishing, performance or use of the technical
data herein. No obligation or liability to recipient or any third party shall arise or flow out of austriamicrosystems AG rendering
of technical or other services.
Contact Information
Headquarters
austriamicrosystems AG
A-8141 Schloss Premstaetten, Austria
Tel: +43 (0) 3136 500 0
Fax: +43 (0) 3136 525 01
For Sales Offices, Distributors and Representatives, please visit:
http://www.austriamicrosystems.com
Revision 1.0, 26.February 2009
www.austriamicrosystems.com
Page 10 of 10
ams AG
Technical content still valid
Table of contents
Other AMS Media Converter manuals