# MT6835 Angle sensor 21bit

**URL:** https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910
**Category:** hardware support
**Created:** [January 30, 2023, 8:54am UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910 "2023-01-30T08:54:12Z")
**Posts on this page:** 19
**Page:** 3

<div class="post-metadata">

### Author: ![Juan-Antonio\_Soren\_E](https://community.simplefoc.com/user_avatar/community.simplefoc.com/juan-antonio_soren_e/32/9969_2.png) [@Juan-Antonio\_Soren\_E](https://community.simplefoc.com/u/Juan-Antonio_Soren_E)
#### Post date: [April 27, 2023, 11:14pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/42 "2023-04-27T23:14:07Z")

</div>

> [@husky](#):
>
> I have lousy L298 drivers

Are you still testing with L298 ?

To rule out the lousyness of L298, being the cause. You could try a different setup.

In my experience, the MT6835 is so sensitive, that the slightest touching the controller will change the angle like 0.0001 degrees.

---

<div class="post-metadata">

### Author: ![husky](https://community.simplefoc.com/user_avatar/community.simplefoc.com/husky/32/4433_2.png) [@husky](https://community.simplefoc.com/u/husky)
#### Post date: [April 30, 2023, 3:39pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/43 "2023-04-30T15:39:19Z")

</div>

at least the MT6835 has a feature to store a calibration table based on comparing its readings with an optical 21+ bits encoder. This is described in the manual. But without having that encoder you can only do the more basic user calibration - I commented about that aleady.  
Regarding the noisy signal: if there is no solution to this by e.g. filtering, we indeed talk about 11bit usable resolution and I am back on square one - getting beyond microstepping resolution…

---

<div class="post-metadata">

### Author: ![husky](https://community.simplefoc.com/user_avatar/community.simplefoc.com/husky/32/4433_2.png) [@husky](https://community.simplefoc.com/u/husky)
#### Post date: [April 30, 2023, 3:46pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/44 "2023-04-30T15:46:01Z")

</div>

yes and no: when the stepper drives my two-motor setup, I am still on L298. Not so easy to get something else. I made a hardware design with TI chips which I can’t buy for two years now…  
When the Maxon motor drives my setup, it uses a separate Maxon controller which for sure has high quality output - my belief in Swiss engineering is rock solid.  
On both setups I don’t get clean signals from the encoder, which takes out the poor L298 from the equation currently :-0

---

<div class="post-metadata">

### Author: ![Anthony\_Douglas](https://community.simplefoc.com/user_avatar/community.simplefoc.com/anthony_douglas/32/2300_2.png) [@Anthony\_Douglas](https://community.simplefoc.com/u/Anthony_Douglas)
#### Post date: [April 30, 2023, 8:06pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/45 "2023-04-30T20:06:16Z")

</div>

You can get 256 microstep drivers for like 8 bucks, though. The actual resolution is swamped by other error sources in almost all practical contexts…

---

<div class="post-metadata">

### Author: ![runger](https://community.simplefoc.com/user_avatar/community.simplefoc.com/runger/32/395_2.png) [@runger](https://community.simplefoc.com/u/runger)
#### Post date: [May 15, 2023, 10:07pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/46 "2023-05-15T22:07:20Z")

</div>

Another bug-fix to the MT6835 driver now fixes setting the ABZ resolution.  
I’ve tested this a bit, and setting ABZ resolution, ABZ on and AB-swap via the driver works nicely.

Code is still on dev branch but will be the next release:

> **[GitHub - simplefoc/Arduino-FOC-drivers at dev](https://github.com/simplefoc/Arduino-FOC-drivers/tree/dev)**
>
> dev

---

<div class="post-metadata">

### Author: ![Juan-Antonio\_Soren\_E](https://community.simplefoc.com/user_avatar/community.simplefoc.com/juan-antonio_soren_e/32/9969_2.png) [@Juan-Antonio\_Soren\_E](https://community.simplefoc.com/u/Juan-Antonio_Soren_E)
#### Post date: [May 27, 2023, 5:59pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/47 "2023-05-27T17:59:08Z")

</div>

[![](https://img.youtube.com/vi/xA142IsjQiE/hqdefault.jpg "Elvis - If I Can Dream (Official Live Performance)") ](https://www.youtube.com/watch?v=xA142IsjQiE)

---

<div class="post-metadata">

### Author: ![runger](https://community.simplefoc.com/user_avatar/community.simplefoc.com/runger/32/395_2.png) [@runger](https://community.simplefoc.com/u/runger)
#### Post date: [May 27, 2023, 7:39pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/48 "2023-05-27T19:39:54Z")

</div>

I’ve pushed another update. I made good on m threat and radically simplified the STM32HWEncoder…  
Now it just runs the timer to capture the encoder pulses, and leaves everything else (velocity, full rotations) to the base class Sensor…

It should now work like all the other sensors and the bugs should be solved 🤞

As usual you can find this code on the dev branch for now, but I will release a proper version soon…

Oh, and it now supports the MT6835‘s full resolution on ABI 🙂

---

<div class="post-metadata">

### Author: ![Juan-Antonio\_Soren\_E](https://community.simplefoc.com/user_avatar/community.simplefoc.com/juan-antonio_soren_e/32/9969_2.png) [@Juan-Antonio\_Soren\_E](https://community.simplefoc.com/u/Juan-Antonio_Soren_E)
#### Post date: [May 27, 2023, 8:23pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/49 "2023-05-27T20:23:15Z")

</div>

So sorry for posting stupid shit all over this wall. OMFG I was bowling a watermelon 🍉 yesterday. It did not roll, it just went swusch. Sorry.

I think I just wanted to say, Hi. You guys are the best! Go team! Yay

---

<div class="post-metadata">

### Author: ![AlexYMo99](https://community.simplefoc.com/user_avatar/community.simplefoc.com/alexymo99/32/7758_2.png) [@AlexYMo99](https://community.simplefoc.com/u/AlexYMo99)
#### Post date: [November 5, 2024, 8:40am UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/54 "2024-11-05T08:40:03Z")

</div>

Hi, sorry for replying directly here, I’m new and a little lost right here, i have a question about the MT6835 driver, i see that you are able to change the ABZ resolution, but i have a question, is that change permanent?, like will it be saved after power cycles and being disconnected from the spi?, thanks in advance

---

<div class="post-metadata">

### Author: ![runger](https://community.simplefoc.com/user_avatar/community.simplefoc.com/runger/32/395_2.png) [@runger](https://community.simplefoc.com/u/runger)
#### Post date: [November 5, 2024, 12:04pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/55 "2024-11-05T12:04:55Z")

</div>

Hey @AlexYMo99 , welcome to SimpleFOC.

The change is not permanent unless you write it to EEPROM. See section 7.6.6 of the MT6835 data sheet about EEPROM programming.

You can use the writeEEPROM() method of our driver class to do so. Pay attention to the fact that you have to wait 6 seconds (!) before talking to the sensor again after programming the EEPROM.

---

<div class="post-metadata">

### Author: ![AlexYMo99](https://community.simplefoc.com/user_avatar/community.simplefoc.com/alexymo99/32/7758_2.png) [@AlexYMo99](https://community.simplefoc.com/u/AlexYMo99)
#### Post date: [November 5, 2024, 8:14pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/56 "2024-11-05T20:14:27Z")

</div>

Got it, thank you so much for your answer, i have never done anything like that but i will research about spi programming on my own, that info deffinetly helps me getting started, only one last question, is there any problem if i do the programming with the ic already soldered in a pcb (with all the complementary components ofc)?, as i will be buying it that way?

---

<div class="post-metadata">

### Author: ![runger](https://community.simplefoc.com/user_avatar/community.simplefoc.com/runger/32/395_2.png) [@runger](https://community.simplefoc.com/u/runger)
#### Post date: [November 5, 2024, 8:38pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/57 "2024-11-05T20:38:08Z")

</div>

Well, the SPI part is done for you in the driver already. 🙂 You just need to configure your settings using the driver’s methods, and then call the writeEEPROM() method to make them permanent.

It should work with any MT6835 board that has the SPI bus exposed.

---

<div class="post-metadata">

### Author: ![AlexYMo99](https://community.simplefoc.com/user_avatar/community.simplefoc.com/alexymo99/32/7758_2.png) [@AlexYMo99](https://community.simplefoc.com/u/AlexYMo99)
#### Post date: [November 5, 2024, 8:48pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/58 "2024-11-05T20:48:05Z")

</div>

Oh, my bad, i didnt get that part the first time, i think i get it now, ill have a look at it, thank you again, you are awesome!

---

<div class="post-metadata">

### Author: ![Backflip](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/b/df705f/32.png) [@Backflip](https://community.simplefoc.com/u/Backflip)
#### Post date: [May 6, 2026, 1:58pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/60 "2026-05-06T13:58:27Z")

</div>

Thank you for all the information here. I am not sure, that I read and understood all of it. I have read the datasheet of the MT6835 and got two issues with questions:

It seems that the sensor got some moving average filter function, and it is set by a programable BW parameter (see page 37 in datasheet). The factory default setting is 5.

How do the sensor actually do this filtering in more specific terms?  
How is the filter changed by the BW parameter?

I read this other thread with some MT6835 information:

> [@Motor runaway in Current Mode - Potential Phase Lag or Offset Error](https://community.simplefoc.com/t/motor-runaway-in-current-mode-potential-phase-lag-or-offset-error/8056/10):
>
> The motor was about to run away due to latency caused by a filter on the MT6835. The datasheet specifies that the factory setting has a propagation delay of 100 µs, but the filter was likely changed by the seller. This resulted in a 2 ms latency, causing an incorrect angle reading.

It seems that BW=5 cause a 2 ms latency, but it is not specific.

Another question is about how the sensor work. The AMS sensor like AS5047 got an internal clock with a cycle time between 90 and 110 us. So in a cycle the internal hall sensors output are sampled, ADC takes place, and calculations take place. When you issue the SPI command, the latest calculated angle or filtered angle can be read.

I guess that the MT6835 works in a similar way - do you agree?  
What is the cycle time of the MT6835?  
Are you able to synchronize your SPI-reading to its internal cycle?

---

<div class="post-metadata">

### Author: ![cSandrini](https://community.simplefoc.com/user_avatar/community.simplefoc.com/csandrini/32/5733_2.png) [@cSandrini](https://community.simplefoc.com/u/cSandrini)
#### Post date: [May 7, 2026, 1:25am UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/61 "2026-05-07T01:25:30Z")

</div>

Just a correction: setting BW to 5 results in a latency of 100 us, as described in the datasheet. The problem I was facing was that I bought a module with the chip configured to BW=0, resulting in an approximately 2 ms of delay relative to the real angle. You can achieve even lower propagation delays by using BW=7, but due to the 21-bit resolution, you may experience some noise in the lower bits. I’m working with BW=5 and it’s running pretty well.

---

<div class="post-metadata">

### Author: ![Digitalmonk](https://community.simplefoc.com/user_avatar/community.simplefoc.com/digitalmonk/32/9846_2.png) [@Digitalmonk](https://community.simplefoc.com/u/Digitalmonk)
#### Post date: [May 7, 2026, 1:54pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/62 "2026-05-07T13:54:37Z")

</div>

Yes, the Z point is usually random unless set through SPI. But in XY/PNP machines it normally doesn’t matter because the machine homes itself at startup.

If ABZ is already configured correctly, the sensor can run fully without SPI. SPI is mainly needed for calibration, setup, or changing resolution.

---

<div class="post-metadata">

### Author: ![Backflip](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/b/df705f/32.png) [@Backflip](https://community.simplefoc.com/u/Backflip)
#### Post date: [May 8, 2026, 10:05am UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/63 "2026-05-08T10:05:21Z")

</div>

Thank you Digitalmonk for your answer, and welcome to the forum. And thank you cSandrini for your clarification.

Latency can have many forms, and I should like to see a typical response for a step angle change. You may be able to do a test setup by making a small coil of copper wire around the sensor and make a step current in it. When you use such a sensor in a closed loop system, you like to know more detail here.

When I look the specifications, the sensor can work with magnetic fields in the range 30 mT to 1000 mT. But it seems, that you cannot read what field, that it got. But with this large range, the sensor likely adapt by changing the amplifications of the amplifiers before the AD converters. If you got a too low field (likely below 30 mT) a status bit will issue a warning in the status register. But I think, that the noise level in resulting angle from the sensor will depend on the field strength from the magnet, so a larger field will reduce noise.

You are able to set a hysteresis (page 36 in datasheet). How would you interpret how this setting work?

---

<div class="post-metadata">

### Author: ![William\_Kers](https://community.simplefoc.com/user_avatar/community.simplefoc.com/william_kers/32/9872_2.png) [@William\_Kers](https://community.simplefoc.com/u/William_Kers)
#### Post date: [May 18, 2026, 10:45pm UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/64 "2026-05-18T22:45:16Z")

</div>

For your info, I did some testing to observe what the filters actually are in frequency domain. They are/seem “special” lag/lead filters which is created by an 2nd order low pass and a 2nd order high pass filter. It’s a weird combination and I turned the filter off. The same for hysteresis. That worked much more relyable as the library has its own pid controllers to shape the frequency response of the motor.

> **[Discord - Group Chat That’s All Fun & Games](https://discord.com/channels/927331369137352734/927332553206149151/1289195234894282755)**
>
> Discord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.

Maybe it’s good to know what is actually is.

---

<div class="post-metadata">

### Author: ![Backflip](https://community.simplefoc.com/letter_avatar_proxy/v4/letter/b/df705f/32.png) [@Backflip](https://community.simplefoc.com/u/Backflip)
#### Post date: [May 21, 2026, 10:23am UTC](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910/65 "2026-05-21T10:23:15Z")

</div>

Welcome to this forum, and thank you for your reply and new information. Yes, it might be the best thing to turn off both the filters and the hysteresis to make it more predictable. You is still left with the possible problem, when you do not synchronize to the timing of the sensors internal clock.

I noticed, that this device make use of Anisotropic **magnetoresistance** (AMR) sensors. I found some information about these kind of sensors here:

Murata: [https://youtu.be/F8B8dm2HFME](https://youtu.be/F8B8dm2HFME)

TI: [https://www.ti.com/video/6350199352112](https://www.ti.com/video/6350199352112)

According to the information, you are able to get signals with less noise than when you use hall-elements only like in sensors such as AS5048A. However, one or more AMR sensors cannot tell the difference between having a field of the same size in the exact opposite direction. Therefore this MT6835 likely do have two smaller hall element sensors as well to help determine the field direction.

[Previous page](https://community.simplefoc.com/t/mt6835-angle-sensor-21bit/2910.md?page=2)
