Hi had a busy Monday so couldn´t read the post.
First, I´m very happy that you guys took the discussing thread furthermore and are taking new and your own conclusions.
Since last discussed I think I´ve got a little problem with the inyector pulse variable.
But first let me clear a question.
The original TDC pulse (4 per rev, as 4 cylinders and SINGLE injector) uses not a HALL effect (as my CPU FAN for tests) but it uses magnetic inductance. And the sensor is inside the distributor. Hence if you give the distributor 10° BTDC (before Top Dead End) you have some fixed advance to spark and injection to start.
However, the H.E.I module below 450 R.P.M (cranking) uses the induction pulses from the pickup coil to fire the spark (and sends a RPM pulse to the E.C.U to start the injection)
After the engine surpasses the 450 R.P.M, the E.C.U sends a HIGH signal through pin B of the H.E.I in order to command it to stop controling spark timing (hardware fixed by 10° BTDC) and then, it will be the E.C.U that through pin E of the H.E.I will send the pulses to control the NPN transistor inside the H.E.I module to cut the coil.
The TDC signal is a ramp up ramp down with max positive and min negative.
In the positive part, is when the piston starts getting close to TDC. the maximum positive amplitude is whe it has reached that.
Then the signal drops to the negative part, wich means that it´s leaving TDC and the piston is getting lower.
Original in the E.C.U and H.E.I documentation it´s said that the spark timing happends sometime after TDC (when the signal changes from MAX to MIN and after it crosses 0). (remember that it will never be less than 10° BTDC because of fixed distribuitor position.
Returning to my doubt.
If have a function that calculates how long the pulse for the injector needs to be HIGH.
unsingned long int PULSE_INY; // Time in micros that the injector needs to be opened, calculated through constant polling of 3 sensors
then
unsigned long PULSE_INY //Calculated in micros through polling sensor data
unsigned long lastInj;
if (micros() - lastInj >= PULSE_INY)
{
//Inyector pulse goes HIGH
micros() = lastInj;
}
else
{
//injector pulse goes LOW
}
But, for each loop when if, checks elapsed time >= TI, if TI is contantly being calculated through polling, wouldn´t this mean that in each pass it can change several micros, thus making innaccurate the time the pulse goes high?
I think that to circumvent this issue I will poll the sensor data, but only calculate PULSE_INY inside a function that will be trigger from a flag set in the ISR()
So
//Variables
bool PMS = false;
unsigned long INY_PULSE; // used in funcionCalculate.... The amount of time the Injector needs to be HIGH
unsigned long lastINY; //Comparative time variable
//Variables
ISR pulse_rpm()
{
bool TDC = true;
}
void loop
{
if (PMS == true;)
functionCalculate_Injector_Pulse; //Returns injector pulse var
if (micros() - lastINY >= INY_PULSE)
{
//Inyector HIGH
micros() = lastINY;
}
else
{
//INYECTOR LOW
TDC = false;
}
Don´t ,mix TDC variable with top dead cylinder. the TDC = true, does mean that the piston is 10° before TDC, but the window in the coding in wich TDC var goes from high to low is just figurative
What do you guys think?
Thanks in advance