PDA

View Full Version : RS485 networking headaches



ABaylog
05-21-2005, 11:11 AM
ииии I am working on setting up a simple RS-485 network for a class project. There are to be four slaves responsive to one master. Each of these has a BS2 and for the time being are just simply connected using a LTC1487 chip much like the Nuts and Volts Column (#28, volume 1).

ииии I have been able to get three of them connected (master and 2 slaves) and have some simple communication back and forth between them. The problem is that I am not getting the response from the slaves that I am expecting. Each slave should just simply respond with its address (A or B) but everytime some odd symbol is returned which has a DEC equivalent to 255. I am not sure if this is a programming error, or if i need to check my wiring again.

ииии If anyone has any suggestions I would be willing to listen. My code is posted below. Thanks for the help!




'Master Code

memory VAR Byte
counter VAR Byte
id VAR Byte
address VAR Byte
serIO CON 1
flow CON 0
baud CON 16468

counter = 0
top:
FOR address = "A" TO "B"
PAUSE 1000
IF memory < 100 THEN
DEBUG "address = ", address,CR, "Memory = ", DEC memory,CR:
HIGH flow: PAUSE 5:
SEROUT serIO, baud,[address, memory]:
LOW flow:
SERIN serIO, baud, 2000, error, [id]:
PAUSE 2000:
DEBUG "ID = ", id, CR,CR,"Next Cycle:",CR:
memory = memory + 1:
GOTO Next_Node:
ELSE
GOTO finish:
ENDIF
Next_Node:
NEXT
GOTO top:

error:
PAUSE 2000
DEBUG "there was an error in the network!",CR,CR
counter = counter + 1
GOTO Next_Node:
finish:
DEBUG "End of program",CR
END



'Slave A

memory VAR Byte
myid CON "A"
serIO CON 1
flow CON 0
baud CON 16468

top:
LOW flow
SERIN serIO, baud,10000,error, [WAIT (myid), memory]
DEBUG "memory = ",DEC memory,CR,"ID = ", myid,CR,CR
HIGH flow
SEROUT serIO, baud,["A"]
GOTO top:
error:
DEBUG "Program timed out, try again",CR,CR
GOTO top:
END




'Slave B

memory VAR Byte
myid CON "B"
serIO CON 1
flow CON 0
baud CON 16468

top:
LOW flow
SERIN serIO, baud,10000,error, [WAIT (myid), memory]
DEBUG "memory = ", DEC memory,CR, "ID = ", myid,CR,CR
HIGH flow
SEROUT serIO, baud,["B"]
GOTO top:
error:
DEBUG "Program timed out, try again",CR,CR
GOTO top:
END

kelvin james
05-21-2005, 02:23 PM
Since you are expecting a ascii character A or B, you have to use the debug formatter to see it ( ASC ? address ) , if i am not mistaken. Check the DEBUG help section. As far as the rest of the code, i am not sure, but that should help to clear up the funky debug response.

kelvin