Shop OBEX P1 Docs P2 Docs Learn Events
BS2 to PLC via RS485 — Parallax Forums

BS2 to PLC via RS485

anthr4xanthr4x Posts: 3
edited 2010-04-07 13:18 in BASIC Stamp
Hello, I'm new to the world of Basic Stamps and am having some trouble getting my BS2 to communicate with my PLC over RS485.

When I send this:
SEROUT 6,baud, [noparse][[/noparse]DEC 48,DEC 49,DEC 50,DEC 51,DEC 52,DEC 53,DEC 54,DEC 55]

My PLC is receiving:
83 83 d0 b0 90 70 50

If I send:
SEROUT 6,baud, [noparse][[/noparse]HEX 48,HEX 49,HEX 50,HEX 51,HEX 52,HEX 53,HEX 54,HEX 55]

I receive this:
99 f0 83 06 2e

If I send:
SEROUT 6,baud, [noparse][[/noparse]48, 49, 50, 51, 52, 53, 54, 55]

I receive randomly:
f0 46 c6 19 93
a3 c6 19 93
46 c6 19 93

I am using this http://www.sparkfun.com/commerce/product_info.php?products_id=9083
It uses a MAX485 CSA chip.

Can anyone make sense of what I'm receiving?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-05 16:20
    1) Are you sure you have the proper Baud constant in the SERIN and SEROUT statements for the requirements of your PLC?

    2) The MAX485 is a half duplex RS485 driver. The SparkFun documentation link gives no information about how the direction of the MAX485 is controlled. How do you have things hooked up?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-04-05 17:24
    In addition to Mike's comments, if you're sure you have the right baud rate, you may have TX+ and TX- reversed. BTW, the values you're sending are ASCII for "01234567". If that's what you intend to send, your third example is the correct one, or you could just do: SEROUT 6, baud, [noparse][[/noparse]"01234567"]

    -Phil
  • allanlane5allanlane5 Posts: 3,815
    edited 2010-04-05 17:38
    You also need to attach a ground wire between the BS2 and the RS485 chip. It's also possible you need to add the 'invert' value to the baud-mode select value.

    Edit: What PhiPi says is very true.

    Post Edited (allanlane5) : 4/6/2010 4:47:22 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-04-05 17:44
    allanlane5 said...
    It's also possible you need to add the 'invert' value to the baud-mode select value.
    This would be equivalent to reversing TX+ and TX-, as I suggested above.

    -Phil
  • anthr4xanthr4x Posts: 3
    edited 2010-04-07 13:18
    I can send with my BS2 now and my PLC is receiving the right values. My problem was it needed to be inverted. I'm using $4054 for my baud constant now. Now I need to get my BS2 to receive. Mike, I need to controll the direction of the MAX485?
    Mike Green said...

    2) The MAX485 is a half duplex RS485 driver. The SparkFun documentation link gives no information about how the direction of the MAX485 is controlled. How do you have things hooked up?
Sign In or Register to comment.