I am looking for a way to get my phone to output a TTL level signal, up to about 1200 baud. Any suggestions?
The only thing I can think of is using an audio output with a square wave signal, and then amplifying it. Is that workable? Anything better?
I am looking for a way to get my phone to output a TTL level signal, up to about 1200 baud. Any suggestions?
The only thing I can think of is using an audio output with a square wave signal, and then amplifying it. Is that workable? Anything better?
Use a non-linear amplifier to get TTL levels, in the form of a comparator with it's threshold set a the mid-point of the audio waveform level. Possible devices might include an LM360.
This won't work for frequencies near zero, as audio output will likely stay close to the threshold and near the noise floor, producing garbage. But will work for a high enough minimum toggle rate.
If you need to get a TTL output toggling at any frequencies from 0 to 1200 Hz, then another strategy is to output a much higher frequency audio signal (say 12 kHz) for the duration of your TTL high, and use a bandpass filter on the output to filter and detect this tone (diode + cap, similar to a AM crystal radio detector) before the TTL output comparator (with its threshold set above the zero-output noise floor and below the bandpass filter ripple).
If you output a lower frequency, say 2400 Hz, to indicate TTL high, another possibility is to use an Arduino chip, audio to ADC input, and measure the time between threshold crossing to detect the tone frequency needed to output a high level on another IO pin. But this lower audio frequency will limit the minimum duration of your TTL pulse transitions (and quantize them in time).
A higher audio frequency will also quantize the TTL output in time, but at a higher time resolution. So an appropriate USB audio DAC might allow very high audio signaling frequencies by supporting a sample rate of 96k or 192k. This would likely provide even better time resolution for your TTL output than signaling via USB (OTG) serial or ethernet packets, as a streaming real time audio driver on a mobile device (RemoteIO on iOS) has much more deterministic latency than either the USB or the network stack drivers on the mobile OS.
a way to get my phone to output a TTL level signal
I assume that this is just about adding a TTL output to a smartphone, not about transmitting data through a telephony channel, since you're not mentioning that anywhere.
The only thing I can think of is using an audio output […] Anything better?
Modern phones have a USB on the go port, meaning that they can act as host to USB devices. For example, USB-to-serial (TTL) adapters. So, plug one of these into your phone, and write an app that has access to USB and interfaces with that adapter. Usually, if you're using one of the more popular USB-to-serial adapters, it will be known to the Linux kernel on an android phone, and unless the manufacturer stripped out that kernel module, you'll see it appear as /dev/ttyUSBx, and can just be dealt with like on any other Linux machine.
Same would be possible via bluetooth, since that has a general-purpose serial profile, too.
Other options include:
That is how computers and synthesizers saved data to cassette tapes back in the day. Some had analog audio interface to work with normal cassette recorders, and the ones that had TTL interface just had a similar analog interface stage in the tape deck. You don't even need amplification. Just AC couple the signal and feed it to a comparator circuit, preferably one that has some hysteresis built into it.