Hi everyone,
i am in the middle of designing a fast idle controller for my project car and cannot work out what my issue is, im still pretty novice in programming and this may be a simple issue, could some of the pros on here please look over my code and see if there are any mistakes?
thanks in advance
Mike
//PWM engine idle valve controller by Mike Quirke 2014 "jupiterengineering" is my username on the arduino forum.
//the code below is designed to control a two or three wire air idle valve used in many fuel injected cars.
//operating on PWM, in similar fashion to a servo, the valve opens to various positions, depending on engine conditions to allow throttle
//compensation for heavy electrical or mechanical loads at idle speed, to pevent engine stall should the A/C power up or, in a condition of a
//cold engine where a small percentage of extra throttle is needed .
//the device takes a 5v signal from either, or both of the A/C controller or compressor solenoid and the cold idle pinout from either the cars
//engine management unit, or a seperate temperature sensor and provides throttle compensation based on the state/s or the two inputs.
//if the two inputs are revieving their 5v signal, both duty cycles are summed up to compensate for the load of two situations, otherwise, either function
//as required by conditions.
//i have configured the pins for use with an attiny 85 chip.
#include <Servo.h>
Servo idlevalve; //initiate servo object to control the idle valve
int warmup; //integer (below) for engine warmup with A/C off
int ac; //integer (below) for A/C on, warmup off
int warmupandac; //integer (below) for warmup on, A/C on
const int goingHigh = 920; // goingHigh = 920: 4.50V/5V * 1023 punch this in calculator to verify...
const int goingLow = 102; // goingLow = 102: 0.50V/5V * 1023 punch this in calculator to verify...
void setup() {
idlevalve.attach (0); //PWM output to idle valve driver transistor
pinMode (1,OUTPUT); //led indicating engine warmup mode activated
pinMode (2,OUTPUT); //led indicating A/C compensation mode activated
pinMode (A3,INPUT); //input from ecu to activate fast idle
pinMode (A2,INPUT); //input from A/C system to activate A/C idle compensation
const int warmup= map(warmup,goingLow,goingHigh,0,90); //for warmup on, A/C off,scaling input values to activate idle valve at (90,which is 50 percent duty cycle to warm up engine
const int ac= map(ac,goingLow,goingHigh,0,45); //for A/C on, warmup off (45 or 25 percent duty cycle)
int warmupandac= map(warmupandac,goingLow,goingHigh,0,135); //for warmup on, A/C on (135 or 75 percent duty cycle)
int enginetempStatus = analogRead(A3); //read A3 to determine if warmup mode required or not
int acStatus = analogRead (A2); //read A4 to determine if A/C mode required or not
}
void loop()
{
if (enginetempStatus >= goingHigh){ //if ecu cold idle activated,
digitalWrite (1,HIGH); //turn on warmup mode LED
idlevalve.write(warmup); //also activate idle valve to specified warmup duty cycle.
}
if (acstatus >= goingHigh){ //if A/C is switched on,but warmup is off,
digitalWrite (2,HIGH); //turn on A/C status LED
idlevalve.write(ac); //activate idle valve to specified A/C duty cycle.
}
if (enginetempStatus, acStatus >= goingHigh){
digitalWrite (1,2,HIGH); //turn on both status LED's
idlevalve.write(warmupandac); //activate idle valve to specified A/C duty cycle.
}
delay (1);
}
Arduino: 1.5.6-r2 (Windows XP), Board: "Arduino Mega or Mega 2560, ATmega1280"
idle_controller.ino: In function 'void loop()':
idle_controller:39: error: 'enginetempStatus' was not declared in this scope
idle_controller:43: error: 'acstatus' was not declared in this scope
idle_controller:47: error: 'enginetempStatus' was not declared in this scope
idle_controller:47: error: 'acStatus' was not declared in this scope
C:\Documents and Settings\Administrator\My Documents\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:125: error: too many arguments to function 'void digitalWrite(uint8_t, uint8_t)'
idle_controller:48: error: at this point in file
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.