sosandroid / AMS_AS5048B

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

simple question i2c error 2 #14

Closed goephs closed 4 years ago

goephs commented 4 years ago

Using the device with arduino uno set up with i2c connections, I only see the error message: Angle sensor raw : I2C error: 2 Is there another setting that should be used?

sosandroid commented 4 years ago

Hello,

Have a look into the code, the angleR() and readReg16() may help.

The error is sent by the last one when an I2C communication error occurs. Maybe you need to check your setup

goephs commented 4 years ago

Many thanks for your tips. I used an i2c scanner routine and saw that the UNO showed 0x44 (once) and then 0x45.

I changed the .h file to comment out two lines and make address changes:

// Default addresses for AS5048B

//#define AS5048_ADDRESS 0x40 // 0b10000 + ( A1 & A2 to GND)

define AS5048_ADDRESS 0x45 // new address

define AS5048B_PROG_REG 0x03

//#define AS5048B_ADDR_REG 0x15

define AS5048B_ADDR_REG 0x44 // new address

The device now works without errors and the read raw angle program is reporting results to me.

Regards,

Gavin Watson

From: sosandroid notifications@github.com Sent: Saturday, October 3, 2020 4:14 AM To: sosandroid/AMS_AS5048B AMS_AS5048B@noreply.github.com Cc: Gavin Watson watson_gavin@yahoo.com; Author author@noreply.github.com Subject: Re: [sosandroid/AMS_AS5048B] simple question i2c error 2 (#14)

Hello,

Have a look into the code, the angleR() and readReg16() may help.

The error is sent by the last one when an I2C communication error occurs. Maybe you need to check your setup

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sosandroid/AMS_AS5048B/issues/14#issuecomment-703066455 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AEOIVBYLHZR7466KNVYLI33SI3MNNANCNFSM4SCHVHLA . https://github.com/notifications/beacon/AEOIVB473MHHDWEEDAYKHA3SI3MNNA5CNFSM4SCHVHLKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFHT7CVY.gif

sosandroid commented 4 years ago

The best way to change the device address into the code is not modifying the class but modifying the object instance call :

AMS_AS5048B mysensor(0x45);

However, this works ... But if you have more than one sensor to deal with this cannot work.