Hello everyone,
I need to setup bidirectional communication between 2 devices, other one is using normal RS-232 and other one is using half-duplex RS-485.
Basically RS-232 is sending commands which are 1 character long and RS-485 is responding with messages which are normally few characters long, usually less than 50 characters.
I tried to find some ready code which does this or atleast something which could be easily modified to do this, but I didn't really find anything that could be quickly taken into use, so I decided to ask if anyone knows if there is some similar project.
I have some Nano boards and RS-232 and RS-485 half-duplex tranceivers so I could easily make PCB for this if there is some code available.
So data flow would be some thing like this.
- Nano has configured uart to rs-232 and one I/O pin let's call it "tranceiver select" to '0' and listen uart until it receives command from rs-232 and stores it.
- Nano will configure uart to RS-485 and set "tranceiver select" to '1' which will physically connect uart to RS-485 tranceiver and disconnect it from RS-232 tranceiver.
- Nano will set DE (RS-485 directional control" to 1 and send command out of uart to RS-485.
4.Nano will set DE to '0' and listen for response and store it. - Nano will set "tranceiver select" to '0' and configure uart to rs-232 and send data to RS-232
- Nano will go back to step 1. and listen new command from RS-232.
few notes:
Main purpose to configure to rs-232 and to rs-485 is to get HW control for RS-485 DE pin. other serial port parameter could probably be mathed between devices.
From rs-232 there wont be carriage return, but that is not a problem since command is always 1 character.
from RS-485 side there will be carriage return to signal end of string.
If anyone could point to some project which could be modified to do his with as little effort as possible it would be appreciated
6 posts - 4 participants