روبوت الى بالميكروكونترولر
صفحة 1 من اصل 1
روبوت الى بالميكروكونترولر
السلام عليكم و رحمه الله
اليكم دائره روبوت متحرك يعمل بالمايكروكنترولر pic16f84
و هو تصميم لربوت متحرك يتحرك بحريه دون ان يصطدم بالاشياء و يعتمد على البرنامج المدخل الى عقل الروبوت و هو المايكرو كنترولر
و الدائره الخاصه بالروبوت كالاتى
http://www.electvillage.com/up05/up/cerb_sch.gif
اما برنامج المايكروكونترولر فهو كالاتى
;CERBERES : MINI ROBOT WITH IR EYES ;
;USES PIC16F84 CONTROLLER ;
;WRITTEN IN MICROCHIP ASSEMBLY USE MPASM ASSEMBLER FROM MPLAB ;
;MPLAB CAN BE DOWNLOADED FROM WWW.MICROCHIP.COM ;
;***SET UP THE CONTANTS & VARIABLES****
LIST P=16C84
ERRORLEVEL -302 ;SUPPRESS BANK SELECTION MESSAGES
STATUS EQU H'03' ;STATUS REGISTER
TRISB EQU H'86' ;TRISB REGISTER FOR SETUP OF PORTB
PORTB EQU H'06' ;PORTB REGISTER TO DRIVE PORT B
COUNT1 EQU H'0C' ;COUNT VARIABLE 1 IS IN GENERAL PURPOSE REG 08H
COUNT2 EQU H'0D' ;COUNT VARIABLE 2 IS IN GENERAL PURPOSE REG 09H
;***SET UP PORT B IN & OUTPUT****
BSF STATUS,5 ;SWITCH TO BANK0 TO SET UP PORT B
MOVLW B'11110000' ;RB7,6,5,4 IS INPUT
MOVWF TRISB ;RB3,2,1,0 IS OUTPUT
BCF STATUS,5 ;SWITCH BACK TO BANK0 TO USE PORT B
;***MAIN PROGRAM****
START MOVLW B'00000101' ;MAKE RB0&2 HIGH: MOVE FORWARD
MOVWF PORTB ;
MOVLW H'FE' ;RESET COUNT1 TO 254
MOVWF COUNT1 ;
MOVLW H'FE' ;RESET COUNT2 TO 254
MOVWF COUNT2 ;
BTFSS PORTB,5 ;CHECK RB5 (INPUT); IF IT IS LOW
CALL BACKL ;THEN EXECUTE BACKLEFT ROUTINE
BTFSS PORTB,6 ;CHECK RB6 (INPUT); IF IT IS LOW
CALL BACKR ;EXECUTE BACKRIGHT ROUTINE
GOTO START ;RETURN TO LABEL START
;***BACKLEFT ROUTINE****
BACKL MOVLW B'00001010' ;MAKE RB1&3 HIGH: MOVE BACKWARD
MOVWF PORTB ;
CALL DELAY ;
MOVLW B'00001001' ;MAKE RB2&3 HIGH: ROTATE LEFT
MOVWF PORTB ;
CALL DELAY ;
RETURN
;***BACKRIGHT ROUTINE****
BACKR MOVLW B'00001010' ;MAKE RB1&3 HIGH: MOVE BACKWARD
MOVWF PORTB ;
CALL DELAY ;
MOVLW B'00000110' ;MAKE RB2&3 HIGH: ROTATE RIGHT
MOVWF PORTB ;
CALL DELAY ;
RETURN
DELAY MOVLW H'EE' ;RESET ALL COUNTER VARIABLES
MOVWF COUNT1
MOVLW H'99'
MOVWF COUNT2
LOOP1 CLRWDT ;RESET THE WATCHDOG TIMER
DECFSZ COUNT1,1 ;this is a delay loop
GOTO LOOP1 ;tuned to make Cerberes
DECFSZ COUNT2,1 ;turn about 90 degrees
GOTO LOOP1
RETURN
END;
اما برنامج المايكروكونترولر فهو كالاتى
;CERBERES : MINI ROBOT WITH IR EYES ;
;USES PIC16F84 CONTROLLER ;
;WRITTEN IN MICROCHIP ASSEMBLY USE MPASM ASSEMBLER FROM MPLAB ;
;MPLAB CAN BE DOWNLOADED FROM WWW.MICROCHIP.COM ;
;***SET UP THE CONTANTS & VARIABLES****
LIST P=16C84
ERRORLEVEL -302 ;SUPPRESS BANK SELECTION MESSAGES
STATUS EQU H'03' ;STATUS REGISTER
TRISB EQU H'86' ;TRISB REGISTER FOR SETUP OF PORTB
PORTB EQU H'06' ;PORTB REGISTER TO DRIVE PORT B
COUNT1 EQU H'0C' ;COUNT VARIABLE 1 IS IN GENERAL PURPOSE REG 08H
COUNT2 EQU H'0D' ;COUNT VARIABLE 2 IS IN GENERAL PURPOSE REG 09H
;***SET UP PORT B IN & OUTPUT****
BSF STATUS,5 ;SWITCH TO BANK0 TO SET UP PORT B
MOVLW B'11110000' ;RB7,6,5,4 IS INPUT
MOVWF TRISB ;RB3,2,1,0 IS OUTPUT
BCF STATUS,5 ;SWITCH BACK TO BANK0 TO USE PORT B
;***MAIN PROGRAM****
START MOVLW B'00000101' ;MAKE RB0&2 HIGH: MOVE FORWARD
MOVWF PORTB ;
MOVLW H'FE' ;RESET COUNT1 TO 254
MOVWF COUNT1 ;
MOVLW H'FE' ;RESET COUNT2 TO 254
MOVWF COUNT2 ;
BTFSS PORTB,5 ;CHECK RB5 (INPUT); IF IT IS LOW
CALL BACKL ;THEN EXECUTE BACKLEFT ROUTINE
BTFSS PORTB,6 ;CHECK RB6 (INPUT); IF IT IS LOW
CALL BACKR ;EXECUTE BACKRIGHT ROUTINE
GOTO START ;RETURN TO LABEL START
;***BACKLEFT ROUTINE****
BACKL MOVLW B'00001010' ;MAKE RB1&3 HIGH: MOVE BACKWARD
MOVWF PORTB ;
CALL DELAY ;
MOVLW B'00001001' ;MAKE RB2&3 HIGH: ROTATE LEFT
MOVWF PORTB ;
CALL DELAY ;
RETURN
;***BACKRIGHT ROUTINE****
BACKR MOVLW B'00001010' ;MAKE RB1&3 HIGH: MOVE BACKWARD
MOVWF PORTB ;
CALL DELAY ;
MOVLW B'00000110' ;MAKE RB2&3 HIGH: ROTATE RIGHT
MOVWF PORTB ;
CALL DELAY ;
RETURN
DELAY MOVLW H'EE' ;RESET ALL COUNTER VARIABLES
MOVWF COUNT1
MOVLW H'99'
MOVWF COUNT2
LOOP1 CLRWDT ;RESET THE WATCHDOG TIMER
DECFSZ COUNT1,1 ;this is a delay loop
GOTO LOOP1 ;tuned to make Cerberes
DECFSZ COUNT2,1 ;turn about 90 degrees
GOTO LOOP1
RETURN
END;
تظهر فى هذه الصوره تصميم عين الروبوت
http://www.electvillage.com/up05/up/sensor.gif
اليكم دائره روبوت متحرك يعمل بالمايكروكنترولر pic16f84
و هو تصميم لربوت متحرك يتحرك بحريه دون ان يصطدم بالاشياء و يعتمد على البرنامج المدخل الى عقل الروبوت و هو المايكرو كنترولر
و الدائره الخاصه بالروبوت كالاتى
http://www.electvillage.com/up05/up/cerb_sch.gif
اما برنامج المايكروكونترولر فهو كالاتى
;CERBERES : MINI ROBOT WITH IR EYES ;
;USES PIC16F84 CONTROLLER ;
;WRITTEN IN MICROCHIP ASSEMBLY USE MPASM ASSEMBLER FROM MPLAB ;
;MPLAB CAN BE DOWNLOADED FROM WWW.MICROCHIP.COM ;
;***SET UP THE CONTANTS & VARIABLES****
LIST P=16C84
ERRORLEVEL -302 ;SUPPRESS BANK SELECTION MESSAGES
STATUS EQU H'03' ;STATUS REGISTER
TRISB EQU H'86' ;TRISB REGISTER FOR SETUP OF PORTB
PORTB EQU H'06' ;PORTB REGISTER TO DRIVE PORT B
COUNT1 EQU H'0C' ;COUNT VARIABLE 1 IS IN GENERAL PURPOSE REG 08H
COUNT2 EQU H'0D' ;COUNT VARIABLE 2 IS IN GENERAL PURPOSE REG 09H
;***SET UP PORT B IN & OUTPUT****
BSF STATUS,5 ;SWITCH TO BANK0 TO SET UP PORT B
MOVLW B'11110000' ;RB7,6,5,4 IS INPUT
MOVWF TRISB ;RB3,2,1,0 IS OUTPUT
BCF STATUS,5 ;SWITCH BACK TO BANK0 TO USE PORT B
;***MAIN PROGRAM****
START MOVLW B'00000101' ;MAKE RB0&2 HIGH: MOVE FORWARD
MOVWF PORTB ;
MOVLW H'FE' ;RESET COUNT1 TO 254
MOVWF COUNT1 ;
MOVLW H'FE' ;RESET COUNT2 TO 254
MOVWF COUNT2 ;
BTFSS PORTB,5 ;CHECK RB5 (INPUT); IF IT IS LOW
CALL BACKL ;THEN EXECUTE BACKLEFT ROUTINE
BTFSS PORTB,6 ;CHECK RB6 (INPUT); IF IT IS LOW
CALL BACKR ;EXECUTE BACKRIGHT ROUTINE
GOTO START ;RETURN TO LABEL START
;***BACKLEFT ROUTINE****
BACKL MOVLW B'00001010' ;MAKE RB1&3 HIGH: MOVE BACKWARD
MOVWF PORTB ;
CALL DELAY ;
MOVLW B'00001001' ;MAKE RB2&3 HIGH: ROTATE LEFT
MOVWF PORTB ;
CALL DELAY ;
RETURN
;***BACKRIGHT ROUTINE****
BACKR MOVLW B'00001010' ;MAKE RB1&3 HIGH: MOVE BACKWARD
MOVWF PORTB ;
CALL DELAY ;
MOVLW B'00000110' ;MAKE RB2&3 HIGH: ROTATE RIGHT
MOVWF PORTB ;
CALL DELAY ;
RETURN
DELAY MOVLW H'EE' ;RESET ALL COUNTER VARIABLES
MOVWF COUNT1
MOVLW H'99'
MOVWF COUNT2
LOOP1 CLRWDT ;RESET THE WATCHDOG TIMER
DECFSZ COUNT1,1 ;this is a delay loop
GOTO LOOP1 ;tuned to make Cerberes
DECFSZ COUNT2,1 ;turn about 90 degrees
GOTO LOOP1
RETURN
END;
اما برنامج المايكروكونترولر فهو كالاتى
;CERBERES : MINI ROBOT WITH IR EYES ;
;USES PIC16F84 CONTROLLER ;
;WRITTEN IN MICROCHIP ASSEMBLY USE MPASM ASSEMBLER FROM MPLAB ;
;MPLAB CAN BE DOWNLOADED FROM WWW.MICROCHIP.COM ;
;***SET UP THE CONTANTS & VARIABLES****
LIST P=16C84
ERRORLEVEL -302 ;SUPPRESS BANK SELECTION MESSAGES
STATUS EQU H'03' ;STATUS REGISTER
TRISB EQU H'86' ;TRISB REGISTER FOR SETUP OF PORTB
PORTB EQU H'06' ;PORTB REGISTER TO DRIVE PORT B
COUNT1 EQU H'0C' ;COUNT VARIABLE 1 IS IN GENERAL PURPOSE REG 08H
COUNT2 EQU H'0D' ;COUNT VARIABLE 2 IS IN GENERAL PURPOSE REG 09H
;***SET UP PORT B IN & OUTPUT****
BSF STATUS,5 ;SWITCH TO BANK0 TO SET UP PORT B
MOVLW B'11110000' ;RB7,6,5,4 IS INPUT
MOVWF TRISB ;RB3,2,1,0 IS OUTPUT
BCF STATUS,5 ;SWITCH BACK TO BANK0 TO USE PORT B
;***MAIN PROGRAM****
START MOVLW B'00000101' ;MAKE RB0&2 HIGH: MOVE FORWARD
MOVWF PORTB ;
MOVLW H'FE' ;RESET COUNT1 TO 254
MOVWF COUNT1 ;
MOVLW H'FE' ;RESET COUNT2 TO 254
MOVWF COUNT2 ;
BTFSS PORTB,5 ;CHECK RB5 (INPUT); IF IT IS LOW
CALL BACKL ;THEN EXECUTE BACKLEFT ROUTINE
BTFSS PORTB,6 ;CHECK RB6 (INPUT); IF IT IS LOW
CALL BACKR ;EXECUTE BACKRIGHT ROUTINE
GOTO START ;RETURN TO LABEL START
;***BACKLEFT ROUTINE****
BACKL MOVLW B'00001010' ;MAKE RB1&3 HIGH: MOVE BACKWARD
MOVWF PORTB ;
CALL DELAY ;
MOVLW B'00001001' ;MAKE RB2&3 HIGH: ROTATE LEFT
MOVWF PORTB ;
CALL DELAY ;
RETURN
;***BACKRIGHT ROUTINE****
BACKR MOVLW B'00001010' ;MAKE RB1&3 HIGH: MOVE BACKWARD
MOVWF PORTB ;
CALL DELAY ;
MOVLW B'00000110' ;MAKE RB2&3 HIGH: ROTATE RIGHT
MOVWF PORTB ;
CALL DELAY ;
RETURN
DELAY MOVLW H'EE' ;RESET ALL COUNTER VARIABLES
MOVWF COUNT1
MOVLW H'99'
MOVWF COUNT2
LOOP1 CLRWDT ;RESET THE WATCHDOG TIMER
DECFSZ COUNT1,1 ;this is a delay loop
GOTO LOOP1 ;tuned to make Cerberes
DECFSZ COUNT2,1 ;turn about 90 degrees
GOTO LOOP1
RETURN
END;
تظهر فى هذه الصوره تصميم عين الروبوت
http://www.electvillage.com/up05/up/sensor.gif
صفحة 1 من اصل 1
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى