# digital controller design and mapping analog signal to digital integer values

I have a specific situation i am trying to wrap my head around but i think it should have a general formalism to address the problem.

I have designed a BiQuad controller for a buck converter and i am trying to implement this controller using a uC routine. the design of the BiQuad is done in the S-domain and converting this controller to the discrete form is a well known procedure and no mystery there.

My concern is about the form of the error signal. the error signal is a simple difference between 2 analog signals (V_reference - V_out). i am using ADC converter to sample V_Out that maps it to an integer value in the range [0 - 65536] which correspond to (0 -> Vcc) [vcc here is related to the ADC converter].

now the floating point coefficients of my discrete BiQuad controller need to be a adjusted to accommodate the fact that the error signal i am feeding it is not a real value but an integer mapped value, right ?

while i can covert the ADC reading to a floating point real representation of the error signal , but i would rather do the computation with integer value to make the controller code run faster.

let's assume this simple :

PWM_Duty = a0 * error + a1 * previous_error + b0 * previous_PWM_Duty.

error, previous_error: 32-bit integer value mapped from floating point value by the ADC converter.

a0,a1,b0: floating point coefficients obtained by the controller design.

PWM_Duty,previous_PWM_Duty: the control signal that change the duty cycle of the PWM, it is an integer value between 0 and 100.

my question is how to convert b0, a1 ,a2 to make the control equation do the right controlling it did in the analog world ?

hopefully i am asking the right question here. i would love some reference or books that talk about coding controllers and address this kind of problem.

sorry for the long post :)

• IMO, you are wasting your time. Use floating point and if you are afraid, then use a MCU with FPU. – Marko Buršič Jan 9 '16 at 20:45