One shot rs232 falling edge triggers 485 Edit
Trigger RS485 Olav.....I went thru the very same thought process you are going thru. I also use a rs485 network in the half duplex mode (on 2 wires) communicating with some 8051 based controllers....after much work the solution i used was a VERY SIMPLE hardware solution....turns out there are times when a few parts replace alot of software and result in a much more reliable system....since i had built a simple rs232 to rs485 converter (worked the same as yours...DTR enabled the rs485 tranmit) i just added a single one shot that was triggered off the falling edge of the rs232 signal and whose output enabled the rs485 transmit....set the one shot for the byte time and your DONE!!!! now i fought this solution for a few weeks as i am a software guy at heart but when i saw how simple it was in the hardware domain and versus how complex it was in the software domain i switched. This approach allowed me to use standard drivers and also the standard linux time slice scheduler rather then the SCHED_FIFO mod to be able to get the execution resoltion i needed to control the DTR lead from user space.
Digital pot Edit
Use a RC combination to set the length of the one shot. There probably are IC's that can be clocked for variable one shot time lengths.
More so than you have realized yet. I'm not familiar with the Linux implementation, but most serial drivers consider the buffer flushed, and done as soon as the last byte to be transmitted as been sent to the uart. The problem is, it takes about 1mS (9600 baud) for the uart to finish transmitting the character. If your using a buffered uart, the problem gets much worse!
If you manage to get a fast DTR shut off routine working, you WILL cut off the last few bits of your last character. Been there, done that.
The easiest solution is to not control the 485 transmitter in software. Use a one shot circuit in the RS-232 to 485 converter to do the dirty work for you.
B&B has just such an animal, and it works great! We use about 20-30 485TBLED units per year. DB25 for RS-232 side, Screw terminals for the 485 side.
Use four wires to Rx the Tx data Edit
Peter <z...@ds1.com> wrote:
> They do give the "all sent" info but only as a status bit - you cannot > program an interrupt from it. > > The main problem here is hardware: none of the 16450, 16550 and > > other UART give the information "char completely sent", they just > > give the information "Tx serialisator empty"...
I had a very similar problem in "2-wire" RS-485 comms, where each Tx/Rx only gets switched into Tx when required, and *must* drop back into an Rx'er asap. 5-byte packets into an 8-byte fifo. With a receiver hanging on the line you simply receive your own outgoing bytes, and as soon as the last byte ends, smack it back into Rx, and flush buffs. You don't actually have to read your own bytes, just count the ints from your own uart, each int being a signal that a full byte has gone.