E.M. based on a Parallax Propeller micro controller

Free and Open Source Engine Management discussions excluding more specific things on this board.
Peter
LQFP144 - On Top Of The Game
Posts: 268
Joined: Tue Dec 27, 2011 5:37 am

E.M. based on a Parallax Propeller micro controller

Post by Peter »

My inspiration for building an electronic fuel injection system came from my 1976 1/2ton Ford pickup. I really like the truck and what it's capable of, but I cant afford to drive it when it's doing 12mpg. So I've been reading this forum, and trying to understand the freeEMS source code for a couple months now. I've decided that it's way too complicated of a system for what I want to do, and mostly for my small brain. Part of the problem is that I have zero experience with C code. A little C++ and some Java so I understand the basic concepts of programming. So I decided to try and program my own fuel system using a Parallax Propeller micro controller, and a throttle body from a Holley efi. Tonight was the first time I've taken it out driving around since I took the carburetor off. So I figured I would share. It's a very simple and limited setup right now, but it should get a little bit better in time. Currently it has no way of performing cylinder specific injection. I'm running all my ignition on the distributor/coil system that came on it. I've based the amount of fuel to be injected on the flow rate of the injectors, and the old PV=mRT equation with an air to fuel ratio(AFR) divider to come up with a mass of fuel to be injected per revolution. (MAP*VolumeOfOneRevolution)/((AFR)*0.287*MAT)=massOfFuelToBeInjected and then a simple calculation with the flow rate to come up with how long the injectors need to be open.

Currently I have no feedback control, acceleration enrichment, air temperature enrichment, or engine coolant temperature enrichment. So the way I'm making it drivable is by running it way too rich. Not too cool, but I like to drive more than I like to program and solder. I have an oxygen sensor in the exhaust, and I plan to put a thermocouple in each of the headers to monitor the EGT. My plan is to start the tuning with the oxygen sensor to get a base map/array of how the PV=mRT equation needs adjusted. Then when the map gets close I'm thinking I want to use the thermocouples with some sort of a home brewed Proportional Integral Derivative(PID) function to hopefully get some fuel efficiency by running the temperature up to the material limits of aluminum. If that doesn't get me what I want I'm thinking I'll put a turbo or two on it, and put some higher gears in the differential. By the way it already has a NV4500 Dodge transmission for the 0.76 over drive 5th gear.

So if anyone is interested in my elementary code and wiring, I'd be happy to share. Or if you have any good ideas on how to make the system better that would be great. Thanks for reading.
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: E.M. based on a Parallax Propeller micro controller

Post by Fred »

Sounds like fun! :-)

There is a guy on here who was planning a propeller based EFI system, but dropped it when he found another existing one out there.

The FreeEMS code is meant to be generic across almost all setups, so there is a lot of extra complexity to handle that properly.

If you want some advice/help/comments, go ahead and throw up pics/code/schematics/whatever you want, you're more than welcome to :-)

I'll remove your noob status so that your posts show up straight away.

Fred.
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!
Peter
LQFP144 - On Top Of The Game
Posts: 268
Joined: Tue Dec 27, 2011 5:37 am

Re: E.M. based on a Parallax Propeller micro controller

Post by Peter »

Thanks for removing my noob status.

I'll attach a copy of my current code, but the commenting is pretty sparse right now. If a comment doesn't make any sense it's because it hasn't been updated since my ideas on how to make it work changed. So lots of the commenting and some of the variables can be ignored. You can get some programs to open .spin files from http://www.parallax.com/tabid/832/Default.aspx. I use Propeller/Spin Tool Software v1.3 most of the time, but if it's acting funny which v1.2.7 did a lot I use Brad's Spin tool which also works on computers you don't have admin privileges on.

I don't know how good or bad facebook is for hosting videos and pictures, but that's the only "hosting" site I currently use.

Here's a picture of my current setup. I'm using the Parallax Propeller micro controller in the center, a MCP3208 ADC off to the left with a 4.096V source MCP1541, four LM1949 injector drivers along the bottom, and a little fuel pump relay that's the blue in the bottom center. All of my wiring comes from the circuits shown in the datasheets.
Image

The LM1949 circuit. I had one of my four injectors work with this setup. I ended up having to lower R_s in the bottom left hand corner from 0.1Ohms to 0.05 and lower to get them to spray any fuel. I used a 0.1 uF capacitor for C_T and a 1kOhm resistor for R_T.
Image
http://www.national.com/images/pf/LM1949/506201.pdf

MCP3204/8 Datasheet
http://ww1.microchip.com/downloads/en/D ... 21298e.pdf

Here's a video of the first start up.
http://www.facebook.com/v/2719734032107

Here's a picture of my "aerodynamic" setup, if there is such a thing with this truck.
Image

Towing
Image

Mud hole
Image
Attachments
Code.zip
(42.07 KiB) Downloaded 720 times
:-p
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: E.M. based on a Parallax Propeller micro controller

Post by Fred »

Any chance of putting your code on github instead of just a zip? People will be much more inclined to play with it if it is :-)

Video is cool! :-) Why did the injector closer to the camera only come on when you gave it some throttle and then not go off again when the throttle went away? Physically stuck?

Will have a poke around more later, have to shower and head to the Wife's parent's place for lunch now!

Fred.
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!
Peter
LQFP144 - On Top Of The Game
Posts: 268
Joined: Tue Dec 27, 2011 5:37 am

Re: E.M. based on a Parallax Propeller micro controller

Post by Peter »

I've been trying to get github to work for a little bit now, and it doesn't want to authenticate the ssh for some reason. Most likely the POS Windows operating system. So I'll play around with that later in linux or I might try XP first.

At the time I hadn't lowered the resistance on the transistors emitters enough to get all the injectors working at low frequencies. So I programmed it to run up to about 1400 RPM on the first injector, and then turn on the second one and the third and fourth at about 2800. It's setup to spray both the primary injectors up to 2600RPM or below half throttle, and then it turns on the secondaries.

My current tasks are setting up a data logger, feedback control, and a ResistanceCapacitance time function to get the ECT and the MAT. The RCtime function should be pretty easy. I need to figure out how I'm going to format a file for data logging so that I can read the results into MatLab, Excel, or a similar program that will let me average results between specific RPM and MAP ranges. For the feedback control I'm thinking I'll let it step the fuel mass by a small percentage at a time based on the oxygen sensor reading. Even though that isn't a very elegant way of controlling it I think it'll work for now. As soon as I get some feedback control I think I'm going to have to make an acceleration enrichment to keep its drive-ability.
:-p
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: E.M. based on a Parallax Propeller micro controller

Post by Fred »

Re the SSH thing and github/git and authentication, you probably just need to setup and launch pagent or whatever the putty agent is called :-) It's not too hard to get it going. I managed to help my technophobe wife setup a working git install on a win box from the opposite side of the world about a year ago, so you should be able to manage ok.

You could make worse choices than encoding the data stream with the FreeEMS escape/header scheme. I'm planning to genericise the OLV support which would mean that you could use it unchanged if you did that. If you didn't, but used some similar scheme (same scheme with different esc, start, stop) then it would be trivial to write a parser to turn it into CSV anyway.

Re feedback, you should do absolutely nothing closed loop until your open loop tune is near perfect, and even then, it's largely a waste of time.

I imagine accel enrichment is pretty important with a TBI setup. None of the port injected setups I've done so far had it and most had usable drivable response without any accel enrich. Then again, FreeEMS does timed calcs that are just in the nick of time and therefore pretty much perfectly up to date with requirements, so the need is minimised anyway.

What is "ECT" ? And why do you need an RC curve for it?

I grabbed your code, but haven't looked yet. I've been busy trying to get a working dev setup again after my JimStim shat itself. It's now purely a set of pots, though I might get it a new CPU and ebay the bloody thing to recoup some costs.

Fred.
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!
Peter
LQFP144 - On Top Of The Game
Posts: 268
Joined: Tue Dec 27, 2011 5:37 am

Re: E.M. based on a Parallax Propeller micro controller

Post by Peter »

https://github.com/pjohns30/Fuel-Injection/downloads I didn't figure out how to get them in the files section like everybody elses, but I can view them from the downloads section when I'm logged out so I assume it works. I don't know what window's problem was/is, but it worked fine from ubuntu. I just noticed I uploaded a different version to github than the zip file on here, but there aren't any real changes just some more specific variable names and different starting values.

Why do you think it's a waste of time to make it a closed loop system?

For the acceleration enrichment I'm mostly going off how a carburetor acts when the accelerator pump isn't spraying enough fuel. But my second thought on that is that the vacuum is sucking the gas through the jets so when you open it up it isn't sucking hard enough to pull the correct amount of fuel in. While the efi is pushing the fuel in so it's not as important. This setup updates fairly fast, but I put this chunk of code in to get away from some of the problems I was having with the injectors not opening up long enough to work correctly.

Code: Select all

      mulFac := 1
      loop := FALSE
      repeat while(loop == FALSE)       
        if((mulFac * cycPerInj) < minCycPerInj)
          mulFac := mulFac + 1                                       
        else      
          cycPerInj := cycPerInj * mulFac
          cycPerDiv := cycPerDiv * mulFac
          loop := TRUE
edit: I'm not too happy with this forum for removing my white space when I submit it
EDIT: Use a code block ;-)

Which basically makes it do multiple revolutions per injection, because my inject function is made to only update the durations after it's completed the last one. I can lower the revolutions by lowering the minCycPerInj, but I don't know where the cutoff is yet.

I use ECT as Engine Coolant Temperature. I've seen that you use CLT, but ECT is already ingrained in my mind. Sorry for the confusion. My plan is to charge a capacitor up to 3.3V, and then see how many clock cycles it takes to discharge to 2.65V or where ever the drop out voltage is to find the resistance. I was at one time thinking about hooking them up to the ADC with a voltage divider circuit, but I think that could possibly heat up the MAT sensor and I don't have any idea of how much current they can handle on a sustained basis. Even though I doubt 3.3V all day could ever hurt them.

Don't worry about looking at my code right away it's nothing special, and it's currently kind of a mess of debugging/optimizing stuff I've commented out. Not to mention the poor commenting and some old ideas that don't apply anymore.

So I bought this custom efi intake manifold from an estate auction for a 73 Plymouth Fury2 with no fuel injectors or any idea of what application would fit it. So I'm wondering if you have any good ideas on how too buy injectors based on dimensions rather than an application. I want the correct flow rate too, because I bought a TA proto card when I thought I was going to use your setup on my truck. So it might get converted to FreeEMS one of these days when it's easier for us simpletons. But right now I mostly just want to plug the holes so I can update the carburetor from it's stock 2barrel to a 4 barrel that'll run when it's cold out.

I was going to get a bunch of programming done today, but I spent most of the day trying to get the speedometer head fixed. Mostly because a new one is $450 from LMC. Maybe tomorrow.
Last edited by Fred on Wed Dec 28, 2011 11:45 am, edited 1 time in total.
Reason: Add code block.
:-p
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: E.M. based on a Parallax Propeller micro controller

Post by Fred »

I have some good info for you, but no time to write it now. Will respond later tonight. What I did do was add code tags, though :-)
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!
Peter
LQFP144 - On Top Of The Game
Posts: 268
Joined: Tue Dec 27, 2011 5:37 am

Re: E.M. based on a Parallax Propeller micro controller

Post by Peter »

Awesome. I should have know there's a code window since I've seen them on here before. There's absolutely no rush today, because I've been talked into going to Vermont for new years. Which is about 31 driving hours away.
:-p
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: E.M. based on a Parallax Propeller micro controller

Post by Fred »

Peter wrote:https://github.com/pjohns30/Fuel-Injection/downloads I didn't figure out how to get them in the files section like everybody elses, but I can view them from the downloads section when I'm logged out so I assume it works. I don't know what window's problem was/is, but it worked fine from ubuntu.
Hmmm, what you likely need to do in your repo directory is this:

git add *.spin
git commit .
<enter commit message>
save commit message file
git push

Then you'll really have them in git. They're not in "git" as such yet :-)
Why do you think it's a waste of time to make it a closed loop system?
I don't necessarily, however for a control loop to work properly, for any given conditions, you need a base value that is suitably close to ideal, and it can fine tune from there. The further you are, the harder the algorithm works, and the more swinging and oscilation and drift and inaccuracies you will get. In truth, you can tune for economy/power/emissions perfectly well without closed loop operation if your code and system is working correctly.
For the acceleration enrichment I'm mostly going off how a carburetor acts when the accelerator pump isn't spraying enough fuel.
I did a thread on this recently, perhaps you'll have something to add to it, or learn from it, so I'll link it here for you:

viewtopic.php?f=8&t=1448
Which basically makes it do multiple revolutions per injection, because my inject function is made to only update the durations after it's completed the last one. I can lower the revolutions by lowering the minCycPerInj, but I don't know where the cutoff is yet.

I don't understand what you mean by cutoff, however if your input signal is per engine cycle, you should only do sequential, and if your input signal is per revolution, you should only do semi sequential, and if it's a dizzy input, then you can take your pick between uneven fueling and inaccurate fueling. However, that all applies to port injection, TBI you might be best off with a per cylinder pulse injection, and if the throttle is staged, so should the injection be, I guess. You should probably set up the injection on two maps, with a threshold system to disable one in certain load/rpm ranges and just tune it to how it runs best rather than hard coding in the logic. You could use the table itself to be the switch, ie, if not zero, use it, if zero do nothing. If you setup the comms to match FreeEMS exactly (fake being FreeEMS) then you can use MTX. I don't mind adding a second fuel table to MTX for you, you can just implement the subset that is required. I think the interrogation is pretty lax so if you have key elements it'll work OK.
I use ECT as Engine Coolant Temperature. I've seen that you use CLT, but ECT is already ingrained in my mind. Sorry for the confusion.
I don't mind what you call it :-) ECT to me is Enhanced Capture Timer, though. I use CHT in FreeEMS for Coolant/Head Temperature with air cooled engines in mind.
I was at one time thinking about hooking them up to the ADC with a voltage divider circuit, but I think that could possibly heat up the MAT sensor and I don't have any idea of how much current they can handle on a sustained basis. Even though I doubt 3.3V all day could ever hurt them.
What you want to do is bias them with 2k - 2.7k or so, and generate/use a curve with something like FreeTherm:

https://github.com/fredcooke/FreeTherm

Code: Select all

git clone git://github.com/fredcooke/FreeTherm.git
Don't worry about looking at my code right away
OK, I'll wait till it's in Git properly :-)
So I bought this custom efi intake manifold from an estate auction for a 73 Plymouth Fury2 with no fuel injectors or any idea of what application would fit it. So I'm wondering if you have any good ideas on how too buy injectors based on dimensions rather than an application.
I'm afraid that I can't help you with that.

The correct flow rate is "enough" and "not too much" so there is a decent range of workable values :-) The closer to the engine's needs the easier to tune it'll probably be. FreeEMS doesn't care much what size they are, just that you know the size and dead time curve, close enough.

Re your injection, do you have a dead time table based on battery voltage? If not, you should add that or your tune will always be wrong with different battery voltages (think headlights on/off, etc).

I hope that helps :-)

Fred.
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!
Post Reply