To make this work, you need to manipulate these GPIO pins (note these are GPIO numbers, not the actual pin numbers on the Pi GPIO connector):
- 4 - The power watchdog pin. Whenever the relay is powered on, you must toggle this pin at 1-10 kHz.
- 17 - The power pin. Set this high to turn the vehicle power on. Whenever it is on, you must toggle the power watchdog pin or else a (synthetic) GFI event will occur.
- 18 - the pilot pin. Set this high for +12, low for -12. See below for using this pin.
- 22 - The GFI status pin. This is an input. When high, the GFI has been set and turning the power on is disallowed.
- 23 - The relay test pin. This is an input. It gives the status of the HV relay / GCM test. Within 100 ms of turning the power on, this pin should go high and stay high. Within 100 ms of turning the power off, this pin should go low and stay that way.
- 24 - The GFI test pin. This is an output pin. A wire connected to the GFI test pin should take two loops through the GFI CT and then connect to ground. Toggle this pin at 60 Hz to simulate a ground fault as part of the GFI test procedure.
- 27 - The GFI reset pin. Pulse this pin high to clear the GFI. You cannot do this while the vehicle power is turned on.
In addition to the above, the MCP3004 ADC is connected to the SPI system, on device zero (/dev/spidev0.0). The first three channels are connected to:
- 0 - the pilot feedback. You should sample this a few hundred times, taking the high and low values found. The high value can be used to detect vehicle state changes. The low value should remain near -12v (when the pilot is oscillating) or else it's a "missing diode" test failure.
- 1 - the current sense transformer. You should sample this pin to obtain samples across two zero crossings (512 is zero), perform an RMS calculation, and scale the result to determine how much current the vehicle is drawing.
- 2 - the AC voltage sense. You should sample this looking for the peak. This will allow you to determine the AC voltage and with the current sense, determine how much power the vehicle is drawing.
To make a proper pilot, you must configure the Raspberry Pi hardware PWM timers (the PWM functionality in the Python GPIO library won't do).
To make the ADC available, you must use raspi-config and enable SPI. In order to turn on the hardware PWM on pin 18, you need to add: