Jump to content

Plug USB into Arduino?

TheNuzziNuzz

I want to connect this USB device to my Arduino mega.

 

I have the drivers for it to work on windows, its a simple serial device I can send/recieve messages form any serial terminal. 

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, TheNuzziNuzz said:

I want to connect this USB device to my Arduino mega.

 

I have the drivers for it to work on windows, its a simple serial device I can send/recieve messages form any serial terminal. 

What's the question?

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, WereCatf said:

What's the question?

Sorry haha, is this possible? How could I accomplish it? 

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, TheNuzziNuzz said:

Sorry haha, is this possible? How could I accomplish it? 

Of course it is. Just connect GND to GND, RX to TX, TX to RX with e.g. a dupont-cable with one male head and one female head. If you want to power the Arduino from this as well, then connect 5V to 5V.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, TheNuzziNuzz said:

Arduino mega

You want to connect a UART adapter... to an Arduino that already has four UART outputs...? Why not just use the built in ones?

 

EDIT: Oh, right, Serial to Serial, USB to computer. I'm tired... nevermind me.

Edited by AbydosOne

Main System (Byarlant): Ryzen 7 5800X | Asus B550-Creator ProArt | EK 240mm Basic AIO | 16GB G.Skill DDR4 3200MT/s CAS-14 | XFX Speedster SWFT 210 RX 6600 | Samsung 990 PRO 2TB / Samsung 960 PRO 512GB / 4× Crucial MX500 2TB (RAID-0) | Corsair RM750X | a 10G NIC (pending) | Inateck USB 3.0 Card | Hyte Y60 Case | Dell U3415W Monitor | Keychron K4 Brown (white backlight)

 

Laptop (Narrative): Lenovo Flex 5 81X20005US | Ryzen 5 4500U | 16GB RAM (soldered) | Vega 6 Graphics | SKHynix P31 1TB NVMe SSD | Intel AX200 Wifi (all-around awesome machine)

 

Proxmox Server (Veda): Ryzen 7 3800XT | AsRock Rack X470D4U | Corsair H80i v2 | 64GB Micron DDR4 ECC 3200MT/s | 4x 10TB WD Whites / 4x 14TB Seagate Exos / 2× Samsung PM963a 960GB SSD | Seasonic Prime Fanless 500W | Intel X540-T2 10G NIC | LSI 9207-8i HBA | Fractal Design Node 804 Case (side panels swapped to show off drives) | VMs: TrueNAS Scale; Ubuntu Server (PiHole/PiVPN/NGINX?); Windows 10 Pro; Ubuntu Server (Apache/MySQL)


Media Center/Video Capture (Jesta Cannon): Ryzen 5 1600X | ASRock B450M Pro4 R2.0 | Noctua NH-L12S | 16GB Crucial DDR4 3200MT/s CAS-22 | EVGA GTX750Ti SC | UMIS NVMe SSD 256GB / TEAMGROUP MS30 1TB | Corsair CX450M | Viewcast Osprey 260e Video Capture | Mellanox ConnectX-2 10G NIC | LG UH12NS30 BD-ROM | Silverstone Sugo SG-11 Case | Sony XR65A80K

 

Camera: Sony ɑ7II w/ Meike Grip | Sony SEL24240 | Samyang 35mm ƒ/2.8 | Sony SEL50F18F | Sony SEL2870 (kit lens) | PNY Elite Perfomance 512GB SDXC card

 

Network:

Spoiler
                           ┌─────────────── Office/Rack ────────────────────────────────────────────────────────────────────────────┐
Google Fiber Webpass ────── UniFi Security Gateway ─── UniFi Switch 8-60W ─┬─ UniFi Switch Flex XG ═╦═ Veda (Proxmox Virtual Switch)
(500Mbps↑/500Mbps↓)                             UniFi CloudKey Gen2 (PoE) ─┴─ Veda (IPMI)           ╠═ Veda-NAS (HW Passthrough NIC)
╔═══════════════════════════════════════════════════════════════════════════════════════════════════╩═ Narrative (Asus USB 2.5G NIC)
║ ┌────── Closet ──────┐   ┌─────────────── Bedroom ──────────────────────────────────────────────────────┐
╚═ UniFi Switch Flex XG ═╤═ UniFi Switch Flex XG ═╦═ Byarlant
   (PoE)                 │                        ╠═ Narrative (Cable Matters USB-PD 2.5G Ethernet Dongle)
                         │                        ╚═ Jesta Cannon*
                         │ ┌─────────────── Media Center ──────────────────────────────────┐
Notes:                   └─ UniFi Switch 8 ─────────┬─ UniFi Access Point nanoHD (PoE)
═══ is Multi-Gigabit                                ├─ Sony Playstation 4 
─── is Gigabit                                      ├─ Pioneer VSX-S520
* = cable passed to Bedroom from Media Center       ├─ Sony XR65A80K (Google TV)
** = cable passed from Media Center to Bedroom      └─ Work Laptop** (Startech USB-PD Dock)

Retired/Other:

Spoiler

Laptop (Rozen-Zulu): Sony VAIO VPCF13WFX | Core i7-740QM | 8GB Patriot DDR3 | GT 425M | Samsung 850EVO 250GB SSD | Blu-ray Drive | Intel 7260 Wifi (lived a good life, retired with honor)

Testbed/Old Desktop (Kshatriya): Xeon X5470 @ 4.0GHz | ZALMAN CNPS9500 | Gigabyte EP45-UD3L | 8GB Nanya DDR2 400MHz | XFX HD6870 DD | OCZ Vertex 3 Max-IOPS 120GB | Corsair CX430M | HooToo USB 3.0 PCIe Card | Osprey 230 Video Capture | NZXT H230 Case

TrueNAS Server (La Vie en Rose): Xeon E3-1241v3 | Supermicro X10SLL-F | Corsair H60 | 32GB Micron DDR3L ECC 1600MHz | 1x Kingston 16GB SSD / Crucial MX500 500GB

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, AbydosOne said:

You want to connect a UART adapter... to an Arduino that already has four UART outputs...? Why not just use the built in ones?

 

1 minute ago, WereCatf said:

Of course it is. Just connect GND to GND, RX to TX, TX to RX with e.g. a dupont-cable with one male head and one female head. If you want to power the Arduino from this as well, then connect 5V to 5V.

Hmm...

 

Ok so i'm confused, I have the FTDI cable linked above and the arduino connected to my computer. I have a serial console two each of them. I have the device i'm interfacing with (a vehicle ECM). And I want the data to flow through the Arduino, not through the FTDI usb cable in my computer if that makes any sense.

 

THe issue is the serial from the arudino and from the FTDI cable are showing completely different outputs. Plus my specialized software for the vehicle ECM works fine through the FTDI but not the arduino. This is the sketch I am using:

 

void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial1.begin(8192);
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.print(inByte, HEX);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.print(inByte, HEX);
  }
}

 

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, TheNuzziNuzz said:

THe issue is the serial from the arudino and from the FTDI cable are showing completely different outputs. Plus my specialized software for the vehicle ECM works fine through the FTDI but not the arduino. This is the sketch I am using:

Why is serial1 configured at 8192bps?

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, WereCatf said:

Why is serial1 configured at 8192bps?

The ECMs baud rate is 8192

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, TheNuzziNuzz said:

The ECMs baud rate is 8192

Well, okay. Anyway, your problem is the HEX-part in your print-clause. Instead of just putting out the byte you received, you're putting out the value of the byte in hexadecimal number. Like, say you receive a byte of value 156 -- that is a single byte -- the print-clause will instead convert that into text that reads "9C", which is two bytes. Remove the HEX-part.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, WereCatf said:

Well, okay. Anyway, your problem is the HEX-part in your print-clause. Instead of just putting out the byte you received, you're putting out the value of the byte in hexadecimal number. Like, say you receive a byte of value 156 -- that is a single byte -- the print-clause will instead convert that into text that reads "9C", which is two bytes. Remove the HEX-part.

That didn't fix it. The reason I had it set to HEX is because the FTDI cable spit out hex to the console. Even if I translate the non hex into hex it doesnt match the FTDI.

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, TheNuzziNuzz said:

That didn't fix it. The reason I had it set to HEX is because the FTDI cable spit out hex to the console. Even if I translate the non hex into hex it doesnt match the FTDI.

Oh, sorry, I had a brainfart since I'm programming something myself atm. Anyways, you need to use .write() instead of .print() -- .print() spits out human-readable text, .write() spits out the actual byte itself as-is.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, WereCatf said:

Oh, sorry, I had a brainfart since I'm programming something myself atm. Anyways, you need to use .write() instead of .print() -- .print() spits out human-readable text, .write() spits out the actual byte itself as-is.

Ahh, Thank You, i'm going to update that now. I just took a screenshot of the two console so you can see:

image.png.99d22ca90c9b77c56a457bb5c5170571.png

The right is the Arduino, left is FTDI. I also wonder if there may be something at play here with incorrect baud rates.

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, TheNuzziNuzz said:

Left is Arduino

@WereCatf

 

This is with Serial.write

That's most likely due to wrong wiring. You'll need to explain exactly how everything is connected up.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, WereCatf said:

That's most likely due to wrong wiring. You'll need to explain exactly how everything is connected up.

For all intensive purposes there are two pins on the ECM. One labeled "8192 Baud" and a Ground.

 

I have the 8192 Baud pin going to a breadboard. From there I have two diodes, one in each direction. From each diode i have a jumper going to the respective TX/RX pins on both the arduino and the FTDI adapter.

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, TheNuzziNuzz said:

I have the 8192 Baud pin going to a breadboard. From there I have two diodes, one in each direction. From each diode i have a jumper going to the respective TX/RX pins on both the arduino and the FTDI adapter.

So, Arduino's and FTDI-adapter's TX are wired together to the same diode and Arduino's RX and FTDI's RX are similarly together into the same diode? If yes, then I dunno. It could be the odd baudrate causing havoc.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, WereCatf said:

So, Arduino's and FTDI-adapter's TX are wired together to the same diode and Arduino's RX and FTDI's RX are similarly together into the same diode? If yes, then I dunno. It could be the odd baudrate causing havoc.

Yep that is how its wired. Now this is interesting, I switched to a different terminal program that displays in hex:

 

Arduino is left:

image.png.92c12098c630d70d13a9e3fbd1039ac2.png

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, WereCatf said:

So, Arduino's and FTDI-adapter's TX are wired together to the same diode and Arduino's RX and FTDI's RX are similarly together into the same diode? If yes, then I dunno. It could be the odd baudrate causing havoc.

So here is what my specific software says/does:

 

Arduino (not working): 

Quote

Shutup request----F45608AE----
Shutup request----F45608AE----
Shutup request----F45608AE----

Time=06:33:35 PM
Vehicle data-->--F4570104B0----
 

(and in a little sub-console it says "06:33:50 PM - Data timeout - signal missing (Engine)"

FTDI (working):

Quote

Shutup request----F45608AE----
Shutup request----F45608AE----
Shutup request----F45608AE----

Time=06:32:52 PM
Idle traffic:92 55 19 F4 56 08 AE F4 56 08 AE F4 56 08 AE 
Vehicle data-->--F4570104B0----
Response: F4 83 01 31 47 34 42 52 38 32 50 37 53 52 34 32 31 38 32 38 00 F7 D9 E3 38 36 33 30 31 4B 31 43 30 45 55 35 30 37 37 4C 00 00 00 00 00 00 00 00 1C  cs=1C OK
Engine request-->--F4570100B4----
Response: F4 92 01 00 00 00 00 00 00 00 00 7C 2E 00 00 00 48 00 40 00 FF FF 00 FF 02 5A 04 59 28 02 F5 22 00 71 F5 48 66 00 00 00 80 80 80 80 00 00 00 00 00 00 00 80 0D 00 00 00 00 02 00 00 00 00 00 AD  cs=AD OK
 

 

I wonder if maybe its not getting the Arduinos serial writes?

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, TheNuzziNuzz said:

Yep that is how its wired. Now this is interesting, I switched to a different terminal program that displays in hex:

 

Arduino is left:

Um, you've set Termite to read Arduino's output at 8192, when you've configured Arduino to output at 9600. That's obviously a problem.

Hand, n. A singular instrument worn at the end of the human arm and commonly thrust into somebody’s pocket.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, WereCatf said:

Um, you've set Termite to read Arduino's output at 8192, when you've configured Arduino to output at 9600. That's obviously a problem.

I changed the source code to 8192 to see if it helped, sorry I didn't tell you.

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

@WereCatf

 

Ok just figured something out.

 

The program seems to fail when the arduino is plugged into my computer. 

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

Plugged the Arduino just into power, not my computer and it causes the program to stop seeing data, unplug it and it comes right back.

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

Alright, I have new information:

image.png.d64057b62c3edf7a2f0efff4e6b3d9ab.png

The left is the working FTDI in my software. On the right I have just the RX pin connected to the Arduino. If I connected the TX to the Arduino everything just stops and instantly resumes where it left off when I disconnect it.

 

If I open the FTDI in termite it has an identical output to the Arduino, but once again gets broken if I connect the TX. Any ideas? And everything is at 8192 baud.

 

 

Thank you so much for your help and time, I really really appreciate it. This has been taking me forever.

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

Can you send a wiring diagram for this project. I have a feeling there is some issue with the way you are connecting the Serial ports.

 

Also since you are using two UARTs at the same time you may want to consider using a UART recieve interrupt routine to save the incoming data before it gets overwritten.

Link to comment
Share on other sites

Link to post
Share on other sites

On 7/26/2019 at 12:30 PM, Mr_sparky said:

Can you send a wiring diagram for this project. I have a feeling there is some issue with the way you are connecting the Serial ports.

 

Also since you are using two UARTs at the same time you may want to consider using a UART recieve interrupt routine to save the incoming data before it gets overwritten.

Honestly this is new to me and I can barely read wiring diagrams never mind create them. But it is not that complicated.

 

I've put figuring out the Arduino on hold thinking maybe I can just write something for a Raspberry PI and connect the FTDI chip to the usb port on it because I know there are drivers for it.

 

The FTDI usb cable works perfectly by just running a jumper to the RX/TX on the FTDI to the 8192 baud bi-directional interface on the OBD port and a jumper to ground. Works exactly as expected.

 

I would assume since they are both serial I could just replace the FTDI cable with an Arduino and it would work. Exact same wiring as above. I tried to add diodes to see if that would make a difference but they seem to serve no purpose in my testing. I don't really understand how the FTDI cable works given the TX/RX pins are essentially connected to eachother but...it does.

 

 

Also what is a UART receive interrupt routing?

 

Thank You!!

Computers r fun

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×