51 single-chip microcomputer driven stepper motor (double four beats and eight beats)

Source: Internet
Author: User

Stepper motor is a kind of electromagnetic mechanical device which transforms electric pulse into corresponding linear displacement and angular displacement. With a fast start-up stop capability, when the motor load does not exceed the torque he provides, the input pulses can be used to control his stop and start in a flash. The step angle and speed of the stepper motor are only related to the frequency of the input pulses.

Usually the rotor of the motor is a permanent magnet, and when the current flows through the stator windings, the stator windings produce a vector magnetic field. The magnetic field will drive the rotor rotation angle, so that the rotor of a pair of magnetic field direction and the stator magnetic field direction. When the vector magnetic field of the stator rotates an angle. The rotor also turns an angle with the magnetic field. Each input an electrical pulse, the motor rotates an angle forward one step. The angular displacement of the output is proportional to the number of pulses in the input, and the rotational speed is proportional to the pulse frequency. Change the order in which the windings are energized and the motor will reverse. Therefore, it is possible to control the rotation of the stepper motor by controlling the number of pulses, frequency and power order of each phase windings of the motor. Each pulse signal corresponds to the power state of a phase or two-phase winding of a stepping motor, and the corresponding rotor turns over a certain angle (a step angle). When the power state changes to complete a cycle, the rotor turns over a pitch. Four-phase stepper motor can operate in different power modes, common power-on mode has single (single-phase winding power) four beats (a-b-c-d-a), double (dual-phase winding power) four beats (Ab-bc-cd-da-ab), eight beats (a-ab-b-bc-c-cd-d-da-a).

The following code is for 8 beats:

Sbit P00 = p0^0; Sbit P01= p0^1; Sbit P02= p0^2; Sbit P03= p0^3;//---------------set into push-pull mode-------force the PIN to pull high-----voidInit_gpio (void) {p0m1= P0M1 &0x0; p0m2= p0m2 |0XFF; P0=0x0; }//-----------Horizontal Motor---------------------------#defineA P00#defineB P01#defineC P02#defineD P03#defineh_coil_a {A = 1; B = 0; C = 0;d = 0;}#defineH_coil_ab {A = 1; B = 1; C = 0;d = 0;}#defineh_coil_b {A = 0; B = 1; C = 0;d = 0;}#defineH_COIL_BC {A = 0; B = 1; C = 1;d = 0;}#defineH_coil_c {A = 0; B = 0; C = 1;d = 0;}#defineh_coil_cd {A = 0; B = 1; C = 1;d = 0;}#defineh_coil_d {A = 0; B = 0; C = 0;d = 1;}#defineH_coil_da {A = 0; B = 0; C = 1;d = 1;}#defineH_coil_off {A = 0; B = 0; C = 0;d = 0;}voidH_right_motor () {h_coil_a Delay_ms (speed);    H_coil_ab Delay_ms (speed);    H_coil_b Delay_ms (speed);    H_COIL_BC Delay_ms (speed);    H_coil_c Delay_ms (speed);    H_COIL_CD Delay_ms (speed);    H_coil_d Delay_ms (speed); H_coil_da Delay_ms (speed);}voidH_left_motor () {H_coil_da Delay_ms (speed);    H_coil_d Delay_ms (speed);    H_COIL_CD Delay_ms (speed);    H_coil_c Delay_ms (speed);    H_COIL_BC Delay_ms (speed);    H_coil_b Delay_ms (speed);    H_coil_ab Delay_ms (speed); H_coil_a Delay_ms (speed); }

  

  

51 single-chip microcomputer driven stepper motor (double four beats and eight beats)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.