Using the results from a difference equation in digital control

Discussion in 'Embedded Systems and Microcontrollers' started by Obanion, Mar 10, 2010.

  1. Obanion

    Thread Starter New Member

    Nov 26, 2009
    24
    0
    Hi guys,

    I'm working on a control system for a DC-DC converter, and I'm stuck on a certain aspect.

    I have the transfer function in difference equation format for my DC-DC convert, but I'm unsure how to program it. I'm using an FPGA with Verilog, but in terms of conceptualization, I believe it applied to any programming language.

    For instance, let's say my difference equation is:

    D(n) = 5.45*I(n) - 123.4*I(n-1) + 1.3*D(n-1) - 0.5*D(n-2)

    Where D(n) is the duty cycle at instant n and I(n) is the current at instant n.

    I guess my question is how do I know what values to use for this input? My maximum current is going to be 1 A. I'm using an 11 bit ADC, so that translates to 11111111111 (for 1 A) in binary. Do I need to scale this value for the difference equation, and if so by what amount?

    My duty cycle routine accepts a number from 0-2048, where 1024 would be 50%, 2048 would be 100% and so on. This is easily modifiable.

    For the duty cycle, is it the same process? In reality, the duty cycle can be from 1-0, and never above. Let's say I assume that my max current value is scaled to 1, and my duty cycle is scaled to 1 also. Feeding my equation, I just may get a number greater than 1. I don't know what the output of the difference equation's duty cycle actually means.

    This is where I'm very unsure what to make of it and I apologize if I'm not making any sense. I'm not sure if this concept is one that has been already addressed in textbooks or such. I'd appreciate any information on this subject. Please let me know if I'm not being clear and I'll try my best to explain it more clearly.


    Thanks,

    Obanion
     
  2. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    It all depends what language you are writing in, how fast the processor is & how fast an update you need.

    Personally, I'd probably scale the values to Amps/1000 and use a 16 bit integer variable for the math.

    That gives you enough overhead for the multiplications without oveflowing.

    It balances accuracy with speed - you may need to avoid floating point maths if you are using something like a PIC as it may be too slow for real-time control at high frequencies.
     
Loading...