Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: USB - Serial Problems

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Posts
    11

    USB - Serial Problems

    Anyone who can help a 'Newbie'?

    I am using the 'Echo Both' example code for serial testing on the Teensy 3.5 board, with a USB to serial convertor lead from another computer which has RX, TX and ground connected to RX1, TX1 and GND on the Teensy board.
    I am using 'RealTerm' on the computer to send data to the Teensy serial port via the USB-Serial convertor lead.
    I have checked that data is being sent correctly from the computer by monitoring it using 'RealTerm' on another computer, and data is being sent and received correctly. Baud rates are set at 38400.
    Using the Arduino serial monitor, I get the expected result when sending 'A' via the USB serial connected to the Teensy board i.e. the monitor shows:

    USB received 65
    USB received 13
    USB received 10

    But the 'RealTerm' monitor just shows garbage:

    UVTʪjTZ6VVU۪ʪjTZ֖VoU۪ʪjTZVo 

    with the occasional brief showing of 'UART Receiver Framing Error' in the bottom status bar. I have triple-checked the baud rate, parity and stop bit settings.

    I get no response in the Arduino serial monitor when sending from the other computer using the USB-Serial convertor lead, but some activity (UART received) is displayed if I connect and disconnect the serial connections (RX and TX) to the Teensy breadboard.

    I would be very, very grateful of any help that anyone can give,

    Many thanks,

    Allen

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,452
    Maybe a wrong connection? Can you show us photos of how the wires are really connected?

    which has RX, TX and ground connected to RX1, TX1 and GND on the Teensy board.
    Double check the grounds are really connected, and that each TX goes to RX on the other side. Sometimes a misunderstanding happen where people connect signals of the same name together. That's correct for SPI & I2C, but with serial each transmit pin needs to connect to a receive pin.

  3. #3
    Junior Member
    Join Date
    Dec 2018
    Posts
    11
    Dear Paul,

    Many thanks for your prompt response.
    I have double-checked the grounds, and also used a 'Null Modem' convertor to reverse the TX / RX connections. With the connections 'reversed', I get no output at all, with the TX / RX connected as they should be, I get the garbage as shown on my first posting.

    Click image for larger version. 

Name:	PCB Layout (2).jpg 
Views:	5 
Size:	233.8 KB 
ID:	17176

    I have attempted to upload a photo of the board layout - not sure if it has worked!

    Many thanks,

    Allen

  4. #4
    Junior Member
    Join Date
    Dec 2018
    Posts
    11
    Quote Originally Posted by AllenCherry View Post
    Dear Paul,

    Many thanks for your prompt response.
    I have double-checked the grounds, and also used a 'Null Modem' convertor to reverse the TX / RX connections. With the connections 'reversed', I get no output at all, with the TX / RX connected as they should be, I get the garbage as shown on my first posting.

    Click image for larger version. 

Name:	PCB Layout (2).jpg 
Views:	5 
Size:	233.8 KB 
ID:	17176

    I have attempted to upload a photo of the board layout - not sure if it has worked!

    Many thanks,

    Allen
    It looks as though the upload of the photo has worked! The pink and white wires are the TX1 and RX1 from the Teensy (1 and 0) to the 9 pin 'D' connector, pins 2 and 3, the black wire is the ground to pin 5 on the 'D' connector from GND (0) on the Teensy board. Using a 'null modem' convertor to reverse pins 2 and 3 gives no response on the RealTerm display, so I assume that they are connected correctly.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,452
    Yikes, that looks like a connector for RS-232 level signals. Teensy 3.6 needs 3.3V "TTL level" signals, which are lower voltage and opposite polarity from RS-232 level signals.

    Without connecting to Teensy, use a voltmeter to measure those signals (without any data flowing). RS-232 transmit will measure between -5V to -12V (yes, negative voltage relative to GND) when the line is idle. TTL level should measure +3.3V when idle, which you can confirm on pin 1 (TX1) on Teensy.

    You're probably going to need a level converter. MAX232 is a popular chip. In fact, you can see one used on the breadboard on the serial page.

    https://www.pjrc.com/teensy/td_uart.html

    However, you MAX232 gives 5V signals. Teensy 3.6 is not 5V tolerant, so you would need a similar MAX3232 part, which is basically the same thing but for 3.3V signals.





    There are also transistor circuits (usually lower performance) to convert the levels, which you can find by searching...

  6. #6
    Junior Member
    Join Date
    Dec 2018
    Posts
    11
    Hi Paul,

    Yes, it is a 'standard' 9-pin 'D' connector, but the RS2332 from the USB to Serial convertor is only giving TTL signal levels of 5 volts.
    I am using the Teensy 3.5, so it is 5 volt tolerant, hence I don't think that the MAX232 is actually required.

    Any other clues?

    Many thanks,

    Allen

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,452
    Check the actual voltage with a voltmeter. Maybe it's really -5V when idle?

    Hard to believe any commercial serial product with that 9 pin connector would have the correct polarity, since it would then be unable to work with all the other 9 pin serial connectors in the world!

  8. #8
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,286
    Quote Originally Posted by AllenCherry View Post
    I get the garbage as shown on my first posting.
    Maybe try to setup UART in teensy with inverse polarity. (I needed that to use a RS232 cable to a T3.2)

  9. #9
    Junior Member
    Join Date
    Dec 2018
    Posts
    11
    Hi Paul,

    I think that you have found the problem - Pin 2 on the USB - Serial convertor is sitting at -5 volts!

    So does that mean I will have to incorporate the MAX232 to drive the RX1 / TX1 serial port on the Teensy?

    Many thanks for your help,

    Allen

  10. #10
    Junior Member
    Join Date
    Dec 2018
    Posts
    11
    Quote Originally Posted by WMXZ View Post
    Maybe try to setup UART in teensy with inverse polarity. (I needed that to use a RS232 cable to a T3.2)
    Many thanks for a possible solution - is the 'SERIAL_8N1_RXINV_TXINV' the correct syntax to use for the UART inverse polarity?

    Best wishes,

    Allen

  11. #11
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,286
    Quote Originally Posted by AllenCherry View Post
    Many thanks for a possible solution - is the 'SERIAL_8N1_RXINV_TXINV' the correct syntax to use for the UART inverse polarity?
    I think so (I got it from include files)

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,452
    Teensy 3.5 is 5 volt tolerant, but no Teensy is negative voltage tolerant.

    You either need a proper level converter like MAX232, or at the very least a resistor and diode to clamp the voltage so Teensy's pin isn't driven negative.

  13. #13
    Junior Member
    Join Date
    Dec 2018
    Posts
    11
    Quote Originally Posted by PaulStoffregen View Post
    Teensy 3.5 is 5 volt tolerant, but no Teensy is negative voltage tolerant.

    You either need a proper level converter like MAX232, or at the very least a resistor and diode to clamp the voltage so Teensy's pin isn't driven negative.
    Thanks Paul,

    The MAX232 is definitely the most robust way forward. I have ordered a couple, and will wire them in tomorrow.

    I'll let you know how I get on.

    Very much appreciate your help,

    Allen

  14. #14
    Junior Member
    Join Date
    Dec 2018
    Posts
    11
    Hi Paul,

    Just to let you know that I used a DSD TECH USB to TTL Serial Adapter purchased from Amazon - two pieces for 8.99. I figured that I would have to have a USB plug and lead going from the computer to the MAX232 IC, so having the TTL levels built into the USB plug seemed to be a neater way.
    All working fine now!

    Again, really appreciate you help and guidance.

    Many thanks,

    Allen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •