"skylinux" <(E-Mail Removed)> schreef in bericht
news:Ud1Te.8048$(E-Mail Removed) ink.net...
> I'm currently building a new robot, this time I would like to split up the
> load of driving the motors and sensors to different PICS. Plans are to use
> a 16F628A as the "main" MCU and use one 16F84A to control the motors and
> one or more for the sensors.
> The way it's supposed to work, the robot triggers an event, bumps the
> wall, the "main MCU" sends commands to the "driver MCU" to navigate around
> the object. I don't need any data transmissions yet, still trying to
> figure out the basics.
>
> And here is where I have the problem.
> The code in the "main MCU" and the "driver MCU" will control the motors
> when connected directly to the h-bridge, one at a time. Once I connect the
> "main MCU"(RA1) to the "driver MCU"(RB2) the motors no longer work.
> Each PIC works on it's own but they don't work together.
>
> Here's how I'm trying to do it:
> Main MCU Driver MCU
> RA0 => RB1
> RA1 => RB2
>
> RA0 is for forward command, RA1 for reverse
>
> I think that my problem is here with the I/O settings of each PIC
> Main MCU:
> startup:
> clrf PORTA ; Initialize port A
> clrf PORTB ; Initialize port B
> bsf STATUS,RP0 ; RAM bank 1
> clrf TRISA ; All pins port A output movlw 0xff ; Make Port B
> Input
> movwf TRISB ; All pins port B input
> bcf STATUS, RP0 ; Back to RAM bank 0
> movlw 7
> movwf CMCON ; Comparators off, all pins digital I/O
> clrf motor_status
> main:
> bsf PORTA, 0 ;Go forward
> call delay_600 ;Run 600ms delay to drive motor
> bcf PORTA, 0 ;Turn Motors off
>
> Driver MCU:
> startup:
> clrf PORTA ; Initialize port A
> clrf PORTB ; Initialize port B
> bsf STATUS,RP0 ; RAM bank 1
> clrf TRISA ; All pins port A output movlw 0xff ; Make Port B
> Input
> movwf TRISB ; All pins port B input
> bcf STATUS, RP0 ; Back to RAM bank 0
> clrf motor_status
> INPUT:
> btfsc PORTB,1 ;Check for High on Port
> call SwitchB1 ;Forward
> btfsc PORTB,2 ;Check for High on Port
> call SwitchB2 ;Reverse
> btfsc PORTB,3 ;Check for High on Port
> call SwitchB3 ;Left
> btfsc PORTB,4 ;Check for High on Port
> call SwitchB4 ;Right
>
> goto INPUT
>
> Please, any help will be greatly appreciated.
> Skylinux
Perhaps you test the wrong pins in the Driver MCU, shouldn't you start
testing with PORTB,0????
Further if you go forward you can go immediatly into reverse if both PORTB,1
PORTB,2 are high, this could result in a blown H bridge :S
|