Help with RS-485 interface
mynet43
Posts: 644
I have a Prop circuit using the MAX485 chip. It's used to connect to a single slave device using only two lines, RX-, RX+ (and GND).
My question is the control of the Send/Receive line on the chip. Since I'm the master, I need to control this.
Does someone have experience with this circuit, to point to a good driver or other source for this application?
I'd prefer to use something like pcFullDuplexSerial4FC, so I can service more than one port with a single cog.
Thank you for your help.
Jim
My question is the control of the Send/Receive line on the chip. Since I'm the master, I need to control this.
Does someone have experience with this circuit, to point to a good driver or other source for this application?
I'd prefer to use something like pcFullDuplexSerial4FC, so I can service more than one port with a single cog.
Thank you for your help.
Jim
Comments
While I've used RS-485 a little myself, I don't think I know enough to give you any useful information.
I know JonnyMac has done some RS-485 stuff. I think there is a Spin Zone article about it (which JonnyMac wrote). I just found the title Do It Up With DMX (N&V Nov. '09). It's nvp3.pdf in the Propeller download section.
pcFullDuplex4FC has been a life saver for many people. I like to think I improved a good thing by increasing the rx buffer from 64 byte to 128 bytes with only adding a few longs to the size of the code. You can find the 128 byte rx buffer version here. (It has 128 added to the end of the name.)
I have some of my other variations of pcFullDuplex4FC on the same thread.
Duane
Thanks for the reference, I'll take a look.
Interesting about pcFullDuplex4FC. I think the I/O from the prop may be the same as RS-232.
See the attached schematic. The RS232 and RS485 look the same to the Prop except for the snd/rcv line on the 485.
Does the driver have some kind of a control signal, like RTS or something that could be used to toggle the line for send/receive?
That would be a lifesaver...
Thanks for the help.
Jim
None of the drivers I'm aware take care of the /RE line for you.
It wouldn't be too hard to add something to the spin portion of the driver to toggle the /RE line when the str or tx function is called. You could add a method to define a port as RS-485 and tell which pin to use as the /RE line.
Using the four port drivers can limit your baud rate. I understand the half duplex drivers can go faster.
As Jon said, you want to make sure there is a 10us delay, after setting the /RE line high, before you start transmitting.
As Jon pointed out in his article, you can save some money by using the 5V version of the RS-485 chip. The 5V version works fine with the Prop as long as you follow Jon's schematic.
Speaking of which; Jon, I noticed a couple of changes in the schematic you just posted from the one in the Nuts & Volts article.
I figure the newest version is preferable?
Duane
The differences in resistor values are minor and both versions work -- I just like the second version as the values seem to make more sense (i.e., we're all used to 10K pull-ups/pull-downs). That said, the earlier version simplifies purchasing.
A couple of questions about the schematic.
1. Are the pull-up and pull-down resistors on RO and DE needed if I'm controlling them from the Prop?
2. Is the 120 ohm resistor needed if I use twisted pair cable?
Regarding the driver. I like your idea of adding a control line to the output routines like tx and str. This way I can leave it in receive mode until I need to send something. Since I'm the master, it seems like this should work.
@ Jon, which driver do you use, and how are your messages terminated.
Thank you for the help.
Jim
My projects, thus far, have been half-duplex one-way, or full-duplex with a full-duplex chip (MAX489). I'm working on a driver that will allow for half-duplex RS-485 with the circuit posted here; I'll put it in ObEx when it's done and working.
Good advice. I'll put them in. I'm still learning this circuit.
I'll always be in half duplex to a single device, since there are only 3 wires to connect to at the other end, including GND.
Do you have an idea when your driver will be ready?
Thanks for the help.
Jim
Yes, half duplex Rx, Tx, with me as the master. I'll only be working at 9600 baud for this connection. It's to an AC motor control box.
It uses the Modbus comm protocol in the Remote Terminal Unit (RTU) transmission mode.
Thanks again,
Jim