Sherline 2000 CNC

 

3-8-2009 Update

I changed all three axii to Gecko, which has an active-low disable input.
Also changed to a PIC 16F648A from the PIC 16F628A, just because that was what I had available.

	  
; =============================================================
;          INCLUDE FILE FOR CNC-1
; =============================================================
		CBLOCK	20H
;-------------------------------------------------------
temp
temp2

var1
var2

countx
county
countz

flash
;-------------------------------------------------------
		ENDC

PORTA_SET       =    b'00000000'	; all output 
PORTB_SET       =    b'11100000'	; high bits are step input, rest output

OPTION_SET	=    b'11111111'	;don't really care
INTCON_SET	=    b'00000000'	;no interrupts

INDR		=	00h		;Indirect addressing register	
porta		EQU	 5
portb		EQU	 6

;	enable lines
#define		EX	porta,2
#define		EY	porta,0
#define		EZ	porta,3

;	step lines
#define		SX	portb,5
#define		SY	portb,6
#define		StepZ	portb,7

#define		RED	porta,1
	  
	  
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;		CNC-1 test    
; 		2-16-2002                                        
;
;		CNC-1.7   July 19, 2003
;		Updating August 25, 2003 for Gecko on X
;		Updating 3-8-2009 for  Gecko on Y and PIC16F648A
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

		list      p=16f648a            ; list directive to define processor
		include  p16f648a.inc          ; processor specific variable definitions
	
		__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _INTRC_OSC_CLKOUT & _MCLRE_OFF & _LVP_OFF

		INCLUDE cnc-1.h
		include macros.h

;---------------------------------------------------------------------------------------------
		ORG     0x000             ; processor reset vector
Main
		bsf	status,rp0	;select correct bank
		bcf	status,rp1

		movlw	PORTA_SET
		movwf	TRISA

		movlw	PORTB_SET
		movwf	TRISB

		movlw	OPTION_SET
		movwf	OPTION_REG

		movlw	INTCON_SET
		movwf	INTCON

		bcf	status,rp0	;select correct bank
		bcf	status,rp1
		movlf	CMCON,#7

;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;	Setup Variables
; 	For Gecko, clearing is disable


		bcf	EX
		bcf	EY
		bcf	EZ

		bsf		RED
		clrf	var1
setred	call	wait
		decfsz	var1,F
		goto	setred
		bcf		RED

		clrf	countx
		clrf	county
		clrf	countz
		
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;---------------------------------------------------------------
;	Main program
;		a) variables: countx,county,countz
;		b) check step lines x,y,z
;		  if step is low, zero corresponding variable and set enable
;
;		c) loop 255 times
;		d) increment countx,y,z if zero, set enablex,y,z	
;		e) loop 4ever

mainloop	

		btfsc	SX		;is X-step low?
		goto	xhigh	;no

		bsf	EX	;enable
		clrf	countx
;--------------
xhigh
		btfsc	SY		;is Y-step low?
		goto	yhigh	;no

		bsf	EY			;enable		G201
		clrf	county
;--------------
yhigh
		btfsc	StepZ	;is Z-step low?
		goto	zhigh	;no

		bsf	EZ			;enable		G201
		clrf	countz

;--------------
zhigh
		decfsz	var1,F	;loop thru 256 times
		goto	mainloop



;--------------------------------------------------------------
bottomloop

		incfsz	countx,F
		goto	xactive
		bcf	EX	;disable X
xactive		

		incfsz	county,F
		goto	yactive
		bcf	EY	;disable Y
yactive

		incfsz	countz,F
		goto	zactive
		bcf	EZ	;disable Z	G201
zactive

		incf	flash,F
		btfss   flash,7
		bsf	RED
		btfsc   flash,7
		bcf	RED

		goto	mainloop
;--*--*--*--*- -*--*- -*--*- -*--*- -*--*- -*--*- -*--*- -*--*- 

wait	movlf	temp2,#5
		clrf	temp
wait2	decfsz 	temp,F
		goto	wait2
		decfsz	temp2,F
		goto	wait2
   		return

		END                       
	  

4-27-2002

;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;		CNC-1 test    
; 		2-16-2003                                        
;
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

		list      p=16f628            ; list directive to define processor
		include  p16f628.inc          ; processor specific variable definitions
	
		__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _INTRC_OSC_CLKOUT & _MCLRE_OFF & _LVP_OFF

		INCLUDE cnc-1.h
		include macros.h

;---------------------------------------------------------------------------------------------
		ORG     0x000             ; processor reset vector

Main
		bsf	status,rp0	;select correct bank
		bcf	status,rp1

		movlw	PORTA_SET
		movwf	TRISA

		movlw	PORTB_SET
		movwf	TRISB

		movlw	OPTION_SET
		movwf	OPTION_REG

		movlw	INTCON_SET
		movwf	INTCON

		bcf	status,rp0	;select correct bank
		bcf	status,rp1
		movlf	CMCON,#7

;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;
;	Setup Variables

		clrf	var1
		clrf	var2

		bsf	EX
		bsf	EY
		bsf	EZ
		bsf	RED

setred		call	wait
		decfsz	var1,F
		goto	setred
		
		bcf	RED
		bcf	EX
		bcf	EY
		bcf	EZ

		clrf	countx
		clrf	county
		clrf	countz
		
;-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
;---------------------------------------------------------------
;	Main program
;		a) variables: countx,county,countz
;		b) check step lines x,y,z
;		  if step is low, zero corresponding variable and clr enable
;
;		c) loop 255 times
;		d) increment countx,y,z if zero, set enablex,y,z	
;		e) loop 4ever

mainloop

		btfsc	SX	;is X-step low?
		goto	xhigh	;no

		bcf	EX	;enable
		clrf	countx
;--------------
xhigh
		btfsc	SY	;is Y-step low?
		goto	yhigh	;no

		bcf	EY	;enable
		clrf	county
;--------------
yhigh
		btfsc	StepZ	;is Z-step low?
		goto	zhigh	;no

		bcf	EZ	;enable
		clrf	countz

;--------------
zhigh
		decfsz	var1,F	;loop thru 256 times
		goto	mainloop
		goto	bottomloop
;--------------------------------------------------------------
bottomloop

		incfsz	countx,F
		goto	xactive
		bsf	EX	;disable 
xactive		

		incfsz	county,F
		goto	yactive
		bsf	EY	;disable 
yactive

		incfsz	countz,F
		goto	zactive
		bsf	EZ	;disable 
zactive

		incf	flash,F
		btfss   flash,7
		bsf	RED
		btfsc   flash,7
		bcf	RED

		goto	mainloop
;--*--*--*--*- -*--*- -*--*- -*--*- -*--*- -*--*- -*--*- -*--*- 
		END                       
 
	  


[ Home | | Sherline Pages Home ]
Contents © 2025