This is a topic intended to re-create one that was lost earlier regarding adding 2-stage fan control using the V1.100 code.
If I was doing this, I would grab the code here:
http://www.msgpio.com/manuals/mshift/4L60Ecode.html. There is a link to the Codewarrior 'special edition' free compiler on that page, as well as a link to a zipped copy of the full V1.100 code project.
Install Codewarrior, unzip the code, and click on the .MCP file in the code's folder (the code should open in Codewarrior). To compile code, press F7 (or go to 'Project/Make' in the menu). Try it once just to make sure everything works (you will get a few errors, these are described in the source code in main.c).
You can edit the code in main.c (it is in the /Sources/ folder of the project). If I was doing this, I would 're-purpose' the 2 spare outputs to acts as the fan relay drivers.
For the added temperature sensor input, I would basically duplicate the current trans temp sensor.
The current code grabs the trans temp by reading analog-to-digital channel 2. I would probably use channel 4 (currently used for the line pressure sensor). The ADC is grabbed in a function called get_adc();
I would replace the code in get_adc():
Code: Select all
case 4:
// line pressure
// line pressure table value if line_units=0
// ADC count if inpram.line_units = 1
// engine brake input if line_units = 2
switch (inpram.line_units)
{
case 0: // use pressure table
adcval = linefactor_table[ATD0DR4];
break;
case 1: // report ADC count
adcval = ATD0DR4;
break;
case 2: // use as engine brake input
if (ATD0DR4 < 50) // if below 0.244 Volts
jake_brake = 1;
else
jake_brake = 0;
adcval = ATD0DR4; // report ADC count
break;
default:
break;
} // end switch (inpram.line_units)
break;
with:
Code: Select all
case 4:
// 2nd temp sensor
// Uses same curve as trans temp sensor
adcval = cltfactor_table[ATD0DR4]; // use the adc count to look up the temp (x10) in the cltfactor table
break;
adcval is returned by the get_adc() function when it is called in the timer section.
Then in the timer section you would change:
Code: Select all
if ((millisec+16) % 24 == 0) outpc.line_pressure = (outpc.line_pressure*9 + get_adc(4))/10; // get line pressure (psi)
to
Code: Select all
if ((millisec+16) % 24 == 0) outpc.coolant_temp = get_adc(4); // get coolant temp (x10)
Then you would have to add coolant temp to outpc. and the INI (or replace an unused variable in these).
At that point, you can use the spare port logic to control the spare outputs, something like:
Code: Select all
if (outpc.coolant_temp > inpram.fan_temp1) spr1(1); else spr1(0);
where you would add coolant_temp to inpram. and to the INI under page=1 of the [Constants] section (though you will likely want hysteresis, so see the existing code for the spare outputs for how that is done).
Lance.