Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/07/07 04:46
Read: times


 
#147960 - hope this helps
Responding to: ???'s previous message
motor_up:	bit p1.0  ;M1 and M2 is motor polarity
motor_down:	bit p1.1
top_limit:	bit p1.2  ;TLS=top limit switch
bottom_limit:	bit p1.3  ;BLS=bottom limit switch
start_Button:	bit p1.4


cycle_motor:

        clr Motor_up ;make sure motor is off
	clr Motor_down

$check_position
        jb bottom_limit,$set_position  ;make sure motor in pos.
$start	
	jb start_button,$up  ;wait for start button to be pushed
	jmp $start

$up	setb motor_up ;motor is at bottom
	jb top_limit,$up ;wait until reach top limit    
	clr motor_up ;stop motor from moving up
	setb motor_down ;start motor moving down

$down	jb bottom_limit,$down ;wait untill reach bottom limit
	clr motor_down
        ret ;operation is complete

;if motor not at bottom limit, set to be bottom limit and 
; jump to wait for start button
        
$set_position
        setb motor_down
$wait   jb bottom_limit,$wait ;wait untill reach bottom limit
	clr motor_down
        jmp $start	
end




List of 4 messages in thread
TopicAuthorDate
Assembler code for driving motor            01/01/70 00:00      
   hope this helps            01/01/70 00:00      
   start button?            01/01/70 00:00      
   you do need to debounce the switches            01/01/70 00:00      

Back to Subject List