PWM preset state issues ("not declared in this scope")
hi everyone,
i in middle of designing fast idle controller project car , cannot work out issue is, im still pretty novice in programming , may simple issue, of pros on here please on code , see if there mistakes?
thanks in advance
mike
//pwm engine idle valve controller mike quirke 2014 "jupiterengineering" username on arduino forum.
//the code below designed control 2 or 3 wire air idle valve used in many fuel injected cars.
//operating on pwm, in similar fashion servo, valve opens various positions, depending on engine conditions allow throttle
//compensation heavy electrical or mechanical loads @ idle speed, pevent engine stall should a/c power or, in condition of
//cold engine small percentage of throttle needed .
//the device takes 5v signal either, or both of a/c controller or compressor solenoid , cold idle pinout either cars
//engine management unit, or seperate temperature sensor , provides throttle compensation based on state/s or 2 inputs.
//if 2 inputs revieving 5v signal, both duty cycles summed compensate load of 2 situations, otherwise, either function
//as required conditions.
//i have configured pins use attiny 85 chip.
#include <servo.h>
servo idlevalve; //initiate servo object control idle valve
int warmup; //integer (below) engine warmup a/c off
int ac; //integer (below) a/c on, warmup off
int warmupandac; //integer (below) warmup on, a/c on
const int goinghigh = 920; // goinghigh = 920: 4.50v/5v * 1023 punch in calculator verify...
const int goinglow = 102; // goinglow = 102: 0.50v/5v * 1023 punch in calculator verify...
void setup() {
idlevalve.attach (0); //pwm output 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 ecu activate fast idle
pinmode (a2,input); //input a/c system activate a/c idle compensation
const int warmup= map(warmup,goinglow,goinghigh,0,90); //for warmup on, a/c off,scaling input values activate idle valve @ (90,which 50 percent duty cycle warm 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 determine if warmup mode required or not
int acstatus = analogread (a2); //read a4 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 specified warmup duty cycle.
}
if (acstatus >= goinghigh){ //if a/c switched on,but warmup off,
digitalwrite (2,high); //turn on a/c status led
idlevalve.write(ac); //activate idle valve 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 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' not declared in scope
idle_controller:43: error: 'acstatus' not declared in scope
idle_controller:47: error: 'enginetempstatus' not declared in scope
idle_controller:47: error: 'acstatus' not declared in scope
c:\documents , settings\administrator\my documents\arduino\hardware\arduino\avr\cores\arduino/arduino.h:125: error: many arguments function 'void digitalwrite(uint8_t, uint8_t)'
idle_controller:48: error: @ point in file
report have more information with
"show verbose output during compilation"
enabled in file > preferences.
i in middle of designing fast idle controller project car , cannot work out issue is, im still pretty novice in programming , may simple issue, of pros on here please on code , see if there mistakes?
thanks in advance
mike
//pwm engine idle valve controller mike quirke 2014 "jupiterengineering" username on arduino forum.
//the code below designed control 2 or 3 wire air idle valve used in many fuel injected cars.
//operating on pwm, in similar fashion servo, valve opens various positions, depending on engine conditions allow throttle
//compensation heavy electrical or mechanical loads @ idle speed, pevent engine stall should a/c power or, in condition of
//cold engine small percentage of throttle needed .
//the device takes 5v signal either, or both of a/c controller or compressor solenoid , cold idle pinout either cars
//engine management unit, or seperate temperature sensor , provides throttle compensation based on state/s or 2 inputs.
//if 2 inputs revieving 5v signal, both duty cycles summed compensate load of 2 situations, otherwise, either function
//as required conditions.
//i have configured pins use attiny 85 chip.
#include <servo.h>
servo idlevalve; //initiate servo object control idle valve
int warmup; //integer (below) engine warmup a/c off
int ac; //integer (below) a/c on, warmup off
int warmupandac; //integer (below) warmup on, a/c on
const int goinghigh = 920; // goinghigh = 920: 4.50v/5v * 1023 punch in calculator verify...
const int goinglow = 102; // goinglow = 102: 0.50v/5v * 1023 punch in calculator verify...
void setup() {
idlevalve.attach (0); //pwm output 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 ecu activate fast idle
pinmode (a2,input); //input a/c system activate a/c idle compensation
const int warmup= map(warmup,goinglow,goinghigh,0,90); //for warmup on, a/c off,scaling input values activate idle valve @ (90,which 50 percent duty cycle warm 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 determine if warmup mode required or not
int acstatus = analogread (a2); //read a4 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 specified warmup duty cycle.
}
if (acstatus >= goinghigh){ //if a/c switched on,but warmup off,
digitalwrite (2,high); //turn on a/c status led
idlevalve.write(ac); //activate idle valve 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 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' not declared in scope
idle_controller:43: error: 'acstatus' not declared in scope
idle_controller:47: error: 'enginetempstatus' not declared in scope
idle_controller:47: error: 'acstatus' not declared in scope
c:\documents , settings\administrator\my documents\arduino\hardware\arduino\avr\cores\arduino/arduino.h:125: error: many arguments function 'void digitalwrite(uint8_t, uint8_t)'
idle_controller:48: error: @ point in file
report have more information with
"show verbose output during compilation"
enabled in file > preferences.
when posting code, best post between code tags. can press number symbol ( # ) button there on format icons , insert code between tags, this:
[ code]
your code here
[ /code]
and like:
as problem, @ first glance seems me trying use variables on loop() declared inside setup().
when declare variable inside function local variable, accessible inside function.
for instance acstatus variable. declaring inside setup() , trying use on loop(). not work.
the way make work make them global variables. can declare before setup(), other variables.
also notice case sensitive, acstatus different acstatus.
so, make acstatus , enginetempstatus variables global, like:
then if want use them on setup () don't need declare them again, can write like
good luck!
[ code]
your code here
[ /code]
and like:
code: [select]
your code here
as problem, @ first glance seems me trying use variables on loop() declared inside setup().
when declare variable inside function local variable, accessible inside function.
for instance acstatus variable. declaring inside setup() , trying use on loop(). not work.
the way make work make them global variables. can declare before setup(), other variables.
also notice case sensitive, acstatus different acstatus.
so, make acstatus , enginetempstatus variables global, like:
code: [select]
int acstatus;
int enginetempstatus <---- maybe write enginetempstatus. helps reading it
then if want use them on setup () don't need declare them again, can write like
code: [select]
acstatus = analogread (a2);
good luck!
Arduino Forum > Using Arduino > Programming Questions > PWM preset state issues ("not declared in this scope")
arduino
Comments
Post a Comment