Pedal Interceptor

From Tinkla: Tinkering with Tesla
Revision as of 16:06, 13 May 2019 by BogGyver (talk | contribs) (Wiring a Tesla Pedal)

The Comma Pedal is used to provide acceleration and regen braking capability on Tesla cars running Openpilot that do not have iBooster installed.

The Comma Pedal is an accelerator pedal interceptor. It is a device that is inserted between a car's electronic accelerator pedal and the DU (Drive Unit). It detects the voltage from the accelerator pedal which represents the pedal's position. It then writes that same voltage back out to the DU as if the accelerator pedal had produced it. When Openpilot is engaged, Openpilot sends the virtual acceleration position through the Comma Pedal instead.

Without electric brakes (iBooster) the car only uses regenerative braking. This is not enough for suddent slowdowns. YOU MUST BE READY TO MANUALLY BRAKE AT ANY MOMENT.

The Comma Pedal is connected to the Giraffe on CAN3-EPAS usually using a Y adapter (that you have to make).

What it Does

The Comma Pedal has 4 main systems:

  1. 2 Analog to Digital Convertors
    • This is used to read the voltage from the car's accelerator pedal into the Comma Pedal's processor. The accelerator pedal produces an output Voltage between 0 and 5 Volts.
  2. 2 Digital to Analog Convertors
    • This is used to send voltage back to the car's DU as if the accelerator pedal had produced it.
  3. 1 CAN Bus
    • The CAN Bus is the car's communication network. The Comma Pedal communicates with Openpilot using the CAN Bus. It connects to the Tesla Giraffe on CAN3.
  4. 1 USB
    • This is used to program and monitor the Comma Pedal, itself.

When Openpilot is NOT engaged, the Comma Pedal reads the voltage from the accelerator pedal and just passes it along to the DU.

When Openpilot IS engaged with longitudinal control, the Comma Pedal gets accelerator commands from Openpilot and emulates a accelerator pedal to the DU.

The Comma Pedal is constantly sending the physical accelerator pedal's position to the CAN bus for Openpilot to read.

Obtaining a Comma Pedal (generic infor from Comma.ai wiki)

You cannot buy a pre-built comma pedal from Comma. Perhaps someone will begin selling them, but for now, you must either build it yourself (not recommended) Or have one fabricated through a service like Macrofab.

More information on HOW to do that will be added to this wiki in the future.

You can find an article written by a community member on how to build your own through MacroFab:

Comma Pedal: Building with MacroFab by Joshua F. Rountree

The information needed to build one is located in Comma's EON GitHub repo.

Wiring a Tesla Pedal

Tesla pedal wiring.png
Pedal pinout.png
Pedal connector.png
Pedal CAN connection.png

In order to create your Tesla Pedal you need:

Note: the two JST2s are needed only if you chose not to use an ethernet cable to conenct your Pedal to the Tesla Giraffe rev B.

Use the diagram to conenct the female WSP-929 pedal connector to the IN side of the pedal board and the male WSP-929 connector to the OUT side of the pedal connector.

To connect the CAN BUS from the Pedal to the Tesla Giraffe you can either use an Ethernet cable to connect the two RJ45 ports (if you have a Tesla Giraffe rev B) or you can use twised wire (preffered) to connect positions 3 and 6 of the fake-ethernet port of the pedal board to the two JST2 connectors (male and female). We need both because you will plug the female one in the Giraffe's EPAS connector and then the EPAS Harness into the male JSP2. Red should be CAN+ and black should be CAN- (that's the convention also used in the image showing the CAN wire soldered to pins 3 and 6 of the fake ethernet port on the pedal baord).

Flashing the firmware for Tesla Pedal

You have to use a Tesla specific firmware on the pedal in order to work for Tesla. 

The firmware in my repo for the Tesla Pedal is located in /data/openpilot/panda/board/pedal_tesla. You can flash the pedal from your computer or from the EON (I did it from the EON). If you have a new board, it will automatically start in DFU mode. If not, you can enter the DFU mode either using a Panda Paw or by applying 5 volts to a special point on the board while conencting the board to USB (to power it up). That usually requires at least 2 people: one to keep the jumper for 5V in place and the other to connect the USB. Instructions on how to enter DFU mode were create by @jfrux.

Once in DFU mode, go to the pedal_tesla directory and run

make recover

Once the firmware flash complete, just reboot the pedal and you should be ready to go.

With 0.5.10 and beyond, there is a new way to flash the pedal via CAN messages which will be used for furture (if needed) upgrades. For now, there are no changes to the firmware for Pedal.

Installing the Tesla Pedal

To install the pedal, there are two steps:

  1. connecting the board to the accelerator pedal
  2. conencting the board to the Tesla Giraffe

This video for a similar product shows you what you have to do in order to install the pedal interceptror between the accelerator pedal and the car existing connector. Take your time and watch the video first. The process is not complicated if you just follow it step by step.

Once that is complete, disconnect the EPAS cable from the Tesla Giraffe and connect the female JSP2 from your pedal to the Giraffe. Then connect the EPAS cable to the male JSP2 from your pedal.

Using the Tesla Pedal

Without electric brakes (iBooster) the car only uses regenerative braking. This is not enough for suddent slowdowns. YOU MUST BE READY TO MANUALLY BRAKE AT ANY MOMENT.

Out of the box, OP will use the Tesla CC (with stalk spamming) to control CC. This in our OP implementation is called Adaptive Cruise Control or ACC. CC on Tesla only works above 18 MPH (29 km/h).

If you turn off the Tesla CC by pressing on the CC stalk, OP will switch to Tesla Pedal (PDL) mode. This will also provide you with adaptive cruise control by sending the right commands to your Tesla Pedal. Tesla pedal works down to 1 MPH, but be careful, regen brakes stop working at 5 MPH (8 km/h).

Once you get used to it and you don't care about ACC anymore, you can modify the config file to always use pedal

force_pedal_over_cc = True

Guides for Building / Troubleshooting Your Comma Pedal

Comma Pedal: Updating the Firmware over CAN by @jfrux Use this guide to update your Comma Pedal for compatibility with Openpilot v0.5.10+

Comma Pedal: Building with MacroFab by @jfrux

Comma Pedal: Flashing the Firmware by @jfrux