Skip to content

Control Pilot

Overview~

The Control Pilot (CP) is the signalling line defined by IEC 61851-1 / SAE J1772 that the charger and the vehicle use to coordinate charging. The charger drives CP and reads it back; the state machine is built entirely on top of what CP reports.

The charger applies a ±12 V, 1 kHz square wave to CP, referenced to protective earth (PE). On the vehicle side a diode and a switchable resistor load the positive half of the wave, pulling the positive peak down to defined levels. The charger measures the positive peak to learn the vehicle's request, and the duty cycle of the square wave tells the vehicle how much current it may draw.

Positive peak State Meaning
12 V A No vehicle connected
9 V B Vehicle connected
6 V C Vehicle requests charging
3 V D Vehicle requests charging with ventilation
below 3 V Treated as a fault by the firmware

Generating the pilot~

The firmware produces the square wave with the ESP32 LEDC (PWM) peripheral on the configured pilot GPIO, at 1 kHz with 10-bit duty resolution. That logic-level signal is converted by an op-amp stage on the board into the ±12 V swing presented on CP.

The pilot can be driven three ways, and the state machine switches between them:

  • Steady +12 V – the PWM is stopped high. Used in states A, B1, C1 and D1 (charger present but not energizing).
  • Steady −12 V – the PWM is stopped low. Used in states E and F (error / unavailable).
  • PWM – the duty cycle advertises the available current. Used in states B2, C2 and D2.

Advertising current~

The duty cycle encodes the current the charger offers, following the J1772 relationship:

  • 6 A to 51 A: current = duty % × 0.6 (so duty % = current / 0.6). For example 16 A is about 26.7 % duty.
  • 51 A to 80 A: current = (duty % − 64) × 2.5.

The advertised value is the working charging current capped by the cable rating; see Charging control.

Sensing the pilot~

CP is read back through a divider-with-offset network that maps the ±12 V line into the ESP32 ADC's input range. Each measurement samples the ADC many times across a single 1 kHz period and keeps the extremes:

  • The highest samples give the positive peak, which selects the state (A/B/C/D, or a fault if it falls below the level for D).
  • The lowest samples are checked against the −12 V level to confirm the negative half is present.

Because the mapping from CP volts to ADC millivolts depends on the exact resistor values of each board, the decision thresholds are not hard-coded. They are listed per board in board.yaml and set during Control Pilot calibration.

Diode short detection~

In a healthy connection the diode on the vehicle side clamps the negative half of the wave, so when the PWM is running the charger still sees a proper −12 V on the low half. If the PWM is running but the negative half does not reach −12 V, the vehicle diode is missing or shorted; the firmware raises a DIODE_SHORT error and refuses to energize. This is an important safety check – without the diode the state encoding is no longer trustworthy.

Configuration~

The pilot is declared in board.yaml:

pilot:
  gpio: 33            # PWM output GPIO (to the op-amp stage)
  adcChannel: 3       # ADC1 channel sensing CP
  levels: [2405, 2099, 1792, 1484, 728]  # thresholds for 12, 9, 6, 3, -12 V in mV

The five levels are the measured ADC voltages (in mV) for the 12 V, 9 V, 6 V, 3 V and −12 V points. See Control Pilot calibration for how to obtain them for your board.

Danger

The Control Pilot circuit and its calibration are safety-critical. Incorrect thresholds can cause the charger to misread the vehicle state – for example energizing when it should not, or failing to detect a diode fault. Calibrate against a known-good reference and verify every state before connecting a vehicle.

CAUTION

Working with high voltage is dangerous. Always follow local laws and regulations regarding high voltage work. If you are unsure about the rules in your country, consult a licensed electrician for more information.

See also~