RS232 to RS485


Closed Thread
Results 1 to 23 of 23

Thread: RS232 to RS485

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default

    You have to clamp the RTS levels to TTL levels. Or else the chip might get fried.

    Why don't you use the 555 circuit idea? It is automatic, no drivers required. Is it necessary to transmit and receive exactly at the same time?

    Ioannis

  2. #2
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    I have been thinking about that for a while. It looked really complicated at first but i think i get the general idea. The description near the bottom was a bit confusing but the diagram makes sense. Since first looking at RS485 i was going to have the PIC chips switch between sender and receiver. I need data to be sent pretty quick but i dont need quick replies from any of the devices so that would have worked pretty well.

    Im doing a little redesigning of the main driver circuit at the moment to add some extra features. The way im doing it might mean i have no choice but to use the 555 way. They are extra components but i suppose they are pretty cheap.

    Thanks for clearing that up anyway. Saved me from releasing the mysterious blue smoke again

  3. #3
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    I think ive finally got a good way of doing it. Im going to use the 555 method in the main controller. The main controller is the bit that connects all the devices to the PC. At the moment its RS232 but i plan to make a USB or ethernet version. All the devices need to be addressed seperately but there isnt really a method to set the address on the device itself so it would mean plugging each one in seperately and assigning an address. Im going to add another wire between each device that is either high or low. The master will make the wire high which will tell the first device on the line to reply. The master will assign it an address then the device will make the wire high for the next device and so on.

    That might seem a little complicated but it should do exactly what i want and it also has the advantage of allowing 2 devices to be swapped around. The 2 that are swapped will pick up each others addresses and continue asif they were still in their origional positions. It does ofcourse mean that they wont be hot pluggable but thats fine.

  4. #4
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Assume a one-byte address. Assign each device an initial address of 0xFE. Connect one at a time and have the master send a message to 0xFE to reset its address to 0x01, 0x02,...,0xNN, etc.

  5. #5
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    The origional idea was similar to that. I normally start all messages with [255] then a command. EG, 254 would mean set address. Any device connected would take the 3rd byte and set it as its address.

    The way im doing it now is a little more complicated. Each device will know how far away from the master it is. Its complicated a little further because there are 2 sockets on each device for in and out but it doesnt matter which way you connect them.

    There are 5 wires (and a screen):-
    1) Power +
    2) Power -
    3) Data A
    4) Data B
    5) Not thought of a name for this yet

    The master will keep #5 high constantly. The first device connected to it will check both of the sockets to see if #5 is high on it. If it is then it knows that socket is the input. The default is for both sockets to be inputs so #5 will be low by default unless the master is present. This means that only the first device will see a high on #5 so only that device will set itself an address.

    Since the last post ive changed the way the addressing works so there is no need for a PIC chip in the master. All devices will default to [0]. The first one to get a high on #5 will add 1 to the address and save it (it is now device 1). It will then switch to send mode and send the address out to all the other devices then switch back to receive mode. All the other devices will use the new address as the default.

    The first device will now make #5 high on whichever socket is still low which causes the next device to set itself an address etc.

    I know it sounds complicated but it means that all the devices will automatically address themselves. If i connect all the devices in a straight line then it doesnt matter which order i put them in along the line, they will still function in the correct order.

    Once all the devices have a unique number that they can be accessed by then i can set a second address through serial. The data would only require the second byte changing and they can be accessed by their specific address or by their position in the line. It saves having to connect one up at a time to address them or having a button on the back that you press to accept the address.

    The position address will be reset everytime the devices turn on but the address that is set by sending a command will be saved in the EEPROM and only change when it gets a change command.

    Im using the 555 method in the master but not in the individual devices. Each device only needs to send a small amount of data when they first turn on and possibly when a certain command is sent. They should never need to send data during normal operation

  6. #6
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Hi, Ive been testing this RS485 stuff out tonite. I had bypassed it before to get everything else working. Now ive tried to get the RS485 bit working and ive found a little problem. The first 1 or 2 bytes seem to get missing from the data. I think its because the 555 doesnt react quick enough to the data. Im using 115200 baud. Is there anything i can do about this problem?

  7. #7
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Attached Images Attached Images  

  8. #8
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    The first 1 or 2 bytes seem to get missing from the data. I think its because the 555 doesnt react quick enough to the data. Im using 115200 baud. Is there anything i can do about this problem?
    I doubt very much whether it's the 555. That method is widely and successfully used for automatic control of line direction. The fact that subsequent bytes are OK would also seem to indicate it's not the 555. Are you using termination resistors? They are absolutely necessary at 115200.

Similar Threads

  1. UART vs software RS232
    By Michael in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 5th September 2008, 19:27
  2. RS232 into 2 PC ports
    By manxman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2008, 14:33
  3. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 21:39
  4. Using 16f676 with comms
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 28th October 2005, 21:01
  5. rs485 to rs232 smart switch
    By RSSHARPE in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th June 2004, 09:44

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts