MPG Cruise Control Algorithm - Fuelly Forums

Click here to see important news regarding the aCar App

Go Back   Fuelly Forums > Fuel Talk > General Fuel Topics
Today's Posts Search Click Here to Login
 
 
Thread Tools Display Modes
 
Prev Previous Post   Next Post Next
Old 04-08-2009, 07:35 AM   #17
Registered Member
 
Join Date: Nov 2007
Posts: 1,111
Send a message via AIM to dkjones96
Code:
int angle, speed, set_speed, min_speed, max_speed, stall_speed, tpsi, tpso, tpseff, ovrdrv;
// Set sensor inputs and constants. In an actual program these would repeat
from within and calculate based on if it was needed or not to keep the processor
from constantly making calculations instead of executing code and also enables 
you to set your +- numbers in one spot instead of 500.
input angle;
input set_speed;
input speed;
input tpsi;
set min_speed = (set_speed - 5);
set max_speed = (set_speed + 5);
set surge_speed = (set_speed + 10);
set stall_speed = (set_speed - 10);
set tpso = '0';
set ovrdrv = '1';
set tpseff = '75';

Repeat {
// If your vehicle angle is less than or equal to -10 degrees(downward slope) the 
computer will calculate when to get out of overdrive based on surge_speed which 
is a pre-programmed temporary speed increase above the normal maximum speed. 
By the time you have reached the bottom of a hill you should be at surge speed, 
in overdrive again, with no throttle input. That will continue until the car either reaches 
min_speed (level ground) or stall_speed (going up a hill again).
		if (angle <= -10) {
			if (speed < min_speed) { set tpso = tpsi + 1 };
			elseif (speed > surge_speed and tpso != '0') { set tpso = tpsi - 1 };
			elseif (speed > surge_speed and tpso = '0') {
			repeat {
				if (speed > surge_speed and ovrdrv = '1') { set ovrdrv = '0' };
				elseif (speed <= (surge_speed - 3)) { set ovrdrv = '1', return 0 };
				else { set ovrdrv = '0'};
				};
			else { set tpso = tpsi };
		};
//If the vehicle angle is between -10 degrees and 10 degrees vehicle speed is 
maintained like any other cruise control system.
		elseif (angle > -10 and angle < 10) {
			if (speed < min_speed) { set tpso = tpsi + 1 };
			elseif (speed > max_speed and tpso != '0') { set tpso = tpsi - 1 };
			elseif (speed > max_speed and tpso = '0') {
			repeat {
				if (speed > max_speed and ovrdrv = '1') { set ovrdrv = '0' };
				elseif (speed <= (max_speed - 3)) { set ovrdrv = '1', return 0 };
				else { set ovrdrv = '0'};
				}; 
			else { set tpso = tpsi };
		};
// If the angle is greater than 10 degrees and actual speed decreases to less 
than stall_speed the control system automatically increases throttle to a 
pre-determined efficient throttle position, in this case it is 75%. This area needs 
work because the program currently would set to the efficient throttle setting 
and immediately unlock the torque converter because both of them would then be 
true. Then, it would hold that until the surge speed is attained and would exit the 
loop only to end up stuck in the 'else' holding 75% throttle until the angle 
changes.
		elseif (angle >=10) {
			if (speed < stall_speed) { set tpso = tpseff };
			elseif (speed < stall_speed and tpso = tpseff ) {
			repeat {
				if (speed < stall_speed and ovrdrv = '1' ) { set ovrdrv = '0'};
				elseif (speed >= surge speed) { set ovrdrv = '1', return 0 };
				else { set tpso = tpsi };	
			};
			elseif (speed > surge_speed) { set tpso = tpsi - 2 };
			elseif (speed > max_speed and speed < surge_speed) { set tpso = tpsi - 1 };
			else { set tpso = tpsi };
		};
// If there is an angle sensor failure it would default to this, essentially making it 
a constant-throttle cruise control.
		else { set tpso = tpsi };
};
__________________
- Kyle
dkjones96 is offline   Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not very precise mpg calculation larjerr Fuelly Web Support and Community News 4 08-20-2012 01:03 AM
Average fuel mileage line in the history graph? BDC Fuelly Web Support and Community News 1 05-06-2009 12:07 AM
91 CRX DX 5 Speed Head Gasket Confusion UfoTofU General Maintenance and Repair 2 04-26-2008 10:09 AM
Is there a website where I can look up... wehrd1 General Maintenance and Repair 3 04-18-2007 05:23 PM
Congratulations Jared!!! SVOboy General Discussion (Off-Topic) 7 08-13-2006 08:55 PM

» Fuelly iOS Apps
» Fuelly Android Apps
Powered by vBadvanced CMPS v3.2.3


All times are GMT -8. The time now is 01:54 PM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2025, vBulletin Solutions, Inc.