Also part of the work was to re-tidy the wiring and re-enable the EPAS. It doesn't bother me much to drive, but parking can be a bit tedious at times.
Here the user interface board that converts the analog signal from the electronic throttle to a current source.
The inverter can detect open/shorted/out of range values. At the time I was in a bit of a rush so I skipped the Electric power steering and the isolated tachometer outputs the old system had. That means the cycle analyst is just working as a amp meter. Mileage is not recorded.
In the meanwhile, since I haven't done so in the past, here's a handy circuit to drive the EPAS
Original Full size image here:
http://oi68.tinypic.com/2z4fxxl.jpg
Small prototype board with the circuit components for the EPAS:
The clocks are generated by an attiny 13. A main clock is set to 35Hz to simulate engine running. The secondary clock sets the assist power.
The default programmed values go from 55 to 218Hz. The correct range goes all the way down from 0, but I found the steering too sensitive.
LED1 blinks to indicate the circuit is working. There is a 3second delay from the moment ignition is turned on to the moment the EPAS is activated. This is to allow the DC-DC to start first.
The 2 NE555 chips are just a push pull buffer to output a nice 12V square wave. Output current is limited trough a 47R Resistor, just in case.
Diode D1 creates a virtual GND as the 555 only resets below 0.7V. I Think the trigger input could be set for this but haven't quite checked yet.
Regarding the Attiny13:
The attiny can be programmed in seconds and costs pennies. It also allows a startup delay that the 555 would not and can disable the EPAS if the voltage goes to low (Not implemented).
To program, the Arduino Environment can be used with a AVR MK2 ISP or a USBASP programmer. The Attiny13 files are required to add support, which can be easily find online.
Programming is done in AVR GGC style. Code Below:
Here the user interface board that converts the analog signal from the electronic throttle to a current source.

The inverter can detect open/shorted/out of range values. At the time I was in a bit of a rush so I skipped the Electric power steering and the isolated tachometer outputs the old system had. That means the cycle analyst is just working as a amp meter. Mileage is not recorded.
In the meanwhile, since I haven't done so in the past, here's a handy circuit to drive the EPAS

Original Full size image here:
http://oi68.tinypic.com/2z4fxxl.jpg
Small prototype board with the circuit components for the EPAS:

The clocks are generated by an attiny 13. A main clock is set to 35Hz to simulate engine running. The secondary clock sets the assist power.
The default programmed values go from 55 to 218Hz. The correct range goes all the way down from 0, but I found the steering too sensitive.
LED1 blinks to indicate the circuit is working. There is a 3second delay from the moment ignition is turned on to the moment the EPAS is activated. This is to allow the DC-DC to start first.
The 2 NE555 chips are just a push pull buffer to output a nice 12V square wave. Output current is limited trough a 47R Resistor, just in case.
Diode D1 creates a virtual GND as the 555 only resets below 0.7V. I Think the trigger input could be set for this but haven't quite checked yet.
Regarding the Attiny13:
The attiny can be programmed in seconds and costs pennies. It also allows a startup delay that the 555 would not and can disable the EPAS if the voltage goes to low (Not implemented).
To program, the Arduino Environment can be used with a AVR MK2 ISP or a USBASP programmer. The Attiny13 files are required to add support, which can be easily find online.
Programming is done in AVR GGC style. Code Below:
Code:
/* EPAS CONTROL UNIT - Open loop, manually adjustable feedback
* Designed by C. Silva - Acessory & user interface PCB's - The Electric VW project (2012-2015)
** December 2015 **
*
* ---------------------------------------------------------------------------------------------------------------------------------------
*
* ADC inputs:
* Analog potentiometer. 0 to VCC, 128 levels.
*
* Outputs:
* Output 1: Engine Running signal, SQUARE WAVE, 35Hz
* Output 2: Power steering assist level. User adjustable from 55 to 218Hz
* Output 3: Blinking Indicator
*
****************************************************************************************************************************************/
//Define CPU Clock, to correctly set up the delay function
#define F_CPU 1200000 // 9.6MHz with CLKDIV8 Fuse Enabled = 1.2MHz
//Atmel delay function
#include <util/delay.h>
byte adc = 0; // Variable to store ADC result
// byte output = 0; // Used to delay EPAS startup
uint16_t i = 0; // Variable to store count value for non blocking delay
// ---------------------------------------------------------------------------------------------------------------
void setup() {
DDRB |= _BV(0); //Make (PB0) an output // Engine running indicator output
DDRB |= _BV(1); //Make (PB1) an output // EPAS control Output
DDRB &= ~_BV(2); //Make (PB2) an input // ADC for user selectable assist level
DDRB |= _BV(4); //Make (PB4) an output // Blinking Indicator
SREG = 128; // Global Interrupt Enable
TCCR0A = 0;
TIMSK0 = 0;
//ADMUX |= (1 << REFS0); // Set ADC reference to AVCC
ADMUX |= (1 << ADLAR); // Left Adjust the result
ADCSRA |= (1 << ADEN); // Enable ADC
ADCSRA |= (1 << ADIE); // Enable ADC Interrupt
ADCSRA |= (1 << ADSC); // Start A2D Conversions
// PWM Configuration
// Pag 78 Datasheet, Table 11.3 - Fast PWM (32KHz)
// OCOA/PB0 - Non Inverting Mode, Clear on Compare match, Set on Bottom
// OC0B/PB1 - Disconnected, Normal I/O operation (This is toggled by software inside the COMPB Interrupt)
/* The overflow flag is used by the damm arduino compiler, so without changing registers
and going crazy we can use hardware PWM as alternative to create a fixed frequency sq wave*/
OCR0A = 128; // Set Duty cycle = 50%
// This is a 73.42 Hz signal to enable the EPAS (AKA Engine Running)
TCCR0B |= 1<<CS01 | 1<<CS00 | 1<<FOC0A; // Prescaller = 64, therefore clock = 73.24Hz/2 = 36.62Hz
_delay_ms(4000); // Wait 4 seconds for the DC-DC Converter to boot up and voltages stabilize.
// Enable the EPAS, by turning the PWM square wave signal output on.
TCCR0A |= 1<<COM0A0 | 0<<COM0B0 | 0<<WGM00; // SET WGM00 FOR OPERATING MODE. 0 = NORMAL, 3 = FAST PWM, ETC
// output = 1; // Wait for voltages to stabilize before enabling the EPAS
TIMSK0 |= (1 << OCIE0B); // Enable COMPB Interrupt
}
// ---------------------------------------------------------------------------------------------------------------
// the loop function runs over and over again forever
void loop()
{
}
// ---------------------------------------------------------------------------------------------------------------
ISR(ADC_vect)
{
// Select ADC3 (PB3) - Pag 135 Datasheet
// Let Justify the result (8bit reading)
ADMUX = (1 << MUX0)|(1 << ADLAR);
/* HOW THE FREQUENCIES ARE CALCULATED:
CLKDIV8 FUSE = ENABLED
DEFAULT PRESCALLER = 64 <-> 9600000/8/64/256 = 73.24Hz
OUTPUT toggled on each cycle, therefore 73/2 = 36.62Hz
The 8 bit ADC reading is shifted once, giving rise to a 0 to 127 read.
Chose the minimun frequency value = 170
9600000/8/64/170/2 = 55.14Hz
Choose the maximun frequency value = 170-127 = 43
9600000/8/64/43/2 = 218Hz
*/
adc = (170-(ADCH>>1));
ADCSRA |= (1 << ADSC); // Start A2D Conversions
}
ISR(TIM0_COMPB_vect)
{
// Togle Pin
PINB |= _BV(PORTB1); // This is the speed signal for the EPAS, to set assit power level
OCR0B = (OCR0B+adc);
//Set up a non blocking delay
i++;
if (i>255)
{
PINB |= _BV(PORTB4); // Blink a LED to indicate operation
i=0;
}
}