But, you don't have a point of reference for where you are in the cycle.
If you knew when the last interrupt fired, and what time it is now, and a very fast calculator, you could determine where the crankshaft is now.
To do this, you'll need to expand what happens in the ISR, to include recording when the interrupt fired. Keep in mind, though, that millis or micros return unsigned longs, and to ensure that the time variable does not get corrupted, interrupts will need to be disabled/re-enabled in the ISR.
Paul, I don't mean to be rude, but have you read my code?
I have already covered all of this except the disabling the interrupts which I will add in, in the future. Hence:
void loop()
{ if(eventcount >=1)
// Calculate position of piston
rt = (micros() - timeold)/ eventcount; // Time Between Each Hall Pulse
rt = rt/360; // Time Between Each Hall Pulse Divided by ( 360 Degrees)--- Time for 1 degree of rotation
timeold = micros();
eventcount = 0;
What I need help with is telling the microprocessor that, when its at a certain point of the revolution when to fire the valves.
I was trying to accomplish it like this
if (degree <= ( rt*179) || (degree >= rt*1) ) // If the piston is inbetween 1 to 179 degrees of revolution then...
{
digitalWrite(So17Pin, HIGH);
But realized that the variable degree does not equal anything