Digital Speedo Project

Loom, lights, gauges, indicators & wiring

Re: Digital Speedo Project

Postby BrianHawley » Mon Dec 12, 2016 12:20 pm

Bidz wrote:You can use "interrupts" for the counter, which is a little complicated but allows a very high rate - I've just yet to test it. I don't entirely understand (yet), but I think the code stops whatever else it's doing to log the pulse, and then carries on. Obviously the monitoring side of this application does need to be running at 16MHz, one update per second will be fine for temperature etc. As I say, it just needs testing.


If it's the same as the old DOS interrupts (showing my age) then it should be fine.

A very interesting project I will watch with interest as it's similar to something I'm planning. If there is a bear-trap in the path, it's always better to send someone else first :)

Good luck.
Brian

"Jodie". '67 Traveller, 1275, discs, van wheels, vert shocks, arb etc.
User avatar
BrianHawley
.
 
Posts: 308
Joined: Sat Nov 19, 2016 5:03 am
Location: Yanbu Al-Sinaiyah
Awards: 1
Contributions 2017 (1)

Saudi Arabia (sa)

Re: Digital Speedo Project

Postby cardiffrob » Thu Dec 15, 2016 10:08 am

Bidz. I have written an Arduino prog for my Austin Seven (1930s) which you could have a copy of. Might save a little time and you might be able to improve it? Getting the interrupt to work was a nightmare but I have now got it working at 1 pulse per rpm without any fudge factors and it works out perfectly. I was also thinking of having a plastic flange on the propshaft/diff flange with 4 neodinium magnets in it to increase the accuracy and allow a faster cycle time. My temp gauge is accurate to 0.01 degree C and will change if you breathe on it. Under a fiver.

Email account died last week but I can post it up here if it helps?
cardiffrob
.
 
Posts: 178
Joined: Fri Jul 02, 2010 9:24 pm
Location: Cardiff, like.


Re: Digital Speedo Project

Postby BrianHawley » Thu Dec 15, 2016 1:58 pm

cardiffrob wrote:Bidz. I have written an Arduino prog for my Austin Seven (1930s) which you could have a copy of. Might save a little time and you might be able to improve it? Getting the interrupt to work was a nightmare but I have now got it working at 1 pulse per rpm without any fudge factors and it works out perfectly. I was also thinking of having a plastic flange on the propshaft/diff flange with 4 neodinium magnets in it to increase the accuracy and allow a faster cycle time. My temp gauge is accurate to 0.01 degree C and will change if you breathe on it. Under a fiver.

Email account died last week but I can post it up here if it helps?


I would love a copy too if you don't mind.

Sounds impressive.
Brian

"Jodie". '67 Traveller, 1275, discs, van wheels, vert shocks, arb etc.
User avatar
BrianHawley
.
 
Posts: 308
Joined: Sat Nov 19, 2016 5:03 am
Location: Yanbu Al-Sinaiyah
Awards: 1
Contributions 2017 (1)

Saudi Arabia (sa)

Re: Digital Speedo Project

Postby cardiffrob » Thu Dec 15, 2016 3:40 pm

I'll try to upload it here later this evening. Other computer got hit by some sort of nasty wiggly amp problem but I should be able to put the info on a memory stick and get it across.
Attachments
rev9.jpg
cardiffrob
.
 
Posts: 178
Joined: Fri Jul 02, 2010 9:24 pm
Location: Cardiff, like.


Re: Digital Speedo Project

Postby cardiffrob » Thu Dec 15, 2016 5:41 pm

I couldn't get the version with the oil pressure sensor in it but this one works well...

/* Using the isr function lets the digi2 pin sense the RISING of the voltage upslope every time the
sensor goes above zero volts. The millis function counts the time from switch-on and thus the
difference between float count from start is the time interval between sensor triggering ie; once
per revolution.
The idea is to run all the instrumentation for a 1932 Austin Seven to save the great expense of buying original/unreliable dials.
The LCD affected the rpm results until a serial chip was added.
The triggering is from a hall-effect sensor and some powerful 3mm barrel magnets, currently one pass per revolution.
The temp probe is a DS18B20 which comes pre-packaged in a stainless steel waterproof bundle and is wedged into a
brass nut on the top of the cylinderhead water casting (so will still show "high" if all water is lost.
An led is triggered if the rpm falls into a known danger band but this could also be adapted to make a limiter indication for max revs.

Rob Thomas, Feb 20, 2015.

*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h> //libraries for the temp probe
#include <Servo.h>
#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3 //Port numbers on the serial chip thingy
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define POL POSITIVE //Backlight polarity
#define ONE_WIRE_BUS 9 //onewire input through pin 9

Servo myservo; // create servo object to control a servo
float value=0;
float rev=0; //clock count from upslope
int rpm;
int oldTime=0; //previous count from upslope
int time; //difference between new and old count
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,
Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin, 3, POL);

byte a[8] = { //manufacturing the 'degree' symbol

0b00010,
0b00101,
0b00101,
0b00010,
0b00000,
0b00000,
0b00000,
0b00000};

byte b[8]={ //manufacturing the small "2" symbol
0b00000,
0b00000,
0b00000,
0b01100,
0b10010,
0b00100,
0b01000,
0b11110};

void isr()
{
rev++; //increase clock count
}

void setup()
{
lcd.begin(16,2);
lcd.setBacklight(HIGH);
lcd.print("Austin Seven"); //brief announcement of the type of vehicle
lcd.createChar(1,a);
lcd.createChar(2,b);
attachInterrupt(0,isr,FALLING); //digital pin 2 (a.k.a "int0")
sensors.begin();
pinMode(13,OUTPUT);
myservo.attach(10); // attaches the servo on pin 10 to the servo object

}

void loop()
{
sensors.requestTemperatures();
delay (1000);
detachInterrupt(0);

time=millis()-oldTime;
rpm=((rev/time)*60000); //count of revolutions in 1 second during 'delay' assuming one magnet pass per revolution
oldTime=millis(); //resets elapsed time count
rev=0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("RPM= ");
lcd.setCursor(4,0);
lcd.print(rpm);
lcd.setCursor(0,1);
lcd.print("H");
lcd.setCursor(1,1);
lcd.write(2); //wrte the small "2" sign
lcd.setCursor(2,1);
lcd.print("O=");
lcd.setCursor(4,1);
lcd.print(sensors.getTempCByIndex(0));
lcd.setCursor(9,1);
lcd.write(1); // write degree sign

if (rpm>=2200 && rpm<=2400) //Vibration band warning for Austin Seven engine
{
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}

attachInterrupt(0,isr,RISING);

rpm = map(rpm, 600, 3000, 179, 1); // scale it to use it with the servo (value between 0 and 180, but reverse direction)
myservo.write(rpm); // sets the servo position according to the scaled value
delay(15);
}
cardiffrob
.
 
Posts: 178
Joined: Fri Jul 02, 2010 9:24 pm
Location: Cardiff, like.


Re: Digital Speedo Project

Postby Bidz » Fri Dec 16, 2016 1:34 pm

Thanks for that Rob! Can you PM me your email address in case I get stuck, perhaps?

Actually, I did hit a couple of snags yesterday. Firstly, mating my new speedo cable to the 'box was a challenge, as the interface was different - I'm not sure what Andy Wilson has given me but it was certainly different! I had to strip down the diameter of my inner...
Photo 15-12-2016, 14 48 50.jpg


A thoroughly boring job.

Eventually, I got it all installed - I also had to use use the outer of the snapped cable that was already down there, as the mating end was a different outer diameter, and the new one slipped through the retaining circlip. Bother.

Here's the Arduino powered from a battery and ready to go:
Photo 15-12-2016, 15 26 17.jpg


Unfortunately, I was picking up a lot of electromagnetic interference from the engine bay, and this meant I couldn't take the car for a calibration run. I either need to re-route the speedo cable so the unshielded 5v wires take a different route to the glovebox (rather than past the coil/HT leads where I suspect they're picking up induction from the high voltage circuitry) or invest in some copper braid as some shielding. I'm going to wait until I've got the calibration figures worked out for the temperature and pressure sensors, and then mock install it, and see how bad the problem is then...
User avatar
Bidz
.
 
Posts: 107
Joined: Mon Jul 28, 2014 5:53 pm
Location: Coventry, for some reason.

Great Britain (GB)

Re: Digital Speedo Project

Postby cardiffrob » Fri Dec 16, 2016 3:32 pm

My hotmail account died so it is out of service until they can regain access control from the scrote who hijacked it, although I have a temporary account for a couple of weeks at tomcundall@outlook.com or 01446 795489 if it is easier?

I used a Hall-effect sensor and mini magnets and have had no interference from the Austin engine which lacks any shielding. Maybe that is an option? Then you can run it off of a wheel, the propshaft or even the speedo output hole?

That display looks good. I could only find an LCD when I started out and have stuck with that. Do those screens that you use cost much? What sort of program do you need to run it?

I've got mine in a hard plastic enclosure after some incidents with shorts on the workbench. Worth getting one of these or the ABS plastic backing plates that keep the soldered terminals from touching the bodywork of the car when tinkering.

If the Mods allow it, can you post up your data? Always keen to see how other people do it. I'm still very new to Arduinos.

Cheers

Rob
cardiffrob
.
 
Posts: 178
Joined: Fri Jul 02, 2010 9:24 pm
Location: Cardiff, like.


Re: Digital Speedo Project

Postby Bidz » Fri Dec 16, 2016 4:08 pm

cardiffrob wrote:My hotmail account died so it is out of service until they can regain access control from the scrote who hijacked it, although I have a temporary account for a couple of weeks at tomcundall@outlook.com or 01446 795489 if it is easier?

I used a Hall-effect sensor and mini magnets and have had no interference from the Austin engine which lacks any shielding. Maybe that is an option? Then you can run it off of a wheel, the propshaft or even the speedo output hole?

That display looks good. I could only find an LCD when I started out and have stuck with that. Do those screens that you use cost much? What sort of program do you need to run it?

I've got mine in a hard plastic enclosure after some incidents with shorts on the workbench. Worth getting one of these or the ABS plastic backing plates that keep the soldered terminals from touching the bodywork of the car when tinkering.

If the Mods allow it, can you post up your data? Always keen to see how other people do it. I'm still very new to Arduinos.

Cheers

Rob

I'll post it up when I'm done, or more done. I found this, which summarises a lot of code I'd already found. http://retromini.weebly.com/blog/arduino-speedometer

The sensor I'm using is essentially a Hall effect sensor specifically made for counting speedo cable revolutions. I'm going to add a ferrite to the cable to see if that helps!

It'll all go in an IP rated enclosure with glands when done. I'm hoping to get a PCB made up for the connections, so they can be attached with screw terminals. This will also have the voltage dividers etc onboard for the sensors, and some 5.1V Zener diodes across the arduino inputs to protect them.

I'll be using two OLEDs - I discovered that the first one (0.96") was a bit too small to fit behind the fuel hole. So hopefully when I get to work today a 1.3" one will have arrived. The total cost for both displays is less than £15 and they have multiple colour options available, right up to full RGB. They take V+, GND and two control lines from the board.
User avatar
Bidz
.
 
Posts: 107
Joined: Mon Jul 28, 2014 5:53 pm
Location: Coventry, for some reason.

Great Britain (GB)

Re: Digital Speedo Project

Postby cardiffrob » Fri Dec 16, 2016 5:54 pm

Too late to edit the original posting so I've added this copy of the prog with the added details for the pressure sensor on the oil line.


/* Using the isr function lets the digi2 pin sense the RISING of the voltage upslope every time the
sensor goes above zero volts. The millis function counts the time from switch-on and thus the
difference between float count from start is the time interval between sensor triggering ie; once
per revolution.
The idea is to run all the instrumentation for a 1932 Austin Seven to save the great expense of buying original/unreliable dials.
The LCD affected the rpm results until a serial chip was added.
The triggering is from a hall-effect sensor and some powerful 3mm barrel magnets, currently one pass per revolution.
The temp probe is a DS18B20 which comes pre-packaged in a stainless steel waterproof bundle and is wedged into a
brass nut on the top of the cylinderhead water casting (so will still show "high" if all water is lost.
An led is triggered if the rpm falls into a known danger band but this could also be adapted to make a limiter indication for max revs.
Yellow=SCL, Orange=SDA, Orange temperature probe single wire=Pin9, Brown Servo wire=pin10, s4w43wszsawerBlue hall-effect single wire=Digipin2(akaInt0)
Oilpressure gauge. 0.5v(analog102) is 0psi, 4.5volts(analog921) is 30psi
Rob Thomas, March 20, 2016.

*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h> //libraries for the temp probe
#include <Servo.h>
#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3 //Port numbers on the serial chip thingy
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define POL POSITIVE //Backlight polarity
#define ONE_WIRE_BUS 9 //onewire input through pin 9

Servo myservo; // create servo object to control a servo
float value=0;
float rev=0; //clock count from upslope
int rpm;
int oldTime=0; //previous count from upslope
int time; //difference between new and old count
int oilout=1;
int oil=1;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,
Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin, 3, POL);

byte a[8] = { //manufacturing the 'degree' symbol

0b00010,
0b00101,
0b00101,
0b00010,
0b00000,
0b00000,
0b00000,
0b00000};

byte b[8]={ //manufacturing the small "2" symbol
0b00000,
0b00000,
0b00000,
0b01100,
0b10010,
0b00100,
0b01000,
0b11110};

void isr()
{
rev++; //increase clock count
}

void setup()
{
lcd.begin(16,2);
lcd.setBacklight(HIGH);
lcd.print("Austin Seven"); //brief announcement of the type of vehicle
lcd.createChar(1,a);
lcd.createChar(2,b);
attachInterrupt(0,isr,RISING); //digital pin 2 (a.k.a "int0")
sensors.begin();
pinMode(13,OUTPUT);
pinMode(A0,INPUT);

}

void loop()
{
delay (1000);
oil=analogRead(A0);

oilout=((oil-102)/2.7266);
detachInterrupt(0);

sensors.requestTemperatures();
time=millis()-oldTime;
rpm=((rev/time)*60000); //count of revolutions in 1 second during 'delay' assuming one magnet pass per revolution
oldTime=millis(); //resets elapsed time count
rev=0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("RPM= ");
lcd.setCursor(4,0);
lcd.print(rpm);
lcd.setCursor(0,1);
lcd.print("H");
lcd.setCursor(1,1);
lcd.write(2); //wrte the small "2" sign
lcd.setCursor(2,1);
lcd.print("O=");
lcd.setCursor(4,1);
lcd.print(sensors.getTempCByIndex(0));
lcd.setCursor(9,1);
lcd.write(1); // write degree sign


lcd.setCursor(10,0);
lcd.print("OIL");
lcd.setCursor(14,0);
lcd.print(oilout);

rpm = map(rpm, 0, 5000, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(rpm); // sets the servo position according to the scaled value
delay(15);


if (rpm>=2200 && rpm<=2400) //Vibration band warning for Austin Seven engine
{
digitalWrite(13,HIGH); //White wire to 13, black to gnd.
}
else
{
digitalWrite(13,LOW);
}
attachInterrupt(0,isr,RISING);

}
cardiffrob
.
 
Posts: 178
Joined: Fri Jul 02, 2010 9:24 pm
Location: Cardiff, like.


Re: Digital Speedo Project

Postby cardiffrob » Fri Dec 16, 2016 5:56 pm

Wow! I like the way that Mini one was done. I might have a good play over th Christmas break. thanks for the link.....wish I'd seen it a few years ago as it would have saved a lot of aggro! :D

Rob
cardiffrob
.
 
Posts: 178
Joined: Fri Jul 02, 2010 9:24 pm
Location: Cardiff, like.


Previous

Return to Electrics, Instrumentation & Security



Who is online

Users browsing this forum: frosty and 2 guests