🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Motor Control Peripherals: Encoder Interface and Dead Time

Microcontrollers & ARMGPIO and TimersđŸŸĸ Free Lesson

Motor Control Peripherals: Encoder Interface and Dead Time

What You'll Learn

  • 1Decode quadrature encoder signals in hardware
  • 2Generate complementary PWM with safe dead time
  • 3Synchronize ADC sampling with the PWM period
  • 4Use break inputs for overcurrent protection

Motor control is where timer peripherals stop being conveniences and become safety components. The same timer block that generates PWM also decodes a quadrature encoder, triggers current sampling at the right instant, and asserts a break output the moment a fault appears. Complementary outputs with programmable dead time drive the two halves of a half bridge safely, and center aligned counting keeps sampling symmetric. Getting the timer architecture right is most of the battle in a field oriented control implementation.

Quadrature Encoder Interface

An incremental encoder produces two square waves in quadrature, and the timer encoder mode counts edges on one input while sampling the other to determine direction, giving four times the pulse count in the highest resolution mode. A third index channel can reset the counter to establish an absolute mechanical position once per revolution. Hardware decoding removes the jitter and missed edges that plague interrupt driven counting at high speed.

Position resolution then depends on counts per revolution and gear ratio, while speed is measured by counting counts over a fixed window or by timing between index pulses. Choosing the window is a trade-off: short windows respond fast but are noisy, long windows are smooth but lag.

Complementary PWM and Dead Time

A half bridge needs the high side and low side switches driven in opposition, but both conducting at once creates a shoot through short across the DC bus. Programmable dead time inserts a short blanking interval after each turn off before the complementary device turns on, and the timer inserts it in hardware for both edges. Output compare mode also defines the idle state of each channel while the timer is stopped, which matters at power up.

Center aligned counting is preferred because current sampling and control updates can be placed symmetrically around the counter peak or valley, away from switching edges. The break input then forces the outputs into their safe inactive state within a few cycles when a hardware fault signal arrives, independent of any software.

Synchronized Sensing and Control Timing

The timer update event can trigger the analog to digital converter so that phase current sampling happens away from switching transitions, which is essential for clean field oriented control. Injection priority lets current conversion preempt a background scan of temperatures and bus voltage. DMA then delivers the results to a buffer that the control task reads at the start of the next period.

The whole timing chain should be documented as a single diagram: counter direction, compare match, break window, trigger edge, conversion time, and interrupt entry. When the loop misbehaves, that diagram usually reveals a sample landing on a switching edge or an interrupt arriving after the duty update.

Motor Control Timer Features

FeaturePurposeWhy It Matters
Encoder modeHardware quadrature countingLossless position and speed feedback
Center aligned countingSymmetric PWM generationClean sampling and control points
Complementary outputsDrive both bridge halvesEnables half bridge topologies
Programmable dead timeBlanking after turn offPrevents shoot through damage
Break inputHardware fault shutdownProtection without software latency
Trigger outputStart ADC conversionsSynchronized current sensing

Real-World Examples

  • Decode a rotary encoder — Select encoder mode on both channels at maximum resolution and read the count once per control tick.
  • Drive a half bridge — Configure complementary outputs with dead time sized from the transistor switching data sheet.
  • Sample phase current — Trigger the ADC from the timer update event away from switching edges and read results with DMA.
  • Trip on overcurrent — Wire the comparator or protection signal to the break input so outputs shut down in hardware.

âš ī¸Dead Time Is Set From Device Data, Not From Guesswork

Too little dead time causes shoot through and destroys the power stage; too much distorts the output and wastes linearity at low duty.

Common Mistakes

Sampling current on a switching edge

Fix: Conversion triggered at the wrong counter position returns switching noise instead of the phase current.

Letting software handle overcurrent

Fix: Software latency is too slow for shoot through events; the break input must act in hardware.

Forgetting the idle state of PWM outputs

Fix: Unconfigured outputs can enable a bridge at reset or during update, so define the inactive level explicitly.

Key Takeaways

  • Hardware encoder decoding gives jitter free position and speed data.
  • Complementary PWM with dead time is mandatory for half bridge stages.
  • Timer events should trigger ADC conversion away from switching edges.
  • Break inputs provide fault protection faster than any interrupt path.

Frequently Asked Questions

Why center aligned PWM for motors?

It produces symmetric pulses and gives clean sampling points that align naturally with the control period.

How is dead time calculated?

From the switching time parameters of the transistors and drivers plus margin, converted into timer ticks at the timer clock.

Can the same timer do encoder and PWM?

Usually not on one timer; a typical design dedicates one advanced timer to PWM and a general purpose timer to encoder input.

Interview Questions

Q1: Explain the control loop timing chain.

The timer counts, the compare match updates the duty, the update event triggers ADC sampling, DMA delivers results, and the control interrupt computes the next duty before the next period starts.

Q2: Why must break input be hardware based?

A fault such as shoot through or overcurrent develops faster than software can respond, so the timer forces outputs to their safe state directly.


Extended Learning: Beyond the Basics

Key Concepts Summary

This lesson covers fundamental concepts that serve as building blocks for more advanced topics. Master these basics before moving to intermediate and advanced material.

Prerequisite Knowledge

Before studying this topic in depth, ensure you understand:

  • Basic definitions and terminology
  • Core formulas and their derivations
  • Common applications in real-world scenarios
  • Typical pitfalls and misconceptions

Step-by-Step Walkthrough

Let us work through a complete example to solidify understanding:

Step 1: Identify the problem type. Determine which category this problem falls into and which approach is most appropriate.

Step 2: Apply the relevant formula. Substitute known values into the appropriate equation, paying attention to units and constraints.

Step 3: Simplify and solve. Work through the algebra step by step, checking each intermediate result.

Step 4: Verify the answer. Check that the solution satisfies the original conditions and makes logical sense.

Common Mistakes to Avoid

  1. Misidentifying the problem type — Always start by categorizing the problem
  2. Incorrect formula application — Verify the formula applies to your specific case
  3. Unit errors — Always check units are consistent throughout
  4. Sign errors — Pay careful attention to positive and negative values
  5. Rounding too early — Keep full precision until the final answer
  6. Forgetting constraints — Check that solutions satisfy all given conditions

Real-World Applications

Understanding this concept is essential for:

  • Advanced problem solving in examinations
  • Building intuition for more complex topics
  • Developing analytical thinking skills
  • Applying mathematical reasoning to practical situations

Practice Exercises

  1. Basic: Solve 5 problems of increasing difficulty using the core concept.
  2. Intermediate: Apply the concept to word problems with multiple steps.
  3. Advanced: Combine this concept with 2-3 other topics in a comprehensive problem.
  4. Challenge: Create your own problem that requires this concept plus additional knowledge.

Interview and Exam Tips

  • Common question patterns: Identify which exam or interview formats test this topic
  • Time management: Practice completing problems within time constraints
  • Common traps: Know the typical mistakes examiners set as distractors
  • Verification strategy: Develop a quick method to check your answer

Related Topics

Quick Reference Card

ConceptFormula/RuleKey InsightCommon Use
Core DefinitionSee main textUnderstand the intuitionFoundation for all applications
Key FormulaSee main textMemorize the derivationDirect problem solving
Special CaseSee main textRecognize when it appliesSimplifies complex problems
Edge CaseSee main textKnow the limitationsAvoids errors

Further Reading

For students who want to go deeper:

  • Standard textbooks on the subject
  • Research papers applying this concept
  • Online courses with video explanations
  • Practice problem collections with detailed solutions
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-11-14

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Microcontrollers & ARM Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement