Switch power line voltage compensation method and adaptive sampler

The invention discloses a line voltage compensating method for a switching power supply, and relates to a switching power supply technology. The method mainly comprises the following steps: (1) sampling process: the sampling is carried out when a power switch is critically cut off, and a first capacitor is charged; (2) finishing the charge distribution process after finishing sampling: the charge distribution is performed for a second capacitor and the first capacitor; (3) connecting reset process: after the charge distribution process is finished, the first capacitor is connected to the output terminal of a sampler and waits for the sampling process for the next time. The method can compensate the line voltage, the process parameter as well as the variation of temperature and output drive without the extra detecting element, the method is simple, and the power consumption is low.