;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;*************************************************************************************@@
; Stepper Motor Test CKT!!							      @@
;---------------------------							      @@
;Steven Kosmerchock                                                                   @@
;Phoenix   Az,   USA								      @@
;www.geocities.com/researchtriangle/lab/6584					      @@
;-------------------------------------------------------------------------------------@@
;-----Revision History-----							      @@
;REV. 1.00A ****** 06/02/2000 SK (INITIAL RELEASE)				      @@
;										      @@
;										      @@
;										      @@
;---------------------------------***********-----------------------------------------@@
;******************************** MCKT_Tst.ASM ***************************************@@
;---------------------------------***********-----------------------------------------@@
;This circuit uses a, "ALLEGRO Semiconductor" ( www.allegromicro.com ) UDN2916B. I was@@
;lucky enough to be sampled them after requesting samples from their website. I used  @@
;a "MICROCHIP" ( www.microchip.com ) PIC16F84-04P running on a 4MHz crystal resonator.@@
;The motor I used was an "Eastern Air Devices" ( www.eadmotors.com ) LA23GCKG-B1      @@
;linear actuator.								      @@
;										      @@
;-------------------------------------------------------------------------------------@@
;Source name (.asm):	mckt_tst.asm						      @@
;Project name (.pjt):   mckt_tst.pjt						      @@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	INCLUDE		<p16F84.inc>
;
	title	"Stepper Motor Test Circuit"
;
	list	p=16F84
	radix	hex
;---------------------------------------------------------------------------------------
indf	equ	0x00
status	equ	0x03
fsr	equ	0x04
porta	equ	0x05
portb	equ	0x06
reg_b	equ	0x0c
reg_a	equ	0x0d
;
option_reg	equ	0x81
;
trisa	equ	0x85
trisb	equ	0x86
;---------------------------------------------------------------------------------------
W	equ	0
F	equ	1
z	equ	2
rp0	equ	5
;---------------------------------------------------------------------------------------
;
	__CONFIG	_XT_OSC & _PWRTE_ON & _CP_OFF & _WDT_OFF
			
;
	org	0x000
;---------------------------------------------------------------------------------------
	goto	main		;Go to beginning of 'MAIN' program!
;---------------------------------------------------------------------------------------
; Initialize "PIC"!!
init_pic:		
	clrf	porta		;clear "PORTA"
	clrf	portb		;clear "PORTB"
	nop
	bsf	status,rp0	;switch to 'bank1'.
	nop
	movlw	b'00000100'	;Fill "W" with 0x00!
	movwf	trisa		;Make "PORTA" all outputs!!
	movlw	0x00		;Fill "W" with 0's!
	movwf	trisb		;Make "PORTB" all outputs!!
	bcf	status,rp0	;switch back to 'bank0'.
	nop
	clrf	porta		;Make "PORTA" low!
	clrf	portb		;Make "PORTB" low!
	nop
	return			;Go back to where you came from!!
;--------------------------------------------------------------------------------------------------
c_clockwise_step_motor:		;"COUNTER CLOCKWISE!!!"
	nop
	movlw	0x00		;Full "power"!
	movwf	portb
	call	pause
;
	movlw	0x13
	movwf	portb
	call	pause
;
	movlw	0x1b
	movwf	portb
	call	pause
;
	movlw	0x1a
	movwf	portb
	call	pause
;
	goto	c_clockwise_step_motor	;
;
;--------------------------------------------------------------------------------------------------
clockwise_step_motor:			;"CLOCKWISE!!"
	nop
	movlw	0x00		;Full "power"!
	movwf	portb
	call	pause
;
	movlw	0x1a
	movwf	portb
	call	pause
;
	movlw	0x1b
	movwf	portb
	call	pause
;
	movlw	0x13
	movwf	portb
	call	pause
;
	goto	clockwise_step_motor	;
;
;--------------------------------------------------------------------------------------------------
main:
	call	init_pic		;Initialize PORTS!!
	call	c_clockwise_step_motor	;Start stepping motor!!
;--------------------------------------------------------------------------------------------------
pause:
	movlw	0x02
	movwf	reg_b
delay4:
	movlw	0xff
	movwf	reg_a
delay3:
	decfsz	reg_a,F
	goto	delay3
	decfsz	reg_b,F
	goto	delay4
	return
;--------------------------------------------------------------------------------------------------
	end
