Home / Wiki / Components / DIY VCM
Components · canonical reference

DIY VCM

While re-using all of the power electronics from the donor cars makes sense, the plan is to design a custom version of what Nissan call a VCM (Vehicle Control Module) — and the same nomenclature is used here. The VCM is the control unit that manages all the main functions of the vehicle and coordinates the other components.

The DIY VCM is the main vehicle ECU. It uses two processors: a primary processor for vehicle control and a secondary safety processor for independent supervision. The VCM handles driver inputs, torque requests, inverter and charger communication, contactor power authorization, cooling, and brake-light control.

The hardware and firmware are in the aphid-ev repository. The board is in ecus/vcm/hardware, the firmware for both microcontrollers in ecus/vcm/firmware, and the logic they share in crates/vcm-core and crates/ev-can.

See also: VCM requirements for the design targets.

Safety

Since this VCM controls a car moving at high speeds and interacts with an electrical system containing dangerous voltages, safety is very important. There are two major things that need to be managed by the safety system:

  • Traction torque
  • High voltages

See Safety architecture for the full system view.

Safe state

In case of a critical failure, the car is taken to a safe state by commanding zero torque and, for faults requiring HV shutdown, opening the battery contactors. This prevents the motor/inverter from producing torque and removes the risk of electrical injury. See the fault state under operating-states.

VCM safety design

The VCM has dual microcontrollers: one runs the main application, the other monitors critical signals and verifies that the main application is executing as expected. The two communicate over a serial link.

  • Both MCUs read and cross-check the dual-channel input from the accelerator pedal.
  • The monitor MCU has read access to the EV-CAN bus and verifies the torque request from the main application is reasonable.
  • The monitor MCU controls the high-side switch for the precharge and main contactors, enabled only while the HV interlock loop is valid.
  • The BMS controllers, not the VCM, switch the low side of the contactor coils. See Main contactors and precharge > roles.
  • The main MCU sends watchdog counters over the serial port.
  • The monitor MCU can disable the EV-CAN transceiver and, as a final option, reset the main MCU.

Operating states

  • Off: the main contactors and EV-system relay are open. The VCM sleeps on its always-on supply. The BMS controllers sleep unless they are keeping themselves alive; traffic on CAN2 wakes them. The key or a charge cable on the proximity pilot wakes the VCM.
  • Ready: the control networks and switched EV loads are powered. After safety checks, the system performs precharge and closes the main contactors; propulsion remains at zero torque until a direction is accepted.
  • Drive: a direction has been accepted with the brake applied, the charge connector is absent, and the VCM may command traction or regenerative torque.
  • Charge: PP detection initiates the sequence, also with the key off. The VCM inhibits drive, locks the inlet and pulls in the EV relay, which powers the OBC and the coolant pump. The contactors close through the normal precharge sequence, and the OBC derives the permitted current from CP. When the charge is finished the VCM unlocks the inlet, opens the contactors and goes back to sleep.
  • Fault: torque is commanded to zero. For faults requiring HV shutdown, or if the main VCM processor stops responding on the internal communication bus, the safety processor removes the high-side contactor-coil supply so the contactors open.

The Main contactors and precharge page describes precharge, and the charge inlet section describes the PP and CP signals.

Hardware

The PCB is created in the open source KiCad software.

Enclosure

The enclosure is the pretty robust Cinch ModICE ME-MX 24. See VCM requirements > enclosure for part numbers. The front and rear BMS controllers use the same ModICE enclosures with Molex MX-150 connectors.

Microcontrollers

The main firmware runs on an STM32G491 with 512 KB of flash, with a separate STM32G431 monitoring it. Every DIY ECU uses the STM32G4 family, so one bootloader and one HAL cover the whole car. The main MCU is the same 512 KB part as the DIY BMS controllers, so they share one flash layout.

The STM32G474 was considered for its dual-bank flash, which would let an update be written to the idle bank and swapped in once checked. Firmware is flashed over CAN in the garage, and an ECU whose update fails stays in the bootloader until it is flashed again, so bank swap is not worth a second part. The G474’s other extras, such as the high-resolution timer and the extra ADCs, are for power conversion, which the VCM does not do.

The monitor is a separate chip, with its own supply and clock, rather than a second core on the main MCU’s die. Two cores on one die share the supply, the clock, the reset and the CAN peripheral, so a single hardware fault could stop both the controller and its supervisor.

The current schematic still has the earlier choice, an STM32F405RG with an STM32F091CC monitor.

I/O

Warning

This pinout predates the current electrical architecture. It does not yet have the charge inlet proximity pilot, lock, LED and stop button signals, the coolant pump PWM and tacho, or the radiator fan relay output.

The VCM has two 12-pin Molex MX-150 connectors:

PinLeftRight
1GNDGND
2CAN1 LowCAN2 Low
3CAN1 HighCAN2 High
4BRAKE1TBD
5BRAKE2TBD
6+12 V INCRANK
7GNDGND
8TBDHigh side out
9EXT 5VEXT 5V
10ACC1DIR_R2
11ACC2DIR_R1
12+12 V INIGNITION

See VCM requirements > i-o for the canonical connector pinout.

The wiring model is the current list of signals. The drawing shows every VCM port and what it connects to, and is the starting point for the I/O of the next board revision. A name that starts with ic_ is a branch connector on the way to the device.

VCM I/O VCM B+ lv:1 GND lv:2 IGN key:1 CRANK key:2 INTLK ACCEL 5V accel:3 ACCEL 1 accel:1 ACCEL 2 accel:2 ACCEL GND accel:4 BRAKE 1 brake:1 BRAKE 2 brake:2 D1 gear:1 D2 gear:2 R1 gear:3 R2 gear:4 PARK BRK gear:5 PP charge:1 LOCK FB charge:5 CHG STOP charge:8 INLET GND charge:9 PUMP TACH cooling:2 CAN1 H can1:1 CAN1 L can1:2 CAN2 H can2:1 CAN2 L can2:2 SAFE PWR EV CTRL FAN CTRL cooling:3 PUMP PWM cooling:1 DCDC EN charge:2 LOCK A charge:3 LOCK B charge:4 LED RED charge:6 LED GRN charge:7 BRAKE lights:1 REVERSE lights:2 ev_fuses.vcm ev_fuses.vcm ← body.stud body.stud ← ic_key.ign (key.ign) ic_key.ign (key.ign) ← ic_key.crank (key.crank) ic_key.crank (key.crank) ← inv.interlock_out inv.interlock_out ← ic_pedal.sens_5v (pedal.sens_5v) ic_pedal.sens_5v (pedal.sens_5v) ← ic_pedal.apps1 (pedal.apps1) ic_pedal.apps1 (pedal.apps1) ← ic_pedal.apps2 (pedal.apps2) ic_pedal.apps2 (pedal.apps2) ← ic_pedal.gnd (pedal.gnd) ic_pedal.gnd (pedal.gnd) ← ic_brake.brake1 (bs1.sig) ic_brake.brake1 (bs1.sig) ← ic_brake.brake2 (bs2.sig) ic_brake.brake2 (bs2.sig) ← ic_gear.d1 (gear.d1) ic_gear.d1 (gear.d1) ← ic_gear.d2 (gear.d2) ic_gear.d2 (gear.d2) ← ic_gear.r1 (gear.r1) ic_gear.r1 (gear.r1) ← ic_gear.r2 (gear.r2) ic_gear.r2 (gear.r2) ← ic_gear.park (park_brake.sig) ic_gear.park (park_brake.sig) ← ac_inlet.pp ac_inlet.pp ← inlet_lock.fb_1 inlet_lock.fb_1 ← chg_button.sw chg_button.sw ← ac_inlet.led_gnd, inlet_lock.fb_2, chg_button.gnd ac_inlet.led_gnd, +2 more ← pump.tach pump.tach ← charger.can_h → charger.can_h charger.can_l → charger.can_l rear.can_h → rear.can_h rear.can_l → rear.can_l rear.safe_pwr → rear.safe_pwr ev_fuses.ev_ctrl → ev_fuses.ev_ctrl ev_fuses.fan_ctrl → ev_fuses.fan_ctrl pump.pwm → pump.pwm charger.dc_sw → charger.dc_sw inlet_lock.motor_pos → inlet_lock.motor_pos inlet_lock.motor_neg → inlet_lock.motor_neg ac_inlet.led_red → ac_inlet.led_red ac_inlet.led_green → ac_inlet.led_green bl_left.stop, bl_right.stop, bl_chmsl.stop → bl_left.stop, +2 more rev_light.rev → rev_light.rev
VCM I/O

The driver’s inputs in one schematic: the key, the two brake switches with their feeds, and the accelerator sensor on the VCM’s 5 V supply.

Driver inputs Primary fuse box SW Rear EV fuse box EV SIG Ignition key IGN 2 CRANK 3 Brake sensor 1 B+ pwr:1 SIG sig:1 Brake sensor 2 B+ pwr:1 SIG sig:1 Accelerator pedal 5V 3 APPS1 1 APPS2 2 GND 4 VCM IGN key:1 CRANK key:2 BRAKE 1 brake:1 BRAKE 2 brake:2 ACCEL 5V accel:3 ACCEL 1 accel:1 ACCEL 2 accel:2 ACCEL GND accel:4 GN YE RD BK RD BN PK GY VT GY ic_gear.feed (gear.feed, park_brake.feed) → ic_gear.feed inv.ignition, charger.igct → inv.ignition, charger.igct Key feed: the Beetle's own wiring
Driver inputs

The harness drawings of the branches to these inputs are on the Cab loom page.

The model has 36 VCM signals. Its connectors are placeholders, one per function, and the interlock input, the safe power output and the EV relay output have no connector pin yet.

The ModICE enclosure size is not chosen. It comes with 32 or 40 connector positions, and the choice waits for the final signal count.

CAN1 (high/low)

Used to communicate with Nissan Leaf EV-CAN nodes: the Nissan Leaf inverter and the Mitsubishi OBC/DC-DC. Available to both the main and the monitor microcontroller.

CAN2 (high/low)

Used to communicate with the DIY vehicle systems: the front and rear BMS controllers, and future DIY nodes such as a driver display. Only available to the main controller. See Nissan Leaf EV-CAN > vehicle-buses.

High side out

High side driver providing +12 V to the high side of the main and precharge high voltage contactors.

+12 V IN

The VCM’s only supply. It is always live, behind a 15 A fuse in the rear EV fuse box, and also feeds the high-side outputs. The ignition input wakes the VCM’s power circuitry, and the VCM then holds itself on from this feed.

Ignition

The key switch keeps its original job. It takes its feed from the Beetle’s own wiring and switches the Beetle’s original ignition circuits. The VCM taps its RUN and START terminals as two inputs; see Low voltage electrical system > original-system.

+12 V when the ignition switch is in the ignition (RUN) position.

Crank

+12 V when the ignition switch is in the crank (START) position.

The key hangs off the cab loom on its own branch, so the key loom unplugs as one.

Accelerator input (ACC1/ACC2)

The accelerator pedal uses a dual-channel analog position sensor so the VCM can cross-check the two signals. See Accelerator pedal sensor for the signal levels and the sensor.

Brake input (BRAKE1/BRAKE2)

The original brake switches connect independently to the VCM. Brake input requests regenerative braking, activates the brake lights, and prevents positive accelerator torque while the brakes are applied. Each switch has its own 12 V feed; see Low voltage electrical system > brake-switch-feeds.

Direction input (DIR_F1/DIR_F2 and DIR_R1/DIR_R2)

Input from the Direction controller: two complementary switch lines per direction from the sprung gear lever. Each pull steps the state along R, N, D. The VCM accepts a step into D or R only while the car is stopped with the brake applied. The parking brake switch uses a fifth input on the same connector.

Charge inlet

Seven signals serve the charge inlet, besides the DC-DC enable to the OBC:

  • The proximity pilot input. It is also a wake source, and reading it as an analogue value gives the cable’s current rating.
  • Two H-bridge outputs for the inlet lock motor, which draws at most 650 mA for up to one second.
  • The lock feedback input, a switch closed to ground while locked.
  • Two outputs for the red and green status LEDs. The green LED pulses while charging, so its output needs PWM or a software blink.
  • The stop button input, a switch closed to ground.

The feedback switch, the LEDs and the button share one ground return pin. The lock is optional, so the car has to charge with the lock pins left open.

External 5 V feed

5 V supply for the accelerator sensor. The brake switches and the gear lever switches take 12 V from the fuse boxes instead.

Firmware

The firmware is developed in Rust, both because it provides a lot of nice safety features and because it is pleasant to work with.

Bootloader

At some point a CAN-based bootloader will be created for both microcontrollers so they can be updated without opening the enclosure. One option is to use the built-in ROM bootloader in the STM32 parts — they are wired so that the ROM bootloader CAN bus is on CAN1 and CAN2 respectively.

The CAN bootloader the other DIY ECUs use does not support the STM32F405 or the STM32F091 yet.

Monitor application

The monitoring microcontroller runs a fairly simple application that monitors the main application and can disable the high voltage contactors if something goes wrong. See VCM monitor firmware.

Main application

See VCM main firmware.

Notes

High side drivers: ST VNQ9025AT

  • Brake lights
  • Reverse lights

The EV, pump and fan relay coils are switched on the low side.

Linked from the build log 14 posts reference this page