Thanks for the help, but it still isn't doing anything. I even tried eliminating the joystick input to the arduino and just send a series of 0's and 1's to make an LED blink - nothing.
Just to double-check my methods, when you say add a pull-up resistor you mean add a resistor in series with the incoming serial line (TX from sender)? Or add a pull-up resistor off the +5V? I have tried both methods, by the way, just making sure I leave it the correct way. Also, elsewhere I see that the data into the pic16f88 should be inverted instead of true.....there was something mentioned in the PBP manual, can't remember off-hand exactly where I saw it.
I have the serial monitor open for the arduino and it looks like it's sending the correct data. I have also changed the arduino code to just send a 0 or 1 instead of dec. 0-999. Here's the updated (and highly revised) pic code I'm using.
Code:
#CONFIG
__CONFIG _CONFIG1, _INTRC_IO & _PWRTE_ON & _MCLR_OFF & _LVP_OFF
#ENDCONFIG
DEFINE OSC 8
OSCCON.4 = 1
OSCCON.5 = 1
OSCCON.6 = 1
ANSEL = 0
DEFINE HSER_RCSTA 90h 'set receive register to receiver enabled
DEFINE HSER_TXSTA 20h 'set transmit register to transmitter enabled
DEFINE HSER_BAUD 9600 'set baud rate
DEFINE HSER_CLROERR 1 ;CLEAR OVERFLOW ERRORS
ON INTERRUPT GOTO serial
INTCON = %1100100
PIE1 = %00100000
PIR1 = %00000000
RCIF VAR PIR1.5
motor1 var portb.0 'assign main motor 1 to pin 6
motor2 var portb.1 'assign main motor 2 to pin 7
thr1 var portb.3 'assign thruster motor 1 to pin 9
thr2 var portb.4 'assign thruster motor 2 to pin 10
thr3 var portb.6 'assign thruster motor 3 to pin 12
thr4 var portb.7 'assign thruster motor 4 to pin 13
tempout var porta.0 'assign temperature sensor output to pin 17
voltout var porta.1 'assign control battery (not flight batteries) voltage sense output to pin 18
joy1v var word
joy1h var word
joy2v var word
joy2h var word
portb.0 = 0
portb.1 = 0
portb.3 = 0
portb.4 = 0
portb.6 = 0
portb.7 = 0
porta.0 = 0
porta.1 = 0
TRISA = %11111100 ;set PA 0 & 1 as outputs
TRISB = %00100100 ;set pb.2 & 5 as inputs
Main: ; Loop to keep your code from running down and dripping all into your other routines
while 1
thrusters:
if (joy1v>600) then
high thr1
'Pauseus 500
'Low thr1
'Pauseus 1500
endif
if (joy1v<400) then
low thr1
endif
if (joy1v<400) then
high thr2
'Pauseus 500
'Low thr2
'Pauseus 1500
endif
if (joy1v>600) then
low thr2
endif
wend
serial:
hserin [wait ("A"), dec joy1v] : RCIF = 0
hserin [wait ("B"), dec joy1h] : RCIF = 0
hserin [wait ("C"), dec joy2v] : RCIF = 0
hserin [wait ("D"), dec joy2h] : RCIF = 0
return
end
And just yesterday I tried using serin instead of hserin, here's that code:
Code:
#CONFIG
__CONFIG _CONFIG1, _INTRC_IO & _PWRTE_ON & _MCLR_OFF & _LVP_OFF
#ENDCONFIG
DEFINE OSC 8
OSCCON.4 = 1
OSCCON.5 = 1
OSCCON.6 = 1
ANSEL = 0
CMCON=7
INCLUDE "modedefs.bas"
'DEFINE HSER_RCSTA 90h 'set receive register to receiver enabled
'EFINE HSER_TXSTA 20h 'set transmit register to transmitter enabled
'DEFINE HSER_BAUD 9600 'set baud rate
'DEFINE HSER_CLROERR 1 'clear overflow errors
ON INTERRUPT GOTO serial
'INTCON = %1100100
'PIE1 = %00100000
'PIR1 = %00000000
'RCIF VAR PIR1.5
'motor1 = portb.0 'assign main motor 1 to pin 6
'motor2 = portb.1 'assign main motor 2 to pin 7
'thr1 = portb.3 'assign thruster motor 1 to pin 9
'thr2 = portb.4 'assign thruster motor 2 to pin 10
'thr3 var portb.6 'assign thruster motor 3 to pin 12
'thr4 var portb.7 'assign thruster motor 4 to pin 13
'tempout var porta.0 'assign temperature sensor output to pin 17
'voltout var porta.1 'assign thruster battery (not main batteries)
'voltage sense output to pin 18
joy1v var word
joy1h var word
joy2v var word
joy2h var word
mode con 2
thr1vin var portb.2
thr1hin var portb.1
thr1vout var portb.6
'portb.0 = 0
'portb.1 = 0
'portb.3 = 0
'portb.4 = 0
'portb.6 = 0
'portb.7 = 0
'porta.0 = 0
'porta.1 = 0
TRISA = %11111100 'set RA 0 & 1 as outputs
TRISB = %00100100 'set RB 2 & 5 as inputs
Main: 'Loop to keep your code from running down and dripping all into your other routines
while 1
thrusters:
if (joy1v==1) then
high portb.3
Pause 250
Low portb.3
Pause 250
endif
if (joy1v==0) then
low portb.3
endif
if (joy1h==1) then
high portb.4
Pauseus 250
Low portb.4
Pauseus 250
endif
if (joy1h==0) then
low portb.4
endif
wend
serial:
serin thr1vin, 2, ["A"], joy1v
serout thr1vout, 2, joy1v
return
end
Could it possibly be that the pic is expecting to see a certain number of bits, and I'm not send them (I'm not using parity or stop bits, I don't think).
I apologize for my absolute noobieness when it comes to serial, but I've been struggling with this for a couple weeks now and I just have no idea what it could be.
Thanks again.
Bookmarks