sosandroid / AMS_AS5048B

Arduino Lib for AMS AS5048B I2C - 14-bit magnetic rotary position sensor
Other
48 stars 29 forks source link

Wrong I2C address in sample programs #8

Closed mmlamare closed 4 years ago

mmlamare commented 6 years ago

In the program_address and read_simple_angle sample Arduino files, the encoder object is constructed with address 0x40. This is inconsistent with the addressed used to program the chip, which is actually constructed with address 0x44. The binary value set is 0b1000100 which is correctly commented. However, that's 0x44, not 0x40. Interestingly, a user will be able to use the program_address.ino file to successfully read the chip after programming it (although the read_simple_angle file will not work because the incorrect address is accessed). This is likely due to the encoder object's address being changed in software when the addressRegW method is run, thus allowing it to correctly read the angle later in the void loop().

sosandroid commented 6 years ago

Hello,

Thank you for this feedback. Not sure to perfectly understand your point.

The proposed examples are not intended to use the "advanced features" of the chip such as the I2C address register programming. For most examples, we are relying on the default address of the chip which ix 0x40.

You're nontheless right, as long as you played with the slave address programmling, the examples are not able to communicate with the chip.

The best way to work with this, from my opinion, is to store the slave address somewhere, program it and set a flag somewhere. As long as you reset your controler, the proper slave address can be used.

Tell me if I am misunderstood your point. BR