A motor controller for controlling a stepping motor, the motor controller comprising: a command value calculator configured to calculate a speed command value (ωtgt) and an angle command value (θtgt) based on a reference clock (refclk); a control method selector configured to select one of open-loop control and closed-loop control in accordance with the speed command value (ωtgt) calculated by the command value calculator; a command value output unit (103, 104) configured to output a first target value (iref) as a first current command value (idt) when the open-loop control is selected by the control method selector, and to output a second target value (itgt) different from the first target value (iref) as a second current command value (iqt) when the closed-loop control is selected by the control method selector, the motor controller is configured to control the stepping motor based on the first target value (iref) when the open-loop control is selected and the second target value (itgt) when the closed-loop control is selected, an angle estimating unit configured to calculate and output an angle estimated value (θest) and a speed estimated value (ωest) based on a driving current supplied to the stepping motor, wherein a phase of the driving current supplied to the stepping motor is synchronized with the angle command value (θtgt) when the open-loop control is selectively executed and is synchronized with the angle estimated value (θest) when the closed-loop control is selectively executed, a first voltage command value calculator configured to calculate and output a first voltage command value (Vd) based on the first current command value (idt); and a second voltage command value calculator configured to calculate and output a second voltage command value (Vq) different from the first voltage command value based on the second current command value (iqt), characterised in that the command value output unit (103, 104) is configured to output a given value as the first current command value (idt) to render a sum of the first voltage command value (Vd) and the second voltage command value (Vq) constant when the closed-loop control has been selectively executed and at least one of the first voltage command value (Vd) and the second voltage command value (Vq) reaches or exceeds a first threshold. a command value calculator configured to calculate a speed command value (ωtgt) and an angle command value (θtgt) based on a reference clock (refclk); a control method selector configured to select one of open-loop control and closed-loop control in accordance with the speed command value (ωtgt) calculated by the command value calculator; a command value output unit (103, 104) configured to output a first target value (iref) as a first current command value (idt) when the open-loop control is selected by the control method selector, and to output a second target value (itgt) different from the first target value (iref) as a second current command value (iqt) when the closed-loop control is selected by the control method selector, the motor controller is configured to control the stepping motor based on the first target value (iref) when the open-loop control is selected and the second target value (itgt) when the closed-loop control is selected, an angle estimating unit configured to calculate and output an angle estimated value (θest) and a speed estimated value (ωest) based on a driving current supplied to the stepping motor, wherein a phase of the driving current supplied to the stepping motor is synchronized with the angle command value (θtgt) when the open-loop control is selectively executed and is synchronized with the angle estimated value (θest) when the closed-loop control is selectively executed, a first voltage command value calculator configured to calculate and output a first voltage command value (Vd) based on the first current command value (idt); and a second voltage command value calculator configured to calculate and output a second voltage command value (Vq) different from the first voltage command value based on the second current command value (iqt), characterised in that the command value output unit (103, 104) is configured to output a given value as the first current command value (idt) to render a sum of the first voltage command value (Vd) and the second voltage command value (Vq) constant when the closed-loop control has been selectively executed and at least one of the first voltage command value (Vd) and the second voltage command value (Vq) reaches or exceeds a first threshold.