DEVICE sx28l,oscxt5 DEVICE turbo,stackx_optionx RESET start FREQ 50_000_000 ; ; Variables ; org 8 Input ds 1 delay1 ds 1 delay2 ds 1 delay3 ds 1 steps ds 1 ; ; Equates ; cf_adjust = Input.6 M1CW = Input.0 M1CCW = Input.1 M2CW = Input.2 M2CCW = Input.3 M3CW = Input.4 M3CCW = Input.5 M1pin1 = rc.0 M1pin2 = rc.1 M2pin1 = rc.2 M2pin2 = rc.3 M3pin1 = rc.4 M3pin2 = rc.5 org 0 ; ; ;*************** ;* Subroutines * ;*************** ; ; ; ;Create an 8ms delay ; ;This is an approx time, though it can be accuratly calculated. ;The delay is required becuase the stepper motors can not respond ;to the impulses at full speed due to the short instruction time. ; delay mov delay3,#2 mov delay2,#150 :oloop clr delay1 :wloop djnz delay1,:wloop djnz delay2,:wloop djnz delay3,:oloop ret ; ;One big movement routine M1 M2 M3 all move one after another in any direction ; ;This should probably be split up into more routine but it works for now ;When the main program detects a change on the input bus the program comes ;here. What happens is this routine check the saved input information and ;then begine to determine what needs to happen as far as movement in concerned. ;Since we defined our directions as bits of the input value we can make use ;of the sb (Skip if src_bit is set). If the bit is not set,i.e. the switch is ;activated, the program then preforms the excitation sequence for the stepper. ;The way the excitation sequence goes is this: ;for CW rotation pin1=1,(8ms),pin2=1,(8ms),pin1=0,(8ms),pin2=0,(8ms) repeat ;for CCW the sequence is reversed. ;the way that this routine is written allows for all three motors to step at ;virtually the same time. ;The combination of the CW and CCW sequence does not cause problems if both ;switches are somehow activated both CW and CCW movement is attempted which ;in effect, cancel each other out. ; ; move sb cf_adjust call slow :loop sb M1CW setb M1pin1 sb M2CW setb M2pin1 sb M3CW setb M3pin1 sb M1CCW setb M1pin2 sb M2CCW setb M2pin2 sb M3CCW setb M3pin2 call delay sb M1CW setb M1pin2 sb M2CW setb M2pin2 sb M3CW setb M3pin2 sb M1CCW setb M1pin1 sb M2CCW setb M2pin1 sb M3CCW setb M3pin1 call delay sb M1CW clrb M1pin1 sb M2CW clrb M2pin1 sb M3CW clrb M3pin1 sb M1CCW clrb M1pin2 sb M2CCW clrb M2pin2 sb M3CCW clrb M3pin2 call delay sb M1CW clrb M1pin2 sb M2CW clrb M2pin2 sb M3CW clrb M3pin2 sb M1CCW clrb M1pin1 sb M2CCW clrb M2pin1 sb M3CCW clrb M3pin1 call delay djnz steps,:loop jmp read ; ;when the cf_adjust switch is used in conjunction with a movement ;Set steps to 1, default is 5 ; ; slow clr steps mov steps,#1 ret ; ; ; ; ; ;******** ;* Main * ;******** ; ; start mov ra,#%0000 mov rb,#%00000000 mov rc,#%00000000 MODE $0F mov !rb,#%11111111 ;setup our ports rb is input rc output mov !rc,#%00000000 read clr steps ;every cycle the nuber of steps per contact is 5 mov steps,#5 ;an important note to remeber, the inputs are high (state 1) mov Input,rb ;*unless* the switches are closed/activated snb cf_adjust ;if the cf button is not depressed call compare ;skip the secondary compare routine cjb input,#%00111111,move ;compare the input reading to this state jmp read ;which corresponds to no input if there is input ;then we go to move, this allows for other programs to run here compare cjb input,#%01111111,move
file: /Techref/scenix/lib/io/dev/stepper/3steppers-ja_files/sxlistcontest.txt, 3KB, , updated: 2002/4/23 10:41, local time: 2024/12/27 18:51,
18.118.120.13:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/TECHREF/scenix/lib/io/dev/stepper/3steppers-ja_files/sxlistcontest.txt"> scenix lib io dev stepper 3steppers-ja_files sxlistcontest</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.