;************************************************************* ;Name: Robot Driver Program ; ;Author: Dan Kohn ; ;Date: 10/28/2005 ; ;Modified: 11/13/06 - Replaced 5 sec delay ; with subroutine. ; ; Replaced Port number with equate. ; ;Instructions: Do Not turn on Robot Arm until program ; is running! Then turn it on and press any ; key. Robot will move in the pre-defined ; sequence (s0..sx) and then repeat the ; sequence. Each step will last aprox 5 sec. ; org 100h port equ 378h mov al, all_stop ;turn off all motors mov dx,port out dx, al mov dx, offset msg ;print message mov ah, 9 int 21h mov ah,00h ;wait for 'any key' int 16h mov si, offset s0 next: mov al, [si] mov dx,port out dx, al call time_delay ;wait 5 sec inc si ;next situation cmp si, sx jb next mov ah,01h ;if q pressed end int 16h cmp al,'q' je exit mov si, offset s0 jmp next exit: ret ;************************************************************* ;Name: TIME_DELAY ; ;Author: Dan Kohn ; ;Date: 10/30/2005 ; ;Revised: 10/31/2005 ; PUSHA does not work on Toshiba XT Compatable ; laptop. Replaced with individual push and pops. ; ;Function: Wait for aprox 5 seconds then return to the ; calling code ; ;On Call: NONE ; ;On Return: All Registers Restored time_delay: push ax ;put all reg on stack for restore push bx push cx push dx mov ah,00 ;get system time int 1ah ;(CX:DX = number of clock ;ticks since midnigh) ;[18.20648 ticks = 1 sec) add dx,005ah ;add 90 ticks (~5 sec) mov bx,dx ;store for compare t_loop: mov ah,00 ;loop until system time > Last int 1ah ;time + 5 sec cmp bx,dx jg t_loop pop dx ;restore all registers pop cx pop bx pop ax RET ; 7654_3210 s0 db 0000_1111b ;gripper open s1 db 0000_0100b ;wrist cw s2 db 0001_0111b ;elbow up s3 db 0010_0111b ;base cw ;s4 db 0000_0011b ;shoulder up s5 db 0000_0000b ;gripper close s6 db 0000_0001b ;elbow down s7 db 1000_0111b ;wrist ccw ;s8 db 0100_0111b ;shoulder down s9 db 0000_0010b ;base ccw sa db 0000_0111b ;stop sx = $ all_stop equ 0000_0111b msg db "Turn on Robot Arm and then press any key to continue",10,13,"Press Q to stop robot at end of sequence. $"