PDA

View Full Version : BS2 to PLC via RS485



anthr4x
04-05-2010, 10:56 PM
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, [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, [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, [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?

Mike Green
04-05-2010, 11:20 PM
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)
04-06-2010, 12:24 AM
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, ["01234567"]

-Phil

allanlane5
04-06-2010, 12:38 AM
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)
04-06-2010, 12:44 AM
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

anthr4x
04-07-2010, 08:18 PM
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?