Sunday, April 13, 2014

58 of 60 Spoof Signal of BMW 325i Harmonic Damper


The previous post assumed that the harmonic damper remained as part of the EV build.  This post shows an alternative that does not require the harmonic damper, but instead creates a spoof signal that is equivalent to the signal that would have been produced by one.  It is hoped that this signal can be used to drive the RPM gauge on the instrument cluster.  At the Arduino forum can be found a previous project by “jackbauer” that uses the Arduino to spoof a harmonic damper and produce a 58 out of 60 pulse output signal.

 
Adding the modification suggested by “johnwasser” in the same forum, resulted in the sketch listed at the end of this posting.  The circuit is shown in picture DSC00838 and the details are listed below.



                    Picture DSC00838 of Arduino Uno circuit to produce 58 of 60 output signal.


Power is supplied from the PC to the Arduino Uno through the USB cable (green on top left).
Black wires are ground, connected to one side of 10.19 kOhm potentiometer, and to the oscilloscope ground.
Red wire is +5 volts from the Arduino Uno board and it is connected to the opposite end of the potentiometer.
White connects the potentiometer wiper (center) to Arduino Uno analog pin A0.
Yellow is the output from Arduino Uno Digital 10, and it is connected to the oscilloscope.  As the potentiometer is rotated from 0 to 100%, the output frequency of the Arduino Uno ranges from 140.8 Hz and 4.739 KHz.

Use of a Tektronix TDS 3012 storage oscilloscope allowed the careful counting of the pulses and confirmed that the sketch produces exactly 58 pulses, followed by 2 missing pulses, and then 58 pulses, repeats again, etc.
 


                Picture DSC00831 with potentiometer at 100% yielded a frequency of 140.8 Hz.



                   Picture DSC00833 showing expansion of the signal shown in picture DSC00831
                                                    and the detail of the 2 missing pulses.


When the potentiometer was decreased to 0% of range, the frequency increased to 4.739 KHz as shown in picture DSC00829.  When the signal was expanded (shown in picture DSC0830), the 2 missing pulses are still absent.



                              Picture DSC00829 with 4.739 KHz Arduino Uno output signal.




                  Picture DSC00830 showing that at a frequency of 4.739 kHz the signals remain
                                                        clean and 2 signals are still absent.

The following is the sketch that was loaded into the Arduino Uno to obtain the 58 of 60 output signals:

/*  harmonic damper signal simulator from http://forum.arduino.cc/index.php?topic=147915.0    */
/* The following sketch is open source and available to any user or application */

#define PULSE_PIN 10
void setup() {
pinMode(PULSE_PIN, OUTPUT);
}
/*  Simulate the high of a tooth on a harmonic damper wheel */
void triggerHigh(int duration) {
digitalWrite(PULSE_PIN, HIGH);
delayMicroseconds(duration);
digitalWrite(PULSE_PIN, LOW);
}
/* Simulate the reference marker on a harmonic damper wheel */
void triggerReference(int duration) {
// pin should be low already
delayMicroseconds(duration);
delayMicroseconds(duration); // two delays for two missing pulses.
}
/*
Simulates a 58 tooth harmonic damper wheel with a 2 missing teeth reference point*/
void loop(){
int val = analogRead(0);
val = map(val, 0, 1023, 100, 3500);
for(int i = 0; i < 58; i++) {
triggerHigh(val);
delayMicroseconds(val);
}
triggerReference(val);
delayMicroseconds(val);
}



No comments:

Post a Comment