📜 ⬆️ ⬇️

Simple implementation of the scheme of the stepping motor on the micron

And so, this post is aimed at beginners in electronics as well as at beginners in programming and mastering microcontrollers and developing electronic devices.
This development represents the simplest inclusion of an MK such as the PIC16F84A for controlling a stepper motor. To build such a device, we need:
Our circuit is powered by a stabilized power supply of +5 volts. However, the power part can be powered from voltage > voltage MK < voltage that your transistors hold.

As the power strata we will take KT815. In this case, they are ideally suited for our task.

And so, we assemble our device according to the scheme (.. if you don't see the scheme, then the server is lying, and soon everything will get better):
')


Suppose we have already collected all this, now it remains to program our controller with a simple program so that our rotor turns.

list p=16F84A
#include <p16F84A.inc>
; _CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;***
del EQU 0xFF ;
count EQU 0x0C ;
ORG 0x00
;***
clrf PORTA ;
clrf PORTB ;
bsf STATUS,RP0 ; 1
movlw INIT_A
movwf PORTA ;
movlw INIT_B
movwf PORTB ;
bcf OPTION_REG,7 ;
bcf STATUS,RP0 ; 0
clrw
movwf PORTB
main
movlw b'01010000
movwf PORTB
call delay
;------- , - ,
call delay
movlw b'01100000
movwf PORTB
call delay
;------- , - ,
call delay
movlw b'10100000
movwf PORTB
call delay
;------- , - ,
call delay
movlw b'10010000
movwf PORTB
call delay
;------- , - ,
goto main
;***
delay movlw del
movwf count
loop decfsz count,f
goto loop
return
END


You have probably noticed that there are buttons on the scheme, this is for every fireman - to extend the functionality. the program can be added for them, and also do not forget to include the internal load on port B

We compile this code in the HEX file in the MPLAB IDE program. and sew a programmer or debugger (which is part-time programmer).

UPD: The programmer in this case was used like this: a clone of the original ICD2 from the company Olimex. It costs about 2.5k. Includes the functions of the programmer and debugger (a fun thing).
Works great with MPLAB + ICD2 as well as PikLab + ICD2 for Linux.

UPD2:
After assembling all this, and turning on the power, your engine rotor should start to rotate in either direction.

The most important part of the program are the values ​​of the register W which then transfers the value to the input / output port. Where the unit is, there will be a +5 volt output.

The leftmost bit is the oldest, the rightmost bit is the lowest. So it is, and this is the law. :)
These register values ​​determine how the voltage will be applied to the engine.

movlw b'01010000 ;1
movlw b'01100000 ;2
movlw b'10100000 ;3
movlw b'10010000 ;4


If you mess up with connecting the engine, then it can “jerk back and forth” with you and therefore you should look in this direction of the firmware, or change the connection contacts.

- If you do not work at all - then you need to check the voltage of the reset controller. it should be +5 volts.
- If there is a reset voltage, then you need to check the power of the processor.
- Another common problem may be that the controller is simply not configured! do not forget - this is important.
- If your circuit still does not work, then you need to make sure that the quartz resonator gives pulses when the voltage is turned on. You can check with an oscilloscope as well as a multimeter. OSC contacts

The engine for this scheme was taken from a 5 "drive from old computers. This engine moved the head there to read information from a magnetic disk. It has 5 contacts.

That's all. :)

Source: https://habr.com/ru/post/50809/


All Articles