View unanswered posts | View active topics It is currently Fri Dec 15, 2017 1:09 pm



Reply to topic  [ 9 posts ] 
MarkIsTuff's DIY EFI controller 
Author Message
Moderator
User avatar

Joined: Tue Jan 15, 2008 2:31 pm
Posts: 14913
Location: Home sweet home!
He attempted to post this on March the 1st some time ago, but I only just found the attachments orphaned. Here it is :

memberlist.php?mode=viewprofile&u=87

http://www.youtube.com/watch?v=8nj2nXmgwC8

Admin.


Attachments:
fuelV0.82.zip [1.88 KiB]
Downloaded 129 times
pcb small.jpg
pcb small.jpg [ 73.46 KiB | Viewed 4065 times ]

_________________
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Thu May 22, 2008 5:20 pm
Profile WWW
TO220 - Visibile

Joined: Sat Mar 01, 2008 8:09 pm
Posts: 4
More info to come after i finish exams this week...


Thu May 22, 2008 6:22 pm
Profile
TO220 - Visibile

Joined: Sat Mar 01, 2008 8:09 pm
Posts: 4
About a year ago i decided to build a fuel injection system for my gokart engine. The carb on the engine was really flaky and i had rebuilt it several times with out much luck. i did some research and this is basically what i came up with. the engine for the project is a 840 cc twin.

I used the SX-28 microcontroller from parallax. the sx series are pretty fast. run on instruction per clock and i have my running at 75 Mhz with is over kill but thats ok. its only 8 bit. but with the extra processing speed i do 16bit in software. i ordered a bunch of parts all at once then started playing around and learning how to program the microcontroller.

i used a MPX4250A for my map sensor,
two MLX90217 hall effect sensors. one on the cam and one on the crank.
two generic temperature sensors
and cheep o2 sensor and i used a potentiometer connected to a throttle body for my tps sensor.

then i picked up the cheapest fuel pump, injectors and pressure regulator i could find. i used ones from a ford escort.

i thought about using data tables and maps but decided just to do some testing then developed my own equations for VE, and pulse width. with doing all the calculations in real time and reading all the sensors every revolution, and using un-optimized code, the little sx microcontroller can handle just above 12,000 rpm. but considering my engine is only suppose to rev to 3600 but i take it to 4500 rmp, 75 MHz is excessive.

first ill describe the pcb then the software.

this was the first pcb i etched, i used an laserjet printer and some magazine paper and after a few tries i was able to iron on a good outline onto the copper. then etched it with ferric chloride and mounded the components as seen in the picture above. I have 4 mosfet drivers. (i accidentally ordered mosfet drivers instead of mosfets but they seem to work for the injectors fine. ) two are for the injectors and the other two along with a set of ignition mosfets are for the ignition coils. i havent installed the electronic ignition yet as i havent had time but its just a matter of connecting up two wires and disconnecting the old point system. anyways the chip in the middle of the pcb is the microcontroller, then i have 2x 8bit 4 channel ADC's and 4KB of eeprom. and a transistor driver for serial communications, sending engine data to a computer program i wrote. fairly strait forward just connecting the correct pins and adding pullups were necessary, should really have some more decoupling caps on there but the noise on the electrical system is minimum. i have lots of unused inputs/outputs that i might connect to relays to turn on and of the fuel pump and other systems.

the program im running on it now basically does this:
it continually reads the crank/cam position and just before the intake valve opens, it reads all the sensors then calculates the pulse width and injects, then repeats.

Pulse width calculations:

By reading the map sensor you get the absolute pressure of the air in the intake manifold. divide that by the air temp. and you get the air density. take that and divide it by number of cylinders, air fuel ratio, then injector flow and out comes the pulse width for a engine that is 100% efficient. then i simply multiply that by whatever the volumetric efficiency of the engine is. and any correction factors from the o2 sensor. add injector opening time and any "accelerator pump" time from the change in the tps sensor and thats the puslewidth. the tricky part is VE. that is only done by testing. i talked to a engineer from ford after i finished the project and asked them how they figured out the VE of there engines for different rpm and he said they run the engine on a dino for a few weeks trying all the different possibility’s then record that into a map. what i programmed the efi to do exactly what i said but i used an extra ADC input and connected that to a potentiometer that went directly to the VE efficiency variable. after plotting different rpms and manifold pressures against VE, i was able to develop an equation that took in those sensor readings and calculate the exact VE for any given engine condition.

if i get around to it this summer, im going to connect up the ignition system then simply create another equation for spark timing. but right now the engine is running way better then before. starts right up, no hesitation when you punch the gas, and more torque climbing hills.

im contemplating building a system like this for my ninja 250 i have. but that will not be for a few years. but a good microcontroller to use would be the propeller chip by the same people who made the sx. it has 8 processing cores on it! and to think computer or only 4 cores, but it is true 32bit, and has 32kb or program space vs the 2kb in the chip im using. its not as fast. think it runs at 50Mhz and reaches 80MIPs running all 8 cores. but with 8 different things running and being able to send data back and forth would make for a really cool system. one could be for just reading sensors, another for the injectors, another for ignition, another for transmission control, one run a user interface and have a lcd screen for the gauges.... but these are all ideas floating around in my head right now.

Anyways i hope this info was help and if you have any questions or comment please ask. ill put up some more pictures and the source code(not very pretty but it does the trick)

Mark


Tue May 27, 2008 4:07 am
Profile
TO220 - Visibile

Joined: Sat Mar 01, 2008 8:09 pm
Posts: 4
Here is the code written in a form of basic. i really should optimize some parts with some inline assembly language. well appaerntly there is an error attaching files. so here it is
----------------------------------------------------------------------------------------------------

' =========================================================================
' Fuel Injection program
' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------

DEVICE SX28, OSCHS3, TURBO, STACKX, OPTIONX, BOR42 'OSCHS3
FREQ 75_000_000
ID "V0.82"

' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------


' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
twov var byte(3)
fivev var byte(3)
idx var byte
idx2 var word
idx3 var byte
temp var word
temp2 var word
ratio var byte
'fire var byte
ve var word
ve2 var word
tpsinc var word
tpsold var byte
rpm var byte
'cou var word
ox var byte
' =========================================================================
PROGRAM Start
' =========================================================================


' -------------------------------------------------------------------------
' Subroutine Declarations
' -------------------------------------------------------------------------
I2CSND SUB 1
I2CST SUB 0
I2CSP SUB 0

' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------


Start:
' allow fuel presure to build up for 50 milli seconds
pause 75 '50

'initialize 5 volt a/d
I2CST
I2CSND %10010010
I2CSND %00000100
I2CRECV RC.6, fivev(0), 1
I2CSP

'initialize 2.5 volt a/d
I2CST
I2CSND %10010000
I2CSND %00000100
I2CRECV RC.6, twov(0), 1
I2CSP

low ra.0
low ra.1
low ra.2
low ra.3

idx = 0
ratio = 147 ' air fuel ratio
'fire = 1
idx2 = 0
idx3 = 0
've = 34 ' volmumetric effieceny 34.453125
tpsold = 163
'''
rpm = 0
ox = 100


low rc.1
high rb.7
low rb.5
high rb.4
low rb.2
low rb.1
low rb.0

'--------------- Intial fuel system prime
if twov(2) > 148 Then ' while engine is less then ~35C prime it. 15 milli seconds
pulsout ra.1, 15, 100 'left side
pulsout ra.0, 15, 100 'right side
endif


Main:


if rc.5 = 1 THEN
pulsin rc.5, 0, rpm, 10 ' get engine rpm
if rpm = 0 THEN
' engin not running
ELSE
'if rc.5 = 0 THEN
'fire = 0

for idx = 0 to 3
' recive 5v
I2CST
I2CSND %10010011
I2CRECV RC.6, fivev(idx), 1
I2CSP
' recive 2.5v
I2CST
I2CSND %10010001
I2CRECV RC.6, twov(idx), 1
I2CSP

next

'if idx3 < 50 THEN ' initial 50 revolutions extra gas ratio of 1:6
' inc idx3
' ratio = 90
'ELSE
if twov(2) < 148 THEN 'wait till engin is about 35C
ratio = 162 '160 '156
high rc.0 ' engin warm
ELSE
low rc.0 ' cold engine 50 at -6C(196) and 160 at 35C(148)
temp = 23 * twov(2)
temp = 5000 - temp
temp = temp / 10
ratio = temp_LSB
ENDIF


'------------------- VE CALC
''if idx3 < 40 THEN
''ve = 45 '45
''ELSE
ve = fivev(1) * 2
ve = ve / 3
ve2 = fivev(1) * rpm
ve2 = ve2 / 220
ve = ve - ve2
''ENDIF
'---------------------- O2 sensor adjusting ----------------
'low rb.0
'low rb.1
if idx3 < 205 then
inc idx3
endif

if rb.6 = 1 then 'if enabled run o2 adjusting
if idx3 > 200 then
idx3 = 100
'if rpm > 65 THEN 'only adjust at closed throttle (disabled)
'if idx3 > 495 then ' wait for end
if twov(2) < 155 then 'enging warm enuf
if fivev(2) > 140 then ' throttle closed

if twov(3) > 70 then ' runnin rich make leaner
ox = ox - 1
endif
if twov(3) < 40 then ' running lean make richer
ox = ox + 1
endif

ENDIF
ENDIF
endif
ve = ve * ox
ve = ve / 100
'endif
endif
' IF twov(3) < 45 THEN 'running lean make richer
'if rb.3 = 1 THEN
' ox = ox + 1
've = ve * ox
've = ve / 100
'ENDIF
' high rb.1
' ENDIF'

'ELSE
' if twov(3) > 75 THEN 'running rich make leaner
' high rb.0
' ENDIF
'
' IF twov(3) < 45 THEN 'running lean make richer
' high rb.1
' ENDIF
'ENDIF
'----------------------TPS sensor enriching
tpsinc = 0
if tpsold > fivev(2) THEN
tpsinc = tpsold - fivev(2)
if fivev(2) > 155 THEN
tpsinc = tpsinc * 24' 25
ELSE
tpsinc = tpsinc * 6 '5
ENDIF ' accerloatior enrich
ENDIF

tpsold = fivev(2)
'---------------------- low rpm idle increase to prevent stall( Expermental, not sure if i want to keep this or not)
if idx3 > 10 THEN '10 '45
if rpm > 120 THEN
tpsinc = tpsinc + 10
ENDIF
ENDIF

'----------------------calculate fuel

temp = 243 * fivev(1) 'map sensor
temp2 = 514 - twov(1) 'temp sensor
temp = temp / temp2
temp = temp * 237 '237


temp2 = temp / 50
temp2 = temp2 * ve
temp2 = temp2 / ratio ' ratio
temp2 = temp2 + tpsinc
temp2 = temp2 + 25 ' injector open time 25 on 4, 100 on 1
pulsout ra.1, temp2, 4 ' left side of engine

'-------------------- second cyclnder
temp2 = temp / 49
temp2 = temp2 * ve
temp2 = temp2 / ratio ' ratio
temp2 = temp2 + tpsinc
temp2 = temp2 + 25 ' injector open time 25 on 4, 100 on 1
pulsout ra.0, temp2, 4 'right side of engine


'ENDIF


endif
ENDIF


'watch temp
'watch ve
'watch fivev(0)
'watch fivev(1)
'watch fivev(2)
'watch fivev(3)
'watch twov(0)
'watch twov(1)
'watch twov(2)
'watch twov(3)

'break

GOTO Main


' -------------------------------------------------------------------------
' Subroutine Code
' -------------------------------------------------------------------------

I2CSND:
I2Csend RC.6, __PARAM1
RETURN

I2CST:
I2CSTART RC.6
RETURN

I2CSP:
I2CSTOP RC.6
RETURN
' -------------------------------------------------------------------------


Tue May 27, 2008 4:11 am
Profile
LQFP112 - Up with the play

Joined: Thu May 01, 2008 6:30 pm
Posts: 135
Location: Ann Arbor, MI
A few links i have been reading for VE

http://www.epi-eng.com/piston_engine_te ... ciency.htm
http://www.installuniversity.com/instal ... 012000.htm
http://www.ajdesigner.com/phpengine/eng ... ciency.php
http://tunertools.com/articles/volumetr ... ciency.asp


Tue May 27, 2008 6:40 am
Profile WWW
Moderator
User avatar

Joined: Tue Jan 15, 2008 2:31 pm
Posts: 14913
Location: Home sweet home!
Thanks for posting that up Mark, very interesting :-)

So the equations you used to represent your VE curve are bespoke to your engine correct?

Admin.

_________________
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!


Tue May 27, 2008 8:38 am
Profile WWW
TO220 - Visibile

Joined: Sat Mar 01, 2008 8:09 pm
Posts: 4
Thats correct.
it all depends on how the intake is designed, valve layout ect. what i did was i had the engine at almost no load, then went through the rpm range, then a full load through the rpms recording the VE setting that would make the engine run good. i downloaded a graphing program that i could graph the two curves. then i did some algerbra and stuck them into one equation. when graphed looks 3d like when you graph a map lookup table, but it should have every posable value instead of defined lookup spots. i did get a wideband O2 sensor had was in the process of building a controller for it to propory tune my engine but i havent gotten around to finishing it yet.

when i first setup the efi i didnt know about VE so the engine ran really really rich. then underload it leaned right out and would backfire like crazy. but after a few revisions of the program code and learning about VE those problems were gone. i should really change the youtube video, that was one of the first test programs i wrote for it, still running from a prototype board and wires everywere.


Tue May 27, 2008 5:00 pm
Profile
Moderator
User avatar

Joined: Tue Jan 15, 2008 2:31 pm
Posts: 14913
Location: Home sweet home!
Firstly, don't change it, just add more :-)

Secondly, in your opinion, would it be possible to use a Fourier style equation to generate a tunable curve for general use with one code base? (Or similar) I suspect it would be A difficult to do, B difficult to tune, C expensive computation wise for a generic solution.

That's a nice project doing it that way :-) Very impressive!

I look forward to your updated videos :-)

Admin.

_________________
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!


Tue May 27, 2008 5:40 pm
Profile WWW
LQFP112 - Up with the play

Joined: Thu Apr 10, 2008 5:51 pm
Posts: 205
Great stuff going on in here!

I currently have two of the aforementioned Propeller chips sitting on my workbench undergoing setup to drive a servo-controlled custom gauge cluster.

Now that I have gotten into it, the power of the Propeller has become very evident to me. I would suggest trying it out, Mark. I am personally very tempted to design a Propeller-based ems system myself. The only caveat is the Spin high-level interpreted language is 1/10th the speed of the equivalent assembly, so it would have to be mostly in assembly. The nice thing is assembly and Spin can be mixed as long as they are on separate cogs.

Here's an example of the power of the Propeller: the built-in "Servo32v3" object runs in a single cog...it can control all 32 i/o pins as servo pwm outputs to the nearest microsecond, all with individual pulse widths. That leaves the other 7 cogs running at full speed to do whatever I need them to do, concurrently.

PS I like that Fourier concept Fred.

_________________
Keith MacDonald
Control Engineering (Systems) Technologist


Tue May 27, 2008 5:54 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF. ColorizeIt.