AS-5600 feedback

Mark BofillMark Bofill
2 min read

When you order your AS-5600 magnetic decoders on Amazon, there’s reasonable odds the supplier will fail to ship you magnets along with the decoders, as they did me.

No biggie, right? Magnets are easy to come by.

Not so fast! My AI overlords tell me a specific type of magnet is needed. You need a diametrically magnetized magnet. It turns out the overwhelming majority of magnets out there commonly available are axially magnetized.

Naturally, diametrically magnetized magnets can be had on the internet. I’m going to try out ALC4040D Sensor magnets, from alliance magnets ( https://alliancemagnets.com/sensor-magnets/ ) They’ll charge you 12$ flat for shipping your order and take about five (5) days to process your order, so I’ll return to this when they arrive.

Meanwhile, we can make sure we can talk with the AS-5600’s via I2C. Raspberry Pi Pico boards are a convenient mechanism for trying this out for now:

This may be a little hard to make out, so schematically:

Wiring

The Raspberry Pi Pico has two I2C controllers, I2C0 and I2C1, which can be mapped to a variety of pins. The most common and recommended pins for I2C are GPIO 4 for SDA and GPIO 5 for SCL, which are part of I2C0.

  • AS5600 VCC to Pico 3.3V (Pin 36)

  • AS5600 GND to Pico GND (Pin 38)

  • AS5600 SDA to Pico GP4 (Pin 6)

  • AS5600 SCL to Pico GP5 (Pin 7)

Ensure your AS5600 module is operating at 3.3V. The Pico's I2C pins have internal pull-up resistors, which are usually sufficient.

We can make sure we are speaking I2C; the AS5600 ought to show up at 0×36h (micropython code on the Pico):

from machine import Pin, I2C

# Initialize I2C0 with the specified pins and frequency
# The default pins for I2C0 are GP4 for SDA and GP5 for SCL.
i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=400000)

print('Scanning I2C bus...')
devices = i2c.scan()

if len(devices) == 0:
    print("No I2C devices found.")
else:
    print(f"{len(devices)} I2C device(s) found.")
    for device in devices:
        print(f"I2C device found at address: {hex(device)}")

# Check specifically for the AS5600
as5600_address = 0x36
if as5600_address in devices:
    print("\nAS5600 Magnetic Encoder detected! 🎉")
else:
    print("\nAS5600 not found. Check wiring and magnet placement.")

and indeed it does.

Get notification by signing up here:

subscribepage.io/AaNkBL

0
Subscribe to my newsletter

Read articles from Mark Bofill directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mark Bofill
Mark Bofill