pic16f628a stepper motor (1)

‘PROGRAM NAME: CONTROLLER
‘AUTHOR: NIGEL (LEDLABS)
‘A PROGRAM TO TURN A STEPPER MOTOR
‘DATE WRITTEN: 18/6/07
‘LANGUAGE: PIC BASIC COMPILER
‘VERSION: 1A
‘STEPPER MOTOR: DEGREES STEP/RESOLUTION   low power ‘like  5V 4-PHASE 28BYJ-48
‘PIC MICROCONTROLLER: 16F628A

output 4 ‘ unused pins set as outputs
output 5 ‘ to avoid floating inputs
output 7 ‘ and pickup

b5 = 0 ‘working button variable set zero

SYMBOL delay = B0 ‘ use b0 as the delay variable
delay = 175 ‘ set the delay to 175msecs

loop:

for B2 = 1 TO 2046 ‘loop counter

HIGH 0 ‘ turn on transistor1
PAUSE delay ‘ wait 175 ms
LOW 0 ‘ turn off transistor1
HIGH 1 ‘ turn on transistor2
PAUSE delay ‘ wait 175 ms
LOW 1 ‘ turn off transistor2
HIGH 2 ‘ turn on transistor3
PAUSE delay ‘ wait 175 ms
LOW 2 ‘ turn off transistor3
HIGH 3 ‘ turn on transistor4
PAUSE delay ‘ wait 175 ms
LOW 3 ‘ turn off transistor4

next B2

for b3 = 1 to 2046 ‘loop counter

high 3 ‘ turn on Q4
pause delay ‘ wait for delay ms
low 3 ‘ turn off Q4
high 2 ‘ turn on Q3
pause delay ‘ wait for delay ms
low 2 ‘ turn off Q3
high 1 ‘ turn on Q2
pause delay ‘ wait for delay ms
low 1 ‘ turn off Q2
high 0 ‘ turn on Q1
pause delay ‘ wait for delay ms
low 0 ‘ turn off Q1
next b3
pause 1000
goto loop

end

THIS SMALL PROGRAM ALOWS A STEPPER MOTOR LIKE THE LOW POWER  STEPPER MOTOR 5V 4-PHASE 28BYJ-48 TO ROTATE IN ONE DIRECTION THEN THE OTHER, THIS CAN BE USED FOR LEDLABS ON BOARD MOTOR
AND WAS WRITTEN IN PIC BASIC COMPILER, THE LOOP COUNTER VALUES CAN BE CHANGED WHICH WILL AFFECT THE AMOUNT OF DISTANCE IT TRAVELS IN ONE
DIRECTION AS IT LOOPS THROUGH THE CODE. THE OTHER FACTOR WHICH WOULD MAKE A DIFFERENCE TO THE DISTANCE TRAVELED AND LOOP COUNTER VALUES
IS THE STEP RESOLUTION OF THE MOTOR ITSELF.
THE PIC 16F628A HAS INTERNAL OSCILLATORS, SO DOES NOT REQUIRE EXTERNAL CRYSTAL OSCILLATORS. THE 4 OUTPUTS FROM THE PIC, 0,1,2,3, ARE THE PINS AND SHOULD BE THE INPUTS TO THE STEPPER MOTOR MODULE ON LEDLABS.
THIS TYPE OF MICRO-CONTROLLER SHOULD BE PROGRAMMED/COMPILED IN THE PIC RANGE OF SOFTWARE ENVIRONMENTS

CIRCUIT DIAGRAM TO FOLLOW 8/9.2016 LEDLABS

picdiagram
THE BUTTON SECTION IS ONLY REQUIRED FOR STEPPER PROJECT 2, SO CAN BE OMITTED HERE