Poslathian, my usage is actually to control an engine. Basically, when a sensor is triggered (falling), I want the fuel injector to fire. Then, after a calculated delay, the spark plug should fire. I used an external interrupt to complete this process, but Gbulmer thought it was a very faulty idea, so we've been working on improving the code. I would like to make a PWM that uses the sensor (again, the falling edge) to set the pulse. Then, there is the pulse length, which I have the equation for. Then, after a short delay, the spark plug fires.
Ideally, I'd like to be able to (now that I think of it) adjust the prescaler for a PWM on-the-fly so that it matches the period of the engine. The problem is that I'm not sure if I can use the prescaler to set periods continuously over the domain 15ms<t<200ms. If I can set it in 1ms increments over that domain, then I guess I have a (partial) solution. The other part, about the spark plug, is still pretty difficult, but setting an interrupt based on a timer (TIMER_OUTPUTCOMPARE- I need sample code here too, thanks!) would solve that problem. That's the ideal solution.
More realistically, the solutions I listed might have to come into play. The next best thing would be to use the intake valve sensor to directly generate a PWM pulse (actually, this may be the ideal solution). I would like to take an input that will pulse on and off and make a PWM that is based on the falling edge of this signal. The signal would vary from 5 to 60Hz. Using this solution, I can better time the fuel injector (which is more critical) and still use a timer interrupt for the spark plug (which is a little less critical for timing). Anyway, everything *should* be explained in the previous posts. Hope this helps you understand!
EDIT: I just noticed that there is a uint16 Timer1.setPeriod(val)
feature! Some example code here might be nice because that would be (nearly) perfect! Thanks everyone for helping me get this far. This might be the solution!