AS5600 Angle sensor support?

If you look at the datasheet for the AS5600 (the grove has one if you google) it can be programmed for different functions (ie PWM vs AnalogOut on OUT pin, PWM Frequency used, etc). I also found out simply by messing with the Output Pin (and grounding it - PGO must also have been grounded) that it can be programmed on the fly without I2C and this, while not messing with the I2C read rawAngle value, does mess with the output value and the I2C read Angle value… There is a video around that shows how to program them in different ways - generally to refine the range supplied - https://www.youtube.com/watch?v=Dwc4hFgNP5I. Essentially the RawAngle should always be correct. The Angle value and the OUT value (in Analog) can be adjust to zoom in on an angular range (the AS5600 can be used as panel knobs if desired).

In regards to the Magnet - I re-wrote parts of a driver Created by Kane C. Stoboi, 22 August, 2018.(and I run this on a test UNO to verify the AS5600 outside of my project) - the driver used incorrect bits in the bool functions to read the magnet for Too Weak, Too Strong, and Magnet present. I created a simply looping program that shows these and the AutoGainControl value so that you can confirm your magnet is in a good place. I also hacked some programming functions so I could reset the Zero and Maximum values so the output value would be corrected (need to write to these and then write to Burn Register to make a new range) if they were changed before. You can only burn 3 times and then your done - so be careful.

The I2C Registers documented in the Driver I have match the datasheet (you see these in the AS5600 SimpleFOC settings) and these are below (0x00 is how many Burn writes have been done, the Zero value, Max value, and Maximum Angle (all can be used to adjust out range), a CONF register that can change common functionality by bits (Power Mode, Hysterisis, Output type & Range, PWM Freq, Slow Filter, Fast Filter, Watchdog ,), Status showing Magnet state, AGC value, and Magnitude Value?, and the Burn value.
There is also a method to burn the Maximum Angle and CONF value permanently via I2C - only once - so be very careful.

  byte _ZMCOAddress = 0x00;
  byte _ZPOSAddressMSB = 0x01;
  byte _ZPOSAddressLSB = 0x02;
  byte _MPOSAddressMSB = 0x03;
  byte _MPOSAddressLSB = 0x04;
  byte _MANGAddressMSB = 0x05;
  byte _MANGAddressLSB = 0x06;
  byte _CONFAddressMSB = 0x07;
  byte _CONFAddressLSB = 0x08;
  byte _RAWANGLEAddressMSB = 0x0C;
  byte _RAWANGLEAddressLSB = 0x0D;
  byte _ANGLEAddressMSB = 0x0E;
  byte _ANGLEAddressLSB = 0x0F;
  byte _STATUSAddress = 0x0B;
  byte _AGCAddress = 0x1A;
  byte _MAGNITUDEAddressMSB = 0x1B;
  byte _MAGNITUDEAddressLSB = 0x1C;
  byte _BURNAddress = 0xFF;

I believe you can write config and it will stay until power is lost so you can easily set PWM Out mode in your setup via the Config register and it should stay while your project is up.

Regards

2 Likes