Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
A DC motor can be commanded to move, but an open-loop voltage or PWM signal cannot guarantee where the shaft stops or how fast it turns. Load torque, friction, supply voltage, inertia, gearbox backlash, temperature, and disturbances all change the result.
The reference design discussed here closes the loop with a quadrature encoder, an 8-bit counter, an external resistor DAC, an analog PID circuit, a GreenPAK mixed-signal device, PWM, and a bidirectional H-bridge. The PID core is analog, but the complete system is hybrid: encoder signals are decoded digitally, position data is converted to analog voltage, the P/I/D calculation is performed with op-amps, and the result is converted back into PWM.
It is a useful educational and prototyping platform—not a formally characterized, safety-rated industrial servo controller. The original design is documented in the All About Circuits industry article and Dialog/Renesas application note AN-CM-250.
Position control and speed control are different problems
Position control asks, “Where is the shaft?” The controller compares the measured encoder position with a target and drives the motor until the position error is small.
#1 Best Overall
- UNIVERSAL INPUT TEMPERATURE RANGE: 200 to 1800 °C (depends on input type). This controller is easy to program and comes with a user friendly manual.
- BOTH DISPLAY TYPES: Display in either Fahrenheit or Celsius temperature unit and decimal points configurable for all inputs, control method: on/off AI MPT with auto tuning, adopting fuzzy logic PID algorithm, alarm mode: absolute value high limit, absolute value low limit, deviation high limit alarm, deviation low limit alarm.
- WIDE APPLICATIONS: Use this PID Temperature Controller when you wish to precisely control the temperature of a kiln/heater/cooler for analog output . Dual display window, be able to display measured temperature and set temperature at the same time.
- HIGH ACCURACY: Simplify operational processes by our dual display temperature controller and you don't need to operate more steps if you want to set the definite value. High accuracy of displaying and controlling. Both Manual and Auto turning are available. Alarm Mode:Absolute value high limit, Absolute value low limit, Deviation high limit alarm, Deviation low limit alarm
- Analog output 4-20mA is predominantly used to control actuators, valves, and motors in industrial environments. If you need 0-10V output simply add suitable resistor. Shipping to USA is 2-5 business days. For more information please go to our website Thermomart
Speed control asks, “How fast is the shaft moving?” It uses the rate of encoder pulses, or encoder counts per unit time, as the feedback signal. A motor can have the correct speed while being at the wrong position, or be at the correct position while stationary. The two control objectives therefore require different feedback signals and tuning.
In the reference position-control implementation, an 8-bit counter is initialized to 127. That midpoint becomes the zero-position reference. Moving the encoder changes the count above or below 127, producing a signed position error. The controller then commands the motor in the direction that returns the count to the setpoint.
The number 127 is not a universal angular zero. Without the encoder resolution, gearbox ratio, decoding mode, and mechanical geometry, a count cannot be converted directly into degrees.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Complete signal chain
DC motor shaft
↓
Quadrature encoder
↓
A/B decoding and direction detection
↓
8-bit up/down counter
↓
External 8-bit resistor DAC
↓
Analog position or speed error
↓
Analog P + I + D stages
↓
Summing and output amplifier
↓
GreenPAK ADC and PWM block
↓
Bidirectional motor driver
↓
DC motor
The design is divided into three practical sections: encoder and position processing, analog PID control, and PWM generation with motor driving. The signal-domain transitions matter. The encoder and counter are digital; the resistor DAC, op-amp PID stages, and error signal are analog; the final motor command is digital PWM again.
Quadrature encoder feedback
A quadrature encoder provides two pulse trains, conventionally called A and B, separated by approximately 90 degrees of phase. The order in which their edges arrive identifies direction:
- If A leads B, the decoder assigns one direction.
- If B leads A, it assigns the opposite direction.
The exact clockwise/counterclockwise polarity depends on the wiring and decoder convention. The GreenPAK logic generates count pulses for the two directions and clocks an up/down counter accordingly. The counter range is 0–255, with 127 used as the initial midpoint.
The source demonstration reportedly needed about 30 counts to cover its physical mechanism. That is a property of the particular encoder, gearing, and travel—not a general resolution specification. A practical design must account for:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall- Encoder counts per revolution and whether x1, x2, or x4 decoding is used.
- Whether the encoder is mounted before or after a gearbox.
- Maximum pulse frequency and counter timing.
- Missed or noisy edges during rapid reversals.
- Gearbox backlash, shaft compliance, and mechanical stops.
- Whether a homing switch or index pulse is required after power-up.
An encoder mounted before a gearbox may report motor-shaft position accurately while failing to reveal output-shaft backlash. For precise positioning, sensor location can matter as much as nominal encoder resolution.
Converting the count into an analog voltage
The GreenPAK built-in DAC could not accept the counter output directly in the required configuration, so the reference design uses an external 8-bit binary-weighted resistor DAC built around the SLG88104 quad op-amp. The resistor value used in the described circuit is 10 kΩ, and the GreenPAK reference voltage is 3.3 V.
The DAC voltage represents the digital counter value. Additional summing and inversion stages provide the polarity and level needed by the PID circuit. The source describes an output amplifier using R1 = 1 kΩ and R2 = 10 kΩ, for a stated gain of 11× and an amplified output of approximately 0–4.7 V in that circuit.
Rank #2
- Versatile Speed Control – 8-stage programmable control with adjustable speed, Suitable for motors, pumps, fans, conveyors, and more. Customize to your exact needs for optimized performance.
- Standard Modes: Comes with standard RS485 RTU mode, multiple analogue input and output, such as 0‑5V, 0‑10V, 4‑20mA, 0‑20mA.
- Multiple Input Options – Supports RS485 RTU mode and analog inputs (0-10V, 4-20mA) for seamless integration with a variety of control systems, giving you flexibility in setup and .
- Energy-Efficient Design – Low-frequency, high- capabilities reduce energy consumption while maintaining superior motor performance. Save on power bills while achieving optimal output.
- Wide Application Compatibility – Ideal for a variety of industrial applications like CNC machines, cranes, mixers, and compressors. Versatile enough to meet the demands of diverse machinery.
There is an important range limitation. With the SLG88104 arrangement described, counter values 194–255 were discarded because the resulting voltage would exceed the circuit’s stated 5 V device limit. A replacement implementation must recalculate the DAC transfer function, op-amp common-mode range, output swing, and ADC input range rather than copying the values blindly.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Dual-supply op-amps can produce positive and negative outputs. If the following PID circuitry operates from a single supply, a level-shifting, inversion, or polarity-correction stage may be required. Verify every intermediate voltage with an oscilloscope or multimeter before connecting the motor.
How the analog PID controller works
The controller combines three responses to the error signal:
u(t) = Kp e(t) + Ki ∫e(t)dt + Kd de(t)/dt
Proportional action
The proportional stage produces an output immediately proportional to the present error:
uP(t) = Kp × e(t)
Increasing proportional gain generally produces stronger correction and a faster response. Too much gain can make the motor overshoot, oscillate, or become unstable. In the reference circuit, op-amp resistor ratios set the proportional gain.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesIntegral action
The integral stage accumulates error:
uI(t) = Ki ∫e(t)dt
Its main purpose is removing persistent steady-state error. For example, friction or a load torque may prevent proportional action alone from reaching the exact setpoint. The integrator continues building a correction until that residual error is removed.
Integral action also creates a common failure mode. If the motor command is already saturated but error remains, the integrator can continue accumulating. When the motor returns to a controllable region, the stored charge drives excessive overshoot and delays recovery. This is integral windup.
The source discusses saturation and anti-windup as control concepts, but it does not document a complete, quantified industrial anti-windup implementation in the circuit. Do not assume that a potentiometer-adjusted analog integrator automatically has robust windup protection.
Derivative action
The derivative stage responds to the rate of change:
uD(t) = Kd × de(t)/dt
Rapidly changing feedback indicates that the motor is moving quickly toward or away from the target. The derivative term can therefore provide braking or damping. A stationary motor produces little derivative output.
Rank #3
- Single/dual potentiometer analog signal and TTL level control modes motor overload protection RS485 PWM speed pid motor control
- maximum load current 20A, 20A fuse
- Support single / dual potentiometer 0 ~ 5 / 10V analog signal and TTL level, -5V ~ +5V differential analog signal and RS485 multiple control
- support MODBUS-RTU communication protocol
Real differentiators amplify high-frequency noise. Encoder quantization, PWM switching, motor-brush noise, and wiring interference can make the derivative output noisy and cause audible chatter. A practical design normally limits the derivative bandwidth with filtering and checks the op-amp’s gain-bandwidth and stability.
Summing and output range
The P, I, and D outputs are combined by a summing amplifier. The resulting analog command must remain inside the op-amp output range and the GreenPAK ADC input range. Clipping at this stage is actuator saturation, not successful control. Measure the signal under startup, reversal, disturbance, and stall-like conditions before selecting final gain limits.
From PID voltage to motor power
The analog PID output cannot drive a motor directly. It is routed into the GreenPAK conversion and PWM functions. The GreenPAK generates the PWM signal, while the direction logic supplies the motor-driver direction command.
In the source circuit, the motor-driver PWM input is connected to GreenPAK pin 5, and the direction input is connected to GreenPAK pin 6. These pin assignments are circuit-specific and should not be treated as universal GreenPAK mappings.
The PWM frequency is adjustable. There is no single correct frequency for every motor. Selection depends on motor inductance, driver switching capability, current ripple, audible noise, switching loss, and the driver’s input limits. The source refers readers to AN-1057 for PWM parameter adjustment and describes a driver capable of PWM operation up to 10 kHz. Confirm the actual limit and mode for the driver being used.
The H-bridge must be sized for more than the motor’s nominal current. Stall current, regenerative energy during deceleration, braking mode, thermal dissipation, logic thresholds, and overcurrent protection all matter. A replacement driver is not automatically compatible because it accepts the same PWM frequency.
Why the design suppresses PWM at the zero position
A position loop can hunt around its target. At count 127, even a small residual voltage can move the motor. That movement creates another encoder count, which changes the error and can command a reversal. The result may be oscillation, buzzing, or repeated direction changes.
The reference implementation uses a multiplexer arrangement to suppress PWM at the zero-position count. In effect, it creates a special stop condition or deadband around the target.
- Too little deadband: chatter, hunting, audible buzzing, and motor wear.
- Too much deadband: visible position error and reduced accuracy.
- Unexamined deadband: backlash, friction, poor tuning, or inadequate encoder resolution may be hidden rather than fixed.
A production design should specify deadband in encoder counts or physical angle and justify it against the required accuracy. It should also distinguish intentional deadband from a controller that simply cannot overcome static friction.
A practical tuning sequence
The source recommends a hands-on P-D-I tuning procedure. It is suitable for a low-energy educational setup, but not a substitute for formal modeling on high-energy machinery.
Rank #4
- Alarm Output: With 1 alarm relay output, AC250 V, 3 A (Resistive load), ON or NC, you can wire a buzzer
- Supports 3-Wire Sensor: a 3-wire sensor or 2-wire sensor, like the K type thermocouple and Cu500, is supported by this PID temperature controller
- SSR Output: With 1 relay output for external SSR, an SSR or relay is a must for this temperature controller; A 40DA SSR is included
- Digital Display Celsius or Fahrenheit: It’s a digital PID controller but also supports Centigrade or Fahrenheit reading
- 2 Temp Displaying Windows: The real-time temperature and the setpoint are shown at the same time
- Set proportional, integral, and derivative gains to zero.
- Increase proportional gain until a disturbance produces sustained oscillation.
- Increase derivative gain until the oscillation is reduced or removed.
- Repeat the proportional and derivative adjustments until additional derivative gain no longer improves the response.
- Keep the last stable P and D settings.
- Increase integral gain until the setpoint is reached with an acceptable amount of overshoot and oscillation.
- Reduce proportional gain if oscillation grows.
- Reduce derivative gain if high-frequency chatter appears.
The suggested disturbance is manually moving the mechanism away from its setpoint and releasing it. Use a current-limited bench supply, physical travel limits, and a low-energy motor during this process. Never use a hand disturbance as the only validation for a machine capable of causing injury.
Free tools Windows power users keep installed
One-click scans. No signup required.
Use measurable acceptance criteria
| Test | Measure |
|---|---|
| Position step | Overshoot, settling time, final error |
| Manual or repeatable disturbance | Peak error and recovery time |
| Load change | Position error or speed droop and recovery |
| Reversal | Overshoot, current peak, and encoder count integrity |
| Stop condition | Residual motion, chatter, and deadband width |
| Long-duration hold | Integral drift, temperature, and repeatability |
Adapting the design for speed control
For speed control, the accumulated position count is replaced by a velocity estimate. The source describes encoder pulse rate as proportional to motor speed and suggests using encoder pulses and counters to determine speed.
Frequency measurement
Count pulses during a fixed measurement window:
speed ∝ pulse_count / measurement_window
This method is simple and works well at moderate and high speeds. Its drawbacks are measurement delay and poor resolution when only a few pulses arrive during the window.
Period measurement
Measure the time between successive pulses:
speed ∝ 1 / pulse_period
Period measurement can provide better low-speed resolution, but it needs timeout handling when the motor stops and is more sensitive to individual pulse jitter. A real speed loop also needs a defined update interval, filtering strategy, direction convention, and behavior during reversal. The source does not specify universal values for these parameters.
For a signed speed estimate, use quadrature direction or a signed count difference. At zero speed, explicitly force the estimate to zero after a timeout; otherwise the last valid period may appear to represent continued motion.
Recommended Free Tools
Speed-loop tuning differs from position-loop tuning. A speed controller usually regulates velocity against load torque, while a position controller must also manage accumulated position error and stopping behavior. Many practical servo systems use cascaded loops:
Position loop → speed command
Speed loop → torque/current command
Current loop → PWM duty cycle
A single position PID can work for a small demonstration motor, but cascaded control provides clearer control of acceleration, current limiting, and disturbance rejection.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Analog or microcontroller PID?
| Approach | Strengths | Trade-offs |
|---|---|---|
| Analog or mixed-signal | Low software overhead, deterministic analog behavior, direct oscilloscope visibility, and physical gain adjustment | Component tolerances, integrator saturation, derivative noise, difficult repeatability, and limited diagnostics |
| Microcontroller | Programmable gains, digital filtering, anti-windup, telemetry, data logging, parameter storage, and easier cascaded loops | Requires firmware; sampling rate, ADC resolution, PWM resolution, latency, and timing jitter affect performance |
The GreenPAK approach is valuable when the goal is to study the interaction between digital encoder processing, analog control, and PWM without building a conventional firmware loop. Renesas currently presents GreenPAK products and configuration resources through its own ecosystem; check the GreenPAK product pages and Go Configure Software Hub for current device and software support.
A microcontroller is usually easier to extend with current sensing, homing, fault states, trajectory planning, communications, logging, and programmable safety limits. The Arduino example associated with the source is illustrative, not a validated production implementation.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Motor, encoder, and driver assumptions
The application-note demonstration uses a small geared DC motor described as operating from approximately 6–12 VDC, with 2.2 W output power, a 1:75 gear ratio, 133 RPM rated speed, a 3 A stall current, and a 5 V Hall-effect quadrature encoder. The available reproduced text does not preserve a complete torque unit, so that torque figure should not be published as a definitive specification without checking the original PDF and bill of materials.
Best Value
- 【Alarm Output】With one alarm relay output: AC220V/DC30V 3A (Resistive load) ON/NC, you may connect it with a buzzer.
- 【Supports 3 Wires Sensors】3 wire or 2 wires sensor , like K(E,J,N,W3-25,W5-26) type thermocouple,PT100,Cu50 , are supported by this PID temperature controller
- 【SSR Output】With one relay output for external SSR, SSR or relay is a must for this temperature controller. A 40DA SSR is included
- 【Digital Display ℃/℉】It’s a digital PID controller but supports both Centigrade and Fahrenheit display
- 【2 Temp Displaying Windows】The real-time temperature and the setpoint are shown at the same time
The associated driver is described as a bidirectional NMOS H-bridge with a 3–25 V motor-voltage range, up to 10 A continuous current, 15 A peak current for 10 seconds, 3.3 V/5 V logic compatibility, PWM capability up to 10 kHz, and locked-antiphase and sign-magnitude modes. These are specifications of the particular demonstration hardware, not requirements for every implementation.
When substituting parts, verify:
- Motor rated voltage and stall current.
- Encoder supply voltage, output type, and logic thresholds.
- Gear ratio, backlash, output-shaft load, and mechanical travel.
- Driver continuous and peak current ratings with thermal margin.
- Braking, coast, regeneration, and overcurrent behavior.
- Op-amp input common-mode range, output swing, bandwidth, offset, and noise.
- ADC input limits and PWM polarity.
Failure modes and debugging checklist
Wrong direction or runaway
Probe encoder A and B and verify the direction convention. Then verify the sign of the DAC error, the PID output polarity, the PWM polarity, and the H-bridge direction input. A feedback loop with reversed polarity is positive feedback and can command maximum drive.
Lost or inconsistent counts
Check encoder voltage levels, edge quality, cable routing, maximum pulse rate, counter timing, and A/B phase. Keep encoder wiring away from motor-current and PWM wiring. Add appropriate input filtering without filtering away valid edges.
Oscillation or chatter
Reduce proportional gain, inspect derivative noise, check mechanical backlash, and review the deadband. Excessive derivative gain can make switching and encoder noise visible as rapid command changes.
Slow recovery or large overshoot
Look for integral windup, output saturation, excessive integral gain, and an integrator that lacks a reset, clamp, discharge path, or other limiting mechanism.
DAC or op-amp clipping
Measure the DAC and PID voltages across the entire count range. Confirm that the resistor network, op-amp supply, common-mode range, output swing, and GreenPAK ADC limits are compatible. Do not use the discarded 194–255 range from the source circuit unless the voltage design has been changed and revalidated.
Motor stops short
Static friction, insufficient drive voltage, deadband, gearbox backlash, and low encoder resolution can all cause a residual position error. Increasing integral gain may help, but it can also create windup and overshoot.
Driver overheating or unexplained resets
Measure motor current, inspect supply droop, separate high-current and analog return paths, add local decoupling, and check regenerative voltage during braking. Verify the driver’s thermal and protection behavior under stall and reversal conditions.
Reproduction checklist
- Confirm the motor voltage, stall current, encoder voltage, and mechanical travel.
- Check the exact GreenPAK device, package, configuration software, and current availability through Renesas availability tools.
- Build and test the encoder and A/B decoder without the motor connected.
- Verify up/down counting and the midpoint initialization at 127.
- Measure the DAC transfer function for every permitted count range.
- Test the P, I, and D stages with a known signal before connecting the motor.
- Verify that no op-amp or ADC input clips.
- Test PWM and direction independently with a current-limited supply.
- Add mechanical stops, a current limit, and an emergency shutdown before closed-loop operation.
- Tune at low energy, then validate with measured overshoot, settling time, error, current, temperature, and repeatability.
Is this design suitable for production?
It is well suited to education, bench experimentation, and small low-energy prototypes where the reader wants to see encoder decoding, DAC conversion, analog P/I/D behavior, and PWM motor control in one system.
It should not automatically be used for a production machine, safety function, or demanding servo application. The source does not establish a formal bandwidth, position accuracy, speed accuracy, load-response envelope, EMC qualification, thermal design, or safety rating. A production system normally adds current sensing, fault handling, homing, travel limits, watchdogs, defined startup behavior, regeneration management, and repeatable verification. A microcontroller or dedicated motion-control architecture may also be more practical, particularly when cascaded position, speed, and current loops are required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.

