EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   OpenGauge / MPGuino FE computer (https://ecomodder.com/forum/opengauge-mpguino-fe-computer.html)
-   -   gunio checkpoint 4/25/08 (https://ecomodder.com/forum/showthread.php/gunio-checkpoint-4-25-08-a-2019.html)

dcb 04-26-2008 01:04 AM

gunio checkpoint 4/25/08
 
Open to suggestions and improvements, might need to trim down for 1.0

HARDWARE:
freeduino board and 2x16 display from nkcelectronics.com. Choose serial or usb freeduino to taste and to available ports on your computer (hint, a laptop compatable setup might prove useful in the early stages):

LCD ($9.99) :
** http://www.nkcelectronics.com/16x2-l...backli162.html

rs232 serial freeduino ($16.99) :
** http://www.nkcelectronics.com/arduin...omplete-k.html
OR
USB freeduino ($27.99) :
** http://www.nkcelectronics.com/freedu...elease-bo.html

Three button interface: scroll left, select, scroll right.
+ misc transistors/resistors ($8)

MAIN SCREENS:
Mainscreen
Line 1, top level trip and function
Line 2, scrollable list of selectable trip functions, + "Setup"

Setup
Line 1, Setup
Line 2, scrollable list:
** Go Back, configuration items list (many sub screens there), utilities

CONFIGURATION ITEMS:
injector settle time
number of injector pulses for 2 revolutions
number of vss tics per mile
injector flow rate
fuel tank size
contrast
brightness
fuel adjustment
distance adjustment
time adjustment (would just affect main loop)
vehicle weight (for auto-coastdown CDA computation and hp calculations)
top display (scroll through all the trips and functions and select the ONE to display on the top line of the main screen)
bottom display (scroll through all the trips and functions and select/unselect the ones to scroll on the bottom line of the main screen)

UTILITIES
follow onscreen directions

*Quick setup
** MPG, estimate your mpg at 50mph
** Injectors, hold 2000 rpm, press select, and hold 2000 rpm for 3 seconds.
** Distance, maintain 50mph, press select and hold steady 50 mph for 3 seconds.


*Compute CDA
** accelerate to 50, coast to 40 in neutral w/no brakes, decelerate to somewhere above 5mph and coast (neutral and no brakes) to a complete stop. If you entered the weight and other configuration items correctly you should see a pretty good approximation of your CDA. Repete and average.


AVAILABLE TRIPS
//trips
instant
current
trip1
tank


AVAILABLE TRIP FUNCTIONS
instant: mpg, mph, rpm, gph, update, reset
current: miles, gallons, hours, mpg, mph, rpm, gph, update, reset
trip1: miles, gallons, hours, mpg, mph, rpm, gph, update, reset, save
tank: miles, gallons, hours, mpg, mph, rpm, gph, dte, update, reset, save

** will need to update all the trips once a second. The time for all trips needs to be associated with computing when the "current" trip is over, i.e. no signals for 15 minutes. So if the end of the current trip is computed 15 minutes after the car is shut off, then 15 minutes will need to be subtracted from ALL the persistant trips (just tank and trip1 for now) before saving their state to the eeprom.


ERROR DETECTION
it is easy to go overboard in this category, but some thoughts:

*Pop up lcd messages for:
** cpu at 100% (i.e. no time left when we go to wait for the remainder of a second at the bottom of loop(), so the time tracking will be off).
** exceedingly short/long injector open times

pop up for a second (or whatever the refresh time is).

MetroMPG 04-26-2008 07:46 AM

Quote:

Originally Posted by dcb (Post 21662)
*Quick setup
** Injectors, hold 2000 rpm, press select, and hold 2000 rpm for 3 seconds.

This step will be problematic for people without tachs. They'll have to figure out a workaround (calculate gearing/speed @ 2k RPM).

Quote:

*Compute CDA
Great feature idea!

RH77 04-26-2008 08:40 PM

Quote:

Originally Posted by MetroMPG (Post 21687)
This step will be problematic for people without tachs. They'll have to figure out a workaround (calculate gearing/speed @ 2k RPM).

Great feature idea!

What if the device displayed your RPMs in the setup screen?

dcb 04-26-2008 11:27 PM

Can't compute RPM till you know how many injector pulses there are per revolution.

Maybe quick setup is a list of questions,

1. how many cylinders do you have?
2. Is your car TBI (one or two injectors just by the throttle body)?
3. make an initial guess at your mpg at 50mph
4. how big is your tank
5. calibrate speedo/injectors, accelerate to exactly 50mph on level ground in no wind, press select and maintain 50mph for 10 seconds.

calibrate will take the number of vss pulses received in the next 10 seconds and use that to determine the vss pulses per mile. (multiply vss pulses by 7.2)

calibrate will also try to match the injector flow rate with the amount of fuel that would have been required at the estimated mpg for those 10 seconds at 50mph.
flow rate: ((10/72)/estimated mpg) gallons/sum of injHI time as minutes. This should get trued up at fillup time.

Or we make some initial guess on the flow rate based on the car or vin or?, and/or slap a web utility to give people a list of setup items, or?

Coyote X 04-27-2008 12:28 AM

how about this for calculating fuel flow, rpm isn't needed for something like this. I haven't had time to mess with the ide everyone is using but it is still C so it should be similar to the codevision stuff I know.


unsigned long int timecount = 0; //global time counter, or at least the left 8 bits of one
unsigned long int period; // total amount if time the injector is open
unsigned long int time;
unsigned long int openstartcount;

Set a timer to count at whatever clock speed you are needing 10khz or whatever. Usually they are only 8 bit or whatever so you have to manipulate the bits to get a larger number.

set an interrupt for the timer overflow.
if (timecount == 16777215) timecount = 0; else timecount += 1;
what this does is make 2 numbers the timecount variable is the left 8 bits and the timer itself is the right set of bits. It is checking to make sure timecount doesn't overflow with the if statement. And when it does it starts it back at 0.

now set a pin to interrupt on going high and a pin to interrupt on going low. It is ok to connect the two pins together on the circuit. Or one interrupt could be used and when it goes high it changes the interrupt to low and when it interrupts low it sets the interrupt to high.

interrupt [EXT_INT0] void ext_int0_isr(void) //this would be when the injector fires (pins go low)
{
time = timecount<<8;
time = time + TCNT0; // shift the timecount left 8 bits and add the timer to the right half so you have a 16 bit timer
openstartcount = time; // this sets the start time that the injectors are open. I know this could be simplified but it is easier to follow hopefully.
}


interrupt [EXT_INT1] void ext_int1_isr(void) //this would be when the injector closes (pins go high)
{
time = timecount<<8;
time = time + TCNT0; // shift the timecount left 8 bits and add the timer to the right half so you have a 16 bit timer :)
if (time > openstartcount) period = period + (time - openstartcount);
else period = 4294967295 - time + openstartcount;
// this if statement is making sure that the time hasn't overflowed and started at 0 again. If it hasn't then it adds the current injector open time to the total open time. If it has overflowed and started back at 0 it knows that the largest number is 42... and time was something before that so it needs that amount of time plus however much has passed since starting back at 0 to get the correct number for period.

With that it gives you total injector open time. So the easiest thing would be to set a timer that is about 3/4 to 1 second interrupt. In this one it knows the vss signal that would be just a simple counter and it knows the total amount of time the injectors are open so it would be a simple matter of saying for miles per gallon, miles = # of vss pulses * some factor / injector open time * some factor. and for L/Km or whatever units you want just do the same thing basically. It would need a way to check to make sure the injector isn't currently open and then zero out the period variable. If it was open a small routine could be added to the injector close time to calc the mileage on injector closing for that time.

I didn't check all that code for overflowed variables or anything so I don't guarantee it will work more than just a way to show how to do this without needing rpm. It should basically work and could be tested with a function generator putting out a square wave if anyone has one handy.

Coyote X 04-27-2008 12:40 AM

Also another way to calculate it would be for the 3/4 to 1 second interrupt time to just set a variable like

{
calculate = 1;
}

then on the next injector close operation it could have this on the end of the function

if (calculate == 1){
mileage= (vsscount * vsscorr) / (period * injcorr) // the counts * the corr
// factors for each of them to get them to miles and gallons. time isn't really
//important. just distance and gallons so calibration could be just drive 1 mile
//using highway markers and use that for calculating the corr factor.

period = 0;
calculate = 0;
vss = 0; // clear everything for the next round of calculations in one second.
}


the gallons corr factor could be a routine to just count total injector open time continuously for a full tank of gas. Then figure out how much is squirted per unit time by that fill up information.

dcb 04-27-2008 08:44 AM

You are Correct that we don't actually need RPM. In my head I thought it would be a nice sanity check that the injector signal processing was working correctly, but if we have (or can attain) confidence in the interface circuit and the signal processing then we can leave it out for now.

Can you take a peek at the signal processing thread? http://ecomodder.com/forum/showthrea...979#post17979?

dcb 04-29-2008 08:42 PM

Ok, well, lets take a look at things onced stripped down to the bare essentials, instant, current, and tank MPG.




Screens:
Main Screens (using right button to switch screens, left button reverses order):
Inst MPG 0000.0
Curr MPG 0000.0

Inst MPG 0000.0
Tank MPG 0000.0

Inst MPG 0000.0
Curr Miles 00000

Inst MPG 0000.0
Curr Gallons 000

Inst MPG 0000.0
Current Reset

Inst MPG 0000.0
Tank Miles 00000

Inst MPG 0000.0
Tank Gallons 000

Inst MPG 0000.0
Tank Refill

Inst MPG 0000.0
Quick Setup

Tank Fillup Screen: (repeating buttons would be nice here,
left scroll button decreases by .1, right scroll increases by .1
Fillup Gallons:
10.7 gallons

Tank Fillup Confirmation Screen (scroll to change option, select to choose):
Save changes?
ok

Save changes?
cancel

quick setup screens, scroll left/ right to change by 1, select=next screen
1:
est mpg @ 50mph?
25mpg

2:
hold 50mph and
press select

3: grab a few vss pulses and injector pulses and if the signals look ok, then figure out the internals and go to the main screen.



Hows that for starters?

Coyote X 04-29-2008 09:30 PM

I looked at that other code you mentioned but didn't know what to do with it since it looked ok to me :)

On the setup screens for the basic version I think the only thing needed is the tank fillup gallons and pulses for a set distance. So for the setup could we have an input for gallons per hour on the injector and pulses per mile? Gallons per hour could be estimated from the factory service manual for the car then fine tuned over a few tanks of gas. Pulses per mile could be calculated easily by driving the car a mile on a highway with mile marker signs.

If the gas was done in gph and they put in a number to start with when they fill up again it would say it thinks so much has been used and then they can adjust the gph value till it matches what has been actually used. So for the setup screen it could be something like:
GPH XX.X
Total ??.? gal

Then the pulses per mile could be like this
PPM XXXXX
# Pulses ?????

The gph one could recalculate the total gal used as the number is adjusted. The ppm could start at 0 for # of pulses then they drive for one mile and that is the number that they input on the top. maybe one digit at a time then hit the middle button to advance to the next digit?

Just an idea but I am not sure if that is the best way to do it or one of the other ways would work out best. Since I am mainly just popping up here and there posting random code that won't compile with the software everyone is using :)

dcb 04-29-2008 10:21 PM

Yah, I can go for the just enter/adjust the flow rate and the vss tics per mile too and just a reset on the tank. If the users can solder together an arduino, they can figure those parameters out and make adjustments accordingly by looking at the tank gallons before resetting, and maybe an online database to look up the values for common vehicles.

So we would have:

Screens:
Main Screens (using right button to switch screens, left button goes in
reverse order, select only works on resets and injector/speed adjust):
Inst MPG 0000.0
Curr MPG 0000.0

Inst MPG 0000.0
Tank MPG 0000.0

Inst MPG 0000.0
Curr Miles 00000

Inst MPG 0000.0
Curr Gallons 000

Inst MPG 0000.0
Current Reset

Inst MPG 0000.0
Tank Miles 00000

Inst MPG 0000.0
Tank Gallons 000

Inst MPG 0000.0
Tank Reset

Inst MPG 0000.0
Speed Adjust

Inst MPG 0000.0
Injector Adjust

So that is 10 items to scroll through on the main screen, with a scroll back button that is probably fine.

Speed Adjust screen (scroll buttons to adjust +-1 , maybe hold for +- 10 every .3 seconds?)
VSS Tics/Mile?
3200

Injector Adjust screen (scroll buttons to adjust +-.1 , maybe hold for +- 1.0 every .3 seconds?)
Max Gals/Hr?
20.1


I'm not sure if 1/10 a gallon/hour will be fine enough resolution. But we can go with it for now.


All times are GMT -4. The time now is 09:38 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com