Problem using attachInterrupt to calculate acceleration using Hall effect SpeedS

Hi,
I'm working on a project using an Arduino Uno and need to calculate the rate of deceleration of a wheel. I'm using a Hall effect speed sensor which gives out a digital square wave - 12 pulses per revolution. The sensor works fine with a scope and I have a sketch/code written which calculates the rpm of the wheel and the correect values show on the serial monitor (I've tested with an accelerometer). The problem is that when I try to edit the sketch to calculate the acceleration, I get a few errors which I can't get past. To get the acceleration I tried to use 2 different rpm values / change in time, i.e. - (rpmA - rpmB)/(millis() - timeOld) = acceleration.
I'm sure the code is completly wrong but as I'm a complete beginner using Arduino, C++ and any type of programming in general, would appreciate some help on this!!
Note: For the output I need either a pulsating output or a constant High output, until acceleration = 0.

See sketch and errors below. (could not find much on the error "not included in scope" and "can't use as function").????
Thanks
JH

/*Arduino code for calculating acceleration */

volatile byte rpmcount; 		//stores rpm count in RAM (ie outside of a function) 
		                        //which can be accessed later in program
volatile byte acceleration;		//stores acceleration values in RPM
 unsigned int rpmA;		        //counts rpm integers from zero up
 unsigned int rpmB;		        //counts rpm integers from zero up
 unsigned long timeoldA;		        //counts timeoldA decimals from zero up
 unsigned long timeoldB;		        //counts timeoldB decimals from zero up

void setup()

{
Serial.begin(9600);		//opens serial port, set data rate to 9600 bps
 attachInterrupt(0, rpmA_fun, RISING);		//Interrupt 0 is digital input pin 2. Triggers on
		                                //rising. ie when square wave starts to go high

rpmcount = 0;	//sets rpm count to 0
acceleration = 0;	//sets acceleration to 0
rpmA = 0;	//sets rpmA to 0
rpmB = 0;	//sets rpmB to 0
timeoldA = 0;	//sets timeoldA to 0
timeoldB = 0;	//sets timeoldB to 0

}
void loop()	//starts loop
{
if (rpmcount >=2) 	//restarts count after every 2 pulses (increase for less error)
{
rpmA = 5*1000/(millis()-timeoldA)*rpmcount;	//calculates value for rpmA. 	
                                                //5*1000 is the time between each pulse 
							//for one rev/min (ie 60 sec/12 pulses)
							// x 1000 milliseconds
timeoldA = millis();
rpmB = 5*1000(millis()-timeoldB)*rpmcount;	//calculates value for rpmB
timeoldB = millis();					//changes variables

acceleration = (rpmB-rpmA/(timeoldA-timeoldB);	//calculates acceleration
rpmB = rpmA
rpmAcount = 0;
rpmBcount = 0;						//resets the rpm count
Serial.print("rpmA: ");				//prints values to serial monitor
Serial.println(rpmA, DEC);
Serial.print("  Acc: ");
Serial.println(acceleration, DEC);
}
{
void rpmA_fun()		//each rotation the interrupt is run 30 times (60/2=30)
}
rpmcount++;		//rpmcount plus 1
}

These are the errors*

Acc_Code.ino: In function 'void setup()':
Acc_Code:15: error: 'rpmA' cannot be used as a function
Acc_Code.ino: In function 'void loop()':
Acc_Code:35: error: '1000' cannot be used as a function
Acc_Code:38: error: expected `)' before ';' token
Acc_Code:40: error: expected `;' before 'rpmAcount'
Acc_Code:41: error: 'rpmBcount' was not declared in this scope
Acc_Code:49: error: expected initializer before '}' token

Have a close look at the braces here:

Serial.print("  Acc: ");
Serial.println(acceleration, DEC);
}
{
void rpmA_fun()		//each rotation the interrupt is run 30 times (60/2=30)
}
rpmcount++;		//rpmcount plus 1
}

On this line:

rpmB = 5*1000(millis()-timeoldB)*rpmcount;	//calculates value for rpmB

you don't have an operator between 1000 and the bracket (it needs +,-,*,/ or ^)

acceleration = (rpmB-rpmA/(timeoldA-timeoldB);	//calculates acceleration
rpmB = rpmA

Should be:

acceleration = (rpmB-rpmA)/(timeoldA-timeoldB);	//calculates acceleration
rpmB = rpmA;

Finally rpmAcount and rpmBcount have not been declared anywhere

The first error that I found relates to "Acc_Code:38: error: expected `)' before ';' token". In the line where you calculate acceleration you have two '(', but only one ')' in your formula.

Just spotted an error relating to "Acc_Code:35: error: '1000' cannot be used as a function". You forgot to include the * between the value 1000 and the difference. This shortcut works for hand-written algebra, not so well here. :wink:

For the first error "Acc_Code:15: error: 'rpmA' cannot be used as a function", line 15 is your attachInterrupt() instruction. I'm wondering if the issue might be the underscore in your ISR routine name. Try changing that and see what happens.

For the error "Acc_Code:40: error: expected `;' before 'rpmAcount'", you are missing a semi-colon in the preceding line: "rpmB = rpmA".

For the error "Acc_Code:41: error: 'rpmBcount' was not declared in this scope", I don't see where you initialize either the rpmAcount or rpmBcount variables. And the only place you seem to use them is setting them to zero. Did I miss something?

And for the last error "Acc_Code:49: error: expected initializer before '}' token", there seems to be an unneeded "{" before your ISR function declaration, and the "}" in the third-to-last line should be "{".

Hope my second pair of eyes helped you.

Edit: I see tobyb121 caught these for you while I was writing this up. Sorry for the duplicate info.

Tobyb121 & Sembazuru,
Thank you very much for your reply. Yes, these changes worked. I've stared at this code for hours trying to figure out what was wrong, and in the end it's staring you in the face!!!! Hopefully the code will calculate the acceleration when I test it tomorrow. Thanks again.
CharlzD