I have been using my own ignition control for some time now, it functions, however there is something that has been bothering me for quite some time. Previously I could not find the answer, and now I turn to the forum for some help.
The issue:
This ignition works by charging an inductor and then suddenly discharging it by closing a transistor (or mosfet). The ignition moment is timed by use of a hall sensor, detecting a rotating magnet (on the crank of the engine). I switch on the change of magnet field (where the magnet turns from N to S). All this works fine to some extent, if the ignition is running at 4000 RPM, I can see about a degree of delay on the crank of the engine (strobe timing light). I understand this is not much, but the whole point of this project was to learn. I time the ignition at the "hard point" so it shuts of the coil directly when it finds the rising edge of the hall sensor (see the test code below).
The schematic:
To be complete, here is the schematic I have used. The IGBT I use has been designed especially for inductive ignitions. There are two hall sensors in the schematic, however for simplicity of this test, I only use one (top dead center). The hall sensors are actually DRV5023AJQDBZT, not A1202LH (just used those for the dimensions)
The test code:
I have thrown out everything but the bare minimum, this is the code that I run in my test, to check the timing. With this code I detect about 1.0 degree of delay at a speed of about 4000 RPM. The code is compiled with avr-gcc for an ATTINY84.
#define set_low(port,pin) port &= ~(1<<pin)
#define set_high(port,pin) port |= (1<<pin)
#define set_input(portdir,pin) portdir &= ~(1<<pin)
#define set_output(portdir,pin) portdir |= (1<<pin)
#define is_set(adr, pin) (adr & (1<<pin))
#define is_clear(adr, pin) (!(adr & (1<<pin)))
while (1)
{
if(is_clear(ADV_BNK, ADV_PIN))
{
set_high(COIL_BNK, COIL_PIN);
}
else
{
set_low(COIL_BNK, COIL_PIN);
}
}
I hope that someone might be able to suggest a reason why I am getting a timing delay of about ~30uS. I have tested with ext. interrupts, the result is the same.