Thread: Small Engine ECU, EFI Moped Using An Audrino UNO

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Sorry, this turned out to be quite a long-winded reply!

    Quote Originally Posted by Sean Armstrong View Post
    Its more like a vespa, just modernized. the newer scooter/mopeds have a vaccum advance carbuereator, electronically controlled ignition via a CDI box, which measures pulses off the magnetic pickup coil, kindof the opposite of what your used to, with a hall effect sensor. Then sends a charge from a capacitor to a step up coil to make the spark plug "spark". Im working on prototyping a new intake system, which would roughly be a metal tube with a butterfly valve controlling air flow, and the fuel injector attached right next to the head, psudo throttle body. The specs from delphi say an ideal reading would be around 320mv, which is a slightly more rich reading of say around 14.5:1. a lower voltage means too rich, and a higher voltage would mean too lean. the board converts analog signals to digital signals as long as you define the input as an integer, each single integer would mean a defference of 4.9mv from the last one. so an int of 65 from pin A2 would be close to 320mv, and a reading of 66 would mean a reading of 324.9 ect ect. im hoping to not have to monitor the intake vaccumm or mass by only monitoring the output of the engine to change what goes in. the whole fuel pump delays aand all are just to build pressure of around 30psi for the injector to work properly. the rest of the delay is for the O2 sesor to heat itself up completely to give an accurate reading once the engine starts to turn over. Logic voltages on the board are 0v for low, 5v for high. the analog converter will digitize the 1.3v reading of the mag pickup to 5v. anytime the magnet on the flywheel isnt passing beneath the coil, there is no voltage reading. Theoretically it should work, i think....
    You can control the engine solely from the O2 sensor, but it's not going to work very well. The O2 sensor just isn't responsive enough, and it's happening after the fact. It will work well enough in steady state, like idling or cruising with the throttle at a fairly constant position. As soon as you open or close the throttle much, or go up or down hill, your control system will start to break down. You need some "before the fact" controls. The O2 sensor should be used in addition to your main control system, which is currently the carburator. The carb that's on there now adjusts the fuel rate based on your throttle position through metering rods and complicated little fluid tunnels, and it probably has an accelerator pump that dumps extra fuel in there when you crank the throttle hard to accelerate quickly. Your throttle body and EFI system should try to replicate this.

    I would say the bare minimum for a good control system would be throttle position, air flow and O2, though air flow may not be practical in your little scooter. Your main control loop adjusts fuel rate based on the air intake and throttle position. The O2 sensor is used to trim that up or down depending on how rich/lean you're running. The throttle position sensor (TPS) is also used to detect large changes in throttle position, for quick acceleration or returning to idle. If you go from idle to wide-open throttle, you need to open the injectors extra long to simulate the accelerator pump, or as you let the engine spin down naturally, you only need the bare minimum of fuel. You could hook up a simple potentiometer to your butterfly valve and tie that into one of your analog inputs as a crude TPS. Most fancier ECUs use two sensors for measuring air intake, manifold absolute pressure (MAP) and manifold air flow (MAF). I think both sensors are always used, but under different conditions you rely on one more than the other. IIRC, the MAP is used more for idle and low speeds when air isn't being forced into the throttle body by the movement of the vehicle. The MAF is relied on more at higher speeds, though the MAP is still used as it helps correct for altitude and ambient temperature, which affect the density of the air. I think they're fairly expensive, and will probably be tough to fit onto your custom throttle body. You could possibly just take some air flow measurements for your throttle body based on how open the butterfly valve is, and take your best guess at air flow based on the TPS. You can keep the previous reading and the current reading of the TPS to detect how big the change was, in case you need to inject extra fuel.

    The sensor on the flywheel (crank position sensor, CPS) sounds like what I'm used to, a simple Hall effect sensor. I misunderstood your initial post, and thought you had some sensor that gave a varying analog reading that corresponded to engine speed, e.g. 0V = 0RPM, 3V = 4500RPM, etc. Whether a missing tooth or a magnet, it's all about the same. The CPS generates a pulse (or lack of pulse) that at a fixed point in the engine's rotation, and is usually expressed as being some number of degrees before/after top-dead-center (TDC). The engine specs should tell you in degrees from TDC when each cylinder is on which part of the combustion cycle, so you know when to inject fuel (in direct-port or multi-port injection) and when to fire the spark plugs. The CDI box does exactly that for the spark. Lucky for you, since you're doing throttle body injection, you don't really have to worry about timing your injector. In fact, many of the first fuel injection systems on cars were throttle body injectors that constantly sprayed fuel, varying the pressure or flow rate to the injector based on the air intake amount. There was no timing involved. You can if you want, however, only open the injector when the cylinder is on it's intake stroke, or probably just before. This would require a bit more tuning, but would probably result in better fuel efficiency and possibly tighter control of the fuel/air mixture meaning better efficiency. That should be good for a 1 cylinder engine, but I'm not sure how practical this is if you have 2 cylinders. Putting this on an analog input or A/D converter is probably not the best way to get your pulse though. That signal has to be converted to a digital value, which is much slower than running it through some logic gates, and you'll have to do more work at the code level to read the analog signal and make sure it's a large enough value to constitute a pulse, and not just noise you're detecting. Besides, I'm not sure if the Uno will let you trigger an interrupt on an analog signal.

    As for the delays, right now, from the moment you start your scooter to the time it's ready to go, you have to wait nearly 20 seconds, which is a really long time. Half of that is the O2 sensor warming up. I would turn it on and record the current time as reported by the millis() function, and have something in your main loop periodically check the millis() function and if >= start_time+10500, and turn off the O2 sensor heater there. I might not even bother warming the thing up until the engine is running. That also goes along with not using the O2 sensor as your only or primary source of control. You probably don't need to wait 3 seconds for the fuel pump to build pressure. I think half a second there would be good. Also, don't just crank the engine for 5 seconds. Turn on the crank and grab the millis() reading. Then keep polling in a loop and if you detect the engine starts up (perhaps by checking the CPS), or you've been cranking for 5 seconds, stop the starter. Repeat 3 or 4 times, and if you don't get an engine start, then give up, you'll kill the battery and starter motor otherwise.

    You probably want the bare minimum in your setup() function, like configuring the A/D converters, which pins are inputs and output, etc, and save all the actual ECU logic for a big state machine in your main loop. Here's the rough approach I might take:
    Code:
    void setup()
    {
        set A/D converter and GPIO
        mode = pre_start
    }
    
    void loop()
    {
        curr_time = millis()
        
        read sensors
        
        switch (mode)
            case pre_start:
                crank_count = 0
                enable fuel pump
                delay 500ms
                mode = try_crank
                
            case try_crank:
                open injector
                enable starter
                crank_stop_time = millis() + 5000    // try to crank for 5s
                crank_count++
                mode = continue_crank
    
            case continue_crank
                if engine_speed > 500 // some number significantly faster than the speed the starter cranks at
                    // engine started, it's spinning at idle speed
                    disable starter
                    enable O2 heater
                    o2_heater_enabled = true
                    o2_heater_stop_time = millis() + 10500
                    mode = engine running
                else if curr_time >= crank_stop_time
                    close injector
                    disable starter
                    crank_stop_time = millis() + 5000    // give the starter a 5s break from cranking
                    mode = pause_crank
                // else, we just stay in this mode and come back here
                // to check if we started up or not
    
            case pause_crank:
                if crank_count > 5
                    can't start engine, bail out
                else if curr_time >= crank_stop_time
                    // break's over, back to work
                    mode = try_crank
                    
            case engine_running:
                if (o2_heater_enabled && curr_time >= o2_heater_stop_time)
                    disable heater
                    o2_heater_enabled = false
                // here is where your control code goes
                
            case error:
                stop fuel pump
                close injector
                disable O2 heater
                disable starter
                // just stay here until the system is reset somehow
    }

  2. #2
    Registered User
    Join Date
    Jan 2012
    Location
    Las Vegas, NV
    Posts
    9
    The only issue with making the system closed loop, meaning measuring the intake air vaccumm, and the total mass, is trying to find a part that will work. automakers send their specs to companies like delphi, and they work around what the manufacturer wants from the product. So i get to pick and choose from all these parts that no one has specs for, and cant program for them because i have nothing to go one, delphi has been working with me, they got interested in the project, and are sending me a few things free of charge. They are sending me an 02 sensor from their generic small engine component lines, a small fuel pump, and an 80g injector. they told me to do anymore than going off the 02 sensor, i would have to hire them on and bring them a sample bike, and they would go about designing the whole thing for me, but thats big $$$, like 5 digits. Although it would get done right, they said they could design a whole plug and play wiring harness, new fuel level sensor and pump unit to replace the in tank float on a stick, a whole custom designed throttle body with MAF, MAP, Fuel Injector, and TPS units in place. That would be the way to go completely, but I don't have the kind of money for that. I'm trying to do it for under $200, and make it affordable for customers to have their mopeds converted. #1 cause of engine failure on a moped/scooter is temperature failure. Usually cause by infrequent oil changes, or using the incorrect type of oil. Too much friction, toom much heat, premature wearing bc of metal on metal contact. The newer mopeds rolling of the line since 2011 have a 60cc engine, instead of a 50cc. They use the same jet setup as the 50cc scoots, making them run lean off the factory floor. misfiring and too high temps have me rebuilding the engines 5,10,15 times a week. I'm hoping to better the moped world with this, lol. (unfortunately I found out the new 2012 yamaha scoots are using fuel injection, so it wont be a first in moped history, but considering the price of that scooter, I have a feeling I wont be seeing those on the streets anytime soon, lol)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is an Engine..
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-09-2003, 12:50 PM
  2. what's an engine?
    By blight2c in forum C++ Programming
    Replies: 5
    Last Post: 04-28-2002, 08:09 PM
  3. A small problem with a small program
    By Wetling in forum C Programming
    Replies: 7
    Last Post: 03-25-2002, 09:45 PM
  4. 3d engine
    By Unregistered in forum Game Programming
    Replies: 0
    Last Post: 01-08-2002, 10:01 PM
  5. What's a 3D engine?
    By Garfield in forum Game Programming
    Replies: 6
    Last Post: 12-18-2001, 04:06 PM

Tags for this Thread