<- 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. Axial 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
timestamp angle rpm timestamp angle rpm timestamp angle rpm timestamp angle_deg rpm
2551016 134.38 0.00 2419745 0.35 621.83 24547056 359.82 -600.68 11641021 100.55 0.00
2551728 134.65 0.00 2420421 0.70 621.83 24547755 358.07 -600.68 11641700 102.04 0.00
2552402 134.82 0.00 2421117 1.23 621.83 24548446 356.04 -600.68 11642391 104.15 0.00
2553079 134.91 0.00 2421803 1.67 621.83 24549155 354.55 -600.68 11643083 106.61 0.00
2553752 135.18 0.00 2422488 2.11 621.83 24549854 352.88 -600.68 11643764 109.95 0.00
2554423 135.26 0.00 2423167 2.64 621.83 24550549 351.04 -600.68 11644452 112.41 0.00
2555100 135.44 0.00 2423852 3.34 621.83 24551242 349.10 -600.68 11645142 115.66 0.00
2555772 135.62 0.00 2424530 3.87 621.83 24551940 347.43 -600.68 11645831 118.74 0.00
2556442 135.88 0.00 2425203 4.39 621.83 24552639 346.03 -600.88 11646514 121.99 0.00
2557139 136.05 0.00 2425889 5.45 621.83 24553328 344.27 -600.88 11647202 125.86 0.00
2557816 136.14 0.00 2426581 6.77 621.83 24554023 342.60 -600.88 11647874 129.46 0.00
2558499 136.14 0.00 2427266 7.65 621.83 24554715 340.93 -600.88 11648565 132.45 0.00
2559179 136.05 0.00 2427951 8.79 621.83 24555401 339.52 -600.88 11649242 136.14 0.00
2559856 135.88 0.00 2428637 10.63 621.83 24556095 337.76 -600.88 11649925 140.01 0.00
2560533 135.53 0.00 2429322 12.66 621.83 24556776 335.92 -600.88 11650602 142.65 0.00
2561216 135.18 0.00 2430013 14.85 621.83 24557465 334.25 -600.88 11651285 145.63 0.00
2561897 134.74 0.00 2430693 16.79 621.83 24558167 332.49 -600.88 11651974 148.80 0.00
2562580 134.21 0.00 2431388 19.60 621.83 24558866 330.91 -600.88 11652657 151.17 0.00
2563257 133.77 0.00 2432084 22.50 621.83 24559563 328.97 -600.88 11653347 153.19 0.00
2563934 133.33 0.00 2432775 25.66 621.83 24560259 327.30 -600.88 11654042 155.39 0.00
2564619 132.89 0.00 2433461 29.18 621.83 24560952 325.46 -600.88 11654726 157.24 0.00
2565296 132.54 0.00 2434146 33.75 621.83 24561648 323.79 -600.88 11655410 158.64 0.00
2565973 132.19 0.00 2434827 36.21 621.83 24562341 321.86 -600.88 11656104 159.96 0.00
2566666 131.84 0.00 2435512 37.18 621.83 24563046 320.01 -600.88 11656793 161.10 0.00
2567348 131.48 0.00 2436191 38.85 621.83 24563742 318.16 -600.88 11657470 162.07 0.00
2568043 131.04 0.00 2436884 41.48 621.83 24564434 316.05 -600.88 11658159 162.86 0.00
2568719 130.69 0.00 2437575 43.68 621.83 24565139 314.03 -600.88 11658848 163.65 0.00
2569396 130.25 0.00 2438256 44.21 621.83 24565837 312.45 -600.88 11659536 164.36 0.00
2570079 129.73 0.00 2438936 45.44 621.83 24566537 310.43 -600.88 11660220 164.88 0.00
2570752 129.02 0.00 2439614 47.64 621.83 24567233 308.14 -600.88 11660903 165.41 0.00
2571422 128.50 0.00 2440300 48.25 621.83 24567919 306.04 -600.88 11661592 165.94 0.00
2572099 127.79 0.00 2440979 47.99 621.83 24568622 303.93 -600.88 11662275 166.46 0.00
2572771 127.18 0.00 2441666 49.13 621.83 24569315 301.90 -600.88 11662964 166.90 0.00
2573442 126.39 0.00 2442346 50.45 621.83 24570019 299.53 -600.88 11663652 167.34 0.00
2574125 125.68 0.00 2443035 51.24 621.83 24570717 297.25 -600.88 11664345 167.87 0.00
2574803 125.16 0.00 2443715 51.68 621.83 24571404 294.96 -600.88 11665046 168.40 0.00
2575486 124.54 0.00 2444401 53.00 621.83 24572103 292.50 -600.88 11665724 168.93 0.00
2576163 123.93 0.00 2445092 53.09 621.83 24572791 289.78 -600.88 11666413 169.45 0.00
2576833 123.49 0.00 2445782 52.73 621.83 24573493 287.75 -600.88 11667102 169.98 0.00
2577504 122.96 0.00 2446468 52.56 621.83 24574189 285.21 -600.88 11667785 170.42 0.00
2578183 122.43 0.00 2447153 54.23 621.83 24574883 282.48 -600.88 11668469 170.95 0.00
2578868 121.90 0.00 2447839 56.34 621.83 24575576 279.58 -600.88 11669158 171.39 0.00
2579544 121.29 0.00 2448530 55.37 621.83 24576274 277.03 -600.88 11669842 171.65 0.00
2580221 120.76 0.00 2449209 56.16 621.83 24576972 274.75 -600.88 11670520 172.18 0.00
2580904 120.06 0.00 2449890 57.92 621.83 24577664 271.76 -600.88 11671207 172.71 0.00
2581581 119.27 0.00 2450573 58.27 621.83 24578365 268.86 -600.88 11671891 172.97 0.00
2582270 118.65 0.00 2451254 58.97 621.83 24579069 266.04 -600.88 11672583 173.23 0.00
2582956 117.95 0.00 2451945 59.15 621.83 24579766 263.32 -600.88 11673267 173.41 0.00
2583639 117.16 0.00 2452631 60.47 621.83 24580453 260.68 -600.88 11673954 173.67 0.00
2584317 116.54 0.00 2453322 62.40 621.83 24581151 257.70 -600.88 11674631 173.85 0.00
2585000 115.93 0.00 2454019 63.54 621.83 24581843 254.97 -600.88 11675322 173.85 0.00
2585689 115.31 0.00 2454708 65.13 621.83 24582533 251.98 -600.88 11675993 173.67 0.00
2586372 114.79 0.00 2455394 66.97 621.83 24583233 248.82 -600.88 11676685 173.50 0.00
2587056 114.17 0.00 2456086 69.08 621.83 24583926 246.18 -600.88 11677367 173.41 0.00
2587727 113.73 0.00 2456771 70.14 621.83 24584619 243.37 -600.88 11678056 173.23 0.00
2588405 113.29 0.00 2457457 71.98 621.83 24585318 240.47 -600.88 11678734 172.79 0.00
2589082 112.68 0.00 2458154 76.99 621.83 24586016 237.22 -600.88 11679427 172.44 0.00
2589760 112.06 0.00 2458840 79.37 621.83 24586709 234.23 -600.88 11680110 172.09 0.00
2590447 111.45 0.00 2459523 81.21 621.83 24587402 231.86 -600.88 11680784 171.65 0.00
2591142 110.74 0.00 2460192 83.67 621.83 24588101 228.87 -600.88 11681473 171.04 0.00
2591823 109.95 0.00 2460882 88.95 621.83 24588787 225.70 -600.88 11682162 170.42 0.00
2592506 109.34 0.00 2461573 92.37 621.83 24589477 222.80 -600.88 11682846 169.98 0.00
2593183 108.72 0.00 2462252 98.17 621.83 24590171 220.08 -600.88 11683529 169.37 0.00
2593874 108.02 0.00 2462938 104.50 621.83 24590872 217.62 -600.88 11684219 168.57 0.00
2594547 107.40 0.00 2463634 110.57 621.83 24591570 214.54 -600.88 11684897 167.87 0.00
2595224 106.79 0.00 2464321 114.43 621.83 24592275 211.73 -600.88 11685584 167.17 0.00
2595907 106.26 0.00 2465013 119.53 621.83 24592967 209.09 -600.88 11686262 166.29 0.00
2596585 105.82 0.00 2465699 126.30 621.83 24593659 206.28 -600.88 11686951 165.41 0.00
2597274 105.29 0.00 2466391 132.01 621.83 24594360 203.82 -600.88 11687626 164.71 0.00
2597956 104.77 0.00 2467089 137.64 619.73 24595060 201.18 -600.88 11688309 163.74 0.00
2598640 104.41 0.00 2467779 143.09 619.73 24595753 198.63 -600.88 11688986 162.77 0.00
2599323 103.89 0.00 2468458 147.57 619.73 24596434 195.91 -600.88 11689664 161.81 0.00
2600021 103.27 0.00 2469157 151.70 619.73 24597135 193.18 -600.88 11690349 160.75 0.00
2600698 102.74 0.00 2469837 154.51 619.73 24597827 191.16 -600.88 11691039 159.87 0.00
2601381 102.13 0.00 2470526 158.29 619.73 24598513 188.79 -600.88 11691714 158.29 0.00
2602065 101.51 0.00 2471199 162.51 619.73 24599219 186.24 -600.88 11692398 156.80 0.00
2602745 100.99 0.00 2471895 164.97 619.73 24599903 183.78 -600.88 11693095 155.74 0.00
2603421 100.37 0.00 2472579 167.43 619.73 24600596 181.85 -600.88 11693784 155.30 0.00
2604110 99.84 0.00 2473264 169.28 619.73 24601282 179.65 -600.88 11694468 153.98 0.00
2604793 99.40 0.00 2473957 170.86 619.73 24601983 177.28 -600.88 11695152 152.40 0.00
2605480 98.88 0.00 2474641 172.88 619.73 24602688 175.08 -600.88 11695838 151.44 0.00
2606167 98.44 0.00 2475322 174.11 619.73 24603385 173.06 -600.88 11696516 150.21 0.00
2606844 98.17 0.00 2476024 175.52 619.73 24604084 171.04 -600.88 11697200 148.89 0.00
2607531 97.82 0.00 2476705 176.57 619.73 24604774 169.19 -600.88 11697877 147.39 0.00
2608214 97.47 0.00 2477395 177.63 619.73 24605467 167.26 -600.88 11698563 145.81 0.00
2608897 97.29 0.00 2478082 178.77 619.73 24606165 165.50 -600.88 11699240 144.40 0.00
2609573 96.94 0.00 2478769 179.65 619.73 24606856 163.65 -600.88 11699918 143.61 0.00
2610256 96.59 0.00 2479451 180.53 619.73 24607556 161.98 -600.88 11700599 142.65 0.00
2610938 96.24 0.00 2480149 181.41 619.73 24608254 160.31 -600.88 11701271 142.38 0.00
2611621 95.89 0.00 2480830 182.11 619.73 24608950 158.64 -600.88 11701961 141.06 0.00
2612294 95.45 0.00 2481522 182.64 619.73 24609648 156.97 -600.88 11702638 138.87 0.00
2612971 95.19 0.00 2482202 183.08 619.73 24610348 155.21 -600.88 11703327 137.90 0.00
2613659 94.75 0.00 2482896 183.52 619.73 24611041 153.90 -600.88 11704004 137.02 0.00
2614341 94.57 0.00 2483586 183.96 619.73 24611734 152.40 -600.88 11704694 135.09 0.00
2615035 94.39 0.00 2484270 184.39 619.73 24612417 150.82 -600.88 11705382 132.98 0.00
2615711 94.31 0.00 2484962 184.83 619.73 24613122 149.15 -600.88 11706072 132.36 0.00
2616394 94.22 0.00 2485654 185.19 619.73 24613815 147.57 -600.88 11706761 131.22 0.00
2617088 94.31 0.00 2486340 185.45 619.73 24614503 146.25 -600.88 11707450 130.52 0.00
2617765 94.39 0.00 2487038 185.80 619.73 24615203 144.58 -600.88 11708127 130.17 0.00
2618453 94.57 0.00 2487729 186.15 619.73 24615895 142.91 -600.88 11708813 128.58 0.00
2619147 94.66 0.00 2488409 186.50 619.73 24616588 141.33 -600.88 11709499 127.71 0.00
2619829 94.75 0.00 2489096 186.77 619.73 24617274 139.92 -600.88 11710182 126.91 0.00
2620516 94.92 0.00 2489783 187.12 619.73 24617967 138.16 -600.88 11710860 126.21 0.00
2621187 95.10 0.00 2490469 187.47 619.73 24618660 136.32 -600.88 11711538 124.28 0.00
2621870 95.27 0.00 2491161 187.82 619.73 24619360 134.74 -600.88 11712218 123.40 0.00
2622546 95.45 0.00 2491842 188.17 619.73 24620060 132.98 -600.88 11712895 122.52 0.00
2623228 95.71 0.00 2492534 188.70 619.73 24620756 131.04 -600.88 11713579 121.38 0.00
2623916 96.06 0.00 2493208 189.23 619.73 24621442 129.20 -600.88 11714268 120.67 0.00
2624603 96.59 0.00 2493901 189.76 619.73 24622148 127.09 -600.88 11714957 119.71 0.00
2625288 97.21 0.00 2494597 190.46 619.73 24622846 124.80 -600.88 11715634 119.27 0.00
2625971 97.82 0.00 2495276 191.25 619.73 24623539 121.90 -600.88 11716312 118.30 0.00
2626662 98.79 0.00 2495969 192.13 619.73 24624235 118.83 -600.88 11716983 117.07 0.00
2627339 99.76 0.00 2496659 193.01 619.73 24624938 116.28 -600.88 11717660 115.66 0.00
2628031 100.63 0.00 2497340 194.24 619.73 24625634 112.76 -600.88 11718345 114.35 0.00
2628708 101.69 0.00 2498033 195.56 619.73 24626327 108.72 -600.88 11719035 113.73 0.00
2629392 102.74 0.00 2498719 196.87 619.73 24627030 104.59 -600.88 11719719 113.12 0.00
2630069 103.71 0.00 2499410 198.63 619.73 24627717 100.37 -600.88 11720406 112.24 0.00
2630750 104.68 0.00 2500103 200.57 619.73 24628408 96.42 -600.88 11721101 110.65 0.00
2631426 105.73 0.00 2500789 202.76 619.73 24629107 91.05 -600.88 11721790 109.25 0.00
2632109 106.70 0.00 2501476 204.96 619.73 24629789 85.96 -600.88 11722465 107.58 0.00
2632790 107.67 0.00 2502164 207.69 619.73 24630479 80.95 -600.88 11723150 106.70 0.00
2633483 108.72 0.00 2502851 210.94 619.73 24631176 76.20 -600.88 11723842 105.47 0.00
2634164 109.78 0.00 2503542 215.24 619.73 24631873 70.14 -600.88 11724530 103.97 0.00
2634841 111.18 0.00 2504222 219.99 619.73 24632560 64.60 -600.88 11725219 103.36 0.00
2635528 112.59 0.00 2504913 226.49 619.73 24633252 59.50 -600.88 11725909 102.13 0.00
2636211 113.82 0.00 2505594 235.99 619.73 24633937 55.02 -600.88 11726590 100.90 0.00
2636900 115.40 0.00 2506275 248.47 619.73 24634636 49.75 -600.88 11727267 99.84 0.00
2637587 117.07 0.00 2506962 268.86 619.73 24635328 45.18 -600.88 11727948 99.58 0.00
2638275 118.65 0.00 2507656 291.88 619.73 24636026 40.96 -600.88 11728632 99.05 0.00
2638963 119.88 0.00 2508339 309.99 619.73 24636713 36.74 -600.88 11729319 98.53 0.00
2639648 121.29 0.00 2509031 326.87 619.73 24637408 33.31 -600.88 11729996 97.73 0.00
2640325 122.61 0.00 2509715 338.55 619.73 24638113 29.88 -600.88 11730687 97.12 0.00
2641015 123.57 0.00 2510406 345.85 619.73 24638793 26.72 -600.88 11731363 96.15 0.00
2641698 124.54 0.00 2511104 349.80 619.73 24639483 23.47 -600.88 11732053 95.62 0.00
2642387 125.51 0.00 2511789 352.97 619.73 24640181 20.92 -600.88 11732728 94.75 0.00
2643065 126.39 0.00 2512470 355.43 619.73 24640878 18.37 -600.88 11733412 94.92 0.00
2643743 127.18 0.00 2513165 356.75 619.73 24641576 15.82 -600.88 11734106 94.83 0.00
2644421 128.06 0.00 2513846 357.71 619.73 24642268 13.45 -600.88 11734789 94.31 0.00
2645104 128.85 0.00 2514535 358.59 619.73 24642961 11.25 -600.88 11735475 94.66 0.00
2645782 129.81 0.00 2515209 359.38 619.73 24643653 9.67 -600.88 11736164 95.45 0.00
2646465 130.69 0.00 2515903 359.82 619.73 24644344 7.73 -600.88 11736847 95.62 0.00
truncated truncated truncated truncated truncated truncated 24645042 5.71 -600.88 11737524 95.71 0.00
truncated truncated truncated truncated truncated truncated 24645727 3.78 -600.88 11738210 96.50 0.00
truncated truncated truncated truncated truncated truncated 24646413 2.29 -600.88 11738901 97.91 0.00
truncated truncated truncated truncated truncated truncated 24647111 0.44 -600.88 truncated truncated truncated
truncated truncated truncated truncated truncated truncated truncated truncated truncated truncated truncated truncated

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! ♥️