PDA

View Full Version : Beam Switches for Laser Table



djdevnull
- 4th May 2007, 15:59
This is a simple beam switch using a 16F628 and two steppers.

'************************************************* ***************
'* Name : Stepper1.BAS *
'* Author : Myron Labrecque *
'* Notice : Copyright (c) 2007 Myron Labrecque *
'* : All Rights Reserved *
'* Date : 12/25/2006 *
'* Version : 1.0 *
'* Notes : This is for a Beam Switch *
'* : Can Control 2 Steppers at once *
'************************************************* ***************

@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F628, WDT_OFF
' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F628, BOD_OFF
' Brown-Out Detect
@ DEVICE pic16F628, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628, CPD_OFF
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
' Set to CPD_ON for Release Copy
@ DEVICE pic16F628, PROTECT_OFF
' Program Code Protection
' Set to PROTECT_OFF for Development Copy
' Set to PROTECT_ON for Release Copy

start:


' set variables:
x VAR BYTE
steps4 VAR WORD
steps6 VAR WORD
stepspause var byte

clear
TRISA = %11111111
TRISB = %00000000
PORTB = 255
stepspause = 10

Pause 1000



main:
IF porta.4 = 1 THEN


if steps4 = 0 then
portb = %00001010
pause stepspause
portb = %00000110
pause stepspause
portb = %00000101
pause stepspause
portb = %00001001
steps4 = 1
ENDIF
ELSE
if steps4 = 1 then
portb = %00001001
pause stepspause
portb = %00000101
pause stepspause
portb = %00000110
pause stepspause
portb = %00001010
steps4 = 0
endif

ENDIF
IF porta.6 = 1 THEN
if steps6 = 0 then
portb = %10100000
pause stepspause
portb = %01100000
pause stepspause
portb = %01010000
pause stepspause
portb = %10010000
steps6 = 1
ENDIF
else
if steps6 = 1 then
portb = %10010000
pause stepspause
portb = %01010000
pause stepspause
portb = %01100000
pause stepspause
portb = %10100000
steps6 = 0
endif
endif
GoTo main

mister_e
- 4th May 2007, 16:02
Hi and welcome on the forum.

Thanks for your code example ! It will be handy for the other readers/member if you could explain a little bit more about your hardware. Schematic part # etc.