How do I figure out what the error codes mean?

You have functions declared in a function. Move these out of the loop() function.

 void tdcIRPT() {                             // the interrupt routines
  tdcStartTime = micros();                 
  }
 void pulseIRPT() {
  injectorStartTime = micros();
  }

The "ino" you're searching for is just the extension of your sketch file name. So this:

diesel_interrupt_state.ino: In function 'void setup()':
diesel_interrupt_state:31: error: 'PulseIRPT' was not declared in this scope

.... means that in the function void setup() of the file diesel_interrupt_state.ino, the error " 'PulseIRPT' was not declared in this scope" was found on line 31.

So look and see why setup() doesn't know about PulseIRTP, and as SurferTim pointed out, it's because you declared the interrupt handlers inside void() so only void() knows about them.

void loop () {
    Serial.print("DATA, TIME,,,");             // Opens PLX-DAQ data line

No idea what "Opens PLX-DAQ data line" means, but you probably don't want to print the header every time you go through the loop. It will probbaly print a few hundred times between state changes.

      //without the state=INJECTORWAIT here it should just go to the next line right?

Not at all sure which statement you are referring to. You have placed some code after the TDCWAIT_2 loop. Are you wanting to remove the statement setting INJECTORWAIT in the TDCWAIT_2 loop? If so, yes, it will just drop through into the next bit of code. That next bit of code, however, if it does not depend on a state that you set in TDCWAIT_2, will execute EVERY TIME through loop(), whether or not it has gathered all the data you are looking for.

I would either do as you have done; setting another state (you used AVERAGEWAIT for some unknown reason. You are not waiting for anything), or, alternatively, do your calculations within TDCWAIT_2. Better still, write a function that takes Btdc pneRevTime, calculated in TDCWAIT_2, call it from within TDCWAIT_2, and in that function, do anthing you want with the data.. average if you want (no idea why you want to), display it, and so on.

Thanks for the help that cleared alot up for me. The numbers are code lines where the problem is,.. not a code for the type of mistake, doh. Also ino has nothing to do with describing the error.

I tried moving the interrupt function into setup,.. that didn't work. So I tried moving it before setup, .. that didn't work either. After setup the same thing.

I checked the referance page: C:\Documents and Settings\craig\My Documents\Arduino\arduino-1.0.3\reference\AttachInterrupt.html Where it was moved to after the loop. Every time I still get the same error message: my interrupts are not declared.

I changed my code. I'm not going to show it to you. It doesn't compile. Why not?

The ball is in your court.

I really appreciate your attempt to help Paul. You make it sound like I didn't post my code or tell you how I changed it. I posted my code and told you how I changed it. I've always appreciated your straight to the point attitude and have learned alot from you over the last year of studying on this forum. .. but do I really need to repost the entire code with the interrupt routines moved into setup, then again after setup, then again after the loop for you to see what I've changed and understand why the error codes still exist? I know there are alot of things wrong with the rest of the code, especially toward the end, far from the interrupts. I'm trying to understand these interrupt errors, then work my way down. While still working to build/finish a proper sketch. This is the code that got moved around.

void tdcIRPT() {                             // the interrupt routines
  tdcStartTime = micros();                 
  }
 void pulseIRPT() {
  injectorStartTime = micros();
  }

FORE,.. oh wait that's golf. What do tennis players yell when they serve or return the ball? Maybe just a grunt? ha. Not sure how to spell a grunt but I'll post that question in the spelling fora.

but do I really need to repost the entire code with the interrupt routines moved into setup, then again after setup, then again after the loop for you to see what I've changed and understand why the error codes still exist?

You need to post the code you are having problems with. You changed what you originally posted. That means that you need to repost.

There have been too many cases where people expect us to follow the changes that they made, when the made a lot more than they told us about. Ctrl-A, Ctrl-C, Ctrl-V really isn't more trouble than several paragraphs to describe the changes.

All of your code is not two snippets. How can you expect us to reproduce your problem with two isolated snippets.

That is all my code.
The whole thing is in the first post. Not 2 snippets, just one.
The interupt was just moved around.
Here it is moved to after setup:

/* Finds time from TDC1, TDC4 and pulseStart. It's a finite state machine. Holds in a loop until the proper state occurs.
* First it looks for a LOW on the pulse detector to trigger an interrupt that logs the timing of the event. The INJECTORWAIT state isn't looking for a LOW on the pin.
* The interrupt does that. The INJECTORWAITT state is looking for data stored because the pin went LOW. Same with *the other 2 states The injector pulse comes before TDC1. How many degrees before top dead center BTDC is what we *are looking for */
#define INJECTORWAIT 0
#define TDCWAIT_1 1
#define TDCWAIT_2 2
#define AVERAGEWAIT

unsigned long tdcStartTime;
unsigned long tdcStartTime_1;
unsigned long tdcStartTime_2;
unsigned long injectorStartTime;
unsigned long Btdc;
unsigned long aveBtdc;
unsigned long oneRevTime;
unsigned long aveRevTime;
unsigned long btdcY;
unsigned long rpmX;

const int pulsePin = 2;
const int tdcPin = 3;
int count = 0;
byte state = INJECTORWAIT;

void setup() {
 Serial.begin(9600);
 pinMode(pulsePin, INPUT);
 pinMode(tdcPin, INPUT);
 while (digitalRead(tdcPin) == HIGH) {	//wait here until we are at TDC (any TDC)
  }
 attachInterrupt(0,PulseIRPT,FALLING);  //enable interrupt attached to pin 2 pulse detector
 attachInterrupt(1,TdcIRPT,FALLING);    //enable interrupt attached to pin 3 flywheel laser sensor
  }
   void tdcIRPT() {                             // the interrupt routines moved to after setup
  tdcStartTime = micros();                 
  }
 void pulseIRPT() {
  injectorStartTime = micros();
  }
void loop () {
    Serial.print("DATA, TIME,,,");             // Opens PLX-DAQ data line
  
 while (state == INJECTORWAIT)  {
  if (injectorStartTime > 0 ) {
       state = TDCWAIT_1;
   }
   }
 while (state == TDCWAIT_1) {
  if (tdcStartTime > 0 ) {
      tdcStartTime_1 = tdcStartTime;      //here we stored the value from the tdcIRPT interrupt routine intdcStartTime_1
      tdcStartTime = 0;                   //set to 0 so the next state knows if it's been retriggered.
      state = TDCWAIT_2;
  }
  }
 while (state == TDCWAIT_2) {
  if (tdcStartTime > 0) {
        tdcStartTime_2 = tdcStartTime;     
      state = AVERAGEWAIT;
  }
  }
 while (state == AVERAGEWAIT) {                    // You now have the three times you need for all your calculations.
    Btdc = tdcStartTime_1 - injectorStartTime;        // BTDC in microseconds
  oneRevTime = tdcStartTime_2 - tdcStartTime_1;     // time for one revolution in microseconds
  injectorStartTime = 0;                            // gets zeroed every time
  tdcStartTime = 0;
  if (count < 16)  {
     aveRevTime = ((15 * aveRevTime) + oneRevTime)/ 16;                //a decaying average allows me to do this without an array
     aveBtdc =    ((15 * aveBtdc) +  Btdc) / 16;
     count++;
  }
  else {
      rpmX = (60000000 / aveRevTime);                                  //oodles of time so calculate RPM
      btdcY = ((aveBtdc) / ((oneRevTime) / 360));                      //don't waste the oodles
     Serial.print(btdcY);Serial.print(",");Serial.println(rpmX);      //Dumps the average results into excel columns D&E
     count = 0;                                                       // zeroing variables that get used for averaging
     state = INJECTORWAIT;                                           //sends it back to the beginning to wait for an injector pulse
  }
  }
 }
 
  // and around the loop() we go again.
}
 
 ///OOOOORRRRR should I do it this way?
        tdcStartTime_2 = tdcStartTime; 
      //without the state=INJECTORWAIT here it should just go to the next line right?
  }
  }             // You now have the three times you need for all your calculations.
    Btdc = tdcStartTime_1 - injectorStartTime;        // BTDC in microseconds
  oneRevTime = tdcStartTime_2 - tdcStartTime_1;     // time for one revolution in microseconds
  injectorStartTime = 0;                            // gets zeroed every time
  tdcStartTime = 0;
  if (count < 16)  {
     aveRevTime = ((15 * aveRevTime) + oneRevTime)/ 16;   //a decaying average allows me to do this without an array
     aveBtdc =    ((15 * aveBtdc) +  Btdc) / 16;
     count++;
  }
  else {
      rpmX = (60000000 / aveRevTime);                                  //oodles of time so calculate RPM
      btdcY = ((aveBtdc) / ((oneRevTime) / 360));                      //don't waste the oodles
     Serial.print(btdcY);Serial.print(",");Serial.println(rpmX);      //Dumps the average results into excel columns D&E
     count = 0;                                                       // zeroing variables that get used for averaging
     state = INJECTORWAIT; 
  }
//and aroound we go again

posting the other 2 ways I changed it exceeds the allowed post length so I’ll make 2 more posts.

Here the interrupts functions are moved before setup:

/* Finds time from TDC1, TDC4 and pulseStart. It's a finite state machine. Holds in a loop until the proper state occurs.
* First it looks for a LOW on the pulse detector to trigger an interrupt that logs the timing of the event. The INJECTORWAIT state isn't looking for a LOW on the pin.
* The interrupt does that. The INJECTORWAITT state is looking for data stored because the pin went LOW. Same with *the other 2 states The injector pulse comes before TDC1. How many degrees before top dead center BTDC is what we *are looking for */
#define INJECTORWAIT 0
#define TDCWAIT_1 1
#define TDCWAIT_2 2
#define AVERAGEWAIT

unsigned long tdcStartTime;
unsigned long tdcStartTime_1;
unsigned long tdcStartTime_2;
unsigned long injectorStartTime;
unsigned long Btdc;
unsigned long aveBtdc;
unsigned long oneRevTime;
unsigned long aveRevTime;
unsigned long btdcY;
unsigned long rpmX;

const int pulsePin = 2;
const int tdcPin = 3;
int count = 0;
byte state = INJECTORWAIT;
   void tdcIRPT() {                             // the interrupt routines
  tdcStartTime = micros();                 
  }
 void pulseIRPT() {
  injectorStartTime = micros();
  }

void setup() {
 Serial.begin(9600);
 pinMode(pulsePin, INPUT);
 pinMode(tdcPin, INPUT);
 while (digitalRead(tdcPin) == HIGH) {	//wait here until we are at TDC (any TDC)
  }
 attachInterrupt(0,PulseIRPT,FALLING);  //enable interrupt attached to pin 2 pulse detector
 attachInterrupt(1,TdcIRPT,FALLING);    //enable interrupt attached to pin 3 flywheel laser sensor
  }
 
void loop () {
    Serial.print("DATA, TIME,,,");             // Opens PLX-DAQ data line
  
 while (state == INJECTORWAIT)  {
  if (injectorStartTime > 0 ) {
       state = TDCWAIT_1;
   }
   }
 while (state == TDCWAIT_1) {
  if (tdcStartTime > 0 ) {
      tdcStartTime_1 = tdcStartTime;      //here we stored the value from the tdcIRPT interrupt routine intdcStartTime_1
      tdcStartTime = 0;                   //set to 0 so the next state knows if it's been retriggered.
      state = TDCWAIT_2;
  }
  }
 while (state == TDCWAIT_2) {
  if (tdcStartTime > 0) {
        tdcStartTime_2 = tdcStartTime;     
      state = AVERAGEWAIT;
  }
  }
 while (state == AVERAGEWAIT) {                    // You now have the three times you need for all your calculations.
    Btdc = tdcStartTime_1 - injectorStartTime;        // BTDC in microseconds
  oneRevTime = tdcStartTime_2 - tdcStartTime_1;     // time for one revolution in microseconds
  injectorStartTime = 0;                            // gets zeroed every time
  tdcStartTime = 0;
  if (count < 16)  {
     aveRevTime = ((15 * aveRevTime) + oneRevTime)/ 16;                //a decaying average allows me to do this without an array
     aveBtdc =    ((15 * aveBtdc) +  Btdc) / 16;
     count++;
  }
  else {
      rpmX = (60000000 / aveRevTime);                                  //oodles of time so calculate RPM
      btdcY = ((aveBtdc) / ((oneRevTime) / 360));                      //don't waste the oodles
     Serial.print(btdcY);Serial.print(",");Serial.println(rpmX);      //Dumps the average results into excel columns D&E
     count = 0;                                                       // zeroing variables that get used for averaging
     state = INJECTORWAIT;                                           //sends it back to the beginning to wait for an injector pulse
  }
  }
 }
 
  // and around the loop() we go again.
}
 
 ///OOOOORRRRR should I do it this way?
        tdcStartTime_2 = tdcStartTime; 
      //without the state=INJECTORWAIT here it should just go to the next line right?
  }
  }             // You now have the three times you need for all your calculations.
    Btdc = tdcStartTime_1 - injectorStartTime;        // BTDC in microseconds
  oneRevTime = tdcStartTime_2 - tdcStartTime_1;     // time for one revolution in microseconds
  injectorStartTime = 0;                            // gets zeroed every time
  tdcStartTime = 0;
  if (count < 16)  {
     aveRevTime = ((15 * aveRevTime) + oneRevTime)/ 16;   //a decaying average allows me to do this without an array
     aveBtdc =    ((15 * aveBtdc) +  Btdc) / 16;
     count++;
  }
  else {
      rpmX = (60000000 / aveRevTime);                                  //oodles of time so calculate RPM
      btdcY = ((aveBtdc) / ((oneRevTime) / 360));                      //don't waste the oodles
     Serial.print(btdcY);Serial.print(",");Serial.println(rpmX);      //Dumps the average results into excel columns D&E
     count = 0;                                                       // zeroing variables that get used for averaging
     state = INJECTORWAIT; 
  }
//and aroound we go again

and here it is with the interrupt function moved to after the loop:

/* Finds time from TDC1, TDC4 and pulseStart. It's a finite state machine. Holds in a loop until the proper state occurs.
* First it looks for a LOW on the pulse detector to trigger an interrupt that logs the timing of the event. The INJECTORWAIT state isn't looking for a LOW on the pin.
* The interrupt does that. The INJECTORWAITT state is looking for data stored because the pin went LOW. Same with *the other 2 states The injector pulse comes before TDC1. How many degrees before top dead center BTDC is what we *are looking for */
#define INJECTORWAIT 0
#define TDCWAIT_1 1
#define TDCWAIT_2 2
#define AVERAGEWAIT

unsigned long tdcStartTime;
unsigned long tdcStartTime_1;
unsigned long tdcStartTime_2;
unsigned long injectorStartTime;
unsigned long Btdc;
unsigned long aveBtdc;
unsigned long oneRevTime;
unsigned long aveRevTime;
unsigned long btdcY;
unsigned long rpmX;

const int pulsePin = 2;
const int tdcPin = 3;
int count = 0;
byte state = INJECTORWAIT;


void setup() {
 Serial.begin(9600);
 pinMode(pulsePin, INPUT);
 pinMode(tdcPin, INPUT);
 while (digitalRead(tdcPin) == HIGH) {	//wait here until we are at TDC (any TDC)
  }
 attachInterrupt(0,PulseIRPT,FALLING);  //enable interrupt attached to pin 2 pulse detector
 attachInterrupt(1,TdcIRPT,FALLING);    //enable interrupt attached to pin 3 flywheel laser sensor
  }
 
void loop () {
    Serial.print("DATA, TIME,,,");             // Opens PLX-DAQ data line
  
 while (state == INJECTORWAIT)  {
  if (injectorStartTime > 0 ) {
       state = TDCWAIT_1;
   }
   }
 while (state == TDCWAIT_1) {
  if (tdcStartTime > 0 ) {
      tdcStartTime_1 = tdcStartTime;      //here we stored the value from the tdcIRPT interrupt routine intdcStartTime_1
      tdcStartTime = 0;                   //set to 0 so the next state knows if it's been retriggered.
      state = TDCWAIT_2;
  }
  }
 while (state == TDCWAIT_2) {
  if (tdcStartTime > 0) {
        tdcStartTime_2 = tdcStartTime;     
      state = AVERAGEWAIT;
  }
  }
 while (state == AVERAGEWAIT) {                    // You now have the three times you need for all your calculations.
    Btdc = tdcStartTime_1 - injectorStartTime;        // BTDC in microseconds
  oneRevTime = tdcStartTime_2 - tdcStartTime_1;     // time for one revolution in microseconds
  injectorStartTime = 0;                            // gets zeroed every time
  tdcStartTime = 0;
  if (count < 16)  {
     aveRevTime = ((15 * aveRevTime) + oneRevTime)/ 16;                //a decaying average allows me to do this without an array
     aveBtdc =    ((15 * aveBtdc) +  Btdc) / 16;
     count++;
  }
  else {
      rpmX = (60000000 / aveRevTime);                                  //oodles of time so calculate RPM
      btdcY = ((aveBtdc) / ((oneRevTime) / 360));                      //don't waste the oodles
     Serial.print(btdcY);Serial.print(",");Serial.println(rpmX);      //Dumps the average results into excel columns D&E
     count = 0;                                                       // zeroing variables that get used for averaging
     state = INJECTORWAIT;                                           //sends it back to the beginning to wait for an injector pulse
  }
  }
 }
 
    void tdcIRPT() {                             // the interrupt routines moved to after the loop
  tdcStartTime = micros();                 
  }
 void pulseIRPT() {
  injectorStartTime = micros();
  }
 
  // and around the loop() we go again.
}
 
 ///OOOOORRRRR should I do it this way?
        tdcStartTime_2 = tdcStartTime; 
      //without the state=INJECTORWAIT here it should just go to the next line right?
  }
  }             // You now have the three times you need for all your calculations.
    Btdc = tdcStartTime_1 - injectorStartTime;        // BTDC in microseconds
  oneRevTime = tdcStartTime_2 - tdcStartTime_1;     // time for one revolution in microseconds
  injectorStartTime = 0;                            // gets zeroed every time
  tdcStartTime = 0;
  if (count < 16)  {
     aveRevTime = ((15 * aveRevTime) + oneRevTime)/ 16;   //a decaying average allows me to do this without an array
     aveBtdc =    ((15 * aveBtdc) +  Btdc) / 16;
     count++;
  }
  else {
      rpmX = (60000000 / aveRevTime);                                  //oodles of time so calculate RPM
      btdcY = ((aveBtdc) / ((oneRevTime) / 360));                      //don't waste the oodles
     Serial.print(btdcY);Serial.print(",");Serial.println(rpmX);      //Dumps the average results into excel columns D&E
     count = 0;                                                       // zeroing variables that get used for averaging
     state = INJECTORWAIT; 
  }
//and aroound we go again
  1. It is an error to declare a function with in another function in C/C++.

  2. the language is case-senisitive Fred is not the same as FREd or fred.

Mark

#define AVERAGEWAIT

Is clearly wrong.

TdcIRPT is a totally different identifier to tdcIRPT.

Your curly braces don't remotely match - you need to get the indentation sorted first, if your not using a text editor with bracket-matching you will benefit from one.

The global variables accessed in an interrupt routine must be declared volatile:

volatile unsigned long tdcStartTime;
unsigned long tdcStartTime_1;
unsigned long tdcStartTime_2;
volatile unsigned long injectorStartTime;

Edit for return key test. OK, got rid of that error message. Thanks for everyone's help. End of the code was cleaned-up alot as I work toward putting the math into a function to be called as lar3ry suggested. And getting rid of all the garbage at the bottom before putting the interrupt functions there got rid of that "not declared" message. Thanks markT for catching the lower case function call that didn't match the function. Played some more. Here's the code. and this time I got auto format working so it's easier to read:

/* Finds time from TDC1, TDC4 and pulseStart. It's a finite state machine. 
* Holds in a loop until the proper state occurs.
* First it looks for a LOW on the pulse detector to trigger an interrupt
* that logs the timing of the event.
* The INJECTORWAIT state isn't looking for a LOW on the pin.
* The interrupt does that.
* The INJECTORWAITT state is looking for data stored because the pin went LOW. 
* Same with *the other 2 states The injector pulse comes before TDC1.
* How many degrees before top dead center BTDC is what we *are looking for */
#define INJECTORWAIT 0
#define TDCWAIT_1 1
#define TDCWAIT_2 2
//declared volatile because it's a global variable used in a function
volatile unsigned long tdcStartTime; volatile unsigned long injectorStartTime;
volatile unsigned long tdcStartTime_2;
volatile unsigned long tdcStartTime_1;
unsigned long oneRevTime;
unsigned long btdcY;
unsigned long rpmX;
const int pulsePin = 2;
const int tdcPin = 3;

byte state = INJECTORWAIT;

void setup() {
  Serial.begin(9600);
  pinMode(pulsePin, INPUT);
  pinMode(tdcPin, INPUT);
  while (digitalRead(tdcPin) == HIGH)  //wait here until we are at TDC (any TDC)
  }
  injectorStartTime = 0;
  attachInterrupt (0,pulseIRPT,FALLING);  //enable pin 2 pulse interrupt
  attachInterrupt (1,tdcIRPT,FALLING);    //enable pin 3 tdc interrupt
}

void loop () {
  Serial.print("DATA, TIME,,,");             // Opens PLX-DAQ data line

  while (state == INJECTORWAIT)  {
    if (injectorStartTime > 0 ) {
      state = TDCWAIT_1;
      tdcStartTime = 0;
    }
  }
  while (state == TDCWAIT_1) {
    if (tdcStartTime > 0 ) {
      tdcStartTime_1 = tdcStartTime;  //we stored the value from the tdcIRPT interrupt
      intdcStartTime_1
      tdcStartTime = 0;    //set to 0 so the next state knows if it's been retriggered.
      state = TDCWAIT_2;
    }
  }
  while (state == TDCWAIT_2) {
    if (tdcStartTime > 0) {
      tdcStartTime_2 = tdcStartTime;
      injectorStartTime = 0;
    }
    unsigned long z;      //a call to the calculate function
    z = calculate (unsigned long tdcStartTime_1,unsigned long injectorStartTime,
    unsigned long tdcStartTime_2);
    delay 10000;
    state = INJECTORWAIT;
  }
}   //end of loop so interrupt and other functions go here
void tdcIRPT() {                     // the interrupt routines
  tdcStartTime = micros();                 
}
void pulseIRPT() {
  injectorStartTime = micros();
}
int calculate  (unsigned long a, unsigned long b, unsigned long c); 
{ //calculate function
  int btdcY;  //degrees before top dead center shouldn't be more than 30
  long rpmX; // can be up to 6000
  unsigned long Btdc;
  Btdc = a - b;                 // BTDC in microseconds
  oneRevTime = c - a;           // time for one revolution in microseconds
  rpmX = 60000000/oneRevTime;   //x-axis data to send to excel
  btdcY = ((Btdc/oneRevTime)/360);  //y-axis data to send to excel
  Serial.print(btdcY);
  Serial.print(","); 
  Serial.println(rpmX);
}

woo hoo knocked some of them down and learned alot. edited to swap in latest code,.. before anyone gave me crap about how bad I messed up the calculate function. Oh you think it's bad now? ha.

/* Finds time from TDC1, TDC4 and pulseStart. It's a finite state machine. Holds in a loop until the proper state occurs.
 * First it looks for a LOW on the pulse detector to trigger an interrupt that logs the timing of the event. The INJECTORWAIT state isn't looking for a LOW on the pin.
 * The interrupt does that. The INJECTORWAITT state is looking for data stored because the pin went LOW. Same with *the other 2 states The injector pulse comes before TDC1. How many degrees before top dead center BTDC is what we *are looking for */
#define INJECTORWAIT 0

Is your enter key broken? Get it fixed!

Thanks for the tip.

/* Finds time from TDC1, TDC4 and pulseStart. It's a finite state machine.
* Holds in a loop until the proper state occurs.
* First it looks for a LOW on the pulse detector to trigger an interrupt
* that logs the timing of the event.
*The INJECTORWAIT state isn't looking for a LOW on the pin.
 * The interrupt does that.
* The INJECTORWAITT state is looking for data stored because the pin went LOW.
* Same with the other 2 states. The injector pulse comes before TDC1.
* How many degrees before top dead center BTDC is what we *are looking for */
#define INJECTORWAIT 0
#define TDCWAIT_1 1
#define TDCWAIT_2 2

//declared volatile because it's a global variable used in a function
volatile unsigned long tdcStartTime;   
volatile unsigned long injectorStartTime;
volatile unsigned long tdcStartTime_2;
volatile unsigned long tdcStartTime_1;
unsigned long oneRevTime;
unsigned long btdcY;
unsigned long rpmX;
const int pulsePin = 2;
const int tdcPin = 3;

byte state = INJECTORWAIT;

void setup() {
  Serial.begin(9600);
  pinMode(pulsePin, INPUT);
  pinMode(tdcPin, INPUT);
  while (digitalRead(tdcPin) == HIGH) {	   //wait here until we are at TDC (any TDC)
  }
  injectorStartTime = 0;
  attachInterrupt (0,pulseIRPT,FALLING);  //enable pin 2 pulse interrupt
  attachInterrupt (1,tdcIRPT,FALLING);   //enable pin 3 tdc interrupt

}

void loop () {
  Serial.print("DATA, TIME,,,");             // Opens PLX-DAQ data line

  while (state == INJECTORWAIT)  {
    if (injectorStartTime > 0 ) {
      state = TDCWAIT_1;
      tdcStartTime = 0;
    }
  }
  while (state == TDCWAIT_1) {
    if (tdcStartTime > 0 ) {
      tdcStartTime_1 = tdcStartTime;      //we stored the value from the tdcIRPT interrupt
      tdcStartTime = 0;        //set to 0 so the next state knows if it's been retriggered.
      state = TDCWAIT_2;
    }
  }
  while (state == TDCWAIT_2) {
    if (tdcStartTime > 0) {
      tdcStartTime_2 = tdcStartTime;
      injectorStartTime = 0;
    }
    unsigned long z;      //a call to the calculate function
    z = calculate (unsigned long tdcStartTime_1,  unsigned long injectorStartTime,
    unsigned long tdcStartTime_2);
    delay 10000;
    state = INJECTORWAIT;
  }
}   //end of loop so interrupt and other functions go here
void tdcIRPT() {                     // the interrupt routines
  tdcStartTime = micros();                 
}
void pulseIRPT() {
  injectorStartTime = micros();
}
int calculate  (unsigned long a, unsigned long b, unsigned long c); 
{ //calculate function
  int btdcY;  //degrees before top dead center shouldn't be more than 30
  long rpmX; // can be up to 6000
  unsigned long Btdc;
  Btdc = a - b;                 // BTDC in microseconds
  oneRevTime = c - a;           // time for one revolution in microseconds
  rpmX = 60000000/oneRevTime;   //x-axis data to send to excel
  btdcY = ((Btdc/oneRevTime)/360);  //y-axis data to send to excel
  Serial.print(btdcY);
  Serial.print(","); 
  Serial.println(rpmX);
}

That shortened it up and made it easier to read.
Can I hit return in the middle of this line without messing up the way it works?
z = calculate (unsigned long tdcStartTime_1, unsigned long injectorStartTime,
unsigned long tdcStartTime_2);

current error codes:

diesel_interrupt_state2.ino: In function ‘void loop()’:
diesel_interrupt_state2:61: error: expected primary-expression before ‘unsigned’
diesel_interrupt_state2:61: error: expected primary-expression before ‘unsigned’
diesel_interrupt_state2:62: error: expected primary-expression before ‘unsigned’
diesel_interrupt_state2:62: error: ‘calculate’ was not declared in this scope
diesel_interrupt_state2:63: error: expected `;’ before numeric constant
diesel_interrupt_state2.ino: At global scope:
diesel_interrupt_state2:74: error: expected unqualified-id before ‘{’ token

diesel_interrupt_state2:61: error: expected primary-expression before 'unsigned'

Normally means an error in the line above - can you see what it is?

Mark

    z = calculate (unsigned long tdcStartTime_1,  unsigned long injectorStartTime,

Are you calling this function with types? Do you see any place in any example where that is done?

Thanks for pointing me in the right direction. It was late and the sketch just kept getting better/closer. Had to post the latest but couldn't get it quite right. Muust sleep. In case you don't know; These Arduino boards wouldn't be worth a damn without all the helpful people on here. Sooo it compiles: and it's readable.

/* Finds time from TDC1, TDC4 and pulseStart. It's a finite state machine.
 * Holds in a loop until the proper state occurs.
 * First it looks for a LOW on the pulse detector to trigger an interrupt
 * that logs the timing of the event.
 *The INJECTORWAIT state isn't looking for a LOW on the pin.
 * The interrupt does that.
 * The INJECTORWAITT state is looking for data stored because the pin went LOW.
 * Same with the other 2 states. The injector pulse comes before TDC1.
 * How many degrees before top dead center BTDC is what we *are looking for */
#define INJECTORWAIT 0
#define TDCWAIT_1 1
#define TDCWAIT_2 2

//declared volatile because it's a global variable used in a function
volatile unsigned long tdcStartTime;   
volatile unsigned long injectorStartTime;
volatile unsigned long tdcStartTime_2;
volatile unsigned long tdcStartTime_1;
unsigned long oneRevTime;
unsigned long btdcY;
unsigned long rpmX;
const int pulsePin = 2;
const int tdcPin = 3;

byte state = INJECTORWAIT;

void setup() {
  Serial.begin(9600);
  pinMode(pulsePin, INPUT);
  pinMode(tdcPin, INPUT);
  while (digitalRead(tdcPin) == HIGH) {       //wait here until we are at TDC (any TDC)
  }
  injectorStartTime = 0;
  attachInterrupt (0,pulseIRPT,FALLING);  //enable pin 2 pulse interrupt
  attachInterrupt (1,tdcIRPT,FALLING);   //enable pin 3 tdc interrupt

}

void loop () {
  Serial.print("DATA, TIME,,,");             // Opens PLX-DAQ data line

  while (state == INJECTORWAIT)  {
    if (injectorStartTime > 0 ) {
      state = TDCWAIT_1;
      tdcStartTime = 0;
    }
  }
  while (state == TDCWAIT_1) {
    if (tdcStartTime > 0 ) {
      tdcStartTime_1 = tdcStartTime;      //we stored the value from the tdcIRPT interrupt
      tdcStartTime = 0;        //set to 0 so the next state knows if it's been retriggered.
      state = TDCWAIT_2;
    }
  }
  while (state == TDCWAIT_2) {
    if (tdcStartTime > 0) {
      tdcStartTime_2 = tdcStartTime;
      injectorStartTime = 0;
    }
  }
  //a call to the calculate function
  unsigned long  calculate (unsigned long tdcStartTime_1,  unsigned long injectorStartTime,
  unsigned long tdcStartTime_2);   //hit return so the screen wasn't too wide.
  delay (1000);
  state = INJECTORWAIT;
}   //end of loop so interrupt and other functions go here
void tdcIRPT() {                     // the interrupt routines
  tdcStartTime = micros();                 
}
void pulseIRPT() {
  injectorStartTime = micros();
}
unsigned long calculate  (unsigned long a, unsigned long b, unsigned long c) 
{                //calculate function
  int btdcY;  //degrees before top dead center shouldn't be more than 30
  long rpmX; // can be up to 6000
  unsigned long Btdc;
  Btdc = a - b;                 // BTDC in microseconds
  oneRevTime = c - a;           // time for one revolution in microseconds
  rpmX = 60000000/oneRevTime;   //x-axis data to send to excel
  btdcY = ((Btdc/oneRevTime)/360);  //y-axis data to send to excel
  Serial.print(btdcY);
  Serial.print(","); 
  Serial.println(rpmX);
}

Started with a pretty messed-up sketch. Lots of error messages in one post should be some help for the next person who searches. Right?

should be some help for the next person who searches. Right?

If only people would. 8)

Glad you got it working.

Sleep's a good thing. The Head First series of books recommends reading hard material, and then sleeping, and then reading the material again. The claim is that sleeping helps you retain the material you read, even if you didn't understand all of it. Rereading then helps connect the dots, to complete the missing links. When I get stuck on a problem, a nap or a good night's sleep often results in a solution that might otherwise never have come.