Hello all,

I'm back here posting due to some massive brain fry over my latest project. Here's what I've got:

PC to a Trendnet TU-S9 (USB to RS232 adapter).
From there, into a custom board with a MAX232 to a MAX3081 RS422 chip (Rx+, Rx-,Tx+,Tx-,Ground).
From there, into board(s) that have a MAX3081, which are then tied into the USARTs of the MCUs.
All of the RS422 wiring is over Cat5e with RJ-45 connectors.
Each board has 2 RJ-45 connectors, wired in parallel, to facilitate a daisy chain configuration.

At present, I have 2 boards: 1 that does ADC stuff (PIC16F1936), and the other that does strictly outputs (PIC16F887).

I think that gets the hardware out of the way.

As far as the software, I'm running them with Term.exe @ 57600,8,N,1.
Here's where it gets weird
When I plug either board in by itself, all is good (receive from the PC and transmit back from the MCU)
When I plug both boards in (daisy chained), both boards receive from the PC just fine but
I can only receive a response back from my 887 output board, although I can send commands just fine to both
of them. I verify this by manually switching some outputs on the 1936 board. When I expect a serial response
from the 1936 board, all I seem to receive at the terminal is a carriage return (or so it appears).
I hope that isn't confusing
Here's the code for the 2 different boards, so maybe one of you fine folks can determine where I'm going astray.
Of course, the following code is clipped for irrelevant content.

Thanks for taking a peek at the code, and for the help.
Chris

*As you will see, I even tried to enable the serial transmit only when it is needed. That got me to the point
of the 887 board responding back to the PC. Previous to that, neither boards would respond.


1936 code:
Code:
'***********************************SERIAL INTERRUPT**************************************
RS232in:
@ INT_DISABLE IOC_INT
@ INT_DISABLE TMR1_INT
@ INT_DISABLE RX_INT
    low RxLED   'Rx LED ON
    HSERIN 300,Stall,[DEC3 SerialIn]
    If SerialIn = 255 then gosub GoodQualifier
    Stall:
    while PIR1.5
        SerialIn = RCREG
    wend    
    high RxLED  'Rx LED OFF
@ INT_ENABLE IOC_INT
@ INT_ENABLE TMR1_INT
@ INT_ENABLE RX_INT
@ INT_RETURN
'*****************************************************************************************

GoodQualifier:

T1CON   = timeroff           'Timer Off

hserin 300,Junk,[str SerBuff\10\"~"]

'Parse ASCII CmdPrefix
CmdPrefix = SerBuff[0]

'Convert Address from ASCII to DECIMAL
for x = 1 to 3
    SerBuff[x] = (SerBuff[x]-"0")
next
'Build the DECIMAL address
CmdAddress = SerBuff[1] * 100
CmdAddress = CmdAddress + SerBuff[2] * 10
CmdAddress = CmdAddress + SerBuff[3]
 
    if CmdPrefix = "A" then
        '-------------------------Address Module----------------------------
            Address = CmdAddress
            write 0,Address
            LOW TxLED
            TXSTA = 36
                HSEROUT [CmdPrefix,DEC3 Address,13]            
                WHILE PIR1.4 = 0 : WEND
            TXSTA = 4
            HIGH TxLED
            read 0,Address
        '------------------------------------------------------------------
    endif
    '--------------------Address Mismatch--------------------------
    if CmdAddress = Address then
    
        TXSTA = 36  'Turn ON transmitter

        '-------------------------Command Module----------------------------            
        if CmdPrefix = "O" then   'Oaaaoo   (6)
            'Convert CmdOutput from ASCII to DECIMAL    
            for x = 4 to 5
                SerBuff[x] = (SerBuff[x]-"0")
            next
            'Build the DECIMAL address
            CmdOutput = SerBuff[4] * 10
            CmdOutput = CmdOutput + SerBuff[5]
            select case CmdOutput
                case 10
                    OUT1 = 0
                case 20
                    OUT2 = 0
                case 30
                    OUT3 = 0
                case 11
                    OUT1 = 1
                case 21
                    OUT2 = 1
                case 31
                    OUT3 = 1
                CASE ELSE
                    goto Junk            
                END SELECT
            HSEROUT [CmdPrefix,DEC3 Address,dec2 CmdOutput,13]
        endif
    
        if CmdPrefix = "Q" then     'Qaaa       (4)
            low TxLED                                           'Tx LED ON
            HSEROUT [CmdPrefix,DEC3 Address, _
                    ",",DEC VOLTS,",",DEC TempF,",",DEC Amps, _
                    ",",dec PORTA.1,",",DEC PORTA.0,",",DEC PORTA.4,13]
            high TxLED                                          'Tx LED OFF
        endif
    
        if CmdPrefix = "P" then     'Paaa       (4)
            low TxLED                                           'Tx LED ON
            HSEROUT [CmdPrefix,DEC3 Address,DEC1 ModType,13]
            high TxLED                                          'Tx LED OFF
        endif
    
        if CmdPrefix = "M" then     'Maaallvvv  (9)
            '10=LowVolts, 11=HighVolts, 12=LowTemp, 13=HighTemp, 14=LowCurrent, 15=HighCurrent
            'M001                     Board Address
            '       10                  EEProm Location (Low Trip)
            '          255             Low Trip Value   
            
            'Convert eepromloc from ASCII to DECIMAL    Maaaeevvv
            for x = 4 to 5
                SerBuff[x] = (SerBuff[x]-"0")
            next
            'Build the DECIMAL
            eepromloc = SerBuff[4] * 10
            eepromloc = eepromloc + SerBuff[5]
    
            if (eepromloc < 10) OR (eepromloc > 15) then
                goto Junk
            endif
            
            'Convert tripval from ASCII to DECIMAL
            for x = 6 to 8
                SerBuff[x] = (SerBuff[x]-"0")
            next
            'Build the DECIMAL
            tripval = SerBuff[6] * 100
            tripval = tripval + SerBuff[7] * 10
            tripval = tripval + SerBuff[8]
                
            write eepromloc,tripval
            HSEROUT [CmdPrefix,DEC3 Address,dec2 eepromloc,dec3 tripval,13]
            ReReadVals = 1
        endif
    
        if CmdPrefix = "C" then   '(CONTROL)    'Caaa1
            ManualControl = (SerBuff[4]-"0")
            HSEROUT [CmdPrefix,DEC3 Address,dec1 ManualControl,13]
        endif

        WHILE PIR1.4 = 0 : WEND 'If we're still transmitting, wait here
        TXSTA = 4               'Turn OFF transmitter

    endif
    '--------------------------------------------------------------
Junk:
for x = 0 to 9
    SerBuff[x] = " "
next
T1CON   = timeron           'Timer ON
return
887 code:
Code:
'*********************************SERIAL INPUT**********************************
RS232in:
@ INT_DISABLE RX_INT
@ INT_DISABLE TMR1_INT
    HSERIN 300,Stall, [DEC3 SerialIn]
    If SerialIn = 255 then gosub GoodQualifier
    Stall:
    while PIR1.5
        SerialIn = RCREG
    wend    
@ INT_ENABLE TMR1_INT
@ INT_ENABLE RX_INT
@ INT_RETURN
'*******************************************************************************

GoodQualifier:

T1CON   = timeroff

hserin 300,Junk,[str SerBuff\10\"~"]

'Parse ASCII CmdPrefix
CmdPrefix = SerBuff[0]

'Convert Address from ASCII to DECIMAL
for x = 1 to 3
    SerBuff[x] = (SerBuff[x]-"0")
next
'Build the DECIMAL address
CmdAddress = SerBuff[1] * 100
CmdAddress = CmdAddress + SerBuff[2] * 10
CmdAddress = CmdAddress + SerBuff[3]

        '-------------------------Address Module----------------------------
        'Aaaa   (4)
        IF CmdPrefix = "A" THEN                    
            Address = CmdAddress
            write 0,Address
            TXSTA = 36
            HSEROUT [CmdPrefix,DEC3 Address,13]            
                WHILE PIR1.4 = 0 : WEND
            TXSTA = 4
            read 0,Address
            newaddr = 1
        endif
        '------------------------------------------------------------------
        '--------------------Address Mismatch--------------------------
    if CmdAddress = Address then
    
        TXSTA = 36  'Turn ON transmitter

            '-------------------------Command Module----------------------------            
            'Qaaa   (4)
            IF CmdPrefix = "Q" THEN
                HSEROUT [CmdPrefix,DEC3 Address, _
                    DEC PORTA.4,DEC PORTA.3,DEC PORTA.5,DEC PORTA.2,_
                    DEC PORTE.0,DEC PORTA.1,DEC PORTC.1,DEC PORTC.0,_
                    DEC PORTC.2,DEC PORTE.2,DEC PORTC.3,DEC PORTE.1,_
                    DEC PORTD.2,DEC PORTD.1,DEC PORTD.3,DEC PORTD.0,_
                    DEC PORTC.4,DEC PORTC.5,DEC PORTD.7,DEC PORTD.6,_
                    DEC PORTB.0,DEC PORTD.5,DEC PORTB.1,DEC PORTD.4,13]
            endif
            
            'Paaa   (4)
            if CmdPrefix = "P" then                                                '(PING)    '$BxxxQ
                HSEROUT [CmdPrefix,DEC3 Address,DEC1 ModType,13]
            endif
            
            'Oaaarrs    (7)
            IF CmdPrefix = "O" THEN                    
                'Convert Relay from ASCII to DECIMAL    Oaaaoo
                for x = 4 to 5
                    SerBuff[x] = (SerBuff[x]-"0")
                next
                'Build the DECIMAL address
                Relay = SerBuff[4] * 10
                Relay = Relay + SerBuff[5]
                Stat = (SerBuff[6]-"0")
                
                    if Relay = 1 then
                        if stat = 0 then
                            OUT1 = 0
                        else
                            OUT1 = 1
                        endif
                    endif
                    if Relay = 2 then
                        if stat = 0 then
                            OUT2 = 0
                        else
                            OUT2 = 1
                        endif
                    endif
                    if Relay = 3 then
                        if stat = 0 then
                            OUT3 = 0
                        else
                            OUT3 = 1
                        endif
                    endif
                    if Relay = 4 then
                        if stat = 0 then
                            OUT4 = 0
                        else
                            OUT4 = 1
                        endif
                    endif
                    if Relay = 5 then
                        if stat = 0 then
                            OUT5 = 0
                        else
                            OUT5 = 1
                        endif
                    endif
                    if Relay = 6 then
                        if stat = 0 then
                            OUT6 = 0
                        else
                            OUT6 = 1
                        endif
                    endif
                    if Relay = 7 then
                        if stat = 0 then
                            OUT7 = 0
                        else
                            OUT7 = 1
                        endif
                    endif
                    if Relay = 8 then
                        if stat = 0 then
                            OUT8 = 0
                        else
                            OUT8 = 1
                        endif
                    endif
                    if Relay = 9 then
                        if stat = 0 then
                            OUT9 = 0
                        else
                            OUT9 = 1
                        endif
                    endif
                    if Relay = 10 then
                        if stat = 0 then
                            OUT10 = 0
                        else
                            OUT10 = 1
                        endif
                    endif
                    if Relay = 11 then
                        if stat = 0 then
                            OUT11 = 0
                        else
                            OUT11 = 1
                        endif
                    endif
                    if Relay = 12 then
                        if stat = 0 then
                            OUT12 = 0
                        else
                            OUT12 = 1
                        endif
                    endif
                    if Relay = 13 then
                        if stat = 0 then
                            OUT13 = 0
                        else
                            OUT13 = 1
                        endif
                    endif
                    if Relay = 14 then
                        if stat = 0 then
                            OUT14 = 0
                        else
                            OUT14 = 1
                        endif
                    endif
                    if Relay = 15 then
                        if stat = 0 then
                            OUT15 = 0
                        else
                            OUT15 = 1
                        endif
                    endif
                    if Relay = 16 then
                        if stat = 0 then
                            OUT16 = 0
                        else
                            OUT16 = 1
                        endif
                    endif
                    if Relay = 17 then
                        if stat = 0 then
                            OUT17 = 0
                        else
                            OUT17 = 1
                        endif
                    endif
                    if Relay = 18 then
                        if stat = 0 then
                            OUT18 = 0
                        else
                            OUT18 = 1
                        endif
                    endif
                    if Relay = 19 then
                        if stat = 0 then
                            OUT19 = 0
                        else
                            OUT19 = 1
                        endif
                    endif
                    if Relay = 20 then
                        if stat = 0 then
                            OUT20 = 0
                        else
                            OUT20 = 1
                        endif
                    endif
                    if Relay = 21 then
                        if stat = 0 then
                            OUT21 = 0
                        else
                            OUT21 = 1
                        endif
                    endif
                    if Relay = 22 then
                        if stat = 0 then
                            OUT22 = 0
                        else
                            OUT22 = 1
                        endif
                    endif
                    if Relay = 23 then
                        if stat = 0 then
                            OUT23 = 0
                        else
                            OUT23 = 1
                        endif
                    endif
                    if Relay = 24 then
                        if stat = 0 then
                            OUT24 = 0
                        else
                            OUT24 = 1
                        endif
                    endif
                HSEROUT [CmdPrefix,DEC3 Address,dec2 Relay,dec Stat,13]
            endif

        WHILE PIR1.4 = 0 : WEND 'If we're still transmitting, wait here
        TXSTA = 4               'Turn OFF transmitter

    endif
    '--------------------------------------------------------------
Junk:
for x = 0 to 9
    serbuff[x] = " "
next
T1CON   = timeron
return