I'm stuck!
I have a program that increments or decreases a variable from 0 to 5, or from 5 to 0 depending on button presses. Each push of the buttons alters the value up or down by one.
Each of the numbers 0 to 5 corresponds to a current output. For simplicity, lets say 0 is off, 1 = 100mA, 2 = 200mA etc etc.
Now, at each current level there is a pwm output. It is altered by a basic feedback loop and can do limited current control by increasing or decreasing the duty cycle.
What I need to do is have a set duty cycle that gives close to 100mA or 200mA etc as soon as the loop is entered, and than is able to control its self by feedback. Basically this is to speed up initial on time or speed up the output when going from say 100mA to 200mA. Otherwise the program has to loop and increase duty cycle from 0 each time or from the level at the previous set current until target is met. I need it to start at closer to target. Obviously if I put that start number in the loop, it will never self regulate.
So how do I get it to start at a number, read it once then enter the regulation loop?
Bookmarks