Shop OBEX P1 Docs P2 Docs Learn Events
Feeler thread: Looking to create our own engine management system — Parallax Forums

Feeler thread: Looking to create our own engine management system

DavidZemonDavidZemon Posts: 2,973
edited 2014-08-14 20:01 in Robotics
In the posts below you will find thoughts on a new engine management system running on a Propeller chip. The core idea that will differentiate this EMS from every other one out there is the auto-tuning. With so much parallel processing power, we will use two cogs to automatically tune the engine as it drives, with 3 modes available (economy, mixed, sport).

This originally started because I needed something on my resume. I wanted to compete in some national competition but have since decided to do this project as my Senior Design class. I will take care of the majority of all low-level programming (reading the maps and controlling spark/fuel) while my good friend Nathan will take care of all high-level programming (writing the algorithms to tune the engine). If we're lucky, we'll find a third person to take care of the GUI, but that is proving difficult.

---Original first post---
Hey all,

This is my first post here. I'm a computer engineer at Missouri S&T (Rolla) looking to partake in the Cornell Cup Competition next year. My team has a couple ideas - the main one being that we want to build our own engine management system, like MegaSquirt (www.megasquirt.info).

I'll post details on this later, once we get some more concrete plans. But, just for starters, do you guys think the Propeller is a good choice for a microcontroller, or would it be overkill?

Thanks,
David
«1

Comments

  • SRLMSRLM Posts: 5,045
    edited 2011-10-03 00:47
    Hey all,
    I'll post details on this later, once we get some more concrete plans. But, just for starters, do you guys think the Propeller is a good choice for a microcontroller, or would it be overkill?

    We think the Propeller is a good choice for all applications involving ambiguous questions.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2011-10-03 01:10
    That was all too deserved wasn't it? :lol:

    Are you familiar with engine management systems and what designing one entails? If you are, then I don't think the question is actually all too ambiguous.
  • mindrobotsmindrobots Posts: 6,506
    edited 2011-10-03 02:57
    That was all too deserved wasn't it? :lol:

    Are you familiar with engine management systems and what designing one entails? If you are, then I don't think the question is actually all too ambiguous.

    Actually, SRLM's answer wasn't too far off base. Do you know what micro controller designs entail and what the capabilities of the Propeller are? If you are, then the Answer isn't too cheeky!

    Do you plan on monitoring and controlling basic engine functions? There are 8 cores and 32 general I/O pins to start with. Do you need to display data on an LCD? Might your requirements change so that a bigger/better display is needed? How abou VGA or composite video? PWM control of some peripheral? Data logging to a SD? ???? Ambiguous requirements at this point? Ambiguous, general purpose micro controller as a solution.

    Come back with more specific needs and an attitude to TEAM with a bunch of professionals and eager, clever amateurs and you'll be amazed at the results!
  • DavidZemonDavidZemon Posts: 2,973
    edited 2011-10-03 08:44
    Our microcontroller needs to:
    - Listen to various engine sensors such as: engine temp, water temp, knock sensor, air pressure, O2 sensor
    - Control fuel injection
    - Control spark timing
    - adjust fuel and spark as the dependent variables on two 3d curves with air pressure and RPM being independent
    - output all of the above engine functions to an LCD

    And the one thing that will make our system stand out from every other built today:
    - adjust the fuel and timing maps automatically, during run-time, therefore auto-tuning the engine as you drive

    I'm going to use this post as an outline for the requirements of the project as prof_braino suggested.
  • TtailspinTtailspin Posts: 1,326
    edited 2011-10-03 12:44
    That has Parallax Propeller written all over it...:thumb::thumb:
    In fact, What would you do with the leftover Cogs?, Maybe output to a dash mounted TV monitor,
    Much data could be logged, and then sent out thru XBee or even to your Smart Phone...

    Check out the Parallax store, I see some stuff from your list that they might have for your team..

    Keep us posted, This sounds like a cool project.

    -Tommy
  • DavidZemonDavidZemon Posts: 2,973
    edited 2011-10-03 14:39
    Well, I'm figuring one cog for outputting spark, another for fuel. Another two cogs for calculating the new values for fuel and spark each. Another cog for video output. Another for controlling the user interface (there will be a way to select fuel savings, power, or mixed curve). That leaves two cogs... so possibly wireless stuff but that's a ways in the future.

    One problem.... I just read up on the Cornell Cup Competition rules... we have to use the Intel Atom Tunnel Creek. Not that it's a bad design, but I was really hoping to use the Propeller lol. Anyone know of other competitions that would fit this project?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-03 15:07
    'Too bad about the Atom; the Propeller would have been perfect. A friend of mine has carved out a niche for himself writing ignition timing code for the Frescale TPU (timing processor unit), which is used in a number of automotive ignition systems. The "language" for it is basically microcode. But that's not so far different from the Propeller architecture, with its multiple counters and selectable condition code writing and conditional execution. I've always thought the Propeller would allow more programming ease and flexibility than what the TPU offers. But car companies are notoriously conservative about switching horses, and per-unit cost is an even bigger driving factor than development costs when you're selling a million of something.

    -Phil
  • DavidZemonDavidZemon Posts: 2,973
    edited 2011-10-03 16:16
    We're thinking pretty seriously about doing this either as a senior project or personal project. I haven't found any competitions in my searches that fit the project, and I'm very excited about doing *this* project with *this* chip.
  • prof_brainoprof_braino Posts: 4,313
    edited 2011-10-04 14:46
    Our microcontroller needs to:
    ....

    One key to success is any project is to start with clear requirements, and translate these into functions you can implement, and test that verify the functions are present and work as required. Another key to success is to do the coding/implementeation LAST, after you have written the requirements, completely described the functions, and established the tests. Most folks don't know this, I don't think its taught in school yet.

    You have a cool project, and have some interesting highest-level requirements. Decompose these into systems, functions, and decide how to test them, this increases the likelihood of success.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2011-10-04 15:00
    One key to success is any project is to start with clear requirements, and translate these into functions you can implement, and test that verify the functions are present and work as required. Another key to success is to do the coding/implementeation LAST, after you have written the requirements, completely described the functions, and established the tests. Most folks don't know this, I don't think its taught in school yet.

    You have a cool project, and have some interesting highest-level requirements. Decompose these into systems, functions, and decide how to test them, this increases the likelihood of success.

    Thanks, that's a really good idea. I do a bit of that already, but hadn't defined the process quite so thoroughly. I'll make sure to follow your suggestions though.

    And again, if anyone hears of or finds a competition that would fit this project, let me know. I want to dominate it =D
  • HughHugh Posts: 362
    edited 2011-10-09 11:21
    Something like this?
  • DavidZemonDavidZemon Posts: 2,973
    edited 2011-10-09 11:33
    Hugh wrote: »
    Something like this?

    Uh... yea! Thanks for the link :) I PMed him
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-01-30 22:25
    Never received a reply from the OP of the link above. Oh well.

    A problem connecting the chip to my computer postponed this project for a long time. With that now out of the way though, I'm finally ready to start coding.

    I found a library not too long ago to drive an character LCD display, so I think my first project is going to be to get that working and try multi-threaded stuff. I'll have a timer on one cog and the LCD display driver on another. Then I will display the time from cog1 with the display driver on cog0. That should give me some practice with shared data.

    I've decided to use post #5 as the outlined requirements for the project as prof_braino suggested. Should keep the project nice and easy to follow and comment on I hope.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-30 22:59
    Looking at the brochure, the Atom actually looks spectacularly bad for an engine management system. If you must use it, I'd do calculations on the Atom, and use the Propeller as an I/O controller to drive the injectors, ignition (Saab DI pack? :)), and take sensor reading. Interface to the Atom with a serial port running at 2Mbps, and you should have a decent EFI system.

    I'm actually planning to make my own EFI system, but based on a servo motor driving a CIS distributor rather than pintle injectors.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-01-31 07:08
    Sorry - forgot how old this thread is. We've decided to do this as a senior project. So my goal(s) for now until I take senior design I & II is to program all kinds of cool stuff onto the prop and learn as much as I can about it (mostly assembly, some Spin too) that way I am as prepared as possible.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-01-31 19:38
    I feel straight-up retarded. How hard is it to copy+paste code? When I run Spin Tutorial Exercise 02-1, the LED blinks. When I copy the code from 239 of the Prop Manual, nothing happens. I shouldn't have to change any hardware right? Both of them work on P16, or pin 21 correct?
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-02-03 21:39
    What would be really awesome would be an EFI controller for the 900t. As it is, does it have Trionic, or is it LH-Jetronic 2.4 with the Saab APC? Either way, start out by using the prop to watch inputs/outputs to/from the existing ECU, and start working on mapping/math from there.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-02-03 21:43
    The classic 900T has LH 2.2 (only the 2.1L had 2.4 I think) with the APC.

    We're going to first build this on Nathan's (my friend helping me with the project) Toyota MR2. I'd love to do this to my '91 900 Turbo, but it's my only car. Nathan is pretty sure he will have a second car by the time we're ready to actually hook anything up, so if something goes horribly wrong, one of us isn't screwed out of transportation.

    Once it's up and running, it WILL be moved/copied onto my car :):):)
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-02-03 22:21
    I figured the '91 was your project car, and the '93 is your Daily. The NA Saabs had LH-2.2, and the turbo's had LH-2.4. For now, hook the prop up to a MAP sensor, tap into the knock circuit in the APC, and watch the output of the APC. From there, you should be able to watch what the APC does, then duplicate it reasonably easily. Nice thing about messing with the APC is, if you break it, the car is still driveable, you just don't get beyond basic boost.

    The 900t should have a B202L. Biggest difference from a 202 to a 204 is that the 204 is straight up an down, and the 202 is tilted. My dad has a B234 in his '99 9-3, and gets over 400hp out of it.

    See what you can do in your '91. I've heard of >300HP without mechanical changes to the engine. Search SaabLink.net for some projects by "Palmer".
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-02-04 09:16
    Ah, now that you remind me, I think you're right. Early N/As had 2.2, turbos had 2.4, and 2.1L N/As had 2.4.1. And no, the '91 is my only car.

    Anyway, I actually have no intentions of replacing the APC - it works beautifully (well... not in my car... but the design is great and some day it'll work in my car again). First step is to replace fuel-injection. When we have that working, we'll move onto spark. Probably won't ever replace the APC.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-02-14 20:02
    Back to the topic. So I did some math and to calculate engine RPM, I need to use the following formula:
    4800000000/delay
    where delay is a register with the calculated delay between engine revolutions. Is there an awesome bit-shifty way to do this? I don't need to keep anywhere near 32 bits of precision. 10 bits would give me 10,000 rpm down to 250 rpm in intervals of 10
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-02-15 11:29
    Nevermind. Google is my friend.
  • joey120373joey120373 Posts: 2
    edited 2012-04-10 15:39
    I think this is a great idea, If it could be done propperly. Full disclosure here, I am a big MegaSquirt (MS) fan. That said, I think a propeller based system would be a welcome addition to the DIY "gearhead" croud. One of the unintended consiquences of the MS was the evolution of the hardware/firmware, while it started as a very affordable and simple fuel only controller, it has evolved into a full blown complex set of boards/processors/code versions that is quite powerfull, and quite pricey, if one chooses the full blown MS3. If the MS forum is any indication, one of the biggest problems for new MS users is the learning curve involved in getting the system up and running on a perticular engine.

    Given the horsepower of the propeller, if a project of this scale were to be undertaken, I think it would be good in the long run to start out with a base code running on one or two cogs, that was designed from the onset to allow features to be added without massive changes to the base code. I think one of the most important things to start with would be a generic wheel decoder to establish high precision timing events for the rest of the code to use, this would be one area where we could learn from the MS development. It started with a simple interupt (tach event) that had to be choped up, modified, and constantly updated to account for new users with oddball crank or cam or crank/cam triggers.
    if we could come up with an elegant general purpose wheel decoder to start off with, then it might be all the easier to customize later versions of code for different engines.
    I also think it would be cool to use the $25 P8X32A board as the "core", and build a few DIY duaghter boards that it could be bought and built by the end user depending on the feature set they required, the P8X32a could then just plug onto the daughter board with minimal fuss.

    As for a base feature set, that is another area where a propeller based system could really shine with a rich set of periferals that would seem to be easy to implement;

    1, SD card data logging with remote button(s) to mark datalogs for events. MS does this with a laptop and the space bar
    2, A display! either a cheep monochrome or full color touch screen whiz bang, or both, would be a huge plus. The diplay could be plugged in to allow monitoring and possibly tuning. The MS has several options for this, but most if not all of them are driven by the serial port, are fairly basic, and usually cost as much or more than the MS itself. If this was added into the code from the onset, then the cost could be kept way down.
    3, A standard, multi-pin automotive grade sealed connector(s). I like the simplicity of the MS DB37 connector(s), but its just dated, and its not very well suited to automotive conditions, although it seems to have worked well. But there are several afordable high quality, high pin count connectors out there. I have used a few of them and find them much easier to use.
    4,Onboard wideband O2 sensor driver(s), If this thing is to be auto tuned, then a wideband O2 is simply a must.
    5, on board RTC battery powered
    6, input for or onboard accelorometer
    7,A generic transmission controller?

    lets see, what else
    minimum of 8 injector driver pins with PWM if needed
    minimum of 8 ignition coil pins
    stepper motor controll for IAC valve
    as many additional digital I/Os as possible, fuel pump, fan relay, fault lamp indicator, boost solinoid, 3-5+trans solinoids, shift lights, etc
    many additional analog I/Os as possible, MAPand orMAF, BARO, TPS, O2(s), BattV,CTS,IAT,
    give it a dedicated serial interface so that all crutial code variables could be transmitted to a second propeller.
    for a start,

    It looks like we would be pin limmited, but many of the digital and analog I/O's are not terribly timing sensitive, so they might be multiplexed or controlled via SPI or I2C to save pins for timing crucial events.

    Something else that came to mind, though I dont know how hard it would be or how much overhead it might take, would be a "SetUp" mode.
    This might be extreamly compilcated, but would be a HUGE benifit to the end user;

    Since most engines this would be used on are alread fuel injected, if the gearhead could tie into the crank/cam signal, an injector(#1), coil signal, and load sensor, then put the propeller in "SetUp" mode, it could monitor all these signals and set itself up for 90% of the engine variables, as well as build rough fueling and timing curves. I Realise this would most likely be even more complicated than than the main code, but it would sure make it marketable to the average gearhead.
  • TtailspinTtailspin Posts: 1,326
    edited 2012-04-10 16:00
    Welcome joey120373, Sounds like you have a plan all worked out.:thumb:
    It looks like we would be pin limmited, but many of the digital and analog I/O's are not terribly timing sensitive, so they might be multiplexed or controlled via SPI or I2C to save pins for timing crucial events.
    Don't forget, it's ok to connect two or more propellers to communicate with each other,
    I bet that would help with some of the more crucial timing events..:smile:


    Tommy
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-04-10 19:19
    Joey,

    Thanks for showing your interest! This much feedback and suggestions is a great help. Unfortunately, I only got about half-way through before slapping myself for not doing homework. I'm completely bogged down by school this week & weekend, but I'll get back to you with comments and an update on progress soon as I can.

    Cheers,
    David
  • pmrobertpmrobert Posts: 673
    edited 2012-04-14 10:22
    Thread subscribed. I'm also a long time Megasquirt user and have a secondary vehicle that is currently MS but would be available as a test bed item. I wrote some fuel-only code 2-3 years ago for a Prop based board that worked well on a distributor ignition rotary. That's the easy stuff - precise ignition timing and precise wheel angle determination in the circumstance of heavy accel/decel/rpm delta is the harder part!

    -Mike
  • joey120373joey120373 Posts: 2
    edited 2012-04-26 12:33
    pmrobert wrote: »
    Thread subscribed. I'm also a long time Megasquirt user and have a secondary vehicle that is currently MS but would be available as a test bed item. I wrote some fuel-only code 2-3 years ago for a Prop based board that worked well on a distributor ignition rotary. That's the easy stuff - precise ignition timing and precise wheel angle determination in the circumstance of heavy accel/decel/rpm delta is the harder part!

    -Mike

    Mike, those are my thought exactly. wheel (crank) angle determination and ignition timing would seem to me to be the single most crucial part to get right. The injector control would be next on the list, but the timing of the injector signal would not be terribly crucial to overall performance. What I mean by this is that if the injection event is off or moves around a few crank degrees I doubt it would make a noticeable difference in how the engine runs. The control over how long the injector is open needs to be tightly controlled, obviously. But my guess is, that if a robust code could be written to accurately read and predict wheel angle to a high precision, the ignition timing, coil dwell, injector timing and injector pulse control would be tied to that peripheral and have all the precision needed.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-07-10 22:11
    Thinking about this more, perhaps my ECU will only control fuel. Not sure I'm up for the challenge of controlling spark (yet). Also, this project (in case you couldn't tell) is basically on hold for the moment. When fall semester starts up, I begin taking Senior Design I and this will be my project for that class. Spring semester will be Senior Design II and I'll continue/finish it.

    Also, my friend is likely picking himself up an old VW Rabbit to play around with as a rally car, so there's a very good chance that will be our test-bed.

    Joey:
    I finally got around to reading your post. lol. That took long enough. There are many many good ideas that I *will* be using. The automotive-quality connector isn't something I'd ever thought of, but I'll make sure that ends up in requirements section. I also love the idea for an on-board accelerometer - could give some fun little outputs to the screen (which was already part of the plan). Why the battery-powered RTC btw? It's certainly not out of the question but I can't imagine why you'd want one in your ECU.
    The "SetUp" mode is something I'd already thought of and would love to implement. We'll see if it happens...

    I think a lot of features will depend entirely on two things: how much my group and I are able to get done during this coming academic year, and how motivated I'll be to continue adding features when I graduate.

    I promise this though - when I graduate, I will do at least one of two things: 1) continue adding features and making it more robust, 2) open-source the software and hardware (of course, this may happen earlier out of necessity when I get stuck on something lol)
  • DavidZemonDavidZemon Posts: 2,973
    edited 2012-07-10 22:36
    I'm designing this with these major goals in mind:
    1) Hardware and software are 100% reliable with some sort of fail-safe in event of failure. Priorities:
    1) Engine life (if engine damage is possible, nothing is off-limits to prevent it)
    2) Engine reliability (if engine failure is possible, anything will be done to prevent it that does not harm the engine)
    3) Performance/Economy (better-than-stock performance and economy are the overall goal of the software)
    2) Fuel/timing control loops will be open-loop, reading from a fuel/ignition maps. Startup maps may be created from the user (SetUp mode is a possibility). Run-time maps will be created by an auto-tuning algorithm reading wide-band O2 sensor data.
    3) Setup of the software on any car is easy and straight-forward without in-depth knowledge of engine tuning. (Your on your own for automotive hardware compatibility - look to megasquirt users for help converting your car)
    4) Full kit is as cheap as possible (while still adhering to Goal #1)


    Because of goal #4, I do not plan to use a Parallax dev board. If I find that using a dev board is cheaper in the long run, I'll do that, but I suspect building my own PCB and buying only the parts necessary will be cheaper than using a dev board. I would rather have the above-listed core functionality and a very inexpensive product than a crazy wizbang board with hundreds of additional features and three times the cost.
  • icepuckicepuck Posts: 466
    edited 2012-07-14 17:42
    One other thing to consider is oil pressure monitoring, especially on turbo charged engines. That way if the ecu sees a drop in pressure while reading vehicle road speeds it would reduce power for x amount of time while flashing the check engine light before shutting down. Caterpillar and Cummins are now doing that with their throttle by wire engines in an effort to prevent severe engine damage.
    -dan
Sign In or Register to comment.