wifi robot car with gripper arm

Status
Not open for further replies.

ashraf858

New Member
hi every one i am new here but i hope to have a solution to my problem
i have made the wifi robot controlled via linksys router with pic16f877a and i want to add an owi arm with gripper on the car so , the idea is to set one bit on port when specific character come from the serial of the router like 'a' . as i have 5 motors for the arm . the code is written in assembly .
please advice as my project will send next week.
thanks to all



#define DEBUG 0
greenLED equ b'00001000' ;8, RC3
redLED equ b'00010000' ;16, RC4
horn equ b'00100000' ;32, RC5


right equ b'00001000' ;8, RB3
left equ b'00000100' ;4, RB2
back equ b'00000010' ;2, RB1
forward equ b'00000001' ;1 RB0



; 16F877a PWM example code
;
; Device 16F877a
LIST p=16f877a
#include "P16f877A.INC"
__CONFIG _BODEN_ON & _CP_OFF & _CPD_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _XT_OSC

errorlevel 0,-302 ;eliminate bank warning


CBLOCK 0x20 ; Declare variable addresses starting at 0x20
dataL
in_char
temp
temp2
d1
d2

ENDC
org 0X00 ; Program starts at 0x000
;
; --------------------------------
; set ANALOG/DIGITAL INPUTS PORT A
; --------------------------------
;
bsf STATUS,RP0
BANKSEL ADCON1
movlw 0x06
movwf ADCON1
BANKSEL PORTA

; ----------------
; INITIALIZE PORTS
; ----------------
;

movlw b'00000000' ; set up portB
movwf PORTB

movlw b'00000000' ; SET UP PORTA
movwf PORTA


movlw b'01000000' ; RC6(TX)=1 others are 0
movwf PORTC

movlw b'00000000'
movwf PORTD

bsf STATUS,RP0 ; RAM PAGE 1

movlw 0x00
movwf TRISB ; portB all pins output

movlw 0x00 ;porta all pins output
movwf TRISA

movlw b'10000000' ; RC7(RX)=input, others output
movwf TRISC

movlw 0x00
movwf TRISD

; ------------------------------------
; set BAUD RATE TO COMMUNICATE WITH PC
; ------------------------------------
; Boot Baud Rate = 9600, No Parity, 1 Stop Bit
;
movlw 0x19 ; 0x19=9600 bps (0x0C=19200 bps)
movwf SPBRG
movlw b'00100100' ; brgh = high (2)
movwf TXSTA ; enable Async Transmission, set brgh

bcf STATUS,RP0 ; RAM PAGE 0

movlw b'10010000' ; enable Async Reception
movwf RCSTA
;
; ------------------------------------
; PROVIDE A setTLING TIME FOR START UP
; ------------------------------------
;
clrf dataL
settle decfsz dataL,F
goto settle

movf RCREG,W
movf RCREG,W
movf RCREG,W ; flush receive buffer
;
; ---------
; MAIN LOOP
; ---------
;
clrf PORTD
movlw redLED
movwf PORTC

call message ; prints out a message if DEBUG is 1
call check_init ; wait for INIT message from WRT54GL
bcf PORTC,4
bsf PORTC,3
loop call receive_delay ; wait for a char
call add_green ;set greenLED on
call process_input ;make sure that forward and backward
;aren't both high!
;or that greenLED and redLED aren't both high!
;or that left and right aren't both high!
call send ; send the char
goto loop

process_input
; Make sure that Forward & Backward cannot be ON at the same time
; Make sure that Left & Right cannot be ON at the same time
; car control
movwf temp
btfsc temp,0
bcf temp,1
btfsc temp,2
bcf temp,3
movf temp,0
andlw 0x0f
movwf PORTB
movf temp,0
;what to do here to control arm.
;??????????????????????????

return

add_green
movwf temp
btfss temp,4 ;If greenLED is LOW execute next line
bsf temp,4
bcf temp,5
return

check_init
; waits to receive 'jbpro' from the router meaning that the software is up and running
; after the message is received, the greenLED is turned on and microcontroller can drive the car
call receive_delay
sublw A'j'
btfss STATUS, Z
goto check_init
call receive_delay
sublw A'b'
btfss STATUS, Z
goto check_init
call receive_delay
sublw A'p'
btfss STATUS, Z
goto check_init
call receive_delay
sublw A'r'
btfss STATUS, Z
goto check_init
call receive_delay
sublw A'o'
btfss STATUS, Z
goto check_init

receive_delay
;299993 cycles
movlw 0x5E
movwf d1
movlw 0xEB
movwf d2
delay_0 btfsc PIR1,RCIF ;check for serial data
goto got_data ;if we do, goto got_data!
decfsz d1, f
goto $+2
decfsz d2, f
goto delay_0
movlw 0x00
return

got_data ;move data in to W
btfsc PIR1,RCIF
movf RCREG,W
return

;#if DEBUG
Delay
movlw d'250' ;delay 250 ms (4 MHz clock)
movwf temp
d11 movlw 0xC7
movwf d1
movlw 0x01
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0

decfsz temp,f
goto d11
retlw 0x00
;#endif
;
; -------------------------------------------------------------
; SEND CHARACTER IN W VIA RS232 AND WAIT UNTIL FINISHED SENDING
; -------------------------------------------------------------
;

send movwf TXREG ; send data in W

TransWt bsf STATUS,RP0 ; RAM PAGE 1
WtHere btfss TXSTA,TRMT ; (1) transmission is complete if hi
goto WtHere

bcf STATUS,RP0 ; RAM PAGE 0
return
;
; -------
; MESSAGE
; -------
;

message
movlw '1'
call send
movlw '6'
call send
movlw 'F'
call send
movlw '8'
call send
movlw '7'
call send
movlw '7'
call send
movlw ' '
call send
movlw 'a'
call send
movlw 'l'
call send
movlw 'i'
call send
movlw 'v'
call send
movlw 'e'
call send
movlw 0x0D ; CR
call send
movlw 0x0A ; LF
call send
return

END
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…