The Backpack variant

The J1772 pilot line on the EVSE end is connected to a ±12 volt square wave generator with a 1 kΩ output impedance. The line can either be pinned at +12 volts, -12 volts, or oscillating at 1 kHz with a variable duty cycle. If no vehicle is connected, or if the EVSE is not ready for charging, it will pin the pilot at +12. If the EVSE is in an error condition from which it cannot reasonably recover, it may pin the pilot at -12 volts. If a vehicle is connected and the EVSE is prepared to supply power, it will oscillate the pilot.

On the vehicle end the circuit is quite simple. There is a 2.7 kΩ resistor in series with a diode from the pilot to ground. Most EVs will have a second 1.3 kΩ resistor in parallel with the 2.7 kΩ one, but with a switch (likely a transistor or MOSFET) to bring the 1.3 kΩ additional impedance into play. Because of the host EVSE's 1 kΩ output impedance, 2.7 kΩ will lower the +12 volts to +9 volts. The added 1.3 kΩ will reduce that to +6 volts. Optionally, a fourth state can be defined by adding another 330 Ω, reducing the voltage to +3 volts. This last state indicates to the host EVSE that this vehicle has lead-acid batteries and requires ventilation for charging. EVSEs mounted indoors are supposed to refuse charging when this happens, but EVSEs mounted outdoors can allow it.

The diode will prevent the added impedance from impinging on the negative portion of the square wave. The EVSE is able to detect the minimum and maximum voltage seen on the vehicle side of the 1 kΩ output impedance and therefore detect the state changes. If the negative portion doesn't reach (close to) -12 volts, then the EVSE can surmise that the diode is missing and that a compliant vehicle is not connected and refuse to charge.

The duty cycle of the 1 kHz square wave indicates the ampacity of the EVSE from 6 amps to 80 amps. Additionally, a special duty cycle can be used to indicate "digital communications required," which is what CCS HVDC EVSEs use.

The EV Sim uses a resistor divider network to rescale the potential input voltage range of -12 to +12 to 0-5 volts. Because the impedance on the input side is 200 kΩ, we must provide an impedance buffer amp (that is an op amp configured for unity gain) in front of the analog input pin on the controller. Not doing that results in the previous voltage of the ADC sample-and-hold cap dragging the scaled voltage away for a few microseconds while the cap charges/discharges to the new level. This is brief, but it's still potentially enough to trigger the analog comparator, which results in weird duty cycle aberrations. The controller is also fed a comparison voltage that represents (near) 0 volts on the pilot line. The controller's analog comparator will output a low or high logic level based on this comparison, which essentially means that the pilot is above or below 0 volts. This comparison is used to trigger an interrupt in the firmware and to capture the value of a free-running timer. The number of times this interrupt occurs during a given sampling period is double the frequency over that period, and the difference between the capture and the previous capture allows the ISR to keep a running timing that represents the duty cycle of the wave. During the sampling period, the controller samples the input voltage repeatedly and captures the maximum and minimum voltage. The EV Sim is a "backpack" board on a 2x16 80x36 mm LCD character display. It will display the frequency and duty cycle of the pilot (if it's oscillating) and translate that into a J1772 ampacity indication. Pressing the button will change it into a mode where it displays the minimum and maximum voltage.

The Remote Variant

There's a second version of the project that exchanges the LCD for a USB connection. The ATTiny84A is replaced with an ATTiny841, which has a USART in it to make serial I/O easier. The serial pins are connected to a CY7C65213 USB UART chip. Like the backpack variant, there's a resistor divider network to scale the ±12v pilot to 0-5v and an impedance buffer amp for the AC and ADC. As with the display backpack variant, the AC ISR is used to track the number of state changes in a half-second sampling period, and relative period of high versus low (from which the duty cycle can be calculated), and ADC sampling, again, is used to determine the positive and negative peak readings. Those are presented over serial to the host as JSON lines.

To control the state, the 3 state setting resistors (2.7 kΩ, 1.3 kΩ and 330 Ω) are switched in and out with N MOSFETs by lines from the controller. Sending a single character A-D over the USB connection will make the EV Sim change states. Unlike the backpack variant, there is no provision to "remove" the diode.

Usage

To use the EV Sim backpack variant, first turn off all four of the DIP switches and then connect the pilot and ground wire up to the J1772 plug of the EVSE. If you look at the plug from the socket end, the pilot pin is at 4 o'clock and the ground pin is at 6 o'clock. *WARNING* Do not connect anything - or even touch - the two large pins at 11 o'clock and 1 o'clock. Those are the two hot pins and one or both of them can be energized with high voltage at any time.

The DIP switches are labeled A through D. A through C engage the different J1772 state resistors. It is invalid to turn on a switch unless all of the switches lower than that switch are also on. That is, the valid combinations are

  1. All three switches off - J1772 state A (no vehicle)
  2. A on by itself - J1772 state B (vehicle present, but idle)
  3. A and B on - J1772 state C (vehicle requests charging)
  4. A, B and C on - J1772 state D (vehicle requests charging and ventilation)

No other combinations will result in a valid state.

The D switch, when turned on, will bypass the series diode required by the J1772 specification. Turning this switch on should result in an error (as long as the EV sim is not in state A).

The display will show the frequency of the pilot and if the frequency is non-zero, its duty cycle. If the frequency is zero, the duty cycle will be replaced with "-" or "+", meaning that the pilot is pinned either to -12V or +12V. The second line will show the J1772 ampacity (or 0, if the pilot is not valid).

For the USB version, connect the USB connector up to a cable and to a host. You'll see a CDC serial interface show up. Open it and set the comm parameters to 9600 baud, 8N1. You should see JSON lines twice per second. The frequency is equal to the state change count (since it's the number of state changes in a half second, that's double the frequency per half second). The duty cycle is (high_count / (high_count + low_count)) as long as the frequency is non-zero (if it is zero, the peak voltage readings should be used to see what's going on). You can convert the positive and negative peak ADC readings to voltage by adding the OFFSET value and multiplying the sum by the SCALE factor. The OFFSET is -556 and the SCALE is 32 (versions of the code with the VREF calibration will instead just show the voltage). If the pilot is oscillating, the negative peak should remain near -12 volts and the positive peak should be either +12, +9, +6 or +3 volts (±1v), depending on the EV Sim's state. To change the state of the EV Sim, send the characters 'A', 'B', 'C' or 'D', depending on what you want (lowercase works as well).

Troubleshooting:

If the backlight does not turn on when power is applied, then check your power supply. Insure that the voltage is between 6 and 12 volts DC, with the center pin positive. Use a voltmeter and look for power on the power jack pins, the input side of the regulator, and then +5 volts on the regulator output.

If the backlight turns on, but the display shows nothing, adjust the LCD contrast pot in the upper right corner of the board. The correct setting is near, but not at, the CCW end of its rotational range.

If the backlight turns on, and you see a row of filled in blocks in the top row of the display and nothing in the bottom row, then that means the program in the microcontroller is not running, or is not successfully talking to the display. Try reprogramming the controller.

If programming doesn't work, check the connections between the programming header and the appropriate pins of the controller. Next, check the connections of the crystal. If none of that works, you may have to replace the controller.