Shop OBEX P1 Docs P2 Docs Learn Events
RS485 networking headaches — Parallax Forums

RS485 networking headaches

ABaylogABaylog Posts: 4
edited 2005-05-21 06:23 in BASIC Stamp
···· 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,[noparse][[/noparse]address, memory]:
      LOW flow:
      SERIN serIO, baud, 2000, error, [noparse][[/noparse]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, [noparse][[/noparse]WAIT (myid), memory]
DEBUG "memory = ",DEC memory,CR,"ID = ", myid,CR,CR
HIGH flow
SEROUT serIO, baud,[noparse][[/noparse]"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, [noparse][[/noparse]WAIT (myid), memory]
DEBUG "memory = ", DEC memory,CR, "ID = ", myid,CR,CR
HIGH flow
SEROUT serIO, baud,[noparse][[/noparse]"B"]
GOTO top:
error:
DEBUG "Program timed out, try again",CR,CR
GOTO top:
END
 

Comments

  • kelvin jameskelvin james Posts: 531
    edited 2005-05-21 06:23
    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
Sign In or Register to comment.