PDA

View Full Version : TTL Serial Cable



cmason
11-16-2012, 05:19 AM
I bought this TTL serial cable from Adafruit (https://www.adafruit.com/products/954) in order to try to debug USB stuff. Their page clearly advertises 3.3V logic levels, which I assumed would make it safe for use with the Teensy 3.

I wired it up to pins 0 (green TX to teensy RX) and 1 (white RX to teensy TX). Right? I never connected the power or ground.

The cable is recognized by the computer, and I can connect with screen. However, I never see any output. The program runs fine with USB serial. I switched to HardwareSerial, as in:


HardwareSerial Serial;
Serial.println("hello, world");

Moreover, it seems like my analog input A0 now has much higher noise, even after disconnecting the USB serial cable from the teensy. I'm seeing wildly varying readings now. Where before I would see readings that were consistent to within a few percent with no input wire attached, now I'm seeing them vary by as much as 50%.

Could I have somehow damaged the ADC section of my chip but left the reset of it functional? Is this plausible or could something else be going on?

Thanks,

-c

Magnethead494
11-16-2012, 05:31 AM
I don't think you used the right typedef alias.

Unless something changed for 3.0, this is what I use for 2.0:

HardwareSerial Uart = HardwareSerial();

Be careful using Serial as the alias name, the compiler may not interpret it correctly since 'Serial' is a keyword. That's why Paul's examples always use Serial for usb and Uart for TTL.

cmason
11-16-2012, 06:15 AM
So I tried switching the names and it had no effect.

I really feel like there's something going wrong electrically here. If I connect RT and TX (or RX, TX, and Ground) and then touch (not even plug in) the shield of the micro USB cable to the outside of the connector, the LED glows faintly (yeah). (I have both the USB serial cable and the micro USB plugged into the same mac laptop.) I'm guessing this cable isn't really 3.3 V compliant: TX to ground measures 3.59 V. I assume this is far enough away from 3.3V to be a problem? Just to be clear: power to ground measures exactly 5V, but I never connected power anywhere near the Teensy.

If I put the teensy back in a breadboard, then this variable analog read behavior goes away. I assume I'm grounding it and bleeding off stray current.

-c

pixelk
11-16-2012, 06:24 AM
0&1 is the first hardware serial, which can be talked to using Serial1, not Serial.
Serial = USB virtual comport (the one popping up on your computer when you hook up the µUSB on the teensy)
Serial1 = 0&1
Serial2 = 9&10
Serial3 = 7&8

I don't really get why you redefine Serial, just use Serial1.

PaulStoffregen
11-16-2012, 09:20 AM
It sounds like there's 2 separate problems here.... #1: no data transmitting on pin 1, and #2: analog noise when the cable is connected. Or maybe I've misunderstood?

One thing I noticed (aside from the Serial vs Serial1 name conflict) is the lack of Serial1.begin(baud). Do you have a line like this in your code?



Serial1.begin(115200); // begin is necessary to set the baud rate


Also, you mentioned seeing 3.59 volts. Aside from the voltage being more than 3.3, is it possible you're connecting the cable's transmit pin to Teensy 3.0's transmit pin?


On the noise issue, I'd try 2 things. First, connect only the ground pin and leave the 2 data pins and power disconnected. If you get the noise problem with only the ground connected, then obviously you're seeing some sort of ground loop issue.

If connecting only the cable's ground works, then go for adding the RX pin to Teensy 3.0's TX1 (pin 1). If that causes noise, then perhaps the cable is not really 3.3 volts and it's injecting quite a lot of current through the ESD protection diode inside the chip?

Zonker
11-27-2012, 09:00 PM
You may have recieved other clues in direct messages, but I didn't see this in the current thread, so here I go...


I bought this TTL serial cable from Adafruit (https://www.adafruit.com/products/954) in order to try to debug USB stuff. Their page clearly advertises 3.3V logic levels, which I assumed would make it safe for use with the Teensy 3.

I wired it up to pins 0 (green TX to teensy RX) and 1 (white RX to teensy TX). Right? I never connected the power or ground....


Your TXD and RXD (data) lines always need a common reference signal, and this is most often the common "ground" of the connected circuits. (This is the "zero voltage", which your transmit and receive signals are measured, to determine if they are "0" or "1".) In your statement, in blue above, you indicated that you had not connected the ground pin.

When you are running your Arduino from a separate power pack than your computer, or from a battery source, you need that third wire for useful 2-way serial communications (not counting whether you need hardware flow-control, or hardware handshaking...).

My guess is that your proto-board somehow has another connection to your computer (like a USB connection?) which provided the needed ground reference connection, which is why your serial communications "just started working". To prove that theory, you can go back to the previous configuration used in your first post, and connect the ground wire from that RS232 cable, and confirm that it now works as you expected.

Best regards, -Z- http://www.conserver.com/consoles/