Padu,
RS485 is strictly a physical spec, any message formatting that needs to be done will have to be done by you. The RS485 bus just spits serial as a half-duplex differential signal. IOW, anything that you can send via RS232, can be sent unchanged in RS485.
That said, there is something that is different. You need to provide an address preamble if you want to address multiple slaves on the bus. This means that what I wrote above is not strictly true IF you want multiply addressed slaves on the bus. Now you need this kind of protocol: send address send data get response ...
I really recommend that you use the "9th bit" to denote an address, it simplifies how the slaves operate. In this way you can set the slave micro to fire an interrupt when it receives a '1' in the 9th bit so that you can look to see if the next bytes coming need to be dealt with. Otherwise your slave can discard the serial data since it knows that it isn't for him.
have fun, DLC
Padu wrote: : "Dennis Clark" : >
: > You can "spoof" the direction line by putting a retriggerable one-shot : > on the line that responds to the transmit data. I've seen reference : > designs that do this. I think a more reliable means is to put a micro : > out there that relays the serial data after it properly sets up the : > data direction line for the RS485 driver, but that's just my opinion. : >
: > DLC : >
: I see, from these feedbacks it sounds like it's easier to just put a PIC : there to make the bridge between the max232 and the rs485 transceiver right? : If this is easier, then I'll just to this way (lazyness is the mother of all : [efficient] inventions).
: Now, if the PC sends messages packed in a software protocol, does the root : mcu need to have any intelligence? Does it need to bufferize that message : prior to sending it down the rs485 bus?
: Here's what I envision: PC needs to send a message to the steering servo to : turn +20 degrees. It first packs that command into a packet (I will decide : later which messaging framework I'm gonna use, but it will probably be : JAUS), for example:
: "@0001-TURN-+20#"
: where @0001 is the address of the mcu that controls the steering servo, TURN : is the command and +20 is 20 degrees to the right and # marks the end of the : message. I just came up with this "protocol" as an example, don't pay : attention to it.
: Then the CPU streams this message to the serial port, connected to the root : mcu. I guess there's no other way right? The mcu must parse that message, at : least to get the device address. Once it has the device address, then it : starts a message on the RS485 bus by activating device "0001", once it gets : the ACK from it, it sends the message "TURN+20". I don't know if I really : need to wait for a final ACK from the device, but let's suppose that yes. : When the root mcu receives the final ACK, then it sends a message to the : host cpu, something like "@0001-ACK"
: Does it seem reasonable?
: I'm going to order Jan Axelson's Serial Port Complete just to grab a few : more concepts on RS-485, as I'll be spending a lot of time creating this bus : in the next upcoming weeks. Any other good pointers on RS-485?
: Thanks!!
: Padu