A controller controls the output current by measuring and controlling the
switching current of the power converter. A first circuit generates a
first signal in accordance with the switching current. A second circuit
detects a discharge-time of the transformer. A third circuit generates a
third signal by integrating the first signal with the discharge-time. The
time constant of the third circuit is programmed and correlated with the
switching period of the switching signal, therefore the third signal is
proportional to the output current. A switching circuit generates a
switching signal and controls the pulse width of the switching signal in
accordance with the third signal and a reference voltage. Therefore, the
output current of the power converter can be regulated.