Buck Converter Normalization in a dsPIC Power Converter
All the control and support operations are performed inside the dsPIC® Digital Signal Controller (DSC). All analog inputs are converted to numbers by the Analog-to-Digital Converter (ADC), while all constants or parameters are numbers stored in the system.
Care must be used in using these numbers. The dsPIC performs high-resolution computation at high speed, taking advantage of the Digital Signal Processor (DSP) engine. Since the dsPIC is a fixed point unit, you must be sure that the numbers never become too big or too small, are always within meaningful limits, and operate in such a way as to always keep the maximum resolution possible.
Whenever a value is truncated, resulting in dropped bits, a noise source is added to the computations. Theoretical analysis of these error sources and how they interfere with each other is possible, but it is quite complex and beyond the scope of this article.
Background
When using x.y format, numbers may be signed. For signed numbers the MSB bit in the x part is used as the sign, leaving x-1 bits to represent the number's absolute value (i.e., a 16-bit signed value now contains 15 bits of range). Listed below are the factors that must be considered with numerical operations in the dsPIC:
- dsPIC DSC registers are 16-bit wide.
- Accumulators are 40-bit wide.
- Numbers are always considered to be in the format x.y, where x is the number of bits reserved for the integer part and y is the number of bits reserved for the decimal part.
- For general purpose registers x + y = 16-bit, for accumulators x + y = 40-bit.
- Proportional-Integral-Derivative (PID) coefficients are in the format 8.8.
- Values from the ADC are integers in the format [16.0].
- All peripheral registers are also integers.
Considering the PID implemented with MAC operations, two concepts must be understood:
- When multiplying two 16-bit numbers, the result is a 32-bit number.
- When adding two 32-bit numbers, the result may need more than 32 bits in order to maintain the sign.
In multiplying two numbers of any format, we do not have to take care of the position of the decimal point. When adding two numbers, we must ensure that the decimal points are aligned.
Computations are performed in order to always reserve the minimum number of bits required to store the integer part. This allows you to keep as many bits as possible in the decimal part. Intermediate results are often scaled to fulfill the requirements.
Normalization in the Voltage Mode Control Loop
Below is a description of how normalization works in the Voltage mode control loop, illustrated in the block diagram.
- The number generated by the ADC, representing the input voltage, is an integer and has a format [16.0]. Note that the ADC is a 10-bit unit, so only the 10-bits will be used.
- The ADC output is multiplied by a factor representing the reverse of the resistor divider used in hardware. This increases the dynamic range of the numbers used. The factor has a format [5.11] because its maximum value is less than 32.
- The result of the product will have the format [16.0] * [5.11] = [21.11].
- The result of the previous multiplication must be subtracted from the reference voltage, which is represented by an integer number in the format [16.0]. In order to perform the subtraction, the result of the previous multiplication has to be processed and reduced in the same format. The number is then shifted left by 5 bits and the H part of the accumulator is considered.
- The result of the subtraction has [16.0] format
- The PID coefficients have a [8.8] format.
- The MAC operations provide a result that has a [24.8] format.
- Since this number represents the duty cycle, it must be stored in the 16-bit register of the duty cycle. The number must then be shifted left by 8 bits.