Weird Speedometer Question

Introduction and miscellaneous that we haven't created categories for, yet
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Weird Speedometer Question

Post by arber333 »

doobedoobedo wrote: Wed May 13, 2020 4:33 pm
Not without modification. You'd either need to use a second timer, the other timer is only 8 bit though so much worse resolution, or if the frequency was low enough you could probably just bit-bang the second output, which would also be simpler.
I would be ok with simple fixed output to run RPM on my RPM dial. I need it to stimulate ABS system and various system throughout the car that have to see engine working.

EDIT: I wanted to ask you if i can use floating value in target or source pulses? To get the value more accurate.

tnx
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Weird Speedometer Question

Post by doobedoobedo »

Is that for your crank position sensor? (the 58/60 hole one) If so for 1000 rpm = 1kHz signal out which could be bit banged on a 16MHz arduino without too much hassle, just turn the pin on or off every 500us, you could even count and miss a couple, If I remember correctly you're passing the signal through a second arduino to ditch the two unwanted pulses?

You can use float in the target pulses but not the source.

I'm currently trying, so far unsuccessfully, to get the PCM in mine to think the engine is still there. I have an even weirder shaped crank position sensor.
Image
I can generate the matching waveform, albeit square, but if it is zero crossing being used it should work so there's something else I'm missing.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Weird Speedometer Question

Post by arber333 »

doobedoobedo wrote: Wed May 13, 2020 7:33 pm Is that for your crank position sensor? (the 58/60 hole one) If so for 1000 rpm = 1kHz signal out which could be bit banged on a 16MHz arduino without too much hassle, just turn the pin on or off every 500us, you could even count and miss a couple, If I remember correctly you're passing the signal through a second arduino to ditch the two unwanted pulses?

You can use float in the target pulses but not the source.

I'm currently trying, so far unsuccessfully, to get the PCM in mine to think the engine is still there. I have an even weirder shaped crank position sensor.
Image
I can generate the matching waveform, albeit square, but if it is zero crossing being used it should work so there's something else I'm missing.
Yes this is Mazda RX8 RPM sensor. For my friend we used the sensor, but first we turned it incorrectly and car wouldnt count pulses. Yes pulses must be correctly oriented. When we fitted it correctly everything woke up. He uses transmission and so he put it directly on motor coupler inside transmission bell.
Maybe it would be best to just record the period to SD card and transmitt it to the ECU when you start.

I am also going nowhere with this. I connected my scope to input and output and i see a thick like in the voltage area. I think sensor pin is swamped with hash. Because i see pulse going to arduino at 4.5V. But nothing is comming out of D9. If i connect it on desk, then everything is good.
I am using just one 3pole cable. I need to get Lycy cable with shield....
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Weird Speedometer Question

Post by doobedoobedo »

Everything goes better on the bench.

You've made me look at my waveform generator again (which I'll realease for esp8266 or esp32 depending on which I decide to use) And I think I messed up, so thanks :)

A flavour:
Screenshot_20200513_214809.png
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Weird Speedometer Question

Post by arber333 »

Ok i got across the hash and i found my Arduino has some faulty solder on it. I solved that and now i have a twitching speedo.

Can you clear up something for me please? I cant turn my wheels fast enough with all the vibrations so i will have to assume everything works. I tried with various settings . I am interested it this:

#define SOURCE_PULSES 12
#define PULSES_PER_REVOLUTION 2

If i have 2 magnets on shaft, those settings mean when shaft rotated 12 times i would get 2 pulses in my speedo?
So with the tires i have they would rotate at 840rpm for 100km/h and speedo would need 135 pulses to show 100km/h. That means i need to show speedo 6.2 times less pulses than on shaft. Then do the settings seem logical?
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Weird Speedometer Question

Post by doobedoobedo »

arber333 wrote: Thu May 14, 2020 9:54 pm Ok i got across the hash and i found my Arduino has some faulty solder on it. I solved that and now i have a twitching speedo.

Can you clear up something for me please? I cant turn my wheels fast enough with all the vibrations so i will have to assume everything works. I tried with various settings . I am interested it this:

#define SOURCE_PULSES 12
#define PULSES_PER_REVOLUTION 2

If i have 2 magnets on shaft, those settings mean when shaft rotated 12 times i would get 2 pulses in my speedo?
So with the tires i have they would rotate at 840rpm for 100km/h and speedo would need 135 pulses to show 100km/h. That means i need to show speedo 6.2 times less pulses than on shaft. Then do the settings seem logical?
OK glad the speedo moves :).

With 2 magnets it would be 6 revolutions to get 2 pulses out with those settings, because you'd have two input pulses per revolution.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Weird Speedometer Question

Post by arber333 »

I got the speedo to correct display of speed. I am surprised because the actual frequency diverges from calculated. Strange!
But all in all i am satisfied that it works.

Now i have tried to add the code of RPM indicator but my Arduino knowledge is not sufficient to jump the missing pulses from speedo count in Arduino. Ron could you help me out please?
I would like to use the signal from the input pin D2 to output speedo on D9 as it does at the moment, with addition of D10 pin sending a pulsetrain of 58 pulses, last pulse timing through three periodes. This would either be a fixed output at 700 or 800rpm or a variable output according to D2 input.

Do you think it could be done with the same Arduino?

tnx
Isaac96
Posts: 656
Joined: Sat Oct 05, 2019 6:50 pm
Location: Northern California, USA
Been thanked: 1 time
Contact:

Re: Weird Speedometer Question

Post by Isaac96 »

I was controlling my tachometer with Arduino using the tone() command. This just outputs a square wave with a given frequency. (I later broke the tachometer by feeding it power instead of using open collector... oof)
https://www.arduino.cc/reference/en/lan ... d-io/tone/
See what the tachometer does with a 200hz signal maybe?

Code: Select all

tone(9,200];
Looks like the 406 is a 4 cyl engine, so 200hz should be 3000 rpm???

-Isaac
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Weird Speedometer Question

Post by arber333 »

Isaac96 wrote: Sun May 24, 2020 8:20 pm I was controlling my tachometer with Arduino using the tone() command. This just outputs a square wave with a given frequency. (I later broke the tachometer by feeding it power instead of using open collector... oof)
https://www.arduino.cc/reference/en/lan ... d-io/tone/
See what the tachometer does with a 200hz signal maybe?

Code: Select all

tone(9,200];
Looks like the 406 is a 4 cyl engine, so 200hz should be 3000 rpm???

-Isaac
Nope! My 406 coupe was made by Pininfarina in Turin. Actually it had V6 3L engine. And to complicate matters further tacho uses 60 hole ring on torque converter with last two holes lengthened. In effect last three pulses are one pulse that lasts 3 periods. I dont think just tone generator would suffice.

Lo and behold! I was playing with Arduino code and copiyng Damiens code into Rons and suddenly i got square pulse out of D10. Since it was 0V to 5V it obviously didnt do anything for my RPM which needs a "zero crossing" to count one pulse. Since last time Ron suggested to use a ceramic cap to invert falling side of pulse below 0V i tried that. Wow! I instantly got a series of relays clicking and my RPM indicator rose to 450RPM!!!!
Now second iteration i setup to 850rpm to look more natural to driver. Surprisingly i even got ABS system working with one wheel up!
IMG_20200524_230706_HDR.jpg
IMG_20200524_230714.jpg
Now i just have to discover if i can use signal from D2 to vary the D10 with 58 pulses per rotation.
See the code i mashed up:

/*
* © 2019 Ron Simpkin
* Public domain - do with it what you will
*
* Works on Arduino Uno and Pro-mini and probably any other 328p based Arduino running at 16MHz
*
* Limitations:
* lowest output frequency available is > 0.0595Hz
* highest output frequency is 4MHz -> but very poor resolution up this high (next highest is 2MHz)
*
* Digital Pins are _fixed_
* Digital pin 2 for incoming pulses
* Digital pin 9 for outgoing pulses
* Default pin for analog in is A2
*
* Un-comment ONE define to set the mode
*
* 1. MODE_FIXED:
* outputs a fixed frequency = RPM * PULSES_PER_REVOLUTION / 60
* change the #defines to suit your needs - all values must be postfixed UL
* 2. MODE_ANALOG_IN:
* outputs a frequency with a settable minimum and maximum depending on
* the voltage on an analog pin (default pin A2)
* 3. MODE_PULSE_IN
* takes an input signal on pin 2 and outputs a signal on pin 9
* set SOURCE_PULSES equal to the number of pulses in per revolution
* set PULSES_PER_REVOLUTION equal to the number of pulses you need to go out each full revolution
* set RPM_CUTOFF to the minimum RPM input you want to map directly to output pulses
* when the input drops below RPM_CUTOFF then the output is RPM_MIN
* NB. SOURCE_PULSES can't be set to 1. If it is actually 1 set it to 2 and double the other settings.
*/

//#define MODE_FIXED
//#define MODE_ANALOG_IN
#define MODE_PULSE_IN


const int pulseInPin = 2;
const int pulseOutPin = 9;
const int analogInPin = A2;
float fTarget, fMinimum, lastTarget;

#ifdef MODE_FIXED
#define PULSES_PER_REVOLUTION 1
#define RPM 2000UL
#endif

#ifdef MODE_ANALOG_IN
#define PULSES_PER_REVOLUTION 8
#define RPM_MIN 40
#define RPM_MAX 800UL
unsigned long analogValue;
unsigned long lastValue;
#endif

#ifdef MODE_PULSE_IN
#define SOURCE_PULSES 2
#define PULSES_PER_REVOLUTION 10
#define RPM_CUTOFF 2UL
#define RPM_MIN 0
#define PULSE_PIN 10
volatile float time = 0;
volatile float time_last = 0;
volatile int rpm_array[5] = {0,0,0,0,0};
int rpm = 0;
float val = 0;
volatile int pulIn = 0;
volatile int lastPul = 0;
volatile unsigned long now;
volatile unsigned long startMicros[SOURCE_PULSES];
volatile unsigned long lastPulMicros = 0;
volatile float fIn = 0;
volatile int suppressStart = 0;
float fCutoff;
#endif

void setup()
{
pinMode(pulseOutPin, OUTPUT); // set pin 9 as output - it's this pin that get togged by PWM
pinMode(PULSE_PIN, OUTPUT);
//Digital Pin 2 Set As An Interrupt
attachInterrupt(0, tach_interrupt, RISING);
noInterrupts();
// Configure timer 1 (16bit resolution)
TCCR1A = 0;
TCCR1B = 0;
OCR1A = 0;
// Select Phase & Frequency Correct PWM Mode, and OCR1A as TOP.
// Enable COM1A0 to toggle OC1A on compare match (pin 9)
TCCR1A |= ((1 << WGM10) | (1 << COM1A0));


#ifdef MODE_FIXED
fTarget = (float) RPM * PULSES_PER_REVOLUTION / 60;
setPWM(fTarget, fTarget);
#endif
#ifdef RPM_MIN
fMinimum = (float) RPM_MIN * PULSES_PER_REVOLUTION / 60;
#endif

#ifdef MODE_PULSE_IN
fCutoff = (float)RPM_CUTOFF * PULSES_PER_REVOLUTION/ 60;
for (int i=0; i < SOURCE_PULSES; i++){
startMicros = 0;
}

pinMode(pulseInPin, INPUT_PULLUP);
// use interrupt 0 (pin 2) and run function countPulse when pin 2 goes HIGH
attachInterrupt(digitalPinToInterrupt(pulseInPin), countPulseIn, RISING);
#endif
interrupts();
}

void loop(){
#ifdef MODE_ANALOG_IN
int pinVal = analogRead(analogInPin);
analogValue = map(pinVal, 0, 1023, RPM_MIN, RPM_MAX);
fTarget = (float) analogValue * PULSES_PER_REVOLUTION / 60;
if (lastValue != analogValue){
setPWM(fTarget, max(fTarget, fMinimum));
lastValue = analogValue;
}
#else if MODE_PULSE_IN
float f = fIn;
fTarget = f * PULSES_PER_REVOLUTION;
if (fTarget < fCutoff){
fTarget = fMinimum;
}
if (micros() - lastPulMicros > 1000000UL){
fTarget = fMinimum;
}
if (lastTarget != fTarget){
lastTarget = fTarget;
if (suppressStart == SOURCE_PULSES){
setPWM(fTarget, fTarget);
}
}

if(time > 0)
{
//5 Sample Moving Average To Smooth Out The Data
rpm_array[0] = rpm_array[1];
rpm_array[1] = rpm_array[2];
rpm_array[2] = rpm_array[3];
rpm_array[3] = rpm_array[4];
rpm_array[4] = 60*(1000000/(time*2));
//Last 5 Average RPM Counts Eqauls....
rpm = (rpm_array[0] + rpm_array[1] + rpm_array[2] + rpm_array[3] + rpm_array[4]) / 5;
}
//val = rpm;
//val = 517; //1000rpm 517uS , 250rpm = 2068uS , 4000rpm = 129uS
rpm = constrain(rpm, 850, 7000);
//Serial.println(rpm);
val = ((rpm/60)*58);

val = 1/val;

val = val/2;
val = val*1000000;
//Serial.println(val);

//val = map(val, 250, 4000, 2068, 129);
//Serial.println(val);

for(int i = 0; i < 58; i++) {
triggerHigh(val);
}

triggerReference(val);

#endif
}

/**
Simulate the high of a tooth on a
reluctor wheel
*/
void triggerHigh(unsigned long val) {
digitalWrite(PULSE_PIN, HIGH);
delayMicroseconds(val);
digitalWrite(PULSE_PIN, LOW);
delayMicroseconds(val);
}

void tach_interrupt()
{
time = (micros() - time_last);
time_last = micros();
}
/**
Simulate the reference marker on a
reluctor wheel
*/
void triggerReference(unsigned long val) {
// pin should be low already
delayMicroseconds(val);
delayMicroseconds(val); // two delays for two missing pulses.
delayMicroseconds(val);
delayMicroseconds(val); // two delays for two missing pulses.
}

void setPWM(float fTgt, float fMin){
float pwmClock;

if (fTgt <= 0.0595){OCR1A = 0;return;}
/* Set all of TCCR1B in one operation - Binary assignment!*/
if (fMin > 61.1 ){
//TCCR1B |= ((1 << CS10) | (1 << WGM13)); // Fcpu/4 61.1Hz -> 4MHz
TCCR1B = B00010001;
pwmClock = 4000000.00;
}else if (fMin > 7.64){
//TCCR1B |= ((1 << CS11) | (1 << WGM13)); // Fcpu/32 7.64Hz-> 500KHz
TCCR1B = B00010010;
pwmClock = 500000.00;
}else if (fMin > 0.952){
//TCCR1B |= ((1 << CS10) | (1 << CS11) | (1 << WGM13)); // Fcpu/256 952mHz->62.5KHz
TCCR1B = B00010011;
pwmClock = 62500.00;
}else if (fMin > 0.239){
//TCCR1B |= ((1 << CS12) | (1 << WGM13)); // Fcpu/1024 239mHz -> 16.25 KHz
TCCR1B = B00010100;
pwmClock = 15625.00;
}else{
//TCCR1B |= ((1 << CS10) | (1 << CS12) | (1 << WGM13)); // Fcpu/4096 59.5mHz -> 3.9 KHz
TCCR1B = B00010101;
pwmClock = 3906.25;
}
OCR1A = round(pwmClock/fTgt);

}

#ifdef MODE_PULSE_IN
void countPulseIn() {
lastPul = pulIn;
now = micros();
if (pulIn < SOURCE_PULSES -1){
pulIn++;
}else{
pulIn = 0;
}
if (suppressStart > SOURCE_PULSES -1){
fIn = (float)1000000/(now - startMicros[pulIn]);
}else{
suppressStart++;
}
lastPulMicros = now;
startMicros[pulIn] = now;
}
#endif
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Weird Speedometer Question

Post by doobedoobedo »

Sorry I've not been particularly active. Glad your tacho works :).

I have code for outputing any wave pattern on a pin, so 58 then miss 2 isn't a problem. I'll take a look at combining with the other code.
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: Weird Speedometer Question

Post by jon volk »

I didnt read through all the pages, but I have my speedo working off the CAN RPM signal from the drive unit. Its going through a Teensy 3.6 and I have a small mosfet switching to ground for the pulses. Ill post the code when Im on my other laptop.


EDIT: here's the code Im using to replicate the BMW sensor input.

Code: Select all

speedfreq = (rpm * .014);
    analogWriteFrequency(speedout, speedfreq);
    analogWrite(speedout, 125);

int rpm is what Im passing the decoded motor RPM CAN message to. I also have a 25" tall tire.
Formerly 92 E30 BMW Cabrio with Tesla power
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Weird Speedometer Question

Post by doobedoobedo »

OK I had a look at this last night. My original code was for ESP so I looked at porting it to the 328p which I have successfully done - however there is an issue which I'll explain.

The 328p has 3 timers:
Timer 0 is used by arduino for the millis() function which is needed by the original code.
Timer 1 is used for PWM of the original code.
That leaves timer 2 (which I've not had to use before). I'm bit-banging the pwm so I can leave the gaps, this requires an ISR on compare match (CTC mode). No problem I think, I check the datasheet and most of the info on timer 2 is an obvious copy and paste from timer 0, including CTC mode, there is one crucial difference though, the bit which sets CTC is marked as read only in the docs and indeed it is - so the documentation tells you how to set up CTC mode etc. on timer 2, but you can't because you can't set the bit.

I have code which works for timer 0 (it's incredibly simple) now but that breaks the original...

I just did a POC it should show 2000RPM

Code: Select all

#define RPM 2000UL
#define GAP 2
#define TICKS 60
#define OUTPIN 10

volatile uint8_t step_count = 0, gap_count = 0, tick_count = 0;

void setup() {
  pinMode(OUTPIN, OUTPUT);

  noInterrupts();
  // Configure timer 0 (8bit resolution)
  TCCR0A = 0;

  // set CTC mode
  TCCR0A |= (1 << WGM01);
  // set prescaler ... 
  TCCR0B = B00000010; // prescaler = 8
  //TCCR0B = B00000011; // prescaler = 64

  // want freq = 2 x (RPM/60) x TICKS
//  16MHz/freq = 2xprescalex(1 + OCR0A)
  OCR0A = 249; // 2000RPM

  // set compare match A interrupt
  TIMSK0 = 0;
  TIMSK0 |= (1 << OCIE0A);

  interrupts();
  //Serial.begin(115200);
}

ISR(TIMER0_COMPA_vect){          // timer compare interrupt service routine
  if (step_count == 0){
    if (gap_count == 0){
      digitalWrite(OUTPIN, HIGH);
    }
    step_count++;
  } else {
    digitalWrite(OUTPIN, LOW);
    step_count = 0;
    if (tick_count == TICKS -1){
      tick_count = 0;
      gap_count = 0;
    }else{
      if (tick_count + GAP >= TICKS){
        gap_count++;
      }
      tick_count++;
    }
  }
}

void loop() {
}
Which gives this waveform
arber.jpg
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Weird Speedometer Question

Post by doobedoobedo »

I take it all back - typos in the datasheet :x

It's now working on timer 2!
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Weird Speedometer Question

Post by arber333 »

I managed to build and test an Arduino Nano interface board for speedo and RPM. It also has couple of inputs and outputs remaining.
If someone needs one i still have 3x bare pcbs available. PM me. Otherwise i put the code and files on my github.
https://github.com/arber333/Arduino-Nano-RPM-Speedo

See my build here:
https://leafdriveblog.wordpress.com/202 ... r-working/
Attachments
IMG_20200617_221024.jpg
sprocketman
Posts: 49
Joined: Tue Jan 21, 2020 7:58 pm
Location: Cumbria, UK

Re: Weird Speedometer Question

Post by sprocketman »

Hi

I had some problems when i tried to send signals to my tacho on a 2008 Toyota until i found this web page

https://www.toymods.org.au/forums/threa ... ster/page2

Adding the coil from a small relay in the circuit made the differance.

It wont work on all types of tacho but it may help sombody.

I changed it so that an Ardunio generates the tone signal and the output from my inverter changes the signal relative to RPM. I set the Tacho to read 1000 rpm when the ignition is on so that the power steering works.

Section copied from their web page:-

Parts

ZT2115 - BC337 transistor - $0.42
ZR1007 - 1N4007 diodes, pack of 4 - $0.60
RR0582 - 2k7 resistors, pack 8, $0.46
SY4068 - SPST 4-pin relay, $7.95
PT4525 - red female spade crimp terminals, pk 8, $2.75
WH5532 - 3.0mm black heatshrink, $1.85
WH5533 - 5.0mm black heatshrink, $1.95
WH5554 - 6.0mm clear heatshrink, $2.25

METHOD:
Start by soldering the 2k7 resistor and 1N4007 diode together. Pay attention to the diode - the grey band should point towards the resistor
Now solder the other end of the resistor to the base (B) leg of the BC337 transistor. Note the pinouts of the BC337 below
Solder wires to the other two legs of the transistor. "E" of the transistor goes to earth, "C" of the transistor goes to the tacho output and also the relay coil.


Attach spade terminals as follows, and connect to your relay.


I converted the following Ardunio code that I found on the web and it works quite well and is simple. input signal on A0 and output on pin 10


created 21 Jan 2010
modified 31 May 2012
by Tom Igoe, with suggestion from Michael Flynn

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/Tone2
*/

void setup() {
// initialize serial communications (for debugging only):
Serial.begin(9600);
}

void loop() {
// read the sensor:
int sensorReading = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorReading);
// map the analog input range (in this case, 400 - 1000 from the photoresistor)
// to the output pitch range (120 - 1500Hz)
// change the minimum and maximum input numbers below depending on the range
// your sensor's giving:
int thisPitch = map(sensorReading, 000, 900, 32, 266);

// play the pitch:

tone(10, thisPitch);
delay(1); // delay inbetween reads for stability
}
User avatar
Cookie6000
Posts: 246
Joined: Wed May 08, 2019 9:27 am
Location: Wicklow, IRL
Has thanked: 12 times
Been thanked: 32 times
Contact:

Re: Weird Speedometer Question

Post by Cookie6000 »

Thought I would tag onto this thread as it has a common theme but one that I am struggling to solve.
The Audi B4 is pre CAN so analogue signals rule. The Speedo is just fine, being fed from a sender on the side of the gearbox next to the flange shafts. The tacho however is fed from the ECU as an AC voltage between 0.1 and 0.3v or 5-12v, depends where you search. Getting the definite values from a similar car this week.
I am using the evbmw Leaf VCU which has commands built into it for Damiens E46 to output the RPM via CAN. No good to me obviously. The RPM is fed to the VCU from the Leaf inverter on CAN and in turn, the rpm is sent through a routine to send data to the wifi on serial2 print to the wifi module for use on the web interface. So can anyone advise if it would be possible to do this on the Leaf VCU to output analogue range to the input feed to the rev counter of the car or would I need to use the likes of a due or uno? I plan to try get the analogue fuel gauge to replicate the SOC also in future.
Home of the #Audi8e - https://twitter.com/FiachraCooke
DaveH
Posts: 91
Joined: Sat Jun 13, 2020 9:04 am
Location: Hull, UK
Has thanked: 1 time
Been thanked: 8 times

Re: Weird Speedometer Question

Post by DaveH »

If there was a PWM output on the VCU you could do it, but I don't think there are any suitable outputs are there? Yes you could use an Arduino with CAN to convert it and drive the fuel gauge at the same time, maybe mount it behind the instrument panel?
User avatar
Cookie6000
Posts: 246
Joined: Wed May 08, 2019 9:27 am
Location: Wicklow, IRL
Has thanked: 12 times
Been thanked: 32 times
Contact:

Re: Weird Speedometer Question

Post by Cookie6000 »

DaveH wrote: Sat Oct 10, 2020 7:01 pm If there was a PWM output on the VCU you could do it, but I don't think there are any suitable outputs are there? Yes you could use an Arduino with CAN to convert it and drive the fuel gauge at the same time, maybe mount it behind the instrument panel?
No outputs that would do the job. USB and CAN out only. The more I look into it, the more I think it's just worth having the Arduino there for extra features in future such as the fuel gauge. I just need to find a suitable bit of code I can manipulate as it's not my strongest talent in the workshop :D
Seem to be plenty on the arduino forums for CAN to analog op signal. cheers
Home of the #Audi8e - https://twitter.com/FiachraCooke
dakol89
Posts: 2
Joined: Mon Dec 14, 2020 7:37 pm

Re: Weird Speedometer Question

Post by dakol89 »

Hello, @arber333 can you provide the parts list that you used for pcb arduino speedo?

arber333 wrote: Wed Jul 01, 2020 8:10 am I managed to build and test an Arduino Nano interface board for speedo and RPM. It also has couple of inputs and outputs remaining.
If someone needs one i still have 3x bare pcbs available. PM me. Otherwise i put the code and files on my github.
https://github.com/arber333/Arduino-Nano-RPM-Speedo

See my build here:
https://leafdriveblog.wordpress.com/202 ... r-working/
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Weird Speedometer Question

Post by arber333 »

dakol89 wrote: Mon Dec 14, 2020 7:49 pm Hello, @arber333 can you provide the parts list that you used for pcb arduino speedo?

arber333 wrote: Wed Jul 01, 2020 8:10 am I managed to build and test an Arduino Nano interface board for speedo and RPM. It also has couple of inputs and outputs remaining.
If someone needs one i still have 3x bare pcbs available. PM me. Otherwise i put the code and files on my github.
https://github.com/arber333/Arduino-Nano-RPM-Speedo

See my build here:
https://leafdriveblog.wordpress.com/202 ... r-working/
Sure, they are elements inside the PCB file. To get their values use Design Spark to make Bom. I will try to see if I forgot something...
dakol89
Posts: 2
Joined: Mon Dec 14, 2020 7:37 pm

Re: Weird Speedometer Question

Post by dakol89 »

arber333 wrote: Tue Dec 15, 2020 5:13 am
dakol89 wrote: Mon Dec 14, 2020 7:49 pm Hello, @arber333 can you provide the parts list that you used for pcb arduino speedo?

arber333 wrote: Wed Jul 01, 2020 8:10 am I managed to build and test an Arduino Nano interface board for speedo and RPM. It also has couple of inputs and outputs remaining.
If someone needs one i still have 3x bare pcbs available. PM me. Otherwise i put the code and files on my github.
https://github.com/arber333/Arduino-Nano-RPM-Speedo

See my build here:
https://leafdriveblog.wordpress.com/202 ... r-working/
Sure, they are elements inside the PCB file. To get their values use Design Spark to make Bom. I will try to see if I forgot something...

You are right i found the information in the pcb file, but i did not find the transistor model to use
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Weird Speedometer Question

Post by arber333 »

dakol89 wrote: Wed Dec 16, 2020 12:34 am You are right i found the information in the pcb file, but i did not find the transistor model to use
True. I actually used NMOS PMV65XP, just because i had them here. You use what you have available for testing...
For the 5V regulator i used LM2596TV the same one Johannes used for rev2 Openinverter board.

Now that you mention... maybe it is because i use NMOS that i have some twitches on speedo line... I should have used 10K pulldowns on transistor line. I will investigate.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Weird Speedometer Question

Post by arber333 »

Hi Ron

I am now using my circuit with your mash-up code for some time and finally i managed to got rid of random speedo twitching on car driveoff. It seemed it was caused by bad inverter-motor setup. Now that my inverter has good parameters i no longer have any problems.

Now i decided it is time to upgrade from Nano to Teensy 3.2. I want that because it has CAN bus. I could use it to transmitt my watt meter data from serial and retranslate on CAN bus line so i can use it with other devices.
I would also like to use other pins to run SOC fuel dial, use RPM indicator as amp meter and temp dial as well.

I remember you said in one of earlier posts where you setup your code to use pins D2(input) and D9(output) for speedo. I will transfer hardware to Teensy 3.2 so i will need some pointers what to use. Can i still use D2 as input and D9 as output or do i need to transfer this to different pins?
Is there any Teensy data where are the pins/timers located?

tnx

A
Post Reply