Trying to use Serial5 to my laptop USB port.

Status
Not open for further replies.

laptophead

Well-known member
The usual "Serial" works fine on my desktop, however I am using it to send data to the teensy by Serial Monitor.

So I need to monitor the behavior of my motors and encoders through SerialPlotter or processing. Therefore I need another USB port just for that , and I selected 5, since is not wired to any of my needs.
From the laptop USB I brought Plus Minus, RX TX and connected them accordingly. RX and TX go to 34 and 33. However the laptop does not see the port, and serial monitor shows nothing.

In the sketch I used,

in setup
Serial.begin(115200);
Serial5.begin(115200);

in the loop
Serial5.println(OutputShoulder);

Thanks
 
You can't connect a USB Port to a Teensy Serial Port. They are totally different. You need a USB adapter.
The Teensy "Serial" has this "built in"... and is a usb-device.
 
You know, I will use a second Teensy to communicate to Serial5, and then output to the USB to my laptop. It is just temporary. Do you think Serial5 to Serial5 would communicate nice from one teensy to another?
 
From the laptop USB I brought Plus Minus, RX TX and connected them accordingly. RX and TX go to 34 and 33.

Can you post a photo showing how you're actually connecting these wires?

Your words aren't clear. At least to me, they sound like you're connecting directly to the USB signals. But that makes no sense, since the USB signals are *not* TTL level serial. They are USB signals which use a very complex protocol, not anything like normal serial. You must use a USB-serial converter, like this:

https://www.digikey.com/products/en?keywords=768-1015-ND

If you don't have one, you can also just use another Teensy. Just program it with File > Examples > Teensy > USB_Serial > USBtoSerial. Then it will appear as another serial port to your PC, and you can connect its RX1 to TX4 and its TX1 to RX5. Your Serial5 communication will then appear at the serial port for this other Teensy.
 
Paul, I would love to use USBtoSerial but I have no code for the sender teensy? Do I use Serial.write?
I need to send 4 integers, 5 digits each. This sketch gets one char. What to do?
 
You would need to run USBtoSerial on a *different* Teensy board. Then you connect that second Teensy to your first Teensy using 3 wires. GND to GND, RX1 to TX5, and TX1 to RX5.

On the first Teensy, you would then use Serial5.print(number); That will cause your first Teensy to transmit data on TX5. Since TX5 is connected to RX1, the first Teensy which is running USBtoSerial receive the data and then sends it to your PC.

Or, instead of a second Teensy board, you could use those dedicated USB-serial products Frank and I showed in msg #4 & #8. They will do the same thing as a Teensy running the USBtoSerial - they receive whatever your code transmits on the TX5 pin and send it to your PC.

Hopefully this makes sense?
 
makes perfect sense,
usb Serial. on teensy1 on desktop
usb Serial. on teensy2 on laptop

Serial5 on teensy1 wired to Serial1 of teensy2

teensy1, serial5 is relaying input to Serial while Serial is relaying output to Serial5
teensy2, Serial1 is relaying inout to Serial while Serial is relaying output to Serial1

but since your sending "special data" on teensy1 just send it to Serial5, and your laptop will see it fine

yes it only does 1 character at a time but you wont notice it, thats how serial writes work
 
Actually, if you open File > Examples > Teensy > USB_Serial > USBtoSerial and look closely at the code, you'll see it uses available(), readBytes(), availbleForWrite(), write() to efficiently move up to 80 bytes at a time.

However, for baud rates below 1 Mbit/sec on 32 bit Teensy, or baud rates below 115200 on 8 bit Teensy, this optimization makes little difference when Teensy isn't doing any other work. But if you use this example code within another larger program that does more, the efficient data movement can help free up more CPU time for your other work.
 
Great, I am trying.

On the sender (teensy1) side I got:
In setup I got,

Serial5.begin(19200); // trying to match the receiver code.

In the loop I got
Serial5.print(OutputExport); // sending an integer OutputExport

The Wiring is correct . Pin 33 of the sender goes to pin 0 on the receiver. 34 goes to 1. and I do have common ground.

Now in the receiver sketch USBtoSerial :

Where is my variable?
Is it n?
I tried a Serial.println (n); and I got a line of zeros. It is at the end of the loop?

The sender is sending a value of 150.
Is n and int? As a char I can not plot it, so is not useful...

I put the scope on the Pin0 of the receiver and ground and I do see pulses,

What to do?
 
Earlier you said you wanted to get data you transmit on Serial5 to arrive in the Arduino Serial Monitor on your PC.

The USBtoSerial does everything you asked. It just moves data from the RX1 pin to the USB, and any data from USB to the TX1 pin. That's *exactly* what you said you wanted.

If you now want to do something more complicated, like manipulate the data on the 2nd Teensy, you certainly can. But why not at least use it as-is first, while you're still learning. Don't make things more complicated than they need to be (which applies to novices and experts alike....)
 
Paul , thanks for the reply.

On the receiver Teensy that runs the USBtoSerial I get all zeros.
I tried a Serial.println (n); and I got a line of zeros.
Actually I dont get the data.

What to do?
 
Is this the original, unmodified USBtoSerial Sketch ?
And you tried this Serial.println (n); on the other Teensy ?
Are you sure that n is <> 0? try Serial.println(123) to check this..

Please post your Sketch.
 
Status
Not open for further replies.
Back
Top