8

I'm working on a project that is going to need two different UART interfaces.

Is there a way to make a regular GPIO pin into a Tx UART pin, I don't need an Rx pin too. Is there a software solution in python maybe, as I doubt there is a hardware solution for turning a digital pin to a serial Tx pin.

2 Answers 2

5

The easy answer is no, the hard answer is yes. The issue lies at the heart of the Linux operating system. Linux is not a real time operating system, unlike the Arduino, so timing is an issue. Any process can take CPU time at any time, which can cause your timing to be off, making it very difficult to interpret the received signal on the remote device.

So theoretically yes, it is possible, but due to these limitations which would make the software unusable, no one that I know of has written anything to do this task.

That being said, you do still have options. There are multiple I2C to UART converter chips, which would allow you to run up to 127 different chips on single 2 wire i2c bus. You can also look into the RS485 protocol. This will allow you to run multiple devices off the same serial bus. There are several converters available that allow you to convert your single UART signal to RS485, but i think you will have to handle addressing in your own software.

2
  • So does that render these two motor controllers I had sitting around useless? As the way I was planning on interfacing with them was through two UART Pins? pololu.com/catalog/product/1376 Aug 15, 2013 at 4:39
  • @MonteCarlo I was adding to my answer while you commented. Check again, I think you will find a workable solution... Not free though...
    – Butters
    Aug 15, 2013 at 4:43
2

The GPIO pins can be on or off or tell you the pin is one or zero. In order for you get information that the letter "A" from a particular pin has arrived you would get a series of ons and offs, say one 1 and two zeros within say a second. You would then conclude that you have within one second received "A" in morse code.

So you have to establish a protocol that at the Raspberry end you should expect letter info in more in one second. The sending end should also know all that.

Futhermore you should establish some sort of "end-of-transmission" and "hand-shake" procotols etc.

Also like the other guy says you would have to read info in a very tight loop or Linux/Windows/whatever may stop reading momentarily (allthough data keeps coming) to conduct some other stuff, like adjust clock etc. Then you would loose some data unless it was save on some stack.

So the easy answer is no. Just too much work, but it can be done.

The UART pin in the other hand does this automatically. It uses extra circuitry and logic + uses pre-established protocols and buffers and whatnot so that you can perform a c-code "read" to read a "character" and not just voltage highs and lows.

Caveat: I am not an electrician - I write code and above is my take on the subject.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.