<- Back

Performance comparison between Axial and Radial Orientations

Key definitions:

  1. Axial Orientation:

Mounting the Magnet at the free end face of the Shaft, and letting the motor to rotate. Now, when it is rotating, you will bring the AS5600 in perpendicular to the axis of rotation.

flowchart LR
    subgraph h[" "]
    direction LR
        M[Motor] -->|"↻ rotates"| S[Shaft]
    end
    subgraph v[" "]
        AS[" A <br> S <br> 5 <br> 6 <br> 0 <br> 0 "]
    end
    h -.- |"end face"| MAG[M<br>a<br>g<br>n<br>e<br>t] -.- |"Sensor is <br>⊥ to rotational axis"| v
    
  1. Radial Orientation:

Mounting the magnet at a tangential curvature of the shaft, (in our case, for n20 motors, we get D-shaft, which has a flat surface.) and letting the motor to rotate. Now, when it is rotating, you will bring the AS5600 in radial offset, in parallel to the axis of rotation.

flowchart LR
subgraph h[" "]
    direction RL
    M[Motor] -->|"↻ rotates"| S[Shaft] 
    end
flowchart TD
    subgraph v[" "]
        direction TD
        MAG[Magnet]
    end
    subgraph h[" "]
        MAG -.-|"Sensor is ∥ to the <br>rotational axis <br> of the shaft."| AS[AS5600]
    end
    style v fill:none,stroke:none

Experiment:

I Tried experimenting with 4 different orientations, by taking a sample of data with Mounting:

  1. Axial Magnet in Axial Orientation Full Log Here
  2. Axial Magnet in radial Orientation Full Log Here
  3. Diametric Magnet in Axial Orientation Full Log Here
  4. Diamteric Magnet in Radial Orientation Full Log Here

I used the same motor, same battery, same code, but - I got naughty and tried varying the RPM by using 203 (20k) variable resistor.

Note, I am using Arduino for now, but for production, I will be using ESP IDF. Using Arduino because it helps me with conceptual clarity faster.

Code:


/*
This code is for measuring RPM, and Angle of a motor shaft. 
NOTE: This Source is for reading values that has
a D-Shaft with all the above 4 configuartions.
In my configuration, the bot is placed around
2-3mm away from the nearest rotating magnet attached to shaft. 
Video reference: https://www.instagram.com/p/DY_T-oABRys/
*/
#include <Wire.h>

#define AS5600_ADDR    0x36
#define RAW_ANGLE_HIGH 0x0C
#define RAW_ANGLE_LOW  0x0D

const float COUNTS_PER_REV      = 4096.0;
const int   SAMPLE_INTERVAL_US  = 100;// For every 0.1ms, take sample. 

// State
int16_t  lastAngle       = 0;
unsigned long lastTime   = 0;

// Revolution period RPM
float    rpm                = 0.0;
unsigned long lastRevTime   = 0;
bool     revStarted         = false;
int16_t  prevAngle          = 0;
long     accumDelta         = 0;//accumulated counts since last full rev

int16_t readRawAngle() {
  Wire.beginTransmission(AS5600_ADDR);
  Wire.write(RAW_ANGLE_HIGH);
  Wire.endTransmission(false);
  Wire.requestFrom(AS5600_ADDR, 2);
  int16_t high = Wire.read();
  int16_t low  = Wire.read();
  return ((high << 8) | low) & 0x0FFF;
}

void setup() {
  // I also have 2 I2Cs, and Just wanted
  // to confirm just before running the loop.
  // one for AS5600 and another for SSD1306 OLED.
  Serial.begin(115200);
  while (!Serial);
  delay(1000);
  Wire.begin(5, 6); // my I2C pins.

  Serial.println("Scanning I2C...");
  for (byte addr = 1; addr < 127; addr++) {
    Wire.beginTransmission(addr);
    if (Wire.endTransmission() == 0) {
      Serial.print("Device found at 0x");
      Serial.println(addr, HEX);
    }
  }
  Serial.println("AS5600 Ready.");
  Serial.println("timestamp_us,angle_deg,rpm");

  lastAngle    = readRawAngle();
  prevAngle    = lastAngle;
  lastTime     = micros();
  lastRevTime  = micros();
  revStarted   = true;
}

void loop() {
  unsigned long now = micros();

  if (now - lastTime >= SAMPLE_INTERVAL_US) {
    int16_t currentAngle = readRawAngle();

    // Angle in degrees
    float degrees = (currentAngle / COUNTS_PER_REV) * 360.0;

    // Revolution period RPM
    int16_t delta = currentAngle - prevAngle;
    if (delta >  2048) delta -= 4096; // wraparound CW
    if (delta < -2048) delta += 4096; // wraparound CCW

    accumDelta += delta;

    // Detect full revolution: +4096 counts = 1 full CW rev
    //                         -4096 counts = 1 full CCW rev
    if (accumDelta >= 4096) {
      unsigned long revPeriodUs = now - lastRevTime;
      rpm         = 60000000.0 / revPeriodUs; // CW positive
      lastRevTime = now;
      accumDelta -= 4096;
    } else if (accumDelta <= -4096) {
      unsigned long revPeriodUs = now - lastRevTime;
      rpm         = -60000000.0 / revPeriodUs; // CCW negative
      lastRevTime = now;
      accumDelta += 4096;
    }

    // Log
    Serial.print(now);
    Serial.print(",");
    Serial.print(degrees, 2);
    Serial.print(",");
    Serial.println(rpm, 2);

    prevAngle = currentAngle;
    lastTime  = now;
    //continue loop.
  }
}

Results and conclusions:

From this experiment, I have learned that it is possible to get accurate angles to track the position of shaft only when:

  1. Axial Magnet is in radial Orientation
  2. Diametric Magnet is in Axial Orientation

the other 2 methods will not give position tracking.

  1. Diametric Magnet in Axial Orientation
  2. Diamteric Magnet in Radial Orientation

Extract of the data in Table

Axial Magnet
in
Axial Orientation
Axial Magnet
in
radial Orientation
Diametric Magnet
in
Axial Orientation
Diamteric Magnet
in
Radial Orientation
timestampanglerpmtimestampanglerpmtimestampanglerpmtimestampangle_degrpm
2551016134.380.0024197450.35621.8324547056359.82-600.6811641021100.550.00
2551728134.650.0024204210.70621.8324547755358.07-600.6811641700102.040.00
2552402134.820.0024211171.23621.8324548446356.04-600.6811642391104.150.00
2553079134.910.0024218031.67621.8324549155354.55-600.6811643083106.610.00
2553752135.180.0024224882.11621.8324549854352.88-600.6811643764109.950.00
2554423135.260.0024231672.64621.8324550549351.04-600.6811644452112.410.00
2555100135.440.0024238523.34621.8324551242349.10-600.6811645142115.660.00
2555772135.620.0024245303.87621.8324551940347.43-600.6811645831118.740.00
2556442135.880.0024252034.39621.8324552639346.03-600.8811646514121.990.00
2557139136.050.0024258895.45621.8324553328344.27-600.8811647202125.860.00
2557816136.140.0024265816.77621.8324554023342.60-600.8811647874129.460.00
2558499136.140.0024272667.65621.8324554715340.93-600.8811648565132.450.00
2559179136.050.0024279518.79621.8324555401339.52-600.8811649242136.140.00
2559856135.880.00242863710.63621.8324556095337.76-600.8811649925140.010.00
2560533135.530.00242932212.66621.8324556776335.92-600.8811650602142.650.00
2561216135.180.00243001314.85621.8324557465334.25-600.8811651285145.630.00
2561897134.740.00243069316.79621.8324558167332.49-600.8811651974148.800.00
2562580134.210.00243138819.60621.8324558866330.91-600.8811652657151.170.00
2563257133.770.00243208422.50621.8324559563328.97-600.8811653347153.190.00
2563934133.330.00243277525.66621.8324560259327.30-600.8811654042155.390.00
2564619132.890.00243346129.18621.8324560952325.46-600.8811654726157.240.00
2565296132.540.00243414633.75621.8324561648323.79-600.8811655410158.640.00
2565973132.190.00243482736.21621.8324562341321.86-600.8811656104159.960.00
2566666131.840.00243551237.18621.8324563046320.01-600.8811656793161.100.00
2567348131.480.00243619138.85621.8324563742318.16-600.8811657470162.070.00
2568043131.040.00243688441.48621.8324564434316.05-600.8811658159162.860.00
2568719130.690.00243757543.68621.8324565139314.03-600.8811658848163.650.00
2569396130.250.00243825644.21621.8324565837312.45-600.8811659536164.360.00
2570079129.730.00243893645.44621.8324566537310.43-600.8811660220164.880.00
2570752129.020.00243961447.64621.8324567233308.14-600.8811660903165.410.00
2571422128.500.00244030048.25621.8324567919306.04-600.8811661592165.940.00
2572099127.790.00244097947.99621.8324568622303.93-600.8811662275166.460.00
2572771127.180.00244166649.13621.8324569315301.90-600.8811662964166.900.00
2573442126.390.00244234650.45621.8324570019299.53-600.8811663652167.340.00
2574125125.680.00244303551.24621.8324570717297.25-600.8811664345167.870.00
2574803125.160.00244371551.68621.8324571404294.96-600.8811665046168.400.00
2575486124.540.00244440153.00621.8324572103292.50-600.8811665724168.930.00
2576163123.930.00244509253.09621.8324572791289.78-600.8811666413169.450.00
2576833123.490.00244578252.73621.8324573493287.75-600.8811667102169.980.00
2577504122.960.00244646852.56621.8324574189285.21-600.8811667785170.420.00
2578183122.430.00244715354.23621.8324574883282.48-600.8811668469170.950.00
2578868121.900.00244783956.34621.8324575576279.58-600.8811669158171.390.00
2579544121.290.00244853055.37621.8324576274277.03-600.8811669842171.650.00
2580221120.760.00244920956.16621.8324576972274.75-600.8811670520172.180.00
2580904120.060.00244989057.92621.8324577664271.76-600.8811671207172.710.00
2581581119.270.00245057358.27621.8324578365268.86-600.8811671891172.970.00
2582270118.650.00245125458.97621.8324579069266.04-600.8811672583173.230.00
2582956117.950.00245194559.15621.8324579766263.32-600.8811673267173.410.00
2583639117.160.00245263160.47621.8324580453260.68-600.8811673954173.670.00
2584317116.540.00245332262.40621.8324581151257.70-600.8811674631173.850.00
2585000115.930.00245401963.54621.8324581843254.97-600.8811675322173.850.00
2585689115.310.00245470865.13621.8324582533251.98-600.8811675993173.670.00
2586372114.790.00245539466.97621.8324583233248.82-600.8811676685173.500.00
2587056114.170.00245608669.08621.8324583926246.18-600.8811677367173.410.00
2587727113.730.00245677170.14621.8324584619243.37-600.8811678056173.230.00
2588405113.290.00245745771.98621.8324585318240.47-600.8811678734172.790.00
2589082112.680.00245815476.99621.8324586016237.22-600.8811679427172.440.00
2589760112.060.00245884079.37621.8324586709234.23-600.8811680110172.090.00
2590447111.450.00245952381.21621.8324587402231.86-600.8811680784171.650.00
2591142110.740.00246019283.67621.8324588101228.87-600.8811681473171.040.00
2591823109.950.00246088288.95621.8324588787225.70-600.8811682162170.420.00
2592506109.340.00246157392.37621.8324589477222.80-600.8811682846169.980.00
2593183108.720.00246225298.17621.8324590171220.08-600.8811683529169.370.00
2593874108.020.002462938104.50621.8324590872217.62-600.8811684219168.570.00
2594547107.400.002463634110.57621.8324591570214.54-600.8811684897167.870.00
2595224106.790.002464321114.43621.8324592275211.73-600.8811685584167.170.00
2595907106.260.002465013119.53621.8324592967209.09-600.8811686262166.290.00
2596585105.820.002465699126.30621.8324593659206.28-600.8811686951165.410.00
2597274105.290.002466391132.01621.8324594360203.82-600.8811687626164.710.00
2597956104.770.002467089137.64619.7324595060201.18-600.8811688309163.740.00
2598640104.410.002467779143.09619.7324595753198.63-600.8811688986162.770.00
2599323103.890.002468458147.57619.7324596434195.91-600.8811689664161.810.00
2600021103.270.002469157151.70619.7324597135193.18-600.8811690349160.750.00
2600698102.740.002469837154.51619.7324597827191.16-600.8811691039159.870.00
2601381102.130.002470526158.29619.7324598513188.79-600.8811691714158.290.00
2602065101.510.002471199162.51619.7324599219186.24-600.8811692398156.800.00
2602745100.990.002471895164.97619.7324599903183.78-600.8811693095155.740.00
2603421100.370.002472579167.43619.7324600596181.85-600.8811693784155.300.00
260411099.840.002473264169.28619.7324601282179.65-600.8811694468153.980.00
260479399.400.002473957170.86619.7324601983177.28-600.8811695152152.400.00
260548098.880.002474641172.88619.7324602688175.08-600.8811695838151.440.00
260616798.440.002475322174.11619.7324603385173.06-600.8811696516150.210.00
260684498.170.002476024175.52619.7324604084171.04-600.8811697200148.890.00
260753197.820.002476705176.57619.7324604774169.19-600.8811697877147.390.00
260821497.470.002477395177.63619.7324605467167.26-600.8811698563145.810.00
260889797.290.002478082178.77619.7324606165165.50-600.8811699240144.400.00
260957396.940.002478769179.65619.7324606856163.65-600.8811699918143.610.00
261025696.590.002479451180.53619.7324607556161.98-600.8811700599142.650.00
261093896.240.002480149181.41619.7324608254160.31-600.8811701271142.380.00
261162195.890.002480830182.11619.7324608950158.64-600.8811701961141.060.00
261229495.450.002481522182.64619.7324609648156.97-600.8811702638138.870.00
261297195.190.002482202183.08619.7324610348155.21-600.8811703327137.900.00
261365994.750.002482896183.52619.7324611041153.90-600.8811704004137.020.00
261434194.570.002483586183.96619.7324611734152.40-600.8811704694135.090.00
261503594.390.002484270184.39619.7324612417150.82-600.8811705382132.980.00
261571194.310.002484962184.83619.7324613122149.15-600.8811706072132.360.00
261639494.220.002485654185.19619.7324613815147.57-600.8811706761131.220.00
261708894.310.002486340185.45619.7324614503146.25-600.8811707450130.520.00
261776594.390.002487038185.80619.7324615203144.58-600.8811708127130.170.00
261845394.570.002487729186.15619.7324615895142.91-600.8811708813128.580.00
261914794.660.002488409186.50619.7324616588141.33-600.8811709499127.710.00
261982994.750.002489096186.77619.7324617274139.92-600.8811710182126.910.00
262051694.920.002489783187.12619.7324617967138.16-600.8811710860126.210.00
262118795.100.002490469187.47619.7324618660136.32-600.8811711538124.280.00
262187095.270.002491161187.82619.7324619360134.74-600.8811712218123.400.00
262254695.450.002491842188.17619.7324620060132.98-600.8811712895122.520.00
262322895.710.002492534188.70619.7324620756131.04-600.8811713579121.380.00
262391696.060.002493208189.23619.7324621442129.20-600.8811714268120.670.00
262460396.590.002493901189.76619.7324622148127.09-600.8811714957119.710.00
262528897.210.002494597190.46619.7324622846124.80-600.8811715634119.270.00
262597197.820.002495276191.25619.7324623539121.90-600.8811716312118.300.00
262666298.790.002495969192.13619.7324624235118.83-600.8811716983117.070.00
262733999.760.002496659193.01619.7324624938116.28-600.8811717660115.660.00
2628031100.630.002497340194.24619.7324625634112.76-600.8811718345114.350.00
2628708101.690.002498033195.56619.7324626327108.72-600.8811719035113.730.00
2629392102.740.002498719196.87619.7324627030104.59-600.8811719719113.120.00
2630069103.710.002499410198.63619.7324627717100.37-600.8811720406112.240.00
2630750104.680.002500103200.57619.732462840896.42-600.8811721101110.650.00
2631426105.730.002500789202.76619.732462910791.05-600.8811721790109.250.00
2632109106.700.002501476204.96619.732462978985.96-600.8811722465107.580.00
2632790107.670.002502164207.69619.732463047980.95-600.8811723150106.700.00
2633483108.720.002502851210.94619.732463117676.20-600.8811723842105.470.00
2634164109.780.002503542215.24619.732463187370.14-600.8811724530103.970.00
2634841111.180.002504222219.99619.732463256064.60-600.8811725219103.360.00
2635528112.590.002504913226.49619.732463325259.50-600.8811725909102.130.00
2636211113.820.002505594235.99619.732463393755.02-600.8811726590100.900.00
2636900115.400.002506275248.47619.732463463649.75-600.881172726799.840.00
2637587117.070.002506962268.86619.732463532845.18-600.881172794899.580.00
2638275118.650.002507656291.88619.732463602640.96-600.881172863299.050.00
2638963119.880.002508339309.99619.732463671336.74-600.881172931998.530.00
2639648121.290.002509031326.87619.732463740833.31-600.881172999697.730.00
2640325122.610.002509715338.55619.732463811329.88-600.881173068797.120.00
2641015123.570.002510406345.85619.732463879326.72-600.881173136396.150.00
2641698124.540.002511104349.80619.732463948323.47-600.881173205395.620.00
2642387125.510.002511789352.97619.732464018120.92-600.881173272894.750.00
2643065126.390.002512470355.43619.732464087818.37-600.881173341294.920.00
2643743127.180.002513165356.75619.732464157615.82-600.881173410694.830.00
2644421128.060.002513846357.71619.732464226813.45-600.881173478994.310.00
2645104128.850.002514535358.59619.732464296111.25-600.881173547594.660.00
2645782129.810.002515209359.38619.73246436539.67-600.881173616495.450.00
2646465130.690.002515903359.82619.73246443447.73-600.881173684795.620.00
truncatedtruncatedtruncatedtruncatedtruncatedtruncated246450425.71-600.881173752495.710.00
truncatedtruncatedtruncatedtruncatedtruncatedtruncated246457273.78-600.881173821096.500.00
truncatedtruncatedtruncatedtruncatedtruncatedtruncated246464132.29-600.881173890197.910.00
truncatedtruncatedtruncatedtruncatedtruncatedtruncated246471110.44-600.88truncatedtruncatedtruncated
truncatedtruncatedtruncatedtruncatedtruncatedtruncatedtruncatedtruncatedtruncatedtruncatedtruncatedtruncated

I started writing this log at June 6, 2026 7:12PM AWST and now, at the time of finishing, it is June 7, 2026, 12:10AM. I will continue tomorrow. Thank you for reading! ♥️