I am using the same microcontroller(PIC16F877A) for miRover2 as I did for
Although a lot of the code has been changed.
The code is written in 'C' and complied in Microchips MPLAB(link) with HITECH PICClite.
NOTE: these are newer versions than the one I am using.
Some of the major changes include, passing miRover2's direction changes to another microcontroller. The direction and speed are passed to this microcontroller. via a USART connection, which now leaves the whole of PORTB free. The cmd's are similar to the ones sent to the RF device(link), 'WW' + direction(f, b, l, r, s), and 'ZZ' for speed.
So now PORTB is used to check the front and rear bumper status. There are now 3 switches to each bumper, which uses 6 pins of PORTB.
Another major change, is turning to a heading rather than to a time. On miRover when
an obstacle was detected it would turn, either left or right for about 2 seconds, then move forward.
So now with miRover2, when a sensor is triggered, it will get the current heading, add/subtract T_MOVE(30 degrees) and turn to the new heading +/- T_TOL(5 degrees), this does seem to work a lot better.
I have reduced the number of possible moves miRover2 can make after an obstacle detection or a collision.
I'm trying a new xtal 11.0592Mhz, which gives a 0 error for baudrate speed and will match for bluetooth connection in the future. So the bluetooth will use a baudrate of 115200(SPBERG 5, BRGH 1) to send data to a computer, then change to 9600(SPBERG 71, BRGH 1) to send messages to the motor brain. I have tested this with a direct USART connection to my computer, and it works OK.
Plugboard with PIC16F877A and connections.
Pin connections for the PIC16F877A
1 = MCLR 2 = RA0 = GREEN = IN = ADC RL pot 3 = RA1 = YELLOW = IN = RL_SWITCH 4 = RA2 = ORANGE = OUT = enable/disable F_ED 5 = RA3 = ORANGE = OUT = enable/disable R_ED 6 = RA4 = 7 = RA5 = 8 = RE0 = 9 = RE1 = 10 = RE2 = 11 = +5v 12 = 0v 13 = CLKIN 14 = CLKOUT 15 = RC0 = YELLOW = SDA for compass = W/O SRF-02 16 = RC1 = GREEN = SCL for compass = W/B SRF-02 17 = RC2 = PURPLE = IN = from Front Edge_Detection 18 = RC3 = PURPLE = IN = from Rear Edge_Detection 19 = RD0 = OUT = I2C_ERROR RED LED 20 = RD1 = OUT = STATUS GREEN LED 21 = RD2 = OUT = AMBER LED, D_MC current high 22 = RD3 = OUT = AMBER LED, P_MC current high 23 = RC4 = 24 = RC5 = ORANGE = IN = MC_HIGH from Motor-brain(PIC16F88) 25 = RC6 = GREEN = TX = RF & to Motor-brain(PIC16F88) 26 = RC7 = GREEN = RX = IR Remote Control input 27 = RD4 = YELLOW = IN = from Passenger side IR 28 = RD5 = YELLOW = IN = from Driver side IR 29 = RD6 = 30 = RD7 = 31 = 0v 32 = +5v 33 = RB0 = F bumper p = PURPLE 34 = RB1 = F bumper c = YELLOW 35 = RB2 = F bumper d = GREEN 36 = RB3 = R bumper p = PURPLE 37 = RB4 = R bumper c = YELLOW 38 = RB5 = R bumper d = GREEN Programming pins 39 = RB6 = CLK = GREEN 40 = RB7 = DATA = YELLOW
Code for PIC16F877A