Hello.
I need to measure two angles and I’m trying to do that with two AS5600 magnetic rotary position sensors connected to an Arduino Nano board.
Each of the sensors works fine via I2C when connected alone to the board but they can’t be both connected because they have the same I2C address and the address can’t be changed on this sensor model.
A good replacement would be the AS5600L magnetic rotary position sensor: it appears to be as good as the AS5600, has a different I2C address than the AS5600 (it could be connected alongside a AS5600 with no address conflict) and its I2C address can be changed (two AS5600Ls could be connected instead with no address conflict).
The problem is I can’t find the sensor and its adapter at a convenient price.
I’d rather not to jump to different sensors for the moment as the AS5600 appears to work fine and exploring other sensors would mean investing more time and effort, so for now I’m sticking to a two AS5600s scenario.
Using a multiplexer isn’t probably feasable: I need to keep the system as small and lightweight as possible and, as far as I understood, a multiplexer is at least as big as an Arduino Nano board.
The AS5600 has an analog/PWM output other than I2C, so it could be possible to use one sensor via I2C and the other sensor via analog or PWM.
Since I need to detect angles with a resolution of at least half a degree, I need a sensor resolution of at least 10 bits (0 to 1023).
As far as I understood, a PWM signal has a resolution of 8 bits (0 to 255), clearly not enough.
I’ve read on the Internet it could be possible to increase the PWM resolution but the solutions explained look very complicated and untested.
The AS5600’s DAC has a resolution of 12 bits (0 to 4095) while the Arduino Nano’s ADC has a resolution of 10 bits (0 to 1023) it should be fine to connect sensor and board this way.
So I connected the sensor’s pin 3 (OUT) to the board’s pin A0 while the sensor’s output is set to analog.
Here’s a very basic sketch (a very short version of the sketch I’m using) which I used to test the system:
#include <AS5600.h>
AS5600 sensor;
void setup() {
sensor.begin(4);
sensor.setDirection(AS5600_CLOCK_WISE);
Serial.begin(115200);
}
void loop() {
Serial.println(analogRead(A0));
delay(1000);
}
Since the board’s ADC resolution, I would expect all the range values (0 to 1023) while I rotate the magnet through all 360 degrees.
Instead, the values change by few units.
My guess is there’s some kind of mismatch between sensor’s DAC and board’s ADC since they have different resolutions but I couldn’t find an answer.
Is there any other way to make the sensors operate via I2C with the same address that I didn’t considered?
Is it possible to safely increase the PWM resolution to 10 bits?
Why the results via analog signal aren’t correct?
Any help would be very appreciated.
Thank you very much.
[sterretje edit]
Fixed code tags
[/edit end]