Compressed Air Engine - Rotary Encoder

What do you mean set a global variable for state? What would that do?

What I meant that instead of displaying the state of the valve in the IRQ (which takes to much time) you can set a global variabele to reflect the state of every valve as I did with the V17() example. Then the normal loop can do the display but it will be too fast to follow. You might add a LED to reflect the state, might be visible.

Quote
next two lines invalid
timing = timingcontrol(); //
timing; // Calling Timing Control Function

For my own curiosity, what makes these invalid?

your code

 int timingcontrol()
{
  a = 1;
  b = 401;

  a1 = 400 - 40 * buttonpushcounter; // a1 is upper end of first half of crank angle
  if (buttonpushcounter ==0) a1 = a1 -1;  // When buttonpushcounter equals 0, it demands a seperate function to equal 179 rather than 0
  b1 = a1 + 400; // b1 is the upper end of the second half of crank angle
  lcd.setCursor(12,0);
  lcd.print(100-10*buttonpushcounter); // print value of timing
  lcd.print("%");
}
  1. timingcontrol() does not return a value although its signature states it should return an int.
  2. "timing; // Calling Timing Control Function" does not call anything, you use a variable as statement.

If you added the timing function directly into the interrupt, how is that reducing it?

first - I removed the function call
second - and more important - I only copied the math part, not the calls to LCD.....()
in short I only copied the absolutely necessary code into the IRQ

int V17state= 0;
void V17(int newState)
{
if (newState != V17state)
{
V17state = newState;
digitalWrite(V17PIN, newState);
}
}
Explain to me the purpose of this code? I thought I understood it but, I apparently don't.

First: there is a global variable to hold the state of the valve.
If a call to V17 is made, the newstate is compared to the state of the valve and if they differ the newstate is remembered and the digitalwrite() to actuate the valve is done.
// as said earlier you could add a LED to the pins simulating the valves

What makes this invalid? I followed a playground post along time ago, but more importantly, I can't get it to compile if I do what you suggest...

Same pattern/problem as with the call to Timingcontrol() discussed above. Can you provide an URL to the example you mention?

Definitely don't want the interrupts to ever be enabled when my hands are touching the gears and valves.

You better take off all the power when touching the G&V's, if a switch bounces or there is a loose wire, bad things might happen, you would not be the first (or last one)

Hopes the above makes sense, otherwise let me know.

Will take a look at your latest code later today,

Rob