Digital Implementation of a Control Loop

Timing is very important in power conversion designs. The complete operation executed by the digital control loop, and the action that is consequently taken, introduce a delay. This delay is also present in analog designs. In the analog domain only small delays are to be considered. While in the digital domain, these delays are generally longer. The corresponding hardware/firmware is required to execute the set of instructions (commands) in a timely fashion. In digital design for example, in order to achieve the maximum possible bandwidth, it is useful to execute all the required operations within the duration of a PWM period. The speed of the core and peripherals allow the dsPIC® DSC to update the controlled variables in a very short period of time.

The figure below summarizes the results and concepts of the digital implementation of the control loop. The PWM period is shown on the left. The ADC trigger located as shown, is at 50% of the active PWM output signal. Time T1 (680 ns) is required by the ADC to sample and convert the signal. At the end of this period, the new values are available and can be processed by the algorithm inside the dsPIC® DSC. T2 (700 ns) is thus the overall time required to compute the updated duty cycle. Time T3 (100 ns) is the sum of other smaller delays that must be added to the loop timing, for instance, the PWM output delay.


Total time Tto = T1 + T2 + T3, which is the overall time required by the system to generate a newly updated duty cycle value. Note that the times in the figure are examples only. Real durations vary according to the specific implementation.

It may seem that it takes considerably longer to process to the “computational” time required by the analog equivalent. Keep in mind that the sampling rate is related to the needed bandwidth of the system. If the sampling rate is 400 kHz, and we take a new sample every other period, the sampling frequency is 200 Kilosample(s) per second (Ksps). The overall system will perform well for a system bandwidth which is 1/10 of this frequency, approximately 32 kHz. Normally, in voltage-mode and average current-mode, we are interested in a signal which is slowly varying compared to the PWM. It also depends on how available the newly updated value for the converter duty cycle is. The position of this instant in time depends on the PWM period and on the other parameters.

  • The new data can be either:
    • Available within the duration of the current period, or
    • Available in the following period. The effect of this results in the reduction of the converter bandwidth.
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.