- Tue Apr 21, 2020 3:04 pm
#42234
Hello!
Im doing a little side project and converting my car (Toyota 4afe) with coil on plugs.
I have a ECU powerd distributer that contains two VR sensors.
The system works like this:
So my plan was to insted of the rotor, just send the IGT signal to a arduino to distribute what coil to fire.
My plan was to set one tooth on the crank and a hallsensor, right before TDC and wiring it up with so the IGT signal goes into the arduino and also get bypassed to the coils by mosfets, Like this:
The code looks like this, i setup two arduino to test it. One to fire 4 IGT signals and 1 crank signal, and the code seems to work like i should, it Sync on the first revulotion and fires 1-4 cylinders.
what i dont manage to do is to set the output to the cylinder to high when active, like i would need to get the IGT signal bypassed the mosfet.
Also, how can i do so the outputs get high when cylinder get rotated?
Im not a good coder
//thanks
Im doing a little side project and converting my car (Toyota 4afe) with coil on plugs.
I have a ECU powerd distributer that contains two VR sensors.
The system works like this:
So my plan was to insted of the rotor, just send the IGT signal to a arduino to distribute what coil to fire.
My plan was to set one tooth on the crank and a hallsensor, right before TDC and wiring it up with so the IGT signal goes into the arduino and also get bypassed to the coils by mosfets, Like this:
The code looks like this, i setup two arduino to test it. One to fire 4 IGT signals and 1 crank signal, and the code seems to work like i should, it Sync on the first revulotion and fires 1-4 cylinders.
what i dont manage to do is to set the output to the cylinder to high when active, like i would need to get the IGT signal bypassed the mosfet.
Code: Select all
So to the questions, do you think this method will work? i have smart coils from toyota 1zz engine, and will feedback the IGF signal to the ecu aswell. const byte IGTPin = 2; //Interrupt pin for IGT signal from ECU (pin3)
const byte crankPin = 3; //Interrupt pin for crankshaft reference pin (pin2)
volatile boolean syncAchieved = 0; //Set this to true if sync has been achieved
volatile byte cylinderCounter = 0; //Sequence which cylinder should fire (0-1-2-3)
const byte fireOrder[] = { //Table containing the fireorder (1-3-4-2)
B00000001, // cylinder 1-4
B00000010, // cylinder 2-3
B00000001, // cylinder 1-4
B00000010
}; // cylinder 2-3
void setup() {
Serial.begin(19200); //for debug
pinMode(crankPin, INPUT_PULLUP); //Interrupt pin for crankshaft position Use pullup to get rid of dangerous wire break situation
pinMode(IGTPin, INPUT_PULLUP);
DDRB = 0b00000011; //Set the first 2 pins on the B register to outputs.
attachInterrupt(digitalPinToInterrupt(crankPin), ISR0, RISING);
Serial.println("Startup");
}
void loop() {
// put your main code here, to run repeatedly:
while (syncAchieved == 1) { //Start sequencing ignition outputs when sync has occured. Otherwise just wait until engine starts rotating.
PORTB = fireOrder[cylinderCounter];
}
}
void ISR0()
{
detachInterrupt(digitalPinToInterrupt(crankPin)); //If sync is achieved, we immedeatly disable keeping track of the position pin permanently
syncAchieved = 1; //Set variable used to start ignition and disable unnecessary measuring of position pin
Serial.println("Sync Achieved"); //Add when troubleshooting
attachInterrupt(digitalPinToInterrupt(IGTPin), ISR1, HIGH); //We no longer keep track of change state once synced. Now we locate rising change on the ref pin.
}
void ISR1()
{
if (syncAchieved == 1) { //If we have achieved sync, do only this part of the interrupt
if (digitalRead(IGTPin) == HIGH) { //This is an "unneeded if". It filters out spark EMI, incorrect pulses will be counted otherwise.
cylinderCounter++; //we sequence the next cylinder that should fire
Serial.println(cylinderCounter); //debug line to see that the right cylinder are shooting
if (cylinderCounter > 3) {
cylinderCounter = 0; //This a reset for the cylinder firing sequencer. We have 4 cylinders, so we reset after we reached the final one.
}
}
}
}
Also, how can i do so the outputs get high when cylinder get rotated?
Im not a good coder
//thanks