Tag Archives: comma ai

Revitalizing your Tesla AP1 vehicle with openpilot

There are a ton of old Teslas out there running Autopilot v1 (AP1), and they fall further behind in assisted-driving capability every year. AP1 felt ultra futuristic in its day, but it’s starting to become outclassed even by the lane assist shipping in everday non-Tesla cars.

One of the biggest reasons I opted to seek an upgrade was the ability to remove the notorious “Tesla NAG”. While I get checking if the driver is paying attention is critical for safety, the way Tesla did it in AP1 was less than ideal by having to apply torque to the steering wheel, even if you are alert and watching the road ahead of you. In addition, the driving capabilities of AP1 on unmarked roads, aggressive curves, phantom braking, etc. make for a significantly less confident driving experience in AP1 and feel dated compared to newer vehicles today.

openpilot – make driving chill

Revive your car with the open source software openpilot, maintained by the company Comma AI! comma.ai — make driving chill

While Comma AI does not officially support old Tesla vehicles there are several forks for older Tesla’s to use openpilot and while Comma AI doesn’t provide an official wiring harness for older Tesla cars, they do provide a developer harness where you can make your own.

You can grab a harness for the vehicle from a developer in the openpilot community, who has helped try to maintain a fork of openpilot (which we’ll talk about later on). This makes installing the Comma 4 significantly easier by bringing peace of mind it’s correct and kick back support to the maintainer for their contributions to the fork for the older Tesla vehicles.

That being said, I went down the road of trying to DIY this myself for two reasons:
1) I wanted to learn
2) cost

When starting the project, cost wasn’t originally my concern, but I was lucky and was able to pick up their official development harness for $50 on a sale and with sourcing the parts and ultimately was able to make it for under $80. The prebuilt harness was > $250 and my understanding at the time is it would have shipped from Europe, so it would have likely gone over $300 with tariffs with that assumption (although they have some stock in the USA I found out later on).

While a cheaper harness sounds great, one big note is if you go down the DIY route, don’t expect the Comma community to help. The folks that really understand this kind of stuff in the unsupported Tesla community really laid it on thick that I should give up and just buy the harness.

IMO, if you have the time and patience it was an interesting project and I learned a lot on the electrical side and comma side debugging the pin configuration.

Nonetheless, if you do this DIY, don’t expect much help. If you just want your car to work, buy the harness, it’s worth it. If you have some background in software development and electrical engineering, then here’s my learnings if you want to take a similar venture; but proceed at your own risk. I’m not responsible if you short out any components of your car.

Acquiring the parts for the harness if you DIY this

You can grab an official development harness from Comma AI’s shop here: https://comma.ai/shop/car-harness?harness=Developer.

These are the parts from Digikey needed to make the harness:

Qty 2: MQS 8P PLUG HSG BLK – 17-1-1743282-2-ND

Qty 2: MQS HDR 8P ASSY(H-TYPE) BLK – 17-1-1743284-2-ND

Qty 20: MQS REC CONT – 17-5-963715-1CT-ND (You only need 16, but they are cheap and if you’ve never crimped these, grab a few extra for practice)

Qty 1: Breakable Protoboard: I used this to connect/solder the two MQS HDR 8P ASSY modules together: 1568-13268-ND

Qty 1: Wiring harness tape – not required, but can help with longevity of your cable.

The pinout of the harness

First, familiarize yourself with the Comma AI dev harness. The pinout for it can be found here: https://github.com/commaai/hardware/blob/master/harness/v3/Developer_Harness.pdf

Next, understand the Tesla harness. Tesla has a copy of the Forward Camera (NCAP) harness here:

https://service.tesla.com/docs/ModelS/ElectricalReference2012/s-lhd-sop7/2015.1_ModelS_LHD_Release.pdf

Pulling it altogether, you get this as the secret sauce to build the harness:

From the mirror connector to the 18pin comma connector:
Pin 1 – GND -> Comma -> Pin 1
Pin 2 – Radar CAN + -> Comma -> Pin 8
Pin 3 – Radar CAN – -> Comma -> Pin 7
Pin 4 – Camera CAN + -> Comma -> Pin 4
Pin 5 – Camera CAN – -> Comma -> Pin 6
Pin 6 DefogHSD_OUT -> Floating
Pin 7 DefogPWR_in -> Floating
Pin 8 12v -> Comma -> Pin 10

From the 18pin comma connector to the original car port:
Comma Pin 17 -> GND – Car Pin 1
Comma Pin 9 -> Car Pin 2 Radar CAN +
Comma Pin 11 -> Car Pin 3 Radar CAN –
Comma Pin 16 -> Car Pin 4 Camera CAN +
Comma Pin 18 -> Car Pin 5 Camera CAN –
Floating Car Pin 6
Floating Car Pin 7
Comma Pin 12 -> 12v Car Pin 8

Pin 3 and 5 are looped on the comma connector (this is standard to the dev harness as-is)

One note about this, be very very very careful you do not mix up the 12v pins with another position when building your harness. If you send 12v down your CAN buses, that will not be good. Use a multimeter to triple check. I was ultra surprised to find that Tesla had a red wire on their harness and it didn’t carry 12v; rather the “blue” wire is what actually carried 12v. Going simply by the color codes would have given me a bad day, so DO NOT make any assumptions.

When building my harness, I terminated both the “to car” and “to camera” cables with the MQS 8P plugs. Connecting the cable from the car to the comma, I placed both MQS HDR 8P ASSY back-to-back on the protoboard and soldered the pins together. This allowed me a secure connection between the car and comma harness. Unfortunately, TE Connectivity doesn’t have the receiving connector without it being mounted to a PCB board, so double connector it was. Given vibration and force from accelerating / braking, I’d recommend locking connectors over the screw down blocks to prevent wires from coming lose.

Mount the Comma 4 Bracket

Before you pull apart your mirror, I would recommend mounting the Comma 4 bracket. Sit how you would normally in your seat, then hold the device up. The camera can be partially blocked by the mirror, but not fully. I saw a guide that said use 3 fingers down and you should be good. I did more like 4-5, since 3 had the entire device completely blocked by the mirror. Once your Comma 4 is mounted, remove the Comma 4 itself from the device, leaving just the mount on your windshield. One thing to make sure is to make sure the yaw (left and right balance) of the unit is as close as level as possible; you have roughly 4 degrees of skew and it’s nearly impossible to adjust once you stick the device, so have someone take a look on the outside of the windshield to gauge if it looks aligned properly.

Install the harness

To install the harness you will need to remove the front mirror assembly. Official instructions can be found on Tesla’s website here:

https://service.tesla.com/docs/ModelS/ServiceManual/en-us/GUID-090CC4A1-9427-4E59-B021-74488A5C74DE.html

If you prefer a YouTube video, this video was helpful on understanding how to remove the mirror (don’t go past moving the mirror):

Mount the Comma 4 and Connect the harness

Next, connect the cable from the car to the harness, and then the harness to the car.

Then mount your Comma 4 on the mount and run the USB-C cable to the dev harness. I routed mine around the mirror bracket and back into the headliner.

Install the xnor fork for the Comma 4

Stock openpilot won’t do anything for you here as it doesn’t support older Tesla vehicles with AP1. The fork that keeps AP1 alive is xnor, maintained by xnor-tech (Lukas Loetkolben on GitHub). Docs on how to get started can be found here: https://wiki.xnor.shop/docs/general/installing_a_fork/

  1. Power on the Comma 4 and wait for the setup screen.
  2. Connect to WiFi
  3. When you get to the software prompt, choose Custom Software (Advanced) instead of the default openpilot build
  4. Enter the installer URL: https://installer.comma.ai/xnor-tech/xnor
    • Unrelated, but whoever at Comma was responsible for the onboard keyboard on the Comma 4 should get a gold star. The second I saw the keyboard I got anxiety that it would be miserable to type the URL in, but the keyboard honestly functions incredibly well for such a small screen. Kudos!
  5. Tap Install — it took about 5-10 mins; was really quick.

The `xnor` branch is the precompiled one and it covers comma four + comma 3X for Tesla Model S/3/X/Y across HW1 through HW4 — HW1 being what we care about for AP1.

There’s also `xnor-dev` at `https://installer.comma.ai/xnor-tech/xnor-dev` which builds from source on the device. It takes considerably longer to install. Unless you have a reason to be on dev, take the precompiled branch.

Setup Comma 4

At this point, I ran through setup and calibration of the Comma 4.

Ideally, you mounted the Comma 4 so you can run through the driver detection mode and pass it on first try. After driver monitoring, you’ll be prompted to run through device calibration, where you drive the car > 15 mph for a little bit of time.

Unlike me, I mounted the Comma 4 blindly after tearing the mirror apart and one thing that later got me is the yaw of the device has to be within ±3.96°. Lucky me, I was off by 0.07 degrees at −4.03° and had to remount the whole thing. As far as I can tell Comma doesn’t seem to have a mounting mode so you kinda have best guess whether or not it’s level on the windshield, but if it’s off, you’ll see a “Unable to calibrate” messages, with no details on what went wrong.

Unrelated, if you have to tear the Comma 4 mounting bracket off, I used a large wide razor blade that you use when scraping items or cleaning windows. Strongly recommend that, trying to pull it off with your fingers is pretty much impossible

At this point, everything should be working. If it is, go ahead and repeat the mirror disassembly steps in reverse to reassemble it.

This is a really brief guide and slightly scattered, but thought I’d post it as I couldn’t find what the mirror pins did and was curious if the original dev harness from Comma could be used as-is (which it looks like it can be! : )

Disclaimer: I am not affiliated with, sponsored, or have any investment in comma ai or openpilot. I’m just some random person that wants to make my car feel like a car of the future again.