Homebrew ECU Increases Mazda Zoom

A big problem with most modern cars is the sheer number of parts and systems that are not user serviceable. This is a big departure from cars of just decades ago that were designed to be easily worked on by the owner. To that end, [Anthony] aka [fuzzymonkey] has tackled what is normally the hardest thing to work on in modern cars: the Engine Control Unit. (Older posts on this project can be found at [Anthony]’s old project log.)

Every sensor in any modern car is monitored by a computer called the Engine Control Unit (ECU), and the computer is responsible for taking this data and making decisions on how the car should be running. In theory a custom ECU would be able to change any behavior of the car, but in practice this is extremely difficult due to the sheer number of operations required by the computer and the very specific tolerances of a modern engine.

The custom ECU that Anthony has created for his Mazda MX-5 (a Miata for those in North America) is based on the PIC18F46K80 microcontroller, and there are actually two units involved. The first handles time-sensitive operations like monitoring the engine cam position and engine timing, and the other generates a clock signal for the main unit and also monitors things like cooling temperature and controlling idle speed. The two units communicate over SPI.

[Anthony]’s custom ECU is exceptional in that he’s gotten his car running pretty well. There are some kinks, but hopefully he’ll have a product that’s better than the factory ECU by allowing him to change anything from throttle response and engine timing to the air-fuel ratio. There have been a few other attempts to tame the ECU beast in the past, but so far there isn’t much out there.

58 thoughts on “Homebrew ECU Increases Mazda Zoom

  1. the problem is that writing backend code isn’t glamorous and people dont feel slighted enough by current ECU firmwares to care. however, if cars start getting hacked and stolen regularly, you will see more of a push for an open ECU.

    1. Quite the contrary, as with stolen phones, the manufacturers love them being stolen, they get to sell replacements. Al the more reason for the status quo.

  2. Unfortunately, the engine control unit is only one of up to hundreds of electronic control units inside a modern car. To have truly open hardware and firmware in the automotive industry would require either unparalleled manufacturer cooperation or a single car model that people can hack at for years…

    1. CAN bus is distributing the “smart” electronics throughout the vehicle, to the point where there are stupidly pointlessly electronified things like interior lights and window motors. Many 1990’s and later vehicles have a secondary computer to handle all that, some call it the Body Control Module. Then there are cars with a separate computer for the transmission.

      1. What happened with Megasquirt? I’ve installed 4 of their ECUs in various cars, and I’m working on a fifth. It will be a shame to hear they’ve fallen apart. Do you have a link or anything?

        On topic, this is a huge accomplishment for one person. When I saw homebrew ECU, my first though was “Why not Megasquirt it?”

      2. you can still get megasquirt but it’s not a complete ECU, never really was it was mostly a fuel injection controller. It’s far easier to simply hack a GM 7730 ECM to work for any car, it’s the mist reverse engineered car ECM ever made.

        And if you want a turnkey commercial product, Painless and Haltech as well as MoTec have great units.

        1. mine does fuel and spark with a whole lot of extra features, im not sure what your talking about, maybe MS1, or MS2, but MS2+ and MS3 have all been able to handle ignition as well.

          why would people most interested in hack a day want something necessarily turn key. the beauty of mega squirt is the fact that at a much lower price point we are able to add a little of our own extra secred sauce and compete with the motec or haltec (painless only makes a harness, no ecu) also haltech and motech are only good if you own one of the few pre determined models that they support as plug n play turn key. on anything else and those two are definitly not turn key. that being said, it is nice to have their support team on call should anything arrise or if you need help with a base tune.

          1. I usually use a Saab trionic 5.5 ECU for any custom ECU needs. Free software suite, extremely cheap to buy one from a junk yard.

            Has ionic knock sensing, individual coil packs, torque limiting, sequential injector firing instead of batch-fire, is smart enough to pull boost/retard timing if it detects knock, etc.

            Really a good system and pretty cheap to get the parts needed out of a junk yard. I transplanted one into my 86′ Saab and got better fuel economy /and/ more power (Not much, but anything more advanced than LH 2.2/2.4/hotwire crap is good).

            Thanks for suggesting the GM 7730 ECM Tim, I’ll look into that.

            I’ve been paranoid about Megasquirt ever since an ‘incident’ that caused the fuel pump of a car to remain running (With injectors open) when the car was off. Luckily the guy noticed gas pouring out under the good before he tried to start it so it didn’t get hydrolocked.

          2. Aryl: Is this SAAB trionic can be used on a naturally aspirated engine? I’m currently thinking of converting my 20 year old 600cc suzuki sportsbike to a fuel injected one, just for fun and of course a lot of curiosity. I’m looking for a hackable and reasonably priced ECU. I found throttle body+injectors from a 10 year younger bike that fit on the engine. My first main concern is this Trionic can cope with about 13k redline? My project is in the research state, but I don’t want to build a custom ECU from scratch because it will not finish before the heat death of the universe…

  3. Wouldn’t this be a huge liability issue? What happens if the ECU acts up and you cause an accident? I guess your insurance won’t cover that.

    There is a huge number of regulations that this stuff _should_ have to pass (MISRA-C coding standards only being a part of that). So much in fact, that car manufacturers will use pre-licensed parts for automotive use from the chip manufacturers.

    1. I know both of the car insurances I have (one a standard insurer the other for a kit car) include a clause asking if anything has been modified from what is supplied from the manufacturer which this change to the ECU would include.
      Granted, for kit-cars there are no manufacturer specifications so it’s impossible to say what is “non-standard” and such ECU changes are acceptable (most use a MegaSquirt or MegaJolt) but that’s a liability that is accepted by the insurers (but you’re legally obliged that your vehicle is at least roadworthy at all times).

    2. Perhaps the problem is not the issue with liability but that certain things which were effectively safety systems have, in modern cars, been bypassed and now controlled in a fly by wire scenario by an ECU with god knows how many lines of code debugged by whom ?
      Top men ?

      Toyota has some experience in this area with phantom acceleration. Also liability. On stock ECU’s.

      Now say if all cars were required to have a cable operated throttle which snaps close if the cable breaks, rather than one controlled by motors it wouldn’t be possible.
      Electronic throttles which don’t respond to the driver input, but to what the ECU actually wants it to do having taken the driver’s request into mind… then maybe it wouldn’t be possible for cars to have run away acceleration. hmmm ?
      A physical block on air getting into the engine is going to give the combustion process a pretty bad day.
      No throttle. no air. no worky.

      I’ve seen electronic throttles stuck open due to internal breakage with crappy plastic cogs that do break/wear out the teeth, on VAG units.
      Cable throttles are generally a cable, a cam and a spring. It’s pretty hard to screw it up.
      Much like pilots asked for in planes. Obviously no plane crash has been caused by software bugs… right ?

      Kinda of like how it used to be, before all of these “benefits” started appearing in cars. Those benefits that cost the consumer a metric shit ton more in servicing and replacing faulty parts, because the window switch stops talking to the window motor over CAN bus and the “comfort ECU” isn’t on speaking terms with the “communication ECU” so it can’t tell you which isn’t working.
      Back in the day you know we used a DPDT switch and it just kinda worked, and was easy to fix.

      Oh yes. I drive older vehicles which are less complicated and thus cheaper to service and maintain.
      I guess for manufacturers, I’m exactly the type of person they want to make it harder for me to continue to do so.
      But then I recall a friend being told by the main dealer that she’d need to buy a new ECU because they were unable to clear the error code from it with their own tools.
      Wow. just wow.

      1. Agreed about mechanical throttles, though I have seen one fail pretty terribly on a 60’s ford truck. My brother was driving it in a crowded parking lot and the cable started to bind…end result was him trying to get out of a parking lot in a 3-speed automatic at full throttle.

        I’ve seen a hell of a lot more electronic throttle bodies fail though. And they usually require you to replace the entire freaking throttle body instead of popping out a potentiometer and putting a new one in.

        1. I had a 2004 Dodge Dakota. It came with some dealer service documentation saying the transmission valve body and a bunch of other stuff had been replaced. The transmission was shifting crazy all over the place and the engine was revving up and down on its own.

          Well after not too long it started doing that again. So I plugged in my OBD2 reader and saw one code, for something about incorrect voltage reading from the throttle position sensor. Swapped a new one of those on, cleared the code and it was back to normal.

          I know the dealer didn’t do one damn thing on the bill, it was the TPS the previous time. When I changed the transmission fluid and filters the screw on filter (crazy thing has two filters inside!) was the original one with a 2004 production date.

          See why those TPS reports are important? ;-)

    3. I thought about that and I can’t see how it could cause an accident since no electronics is involved in any of the safety systems on my car. An “unintended acceleration” situation is impossible since there is no drive-by-wire. When I release the accelerator a spring pulls the throttle closed. The worst thing that could happen is that the car stalls while pulling into fast moving traffic – but if i’m being a responsible driver then I would wait for a sufficient gap in traffic whether or not my car is running properly.

      1. Impressive work man, I’ve always wanted to attempt this but I don’t have the time with all my other ‘projects’. I ended up working on what will eventually be an open source avr powered dashboard.

    4. i make commercial ecus , hack factory ecus , write software etc. there isn’t such a thing in reality. most oems buy a base ecu with software then adapt it, the bigger ones are done in simulation mostly in matlab, or vertical, then engine dynos, theres a few big manufacturers bosch, siemens, etc some are in house. some come with full source you adapt, others tables.

      but like in most things the code is appallingly bad.. misra means very little its mostly designer to force good practices by programmers with lack of experience , especially since the code is often changed after the compliance but its just a style, ruleset it doesn’t stop problems happening. mostly static analysis

      there are cars that cost $200,000 with buffer index problems that the ecu will crash if the rpm goes out of the expected range.

      good hack though.

    5. If your ECU acts up your car will not suddenly swerve into another lane. all that will happen is a loss of power or engine stall. Unless you are doing 100 in the fast lane with people tailgating you that will not cause an accident.

        1. Maybe on some cars with electric power steering… But not on a Miata or anything else with hydraulic power steering. Usually those systems have no electronic components other than a pressure sensor on the high pressure line.

  4. [Anthony]/[fuzzymonkey] If you’re out there. Have you taken the car to any rolling-road / dyno tuning places, how do they react to your own re-mapping software?

    1. depends on the shop/dyno, most don’t care, the car is more likely going to break than the dyno. Typically they’ll have a dyno operator and the rules of you break you buy, and any damage you do to the car is your fault. i did most of my early RnD in a shop and they’re happy to get the money since a dyno not running, its just losing money. i’ve tuned at 100’s of shops across the usa and never had an issue, at first you get the yeah right good luck with that guys, but they’ll usually come around. eventually.

  5. I found this recently http://speeduino.com/wiki/index.php/Speeduino . It looks like a pretty decent project. It’s be better once they switch over to one of the ARM Cortex chips that’s planned… I’ve been looking into this sorta thing because my old 1st gen 4Runner has a distributor and I’d really like to go to a distributorless ignition because it causes a lot of hash on my mobile HF (ham) radio.

    1. Hey, that one is my project :)

      At this point there’s very, very little point in upgrading to an ARM chip. The good ol’ 2560 is fast enough for everything I’m doing (With overhead for new features) and going to ARM means having to deal with the 3.3v vs 5v thing all the time.

  6. Back in my college days I worked for Oldsmobile, right when ECUs were new (they were controlling the carburetor, for pity’s sake). We had a slick setup where the ECU sat in a custom box on the seat, with a ZIF socket so we could change the ROMs. Plus there was a control box about two feet wide and 2 1/2 inches high that sat on the dash, connected to the box by a ribbon cable. It had an LED display, maybe four digits if I remember correctly, and a whole mess of switches. You could display – and change! – any parameter on the fly. You could lower the idle speed until it about stalled, then futz with the timing and air/fuel ratio until it ran smooth again, stuff like that. I always wanted one for my personal car.

    1. I had a Sport/eco mode in a 1986 Fiero by simply switching the high bit address line on or off. I loaded the eprom with both the base Factory code and then my code in the top of the eprom. flip the switch and you are to the more aggressive gas wasting program. you could even do it while the engine was running.

  7. Too many nay sayers in the comments here. I say, it goes suck squeeze, bang blow, and you can control all that mechanically. A hackable ECU sounds like a pretty nifty device, yes it is a (minor) liability, but I suspect the average nutcase behind the wheel is a bigger liability by several orders of magnitude. Leave the liability talk to the actuaries and risk managers and enjoy the fact that this [fuzzmonkey] is giving something to the world. Life is not 100% risk free, so hang on tight, press the throttle hard and enjoy the ride.

  8. Megasquirt has many offspring out there. They’re targeted at Ford products mostly from what I’ve read. Been around for well over a decade. Mostly for the the Ford EEC-IV, 68 pin wiring harness. Go onto YouTube and search for MegaSquirt.

  9. I like it. But I am reminded of recent article in regards to John Deer and auto makes wanting to implement a licensed approach to machinery instead of you outright owning the machine. Thus preventing such modding. I say go for it anyways!

    1. That was in regards to the copyright of the software running inside their tractors, same thing with GM. So this modification would be a good thing since your replacing the software with your own. Not matter what, if its physical no one can tell you what to do with your stuff, applies under the first sale doctrine. Software on the other hand is bastardized by the DCMA. If someone writes code on a device, and uses encryption, you effectively don’t have power to change anything on the device, making it more or less, you lease the product for free after purchase.

      Article here http://consumerist.com/2015/05/20/gm-that-car-you-bought-were-really-the-ones-who-own-it/
      and EFF article here https://www.eff.org/deeplinks/2015/04/automakers-say-you-dont-really-own-your-car

      1. doesn’t have to be encrypted, since anything that is not a wide open barn door is interpreted as “encryption”, a checksum for instance.

        but in reality, nothings ever really happened, they’ll try. but there is the magnusson moss act and interoperability clauses, plus modifying your car in this can take it out of warranty so a lot of OEM’s are ok with it on the quiet, its only when someone makes a big fuss it gets squirrelly.

        in the USA its the EPA you gotta watch out for, you’re not allowed to mod the ECU at all, or any part of the emissions system.

        also usa side of things, “track use only” is baloney, no such rule exists, if the vehicle got a vin, and not originally a track car, it can’t be modded in anyway that touches the emissions chain.

  10. Damn impressive project, but … PIC18F? Jeez. The weirdest thing about these various ECU projects that people put together are the *ancient* parts that the elect. MegaSquirt, discussed elsewhere, was running a 68K. I’ve seen a couple of hobby projects uses Renases chips.

    For the love of god, just use an ARM Cortex. And just use one from a vendor that has really good library support. So then we can write an in-the-clear engine controller that is entirely based on CMSIS.

    1. Doesn’t really add anything to most cars til fairly recently, their table driven so no complex code, a couple of them used fpga’s to help with any heavy lifiting.

      The parts are well tested and known, have automotive parts, infineon tricore is the current heavily used one, and widely supported. powerpc is pretty common too. ARM hasn’t really made any inroads into ECU’s.

      lotus and lambo used 68K til around 2007, then went to powerpc

      1. An engine control unit really doesn’t need to run all that fast. They do a well-defined task involving a never changing number of parameters. There are some variables and a set of equations that take input from the variables then change various outputs according to how the inputs change.

        As for Lamborghini, I have an Alpine stereo in my 1982 GMC truck that’s the same model used as OEM in the Countach in the mid 1980’s. ;-) Pulled it from another GM truck in a wrecking yard. Good dual shaft cassette stereos with digital tuners are getting hard to find.

        Heh, spell check wants to change Countach to Accountant. Seems appropriate.

        1. yep pretty much, newer cars that are closed loop all or most of the time with traction control and so on are out of the realms of 68K now, but still well within a tricore/powerpc’s capabilities. We are starting to see ECU’s that don’t have precalculated tables anymore and are using the formula that generates the table instead.

          but yeah a basic engines ecu is a a main loop of a dozen or less function calls with a few interrupt routines.

  11. I just want to say Thanks! to [fuzzmonkey] for working on this project. While there are certainly quite a few nay-sayers commenting on this project I say keep up the good work. I see a lot of potential in the hackable ECU, such as making the process of converting a vehicle to your fuel type of choice easier. Then there is something my oldest son pointed out, a device like this could be used to improve other “vehicles” like go-karts.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s