====== lamaPLC: AS5600 Magnetic Induction Angle Measurement Sensor Module ====== {{ :sensor:as_5600.png?160|AS5600}} The AS5600 is a straightforward magnetic rotary position sensor featuring a high-resolution 12-bit analog or PWM output. It measures the absolute angle of a diametrically magnetized on-axis magnet without contact. Designed for contactless potentiometer applications, its durable build prevents interference from external homogeneous magnetic fields. The industry-standard [[com:basic_i2c|I²C]] interface allows easy programming of non-volatile parameters without a dedicated programmer. By default, the output covers 0 to 360 degrees, but a smaller output range can be set by programming a start (zero) and stop (maximum) angle. Additionally, the AS5600 includes a smart low-power mode to automatically lower power consumption. An input pin (DIR) determines the output polarity based on rotation direction: connecting DIR to ground causes the output to increase clockwise, while connecting it to VDD causes it to increase counterclockwise. {{ :sensor:as_5600_3.png |AS5600}} **Key Features** * **Resolution:** 12-bit digital output, providing 4,096 positions per full 360° rotation (approximately 0.087° per step). * **Multiple Output Modes:** Supports I²C digital interface, PWM, and ratiometric Analog voltage output. * **Programmable Range:** While the default is 0° to 360°, users can program a custom maximum angle from 18° to 360° to apply full resolution to a smaller range. * **Direction Control:** A dedicated DIR pin allows you to set whether the output value increases with clockwise or counterclockwise rotation. * **Low Power:** Features smart low-power modes that automatically reduce consumption, making it suitable for battery-powered devices. === Technical Specifications === * **Operating Voltage:** 3.3V to 5V * **Interface:** I²C (fixed address **0x36**) * **Temperature Range:** -40°C to +125°C * **Magnet Distance:** Best performance within 0.5 mm to 3 mm air gap {{ :sensor:as_5600_2.png |AS-5600}} === AS5600 Pinout === |< 100%>| ^Pin Name^Function^Description| ^VCC|Power Supply|Connect to 3.3V or 5V.| ^GND|Ground|Connect to establish common ground with your circuit.| ^SCL|I²C Clock|Serial clock line used for digital communication (0x36 fixed) address).| ^SDA|I²C Data|Serial data line for angle readings and configuration.| ^DIR|Direction|GND clockwise increases value; VCC = Counter-clockwise increases.| ^OUT|Output|Can provide an analog voltage or PWM signal proportional to the angle.| ^PGO|Program Option|Used for programming the sensor's non-volatile memory (OTP), which is usually left disconnected for standard applications' use.| **Critical Usage Notes** * **Operating Voltage:** When powering with 5V, make sure the module's onboard voltage regulator (if available) is used properly. For the raw chip, Pin 1 (VDD5V) and Pin 2 (VDD3V3) have specific wiring needs for 3.3V versus 5V operation. * **Pull-up Resistors:** The I²C lines (SDA/SCL) need pull-up resistors (typically 4.7kΩ) to VCC if they are not already present on your specific module. * **DIR Pin Stability:** It is strongly advised not to leave the DIR pin floating. Connect it to GND or VCC to avoid erratic position readings. * **PGO Pin:** Some modules include a resistor between PGO and GND that may disable the OUT pin. If the analog/PWM output isn't working, check this connection. === AS5600 Wiring === {{ :sensor:as_5600_4.png |AS5600 Wiring}} === AS5600 Arduino Wiring (I²C Mode) === |< 100%>| ^AS5600 Pin^Arduino Pin (Uno/Nano)^Arduino Pin (Mega)| ^VCC|5V (or 3.3V)|5V (or 3.3V)| ^GND|GND|GND| ^SDA|A4|Pin 20| ^SCL|A5|Pin 21| ^DIR|GND (for clockwise)|GND (for clockwise)| === AS5600 Arduino example code === To read angle data from the AS5600 using an Arduino, the most reliable approach is to use the I²C interface. You can use a library like the **Adafruit AS5600 Library** or the **Rob Tillaart AS5600 Library** for simplified functions. This code initializes the sensor and prints the angle in both raw units (0–4095) and degrees (0–360°) to the Serial Monitor. #include "AS5600.h" #include "Wire.h" AS5600 as5600; void setup() { Serial.begin(115200); Wire.begin(); if (!as5600.begin()) { Serial.println("Error: AS5600 not detected. Check wiring!"); while (1); } // Set clockwise as the increasing direction as5600.setDirection(AS5600_CLOCK_WISE); Serial.println("AS5600 Initialized."); } void loop() { // Read raw 12-bit value (0-4095) uint16_t rawAngle = as5600.readAngle(); // Convert to degrees (360.0 / 4096.0) float degrees = rawAngle * (360.0 / 4096.0); Serial.print("Raw: "); Serial.print(rawAngle); Serial.print(" | Angle: "); Serial.print(degrees, 2); Serial.println("°"); delay(100); // Read every 100ms } **Key Functions** * **as5600.readAngle():** Returns the current 12-bit filtered angle. * **as5600.getMagnetStatus():** Returns a status byte (//0x20 = Magnet detected; 0x10 = Too weak; 0x08 = Too strong//). * **as5600.setDirection():** Allows you to flip the rotation direction in software if the DIR pin is left floating or controlled by an I/O pin. **Troubleshooting** * **Magnet Detection:** If the serial monitor displays constant values, verify the magnet distance (0.5-3mm). * **Address:** The I²C address is fixed at 0x36 and cannot be modified. * **Pull-up Resistors:** Make sure your module has pull-up resistors on SDA/SCL, or add 4.7kΩ resistors to VCC if the I²C scan fails. ===== I²C topics on lamaPLC ===== {{topic>i2c}} \\ \\ {{tag>communication i2c AS5600 AS-5600 magnetic induction angle sensor}} \\ This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}