Beruflich Dokumente
Kultur Dokumente
Start/stop circuit
This is the circuit for the clockwise rotating, the counterclockwise rotating or stopping a motor.
The baton switch of the non lock is used. Pull-up resistor is used for the port to become H level
when the switch is OFF. The RB port of PIC16F84A has an internal pull up feature. However,
because RB5 is used for the voltage detection of the capacitor at the circuit this time, an internal
pull up feature isn't used. If using RA port for the voltage detection of the capacitor, the RB
internal pull up feature can be used. The circuit this time put an external pull-up resistor in the
relation of the pattern.
Oscillator
4-MHz resonator is used because the circuit this time doesn't need high-speed
operation.
The control of the stepper motor is done by this PIC. To have explained in the operation principle, coil,
coil, coil and coil are controlled by the software.
At first, I used 2SD1590 ( 8A type ) as the transistor for the drive. However, in case of the motor which was
used this time, the coil current was about 250 mA. So, I changed into the small type transistor. The
maximum collector current of 2SD1209K is 1A and "hfe" is more than 4000.
This is the diode to protect a transistor from the back electromotive force which occurs with the coil of the
stepper motor. It depends on the kind of the stepper motor but it is to be OK if it is possible to pass a
hundreds-of-mA electric current.
Baton switch
IC socket
Resonator
B type is used.
Resistor
It is to be OK at 1/8 W.
This is the series resistor to be using for start/stop switch pull up.
This capacitor is used to bypass the high frequency noise of the input and output of the power
supply.
Electrolytic capacitor
This capacitor is used as the ripple filter capacitor of the power circuit.
Printed board
Wiring terminal
This terminal is used to connect a power supply wire and the variable resistor for the speed control.
Stud
00001
;********************************************************
00002 ;
00003 ; Stepper Motor controller
00004 ;
00005 ; Author :
Seiichi Inoue
00006
;********************************************************
00007
00008 LIST P=PIC16F84A
00009 INCLUDE P16F84A.INC
00001 LIST
00002 ; P16F84A.INC Standard Header File, Version
2.00'(modify)
00134 LIST
2007 3FF2 00010 __CONFIG _HS_OSC & _WDT_OFF &
_PWRTE_ON & _CP_OFF
00011
00012 ;**************** Label Definition
********************
00013 CBLOCK H'0c'
0000000C 00014 MODE ;Operation
mode
00015 ;0=stop
1=right 2=left
0000000D 00016 COUNT1 ;Wait
counter
0000000E 00017 COUNT2 ;Wait
counter(for 1msec)
00018 ENDC
00019
00000000 00020 RB0 EQU 0 ;RB0 of
PORTB
00000001 00021 RB1 EQU 1 ;RB1 of
PORTB
00000002 00022 RB2 EQU 2 ;RB2 of
PORTB
00000005 00023 RB5 EQU 5 ;RB5 of
PORTB
00000007 00024 RB7 EQU 7 ;RB7 of
PORTB
00025
00026 ;**************** Program Start
***********************
0000 00027 ORG 0 ;Reset
Vector
0000 2805 00028 GOTO INIT
0004 00029 ORG 4 ;Interrupt
Vector
0004 018B 00030 CLRF INTCON ;Clear
Interruption reg
00031
00032 ;**************** Initial Process
*********************
0005 00033 INIT
0005 1683 00034 BSF STATUS,RP0 ;Change to
Bank1
0006 0185 00035 CLRF TRISA ;Set PORTA
all OUT
0007 3027 00036 MOVLW B'00100111'
;RB0,1,2.5=IN RB7=OUT
0008 0086 00037 MOVWF TRISB ;Set PORTB
0009 3080 00038 MOVLW B'10000000' ;RBPU=1 Pull
up not use
000A 0081 00039 MOVWF OPTION_REG ;Set
OPTION_REG
000B 1283 00040 BCF STATUS,RP0 ;Change to
Bank0
000C 018C 00041 CLRF MODE ;Set mode =
stop
000D 018D 00042 CLRF COUNT1 ;Clear
counter
000E 018E 00043 CLRF COUNT2 ;Clear
counter
000F 3005 00044 MOVLW B'00000101' ;Set PORTA
initial value
0010 0085 00045 MOVWF PORTA ;Write PORTA
0011 1786 00046 BSF PORTB,RB7 ;Set RB7 = 1
0012 1A86 00047 BTFSC PORTB,RB5 ;RB5 = 0 ?
0013 2812 00048 GOTO $-1 ;No. Wait
00049
0014 00050 START
MPASM 02.50.02 Intermediate STEP.ASM 3-9-2001 23:52:45
PAGE 2
Errors : 0
Warnings : 0 reported, 0 suppressed
Messages : 0 reported, 0 suppressed
Processing explanation of Stepper Motor
controller
Label definition
;**************** Label Definition ********************
cblock h'0c'
The data area is automatically assigned from 0ch by CBLOCK directive. ENDC is used for the
ending of assignment.
The purpose of each data area is shown below.
Label Purpose
This is the area which manages the condition of the motor control.
mode :
0=Stop, 1=Clockwise, 2=Counterclockwise
This is the count area to make control waiting time.
count1 :
It counts 1 millisecond five times and 5 milliseconds are made.
count2 : This is the counter to make 1 millisecond.
Program start
;**************** Program Start ***********************
Instruction is executed from Zero addresses of the program memory when making the
power ON of the PIC. When there is interruption processing, processing is begun from
the addresse 4. Because it isn't using interruption this time, there is not program
execution from the addresse 4. It makes the interruption prohibition condition if the
interruption occurs. It isn't necessary to do this processing.
Initialization process
;**************** Initial Process *********************
The following processing is done as the processing of being initialized after the turning
on.
The initialization of the mode of port A
All ports are set to output mode.
Port A initialization
It sets 0101 as the initial state of port A. Because it drives with the transistor, the
logic reverses. It is in the condition, =H =L =H =L, from the bit on the
left.
The charging of a capacitor for the speed control and the confirmation process
It makes RB7 an L level and it begins charging the capacitor. It confirms that the
charging completes by RB5. It is completion if RB5 becomes H level. Correctly, it
is not charging completion and it is the fact that the voltage of the capacitor
became above the threshold voltage of RB5.
The most low speed can make the turn which was more slowly if it makes the value of
the capacitor for the speed control big.
Because the full speed is the speed that the turn stops when applying a few loads, it isn't
practical. Because the mass of rotor of the motor is related, this is the speed limitation
of this motor.