Hello,
I'm working on my own testbench to measure the power of a race engine
All my hardware is working, I'm now stumble with the software
First just a few pictures from stuff I already made.
http://img163.imageshack.us/img163/8646/09042012109.jpg
http://img442.imageshack.us/img442/3986/img181cy.jpg
http://img213.imageshack.us/img213/8867/02052012035.jpg
http://img248.imageshack.us/img248/2459/img037nv.jpg
The encoderdisc on the elektrical motor is for testing te program. This disc is also place on the drum of the testbench
The arduino board gets 2 signals; the rpm of the drum, and the rpm of the engine
Both pulses the arduino gets are good.
I using the code from the arduino site:
http://arduino.cc/playground/Learning/Tachometer
I have the code slightly modified so now the arduino reads 2 signals
I also downloaded software from parallax. This software reads the signals from arduino and then prints the values of the serial print in Excel.
This works just fine
Now only the following problems with the arduino code:
The encoderdisk has 100 notches. This means 100 pulses per revolution. The circumference of the drum is 1 meter. So if I calculate, the drum at 100 km/h makes 1667 rpm. That means 166,700 pulses in one minute, and that means 2778 pulses every second.
This should not be a problem for the arduino. It works fine if I only measure the rpm of the drum, but if i load the code in arduino with both readings, the rpm of the drum don’t go above 900 rpm. I know it's in the code, but how do I solve the problem?
Then the next problem. The Arduino sends 20 times in second a rpm update to excel. This is for the rpm of the drum not a problem, because he still receives enough pulses, but this updatespeed is too high voor the rpm reading of the engine. Set the engine turned 1500 rpm. This means 25 pulses at one second. But if he makes 20 times in one second an update, he’s gets 1.25 pulses. So 1 pulse per 0.05 sec. This produces a mega inaccurate measurement.
How can I modify my code so that I have the accurate measurement of 20 times in one second for the drum, but that the rpm of the engine updates 2 times in one second?
int val;
int valblok;
long last=0;
long lastblok=0;
int stat=LOW;
int statblok=LOW;
int stat2;
int stat2blok;
int contar=0;
int contarblok=0;
int sens=1000; // this value indicates the limit reading between dark and light,
// it has to be tested as it may change acording on the
// distance the leds are placed.
int nPalas=100; // the number of blades of the propeller
int nPalasblok=1;
int milisegundos=50; // the time it takes each reading
void setup()
{
Serial.begin(128000);
pinMode(50,OUTPUT);
pinMode(51,OUTPUT);
Serial.println("CLEARDATA");
Serial.println("LABEL,Time,rpmrol,rpmblok");
}
void loop()
{
val=analogRead(3);
if(val<sens)
stat=LOW;
else
stat=HIGH;
digitalWrite(50,stat); //as iR light is invisible for us, the led on pin 13
//indicate the state of the circuit.
if(stat2!=stat){ //counts when the state change, thats from (dark to light) or
//from (light to dark), remmember that IR light is invisible for us.
contar++;
stat2=stat;
}
valblok=analogRead(2);
if(valblok<sens)
statblok=LOW;
else
statblok=HIGH;
digitalWrite(51,statblok); //as iR light is invisible for us, the led on pin 13
//indicate the state of the circuit.
if(stat2blok!=statblok){ //counts when the state change, thats from (dark to light) or
//from (light to dark), remmember that IR light is invisible for us.
contarblok++;
stat2blok=statblok;
}
if(millis()-last>=milisegundos){
double rpmrol=((double)contar/nPalas)/2.0*60000.0/(milisegundos);
double rpmblok=((double)contarblok/nPalasblok)/2.0*60000.0/(milisegundos);
Serial.print("DATA,TIME,"); Serial.print(rpmrol); Serial.print(","); Serial.println(rpmblok);
contar=0;
contarblok=0;
last=millis();
}
}
Has somebody a solution for me?
Sincerely,
Jordy Laan