Author Topic: Bi-directional uart  (Read 1496 times)

0 Members and 1 Guest are viewing this topic.

Offline piamTopic starter

  • Newbie
  • Posts: 6
  • Country: gb
Bi-directional uart
« on: January 09, 2020, 11:08:12 am »
Hi,
I have a circuit that I'm trying to implement that is quite old and uses RS232 to communicate bi-directionally over a single pin to an MCU.

Here's the circuit:


I'd rather not use RS232 and just want to communicate using a rasperry Pi or similar with PTA0, but it both receives and transmits over a single pin. Can someone suggest how I might do this natively on a pi, either by driving a GPIO bi-directionally and doing this in software, or using the native UART and somehow tieing rx and tx together, perhaps with some other chip?

 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 5050
  • Country: si
Re: Bi-directional uart
« Reply #1 on: January 09, 2020, 11:25:21 am »
And why not just connect pins 16 and 15 of that MC145407 to the RX and TX pins of a raspberry UART port?
 

Offline piamTopic starter

  • Newbie
  • Posts: 6
  • Country: gb
Re: Bi-directional uart
« Reply #2 on: January 09, 2020, 11:28:11 am »
I don't have the MC145407 or MC74HC125 and was hoping to avoid it if I didn't need them.
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 5050
  • Country: si
Re: Bi-directional uart
« Reply #3 on: January 09, 2020, 11:40:06 am »
In that case why not just buy a off the shelf USB to RS232 dongle and use it with a DB9 do DB25 serial adapter.
 

Offline mvs

  • Frequent Contributor
  • **
  • Posts: 370
  • Country: de
Re: Bi-directional uart
« Reply #4 on: January 09, 2020, 11:50:49 am »
I don't have the MC145407 or MC74HC125 and was hoping to avoid it if I didn't need them.
You do not need RS232 driver (MC145407), but perhaps 3.3v <-> 5v level shifter (RPi has 3.3v IO levels).

74hc125 is just cheap Tri-state buffer. You may replace it with a small signal diode (cathode to RPi TX, anode to RPi RX and PTA0 + Pullup R).
 

Offline piamTopic starter

  • Newbie
  • Posts: 6
  • Country: gb
Re: Bi-directional uart
« Reply #5 on: January 09, 2020, 11:53:48 am »
I do have a USB to RS232 dongle, but it feels really ugly going from USB to RS232 to TTL to this single pin interface via two chips that I don't (yet) have and that seem superfluous. I was thinking of using http://abyz.me.uk/rpi/pigpio/cif.html to do this UART in software. I do have those two chips on order and should get them in a few days. Would be good not to have to use them though.

I don't actually need 5v anywhere, that's just because of the RS232.
 

Offline piamTopic starter

  • Newbie
  • Posts: 6
  • Country: gb
Re: Bi-directional uart
« Reply #6 on: January 09, 2020, 12:00:44 pm »
74hc125 is just cheap Tri-state buffer. You may replace it with a small signal diode (cathode to RPi TX, anode to RPi RX and PTA0 + Pullup R).
Cool, that sounds like a plan. Thanks.
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 5050
  • Country: si
Re: Bi-directional uart
« Reply #7 on: January 09, 2020, 12:05:58 pm »
Ah you want to go the other direction.

In that case just use the same 74HC125 circuit and instead of connecting it to the MC145407 you connect it to the TX and RX pin on a raspberry.

You can try bitbanging UART but you will have a world of trouble getting it to work at anything higher but the slow snails pace baudrates. Id say paying for a 10 cent 74 series quad buffer IC is cheaper than investing days of work to do it with direct connection to the Raspberry IO pin.
 

Offline piamTopic starter

  • Newbie
  • Posts: 6
  • Country: gb
Re: Bi-directional uart
« Reply #8 on: January 09, 2020, 01:49:45 pm »
In that case just use the same 74HC125 circuit and instead of connecting it to the MC145407 you connect it to the TX and RX pin on a raspberry.

You can try bitbanging UART but you will have a world of trouble getting it to work at anything higher but the slow snails pace baudrates. Id say paying for a 10 cent 74 series quad buffer IC is cheaper than investing days of work to do it with direct connection to the Raspberry IO pin.

At the moment, because of the crystal I have (ordered some more), it'll be 13240 baud...  I'm not sure of the status of my orders, but if I don't get the stuff I want by tomorrow, I might try the software mechanism in the interim.
 

Offline piamTopic starter

  • Newbie
  • Posts: 6
  • Country: gb
Re: Bi-directional uart
« Reply #9 on: January 10, 2020, 02:54:02 pm »
74hc125 is just cheap Tri-state buffer. You may replace it with a small signal diode (cathode to RPi TX, anode to RPi RX and PTA0 + Pullup R).
This is exactly what I did (I think!). For every byte I write I get it echoed back and then I get the data I'm expecting. I have some anomalies with failed reads after a while but I can just work around those by repeating the command I'm sending.
Thanks
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf