A controller for performing synchronization control over a master axis and a slave axis to follow an electronic cam profile, the control device comprising: a reference position storage configure to store the reference position of the master axis and the slave axis, as well as the positions of the master axis and the slave axis at the time when the master axis and the slave axis are synchronized with each other through cam control; a synchronization control unit configured to control the position of the master axis and the position of the slave axis to correspond to the position of the master axis to follow the electronic cam profile; a reference position updater configured to, in response to power being restored after a power disconnect, obtain a position of the master axis and calculate a reference position of the master axis and a reference position of the slave axis based on the obtained position of the master axis, a position of the master axis at cam synchronization, and the electronic cam profile; and a return control unit configured to perform return control to determine a position of the slave axis corresponding to a current position of the master axis based on the current position of the master axis, the electronic cam profile, and the reference position of the master axis and the reference position of the slave axis calculated by the reference position updater, and to move the slave axis to the determined position, wherein the electronic cam profile presents information indicating the relationship between the phase of the main axis and the displacement amount of the slave axis, wherein the phase of the master axis refers to a change in the position of the mater axis either from its position at cam synchronization or from the reference position of the master axis, and the deviation of the slave axis refers to a change in the position of the slave axis either from the position of the master axis at cam synchronization or from the reference position of the slave axis. a reference position storage configure to store the reference position of the master axis and the slave axis, as well as the positions of the master axis and the slave axis at the time when the master axis and the slave axis are synchronized with each other through cam control; a synchronization control unit configured to control the position of the master axis and the position of the slave axis to correspond to the position of the master axis to follow the electronic cam profile; a reference position updater configured to, in response to power being restored after a power disconnect, obtain a position of the master axis and calculate a reference position of the master axis and a reference position of the slave axis based on the obtained position of the master axis, a position of the master axis at cam synchronization, and the electronic cam profile; and a return control unit configured to perform return control to determine a position of the slave axis corresponding to a current position of the master axis based on the current position of the master axis, the electronic cam profile, and the reference position of the master axis and the reference position of the slave axis calculated by the reference position updater, and to move the slave axis to the determined position, wherein the electronic cam profile presents information indicating the relationship between the phase of the main axis and the displacement amount of the slave axis, wherein the phase of the master axis refers to a change in the position of the mater axis either from its position at cam synchronization or from the reference position of the master axis, and the deviation of the slave axis refers to a change in the position of the slave axis either from the position of the master axis at cam synchronization or from the reference position of the slave axis.