Arduino projects for auto electronics, mini ECU etc

For Automotive-related projects such as ECUs and microcontollers. For Scimitar and Sabre original equipment, please use the relevant model areas.

Moderators: scimjim, Roger Pennington, Lukeyboy46, philhoward, erikscimitardemon

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Arduino projects for auto electronics, mini ECU etc

Post by AJL Electronics » Wed Aug 19, 2015 2:54 pm

Calibrating standard fuel gauges with non standard senders


Out of necessity, I am working on a converter to map the standard fuel gauge to a non standard sender. I am working with two at the moment, an LPG and a petrol. My system will display the contents of each tank when selected.

Circuit is dead simple. One Arduino Nano. Sender signal connected to A1 with a matching resistor to a 5V regulator (Nano cannot provide enough current), Output from D9 into a 2K resistor which feeds the base of a TIP120 Darlington pair. Fuel gauge is wired to the collector, other side fed from 10V stabiliser as normal. I haven't tested it with a switching regulator, but can't see why it shouldn't work.

Software:

LPG_PetrolGauge

Fuel gauge conversion

The circuit:
* Petrol tank sender connected to analog pin 1 and ground.
240R 1W resistor connected from A1 to +5V regulator.
Value varies from 20R full, to 240R empty

LPG tank sender conected to analogue pin 0 and ground.
100R 1W resistor connected from A0 to +5V regulator.
Value varies from 0R full, to 90R empty.

PWM D9 connected via 2K resistor to the base of a TIP120.
Emitter grounded, Collector to fuel gauge. Fuel gauge to 10V regulator.

created 18/08/15
By Classic Microcars

.

*/

// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A1; // Analogue input pin that the petrol sender is attached to
const int analogInPin0 = A0; // Analogue input pin that the LPG sender is attached to
const int analogOutPin = 9; // Analogue output pin that the fuel gauge is attached to

int sensorValue = 0; // value read from the sender
int outputValue = 0; // value output to the PWM (analog out)

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}

void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 76, 460, 150, 0); // Calibration to the actual sender
// change the analog out value:
analogWrite(analogOutPin, outputValue);

// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);

// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}
Last edited by AJL Electronics on Thu Apr 14, 2016 10:39 am, edited 1 time in total.


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
philhoward
RSSOC Member
Posts: 22703
Joined: Tue Aug 29, 2006 5:41 pm
Location: Staffs, UK
Has thanked: 32 times
Been thanked: 411 times
Contact:

Re: Calibrating standard fuel gauges with non standard sende

Post by philhoward » Wed Aug 19, 2015 3:00 pm



Phil Howard
Scimitarweb Forum Admin
SS1's - 1600 Rooster Turbo; Sabre Mk1.5
SE5a Barn Find Project 24 Valve conversion
Previous: SE5/5a/SS1 No.1/SS1 Rooster/SS1 1800Ti
http://www.ss1turbo.com
Never try and argue with an idiot. They drag you down to their level, then beat you based on experience.

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Calibrating standard fuel gauges with non standard sende

Post by AJL Electronics » Wed Aug 19, 2015 3:10 pm

It can do more than that and the cost is peanuts. Arduino Nano and components for under a fiver. Low fuel output will be added to the software as it progresses, but should be trivial. Then there is the versatility. It can be asked to do lots more, mine will handle the gearbox requirements too.


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Calibrating standard fuel gauges with non standard sende

Post by AJL Electronics » Sun Aug 23, 2015 1:44 pm

I have made a little progress. The protoype board is built and the program is coming along nicely.

Would a seperate category for computer projects be a good idea? It may help people find previous relevant threads.
Attachments
image.jpg
image.jpg (128.82 KiB) Viewed 1656 times


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Calibrating standard fuel gauges with non standard sende

Post by AJL Electronics » Wed Aug 26, 2015 11:48 am

Well it all seems to be working. Final software in case anyone else finds it useful. I'm aware that is could be cleaned up a bit, but I may do that when I have less to do. The USB connection is in the boot, so I can connect to modify the software easily...

/*

LPG_PetrolGauge 25/08/2015

Fuel gauge conversion

The circuit:
* Petrol tank sender connected to analog pin 1 and ground.
240R 1W resistor connected from A1 to +5V regulator.
Value varies from 20R full, to 240R empty

LPG tank sender conected to analogue pin 0 and ground.
100R 1W resistor connected from A0 to +5V regulator.
Value varies from 0R full, to 90R empty.

PWM D9 connected via 2K resistor to the base of a TIP120.
Emitter grounded, Collector to fuel gauge. Fuel gauge to 10V regulator.

created 18/08/15
By Classic Microcars

.

*/

// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analogue input pin that the petrol sender is attached to
const int analogInPin1 = A1; // Analogue input pin that the LPG sender is attached to
const int analogOutPin = 9; // Analogue output pin that the fuel gauge is attached to
const int alarmLedPin = 13; // Low fuel warning light output.
const int petrolEnablePin = 10; // Input from fuel pump (petrol)


int sensorValue = 0; // value read from the sender
int outputValue = 0; // value output to the PWM (analog out)
int outputValue1 = 0; // value output
int val = 0; // Tank switch value


void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(alarmLedPin, OUTPUT);
pinMode(petrolEnablePin, INPUT);
}

void loop() {

val = digitalRead(petrolEnablePin);

if (val == LOW) {

lpgSender();

}

else {
petrolSender();
}

}

void petrolSender(){

// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 301, 512, 150, 10); // Calibration to the actual petrol sender
// Alarm threshold SensorValue of 450 to put the LED on

if (sensorValue > 450) {
digitalWrite(alarmLedPin, HIGH);
}
else
{digitalWrite(alarmLedPin, LOW);
}
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);

}


void lpgSender(){

// read the analog in value:
sensorValue = analogRead(analogInPin1);

// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 514, 150, 10); // Calibration to the actual LPG sender

// Alarm threshold SensorValue of 401 to put the LED on

if (sensorValue > 400) {
digitalWrite(alarmLedPin, HIGH);
}
else
{digitalWrite(alarmLedPin, LOW);
}

// change the analog out value:
analogWrite(analogOutPin, outputValue);

// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}
Last edited by AJL Electronics on Wed Aug 26, 2015 11:54 am, edited 1 time in total.


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Calibrating standard fuel gauges with non standard sende

Post by AJL Electronics » Wed Aug 26, 2015 11:52 am

IMG_1448.JPG
IMG_1448.JPG (90.9 KiB) Viewed 1603 times
IMG_1450.JPG
IMG_1450.JPG (112.37 KiB) Viewed 1603 times


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Calibrating standard fuel gauges with non standard sende

Post by AJL Electronics » Thu Apr 14, 2016 10:37 am

Next Arduino project started. This is a mini ECU to mimic the functions of an EEC-IV which controls gearbox kickdown and TCC lockup. This project will also monitor gearbox temperature and do the LPG / Petrol functions like switching, calibrating one fuel gauge for two tanks and controlling fuel pump and gas solenoids. The procesor is the Arduino Nano, that tiny bit of blue board, with the USB cable hanging from it. Case is still being designed and mocked up.
Attachments
IMG_1664.JPG
IMG_1664.JPG (84.14 KiB) Viewed 1437 times
IMG_1663.JPG
IMG_1663.JPG (142.63 KiB) Viewed 1437 times
IMG_1662.JPG
IMG_1662.JPG (112.46 KiB) Viewed 1437 times


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Calibrating standard fuel gauges with non standard sende

Post by AJL Electronics » Thu Apr 14, 2016 10:38 am

IMG_1661.JPG
IMG_1661.JPG (109.82 KiB) Viewed 1437 times


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
philhoward
RSSOC Member
Posts: 22703
Joined: Tue Aug 29, 2006 5:41 pm
Location: Staffs, UK
Has thanked: 32 times
Been thanked: 411 times
Contact:

Re: Arduino projects for auto electronics, mini ECU etc

Post by philhoward » Thu Apr 14, 2016 10:44 am

What's the current rating of the outputs as they stand on the Arduino?


Phil Howard
Scimitarweb Forum Admin
SS1's - 1600 Rooster Turbo; Sabre Mk1.5
SE5a Barn Find Project 24 Valve conversion
Previous: SE5/5a/SS1 No.1/SS1 Rooster/SS1 1800Ti
http://www.ss1turbo.com
Never try and argue with an idiot. They drag you down to their level, then beat you based on experience.

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Arduino projects for auto electronics, mini ECU etc

Post by AJL Electronics » Thu Apr 14, 2016 10:51 am

philhoward wrote:What's the current rating of the outputs as they stand on the Arduino?

http://electronics.stackexchange.com/qu ... uinos-pins


This is a bit complex. Basically, there are a number of limiting factors:

The IO lines from the microcontroller (i.e. the analog and digital pins) have both an aggregate (e.g. total) current limit, and an per-pin limit:


However, depending on how you define the Arduino "Pins", this is not the entire story.

The 5V pin of the arduino is not connected through the microcontroller. As such, it can source significantly more power. When you are powering your arduino from USB, the USB interface limits your total power consumption to 500 mA. This is shared with the devices on the arduino board, so the available power will be somewhat less.
When you are using an external power supply, through the barrel power connector, you are limited by the local 5V regulator, which is rated for a maximum of 1 Amp. However, this it also thermally limited, meaning that as you draw power, the regulator will heat up. When it overheats, it will shut down temporarily.

The 3.3V regulated output is able to supply 150 mA max, which is the limit of the 3.3V regulator.
In Summary

The absolute maximum for any single IO pin is 40 mA (this is the maximum. You should never actually pull a full 40 mA from a pin. Basically, it's the threshold at which Atmel can no longer guarantee the chip won't be damaged. You should always ensure you're safely below this current limit.)
The total current from all the IO pins together is 200 mA max
The 5V output pin is good for ~400 mA on USB, ~900 mA when using an external power adapter
The 900 mA is for an adapter that provides ~7V. As the adapter voltage increases, the amount of heat the regulator has to deal with also increases, so the maximum current will drop as the voltage increases. This is called thermal limiting
The 3.3V output is capable of supplying 150 mA.
Note - Any power drawn from the 3.3V rail has to go through the 5V rail. Therefore, if you have a 100 mA device on the 3.3V output, you need to also count it against the 5V total current.

Note: This does not apply to the Arduino Due, and there are likely some differences for the Arduino Mega. It is likely generally true for any Arduino based off the ATmega328 microcontroller.


My note: There are some limitations with the Nano, to do with the on board regulator. However, it will be powered by a stepped down, regulated 5V supply from the car electrics, so no issue.


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
philhoward
RSSOC Member
Posts: 22703
Joined: Tue Aug 29, 2006 5:41 pm
Location: Staffs, UK
Has thanked: 32 times
Been thanked: 411 times
Contact:

Re: Arduino projects for auto electronics, mini ECU etc

Post by philhoward » Thu Apr 14, 2016 11:01 am

In that case, pumping voltage into a 470 Ohm load (probably 2 seperate loads) isn't going to worry it. I think I need to do this at 12V though so would still need to buffer it. I'm assuming this is how you're going to be driving the autobox solenoids and gauges, for example?


Phil Howard
Scimitarweb Forum Admin
SS1's - 1600 Rooster Turbo; Sabre Mk1.5
SE5a Barn Find Project 24 Valve conversion
Previous: SE5/5a/SS1 No.1/SS1 Rooster/SS1 1800Ti
http://www.ss1turbo.com
Never try and argue with an idiot. They drag you down to their level, then beat you based on experience.

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Arduino projects for auto electronics, mini ECU etc

Post by AJL Electronics » Thu Apr 14, 2016 11:07 am

Yes, rather than use TIP 120s again, I have ordered a 4 way relay board, with contacts rated at 10A at 30V. It was a fiver, so will integrate that. Outputs are active low, I assume because the original ECU uses NPN power transistors for switching. There are two signals for the kickdown.. After a 500mS delay, the pull coil energises and drops out 500mS later after the hold coil energises. I believe that the hold coil stays energised as long as it sees a kickdown input. I just might try to incorporate a throttle position sensor at the pedal if I get bored enough. That will give me more information to the processor that may be usedful with an A4LDE.


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
manny
RSSOC Member
Posts: 838
Joined: Sat Sep 29, 2012 10:11 pm
Location: Smethwick, West Midlands
Has thanked: 23 times
Been thanked: 10 times

Re: Arduino projects for auto electronics, mini ECU etc

Post by manny » Thu Apr 14, 2016 11:14 am

cool.. i was looking at using mine to display volt\temp etc - all very simple hardware wise- but i am no programmer...Andy clearly is.. ( at the moment mine is just in its box!)
very clever stuff..!!!- i got as far as hooking up a LCD screen and getting some temp\volt inputs but then lost interest..


GTE Progress#
Ti Progress#
1600 Progress#
GTC Progress#
Tr7 V8 1982 #Bajaj Legend NXT ( Vespa)#bicycle 2010

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Arduino projects for auto electronics, mini ECU etc

Post by AJL Electronics » Thu Apr 14, 2016 11:15 am

The gauge still needs driving with a power transistor of course as the output is PWM. Not much use for a gauge with just empty or full indications!


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

User avatar
AJL Electronics
RSSOC Member
Posts: 7255
Joined: Fri Oct 17, 2008 8:49 pm
Location: Gloucester
Has thanked: 37 times
Been thanked: 187 times
Contact:

Re: Arduino projects for auto electronics, mini ECU etc

Post by AJL Electronics » Thu Apr 14, 2016 11:19 am

Not too difficult Manny. The first thing to do is to provide a potential divider, so that the pin Voltage can't rise above 5V. A three to one will do and will map 15V to 5V. Then in the software, you monitor the value coming out via the serial monitor and do some simple maths to convert it into a Voltage.
Current modules are available very cheaply and they just give you a voltage output relative to current.

// print the results to the serial monitor:

Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);

// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:

delay(2);
}



Once you have that working, you can then incorporate the LCD which is quite straightforward as the commands are similar to the serial monitor function. Break the project down into baby steps and then put them together to walk.


Yes, we can mend your Scimitar!
Order your Scimitar parts any hour of the day at http://www.classicmicrocars.com (member's discounts).

Fancy a holiday in Gael, France? http://www.ianrhu.com

There is no point trying to teach a pig to sing. It doesn't work and it annoys the pig.

Post Reply

Return to “Automotive Electronics”