Ok here is my full code:
#include <TimerOne.h>
// to the pins used:
const int WindInPin = A0; // Analog input pin for the Wind direction – Potentiometer
const int TurbineInPin = A1; // Analog input pin for the Turbine orientation – Potentiometer
float maxallow = 0.0;
float degout = 0.0;
float K = 0.0;
volatile float WindMS = 0.0;
volatile float WindRPM = 0.0;
volatile float TurRPM = 0.0;
volatile int Count1 = 0;
volatile int Count2 = 0;
const float CRPM = 367.4;
const float k1 = 2.68;
const float k = 0.708;
const float k2 = 0.763;
const float pi = 3.14;
const int analogOutPin = 9; // Analog output driver is attached to this pin
int WindValue = 0; // value read from the Wind direction – Potentiometer
int TurbineValue = 0; // value read from the Turbine orientation – Potentiometer
int outputValue = 0; // value output to the PWM (driver - analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
attachInterrupt(2, WindSpeed, RISING);
attachInterrupt(1, TurbineRPM, RISING);
attachInterrupt(Second);
}
void loop() {
// read the analog in value:
initialize(1000);
WindValue = analogRead(WindInPin);
TurbineValue = analogRead(TurbineInPin);
error = WindValue - TurbineValue;
if (error < 0.0)
direc = 0.0;
else
direc = 1.0;
if(TurRPM>0.0)
maxallow = CRMP/TurRPM; //Maxallowin RPM
else
maxallow = 0.0 ;
//convert to motor max RPM /50 for gear ratio and max
if((error >= 10.625) || (maxallow >= 6.67)) // bigger than 15deg or maxallow speed
maxallow = 335.0;
else
{
maxallow = maxallow*50;
degout= error/k;
K =(15-degout)k1;
maxallow = 335.0K;
}
//convert to 0-5V output range
maxallow = maxallow*k2;
// map it to the range of the analog out:
outputValue = map(maxallow, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// wait 10 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(10);
}
void Second()
{
TurRPM = (Count2*60)/2; //Gives Turbine in RPM
Count1 = 0;
WindRPM = (Count260)/2; //Gives wind in RPM
WindMS = (2pi6)/(60100); //wind M/S
Count2 = 0;
}
void WindSpeed()
{
Count2 = Count2 +1;
}
void TurbineRPM()
{
Count1 = Count1 +1;
}
Here isthe error:
sketch_nov02b.cpp: In function 'void setup()':
sketch_nov02b:38: error: invalid conversion from 'void ()()' to 'uint8_t'
C:\Users\Steven\Documents\Project\Micro\Software\arduino-0022\hardware\arduino\cores\arduino/wiring.h:125: error: too few arguments to function 'void attachInterrupt(uint8_t, void ()(), int)'
sketch_nov02b:38: error: at this point in file
sketch_nov02b.cpp: In function 'void loop()':
sketch_nov02b:43: error: 'initialize' was not declared in this scope
sketch_nov02b:47: error: 'error' was not declared in this scope
sketch_nov02b:49: error: 'direc' was not declared in this scope
sketch_nov02b:51: error: 'direc' was not declared in this scope
sketch_nov02b:53: error: 'CRMP' was not declared in this scope
sketch_nov02b:79: error: 'sensorValue' was not declared in this scope
I still want to use the results from the interupts but cant yet. also wats withthe error " 'direc' was not declared in this scope" i think it has something to do with the floats but i dunno what?
At first glance, you seem to be calling attachInterrupt() with one argument, and with three arguments. How many arguments does it actually take?
Itusually takes 3 but the info on timer1 (using this library,Timer1 : Arduino Playground - HomePage) says do it like this. Thats what i need help with. how to use this in sketch.