PULSOUT emulating phase shift
As part of my project to build a timing controller for my car (taking reading from a crank angle sensor, then delaying the pulses using the pic) I'm now working on getting the pulses out.
I'm taking my reading and know the rpm and therefore the pulse high and low that I should be generating so that's not a problem.
I seem to be having a couple of issues at the minute though.
I'm trying to emulate and approx 800rpm pulse (2 pulses per rev at about a 45% duty cycle - 26 pulses per second).
This is working fine using the pulsout command and using pauseus to work on the dwell of the pulse.
What I can't quite get my head around is how to delay the phase of the pulse - if I put a delay in each cycle it will alter the pulse time not the phase.
Should I be doing this another way (ie using PWM) or do I just need to restructure the code a bit more?
Here's a simple graphic representation of what I'm trying to achieve...
Pulse in - ____###____###____###_
Pulse out - _____###____###____###_
So say I want to delay the pulse train by 22uS I need to alter the pulse start time by the appropriate amount.
This needs to be done on the fly and adjust the phase according to variables taken by my other code which reads the RPM and other engine factors so the higher the airflow and RPM then the more the phase will be delayed.
I've generated a table to look this up and that is working fine, I just need to convert the looked up level to the phase delay.
Hope that makes sense anyway.
Leigh