# Use UART Tx as digital output?

Would it be possible to send a 5 V "true" signal from the Tx of a UART dongle? As if it were a digital output?

Here is the UART adapter I purchased.

-
they did not think you were crazy, they were training to explain those are not intended to drive any real power, the power line is meant for that. –  Kortuk Jun 21 '12 at 21:40

Would it be possible to send a 5 volt "true" signal form the Tx of a UART dongle? As if it were a digital output?

Conditional yes.

(1) The module you linked to has TTL output levels.
Assume it uses +5V = high and 0V = low (I see it has 3V3 and 5V mentioned on its PCB).

This means that RXD will be at 5V in the idle state, a start bit will be 0V, data bits will be +5 for logic 1 and 0V for logic 0 and sytop bits will be 5V.

When data is not being sent V_RXD will be 5V.

If you send a $00 signal (00000000 binary) the UART will output start + 8xdata + stop = 0 00000000 1 The average DC level for this signal will be 1/10 x 5V = 0.5V. If you resend successive$00 bytes at maximum channel speed the output may be as low as 0.5V DC when suitably filtered. Depending on hardware and the USB interface and PC configuration and the phase of the moon you MAY get interuptions between btes and see occasional 5V signal level.

If you add a very simple RC + diode filter such that a RDX low discharges the cap immediately but charge up is via the resistor you can get low output during periods that the TXD line is high for limited periods.
If $00 bytes are able to be sent end-to-end with no breaks an RC+D filter can have a time constant of only a bit time or so. If longer highs occur you need a longer time constant. Whether an RC+D filter suits your needs depends on the data rate you want and system behaviour. If this is to control something that needs slow response - say 1 second or longer between changes and slow low to high change is acceptable, then this could work well for you. (2) External UART: A better method is to add an external UART at the receiving end and decode the serial signal to a parallel word. This gives you 8 bits of on off. (3) If you want something already built that does what you want buy a USB to parallel port (printer port) converter - this gives 8 (or more) lines of on/off control from USB. Many on ebay. Here is one for$US2.66 buy now withe free shipping !!!!!!!!!!!!!!!!! . Many more similar. Some people have commented that this may have printer functionality but not parallel port functionality. If so it should still be usable. At worst you may need to latch the data at "print time".

Indented text added as a result of a comment by CS:

• You specifically mentioned using the TX line, which is what I initially responded to.
Others have mentioned using flow control lines (which did not visibly appear to be available on your device and were not mentioned in the ad)and some suggested buying a converter which had these signals.

I recently spotted a USB-TTL serial converter on a local auction site and noted that the holes along the sides of the board had flow control labels. As your unit has similar holes it MAY also have similar functionality. So ...

Look at the bottom of your USB to TTL converter - it may have RTS/CTS and perhaps other signals available. If so, one or more of these can be controlled as an output.

See photo below. This is your unit. Note holes marked by red lines.

The photo below is a unit sold on a local auction site.
Of the 4 lines marked by arrows, 2 will be outputs and two will be inputs. These are controllable as part of a COM port. Yours may have these lines active or they may be disabled. Do you have a data sheet or detailed model number?

-
Are you sure that USB to parallel printer cables can be used to bitbang? I'm pretty sure that for something like that a real PCI/PCI-E card is actually needed because almost always USB to parallel port devices create a virtual printer and aren't bitbangable. –  AndrejaKo Jun 21 '12 at 21:42
+1 for crazy! :) –  Toby Jaffey Jun 22 '12 at 8:25
@TobyJaffey - I was not the user of "crazy". You may have +1'd the wrong person :-). –  Russell McMahon Jun 22 '12 at 9:05
Nope, I think sending 0x00 and using a filter is nuts, but I like it. –  Toby Jaffey Jun 22 '12 at 9:08
@AndrejaKo - If it does not give you port access but does give printer access then presumably it would strobe a latch (which could be powered from the port) and you could make a logic arrangement with a few transistors or gates that allowed bit set/clear with minimal hardware. / For the serial port A microcontroller acting as a uART and serial to latched parallel converter sounds like a simple solution. –  Russell McMahon Jun 22 '12 at 9:10

I did not think you crazy for asking, even though the answer was clearly 'impossible'.

On your new question: yes, you can probably control the level of the Tx pin, by either sending nothing at all, or setting the 'break' condition. (but the break condition is not very well sepecified, it might be that some OSes or drivers interpret it as having a limited time. IME Windows and Linux do NOT fall in this category.)

But it is probably far easier to set the levels of the various control pins. How this is done depends on your programming language and library.

When you use a standard serial port or an off-the-shelve usb-to-serial converter you het outputs at RS232 polarity (=inverted) and level (-10V / +10V or something like that).

It is probably easier to use a 'bare' converter chip, without the RS232 level shifter. FTDIchip makes some, check http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm

IME usb-to-parallel converters are useless for your purpose, because they create a virtual printer port, not a virtual parallel port.

-
+1 I don't know what IME means, but I know it's easy to set an infinite or any length break in Windows. –  kenny Jun 21 '12 at 21:26
@kenny - IME = "In My Experience" –  Oli Glaser Jun 21 '12 at 21:46
I'm not sure which language to use yet. I am thinking I will use Python or C# because (from the googleing that I have done) it seems like Python has a very good "PySerial" library, and (from experience) C# has .NET backing it which is also very easy to use. But if people have other languages or libraries they recommend I am happy to hear suggestions. –  Keegan McCarthy Jun 21 '12 at 22:52
I use Python and pyserial, to my satisfaction. –  Wouter van Ooijen Jun 22 '12 at 6:32

I don't think you can keep the TX pin high or low at all times. Every byte you send will have a start bit (logic low) and a stop bit (logic high). Your best bet would be to get a usb-to-uart adaptor that has DTR and/or RTS pins. These lines can be toggled easily.

However.

This answer is only as good as your question, which is not that good really, as you don't give many details. If you tell us what exactly is that you're trying to do, what hardware you have (and so on), we might be able to give you a better advice.

My first question would be this: If you have an arduino and a relay module for it, why do you have to use some roundabout way to solve your problem?

-
+1 for suggesting DTR pin instead of TX. –  semaj Jun 22 '12 at 15:19