But, so what? When you are doing this, you have no idea where the crankshaft is. The last eventcount increment could have been 3 degrees or 180 degrees or 350 degrees in the past.
The magnet is placed at TDC. If the event count is only once, and there is only one magnet, there will always be 360 degrees of revolution between each hall pulse. It will also dictate where TDC is for each pulse as well as give you a way to find in degrees where the pistons are through the rotation.
In addition to recording that the hall effect sensor fired, you need to record WHEN it fired. Then, when you know how long it takes to travel one degree, you'll know when (assuming a (relatively) constant speed of rotation) the crankshaft will be at a given position. When it gets to be that time, change the state of the pin.
I agree completely. After rt has been divided by 360, you multiple it my the desired degree. For example. It takes 1000us to make one revolution, 1000/360= 2.778us to make one degree. Say we want to know when its at 50 degrees
2.778 * 50 = 138.889 us
Again my issue is the actual command to tell my device that when the piston is between say 50 degrees and 60 degrees to change the pin state. I was trying to use an if >= and <= statement but couldn’t manage to set it up the way I describe.