Sorry I thought it would be a catchy title.... maybe not....
But really now, I want to say thanks in advance for any/everyone whom may assist me in my dilema.
My project is really kind of simple. All I'm looking to do is control a robot (two small dc motors) to drive it like a tank/bulldozer. Using relays I can reverse the motor direction and have made it operate with pushbutton switches. I have two 16F84A's, PBP, and an Epic Programmer. I can compile/program the chips to test I/O and everything worked fine until I tried to establish serial comms. Eventually I intend to make the comms wireless but for now I have them hardwired together. I'm pretty confident in the hardware aspect of the project. My code compiles/programs fine but when I power up the majic never happens. I get erratic behavior on the recieving end (like a high speed chattering on the relays) and there is sometimes a response to changing the inputs but nothing close to being considered operational.
I have tried every baud rate in the PBP manual and have also added/removed qualifiers but I've had no change in operation.
My limited experience has led to a temporary roadblock which hopefully one of you can help me pass. I fear my error is something spelled out clearly in a reference I haven't came across yet. I have done a lot of looking around but cannot figure out what I'm doing wrong. Hopefully my post isn't to trivial due to my short commings.
Again thanks for any assistance!!!
Dan
Here is my code for the tx:
Include "modedefs.bas" ' Include serial modes
INPUT PORTB.2 ' Right Forward output
INPUT PORTB.3 ' Right Reverse output
INPUT PORTB.4 ' Left Forward output
INPUT PORTB.5 ' Left Reverse output
OUTPUT PORTA.0 ' Serial Output Pin
A0 VAR BYTE
DEFINE OSC 4
loop:
' -----(READ ALL THE INPUTS)----- '
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 0) THEN ' "STOPPED"
SEROUT PORTA.0 , T2400 ,[1]
ELSE
endif
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) THEN ' "RR ONLY"
SEROUT PORTA.0 , T2400 ,[2]
ELSE
endif
IF (PORTB.2 = 0) AND (PORTB.3 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 0) THEN ' "RF ONLY"
SEROUT PORTA.0 , T2400 ,[3]
ELSE
endif
IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 0) THEN ' "LR ONLY"
SEROUT PORTA.0 , T2400 ,[4]
ELSE
endif
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 0) THEN ' "LF ONLY"
SEROUT PORTA.0 , T2400 ,[5]
ELSE
endif
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.4 = 1) AND (PORTB.5 = 0) THEN ' "RF AND LF"
SEROUT PORTA.0 , T2400 ,[6]
ELSE
endif
IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.4 = 1) AND (PORTB.5 = 0) THEN ' "RF AND LR"
SEROUT PORTA.0 , T2400 ,[7]
ELSE
endif
IF (PORTB.2 = 1) AND (PORTB.3 = 0) AND (PORTB.4 = 0) AND (PORTB.5 = 1) THEN ' "RR AND LF"
SEROUT PORTA.0 , T2400 ,[8]
ELSE
endif
IF (PORTB.2 = 0) AND (PORTB.3 = 1) AND (PORTB.4 = 0) AND (PORTB.5 = 1) THEN ' "RR AND LR"
SEROUT PORTA.0 , T2400 ,[9]
ELSE
endif
GOTO LOOP;
END
__________________________________________________ ______
Here is my code for the rx:
Include "modedefs.bas" ' Include serial modes
OUTput PORTB.0 ' Right Forward output
OUTput PORTB.1 ' Right Reverse output
OUTput PORTB.2 ' Left Forward output
OUTput PORTB.3 ' Left Reverse output
input PORTA.0
A0 VAR BYTE
DEFINE OSC 4
LOOP:
SERIN PORTA.0 , T2400 ,A0
if A0 = 1 then STOPPED ' "STOPPED"
if A0 = 2 then RR_ONLY ' "RR ONLY"
if A0 = 3 then RF_ONLY ' "RF ONLY"
if A0 = 4 then LR_ONLY ' "LR ONLY"
if A0 = 5 then LF_ONLY ' "LF ONLY"
if A0 = 6 then RF_AND_LF ' "RF AND LF"
if A0 = 7 then RF_AND_LR ' "RF AND LR"
if A0 = 8 then RR_AND_LF ' "RR AND LF"
if A0 = 9 then RR_AND_LR ' "RR AND LR"
goto loop;
'-------Read the Serial Data and decode into motion control --------'
STOPPED: ' "STOPPED"
PORTB.0 = 0 'Right Forward output
PORTB.1 = 0 'Right Reverse output
PORTB.2 = 0 'Left Forward output
PORTB.3 = 0 'Left Reverse output
GOTO LOOP;
RR_ONLY: ' "RR ONLY"
PORTB.0 = 0 'Right Forward output
PORTB.1 = 1 'Right Reverse output
PORTB.2 = 0 'Left Forward output
PORTB.3 = 0 'Left Reverse output
GOTO LOOP;
RF_ONLY: ' "RF ONLY"
PORTB.0 = 1 'Right Forward output
PORTB.1 = 0 'Right Reverse output
PORTB.2 = 0 'Left Forward output
PORTB.3 = 0 'Left Reverse output
GOTO LOOP;
LR_ONLY: ' "LR ONLY"
PORTB.0 = 0 'Right Forward output
PORTB.1 = 0 'Right Reverse output
PORTB.2 = 0 'Left Forward output
PORTB.3 = 1 'Left Reverse output
GOTO LOOP;
LF_ONLY: ' "LF ONLY"
PORTB.0 = 0 'Right Forward output
PORTB.1 = 0 'Right Reverse output
PORTB.2 = 1 'Left Forward output
PORTB.3 = 0 'Left Reverse output
GOTO LOOP;
RF_AND_LF: ' "RF AND LF"
PORTB.0 = 1 'Right Forward output
PORTB.1 = 0 'Right Reverse output
PORTB.2 = 1 'Left Forward output
PORTB.3 = 0 'Left Reverse output
GOTO LOOP;
RF_AND_LR: ' "RF AND LR"
PORTB.0 = 1 'Right Forward output
PORTB.1 = 0 'Right Reverse output
PORTB.2 = 0 'Left Forward output
PORTB.3 = 1 'Left Reverse output
GOTO LOOP;
RR_AND_LF: ' "RR AND LF"
PORTB.0 = 0 'Right Forward output
PORTB.1 = 1 'Right Reverse output
PORTB.2 = 1 'Left Forward output
PORTB.3 = 0 'Left Reverse output
GOTO LOOP;
RR_AND_LR: ' "RR AND LR"
PORTB.0 = 0 'Right Forward output
PORTB.1 = 1 'Right Reverse output
PORTB.2 = 0 'Left Forward output
PORTB.3 = 1 'Left Reverse output
GOTO LOOP;
END
Bookmarks