Will this actually work? Let’s inspect the ATmega328P to see if it is capable of supporting EFI theoretically.
Is the CPU Fast enough?
Short answer: Yes
The first question has to be: is the ATmega328P processor (running 16mhz) fast enough to handle the job? So let’s figure out what the NanoEFI system needs at it’s most basic level, then see what the 328P offers.
Scale of operation required:
R = 1 Rotation
L = 12000 RPM Rev Limit
Time per rotation at 12,000RPM
R per second: 12000/60 = 200 RPS
Time per R: 1/200 = 0.005s
So in following the math, we find that (at our target redline of 12,000RPM) each revolution will occur at intervals of 0.005 seconds. That is 5 milliseconds.
That’s pretty fast, but it’s still not nearly on the scale in which we have to operate. In order for an EFI system to work, events have to be timed down to the degree level. So let’s figure out
Time per degree of rotation at 12,000RPM
Time per degree: 0.005/360 = 0.00013s
That’s 130 microseconds.
Comparing this data with the Arduino Mini 328 Pro Capabilities:
The ATmega328P processes 1 instruction per cycle. Meaning that 16mhz = 16mips.
Time per instruction: 1/16000000 = 0.0000000625s
So this thing operates on the scale of nanoseconds. With fine tuning of the fueling needing to be accurate to 130us in order to have 1° of accuracy, it looks like we’re on the right track. Let’s take it a step further.
Now armed with these two numbers, we can see how many instructions can processed for every degree of rotation at redline engine speed.
- 0.00013 / 0.0000000625 = 2080 instructions executed per degree of rotation
Alright! So it looks like the 16Mhz 328P CPU is fast enough for the job. Of course, this doesn’t take into account time required to access timer and ADC peripherals, make calculations, and handle all helper routines, etc. But it’s a solid start.
Are there enough timers?
Short answer: Yes
At first glance, it appears 2 timers will be required at a minimum. The Arduino Mini has 3 timers. A timer (with hardware interrupt) will be needed for determining RPM. And a separate 16-bit timer will be needed for scheduling our calculated firing events and the associated ISR.
We’ll still have an extra timer left over, useful for for sending serial information every few seconds while in diagnostic mode. Although it may be discovered soon that the third timer will be needed for an aspect of the EFI process that I’m not currently anticipating.
First timer: Tachometer – Timer0 in hardware interrupt mode
One to use in hardware interrupt mode to acquire our tachometer signal, as well as to provide the reference point for our firing event schedules. I believe Timer 0 tied to Pin 2 will fit the bill nicely.
Second timer: Event Scheduler – Timer1 (16-bit)
To schedule the beginning of firing events, Timer 1 should be much more than sufficient.
Is it cost efficient?
Short answer: Yes, definitely
This is where the 328P shines. The pricing works well, at $9.95 for an Arduino Mini board from Sparkfun for easy development, or ~$3 for the ATmega328P chip from Mouser if purchased individually.
So far so good!
A proof of concept build will follow shortly to verify that this theory checks out.