ON INTERRUPT works just fine, especially when you are only using one interrupt. For multiple INTERRUPTs, your ISR does nothing more than filter through possible Flags & sends the code where it needs to go.
Not sure what all you're controlling, but HPWM can control your coolant fan, with temperature thresholds for duty cycle. Reading the analog port only takes maximum 50 uS (microseconds). If no change in temperature, no change to the HPWM DC%. As for fuel pump Duty Cycle%, what are you using to determine your needs? I would use either a pressure sensor (some of the newer vehicles have them built into the fuel rail) with a MAP where you are maintaining a constant absolute pressure, or perhaps just TPS. Absolute pressure is way more accurate and would be less likely to cause a lean condition at WOT.
May I suggest using something like a PIC18F46K22. It is a 40-pin device. You have an entire PORTB to control your LCD, it has plenty of analog channels, plus it has 5 CCP/PWM modules. Use one Analog port for your ECT, one for MAP, one for Fuel Pressure, and perhaps one for TPS. Controlling the fan is rather simple using SELECT CASE CTS
CASE IS < 90 : HPWM 1, 0, 1000
CASE IS < 100 : HPWM 1, 127, 1000
CASE ELSE : HPWM 1, 200, 1000
END SELECT
For fuel pressure & MAP you'll need to find what voltages equate to what pressures. If turbo, you're probably using at least a 2-BAR MAP. With a 5 volt VREF, anything above 2.5 volts and you have boost. You probably need about 2.4 BAR of fuel pressure.
Duty VAR BYTE
IF (Fuel_Value) < (MAP) THEN
Duty = Duty + 1
HPWM 2, DUTY, 1000
ENDIF
Of course this is rather simplified as you need to do the conversions before comparing.
If you can get by with 28 pins, the PIC18F26K22 is the same basic MCU but with fewer pins.
Bookmarks