element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Documents Engine Management (part 1: basic principles)
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Arduino requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: jack.chaney56
  • Date Created: 28 Jan 2016 5:57 PM Date Created
  • Last Updated Last Updated: 6 Oct 2021 8:46 PM
  • Views 3869 views
  • Likes 6 likes
  • Comments 37 comments
Related
Recommended

Engine Management (part 1: basic principles)

Best place to start is at the beginning.  The problem is, which beginning.  There is a beginning to the platform, and a beginning to the process of engine management.  I guess the platform is something that can come later, so, I will begin with the process of engine management.

 

Engines (internal combustion type), have some basic principles. They need air, fuel, and spark to make them work. Engine diagnostics tell us, if you take any one of the three away, the motor doesn't run. We will start with the spark generation, and how to get it "just right".  Now, to make my train of thought a little more difficult to follow, a little bit about problem solving.  Dijkstra tells us, if a problem seems too big, solve the parts that you can solve, then work on filling in the parts that are left.  For a process problem, quite often, the "steady state" is the main part of the process, and the management of the exceptions is where things get troubled.  So for our engine management problem, we will start from the steady state condition (no changes due to acceleration, positive or negative).

 

Kind of a long winded introduction to get us to a point of where I want to start the discussion, which is about timing. I am going to work with four cycle motors in this series, so people interested in two cycle, or diesel, will have to wait until another series. Four cycle, means the crankshaft turns twice causing the piston to rise and fall twice, per each sequence (called a cam cycle). There is a compression sequence, and an exhaust sequence. The compression sequence is where the spark needs to happen. But when in that cycle should we make the spark happen? Still more background. For the energy event during the compression, we have an air:fuel mix that is put under pressure, and ignited by a spark. How to generate the spark in just a moment, first when exactly do we need to make the spark happen. The way the ignition occurs is interesting because it is not immediate. If you were to take a very high speed film of the ignition event, you would see that when the spark ignites the air:fuel mix, the burn extends from the ignition point in a plume. Because of the properties of the fuel, this rate is fairly constant. Keeping in mind different fuel types have a different burn rate (alcohol, very fast, diesel, very slow). The ideal timing for ignition, is so the plume reaches the top of top of the piston, just as it reaches its state of top dead center(TDC) (highest point in the cycle).  To make this happen, the ignition needs to happen a little before TDC, this is referred to as the advance. The advance changes as the motor changes speed, the faster the motor is turning the earlier the advance needs to be. Luckily for us, we are dealing with the steady state first, so adjustments to advance will come later.

 

Our next piece of the timing puzzle is about generating the spark, this is done in many different ways, but we will be starting with the conventional method first, the ignition coil. Coils work on an interesting electrical principle. By applying a direct current to the coil, for a brief period, it behaves like a resistor until it reaches its saturation point (can't absorb more current), then it behaves like a shorted wire (no resistance). When the current is removed from the coil quickly, an interesting phenomenon occurs, called field collapse. This drives a voltage at a high current spike through the circuit, which generates the spark at the plug. I over simplified because I don't want to get too hung up in coil design and efficiencies, again this leans toward exceptions. What I did want to cover was there was a period of time before the ignition, when we need to charge the coil. This time is called the dwell, and dwell is dependent on the type of coil, but some general cases can be used for now and we will just call it our dwell.

 

Now we have what we need for our basic system, at least for one cylinder. Oh, first diversion from general case engine model, the cylinder object. If we write all the code for a single cylinder, then make N number of instances, we can have any number of cylinders we want in our motor. Information we have about our cylinder is the angle of its TDC, the dwell time for the coil it is attached to (multiple coils are an exception to be discussed). So we need to determine some elements; current angle in cam cycle, and engine speed, which will help determine the value of the advance.  Sounds like we need some inputs, most engines with electronic ignition systems have a couple of signals that are helpful, called cam and crank. These signals are generated from the camshaft, and crankshaft. and have one, or a series of triggering elements mounted to produce a signal to identify position. Here is where I am going to diverge again. The thing we are interested in, is rotational speed, and current position. The cam and crank are a closed system, so the process is continually repeating, and once we have identified were we are in a cam cycle, as long as the speed remains consistent, we should know were we are at any time, and additional inputs, provide additional information.

 

Lets look at a common type of cam and crank configuration 4x crank and single pulse cam. The good thing for this part is the engine manufacturers go though a very large effort to make sure the active edge of the crank and cam signals are extremely precise. As a result each active edge of the crank is exactly 90 degrees from the previous signal. Also, the cam signal only occurs one time in a cam cycle. This gives us our prime reference.  How this works is, a value of TDC0 is set, based on the operation of the motor, which is the 0 degree reference point and synchronized with one of the crank signals (called teeth), and the cam signal is given as number of crank signals from cam to TDC.

 

So we have input signals, and can begin doing some determination. Starting our timer when we get a crank event, and stopping the timer when the next event occurs, we now know how fast the motor is running, because the time dT, to move 90 degrees is 1/4 the time for a full rotation. and if we convert the units of dT to one minute, then multiply by 4 to provide RPM. If we know which crank signal just passed, we also know our position, this is possible if we have had a cam signal, in which case we count the number of teeth for cam to TDC. Some clever calculation will let us know where we are, as soon as the cam signal is detected, because cam to TDC means the crank signal that just passed when the cam signal is detected is 2x number of teeth - cam to TDC number. Now that we have our information, we can get to work, since it is ridiculous to think that a motor doesn't change velocity we will need to provide continuous update to the dT value, so the stopwatch idea is not practical. Instead, we will use a free running timer, and get a trigger time when the crank event is recorded. Then, take previous recorded timer value, and current recorded timer value, and the difference is our dT that gives us our rotational speed.  Hopefully, you can begin to see now, that the number of events in a crank, provided they are equally spaced, is only significant to determine accuracy of rotational speed, and more quickly determine change.

 

The result also provides a means of predicting the precise moment when the next event will occur, as well as other, future events. This is important, because from our earlier discussion, the spark event needs to occur before the TDC event (which is usually synchronized with a crank event), and the start of dwell needs to occur before the spark event.  Also, remembering, starting the dwell too soon, can cause potential damage due to heat buildup from a shorted system, so the dwell cannot be started too soon.  I will finish off this first entry by establishing some formulas to use...

 

     t0 is the previous recorded event time (time of the previous crank event), in an arbitrary unit of "ticks"

     t1 is the current recorded event time (time of this crank event), again in the arbitrary unit of "ticks"

     dT is the delta time providing rotational speed (t0 - t1) in ticks

 

     teeth is the number of crank events in a single rotation

     TicsPerMin is the number of tick units in a single minute

     RPM is now calculated as: TicsPerMin / (dT * teeth)

  • Share
  • History
  • More
  • Cancel
  • Sign in to reply

Top Comments

  • phoenixcomm
    phoenixcomm over 9 years ago +2
    I have some help for you. I was/am (long story) building a digital fly-by-wire experimental aircraft working with my local EAA chapter. Anyway here is a page for the sensors; Phoenix2000 EFIS or Electronic…
  • jack.chaney56
    jack.chaney56 over 6 years ago in reply to phoenixcomm +2
    Thank you so much for your response. This is kind of why I backed out the first time. First, I have been doing embedded system programming since before it had a name (boot process development on PDP-12…
  • mcb1
    mcb1 over 9 years ago in reply to jack.chaney56 +1
    I never expect replies instantly ... we all have other lives. ...:) I have seen this applied to a ride-on lawn mower, which overcame the simple carburetor that caused headaches in the varying temperatures…
Parents
  • amgalbu
    amgalbu over 9 years ago

    Very interesting topic!

    One question raises in my mind: on the camshaft sensor there is a single sensor? If this is the case, how can you determine for each cylinder the exact time when inject the fuel and activate the spark coil? do you need to known the angles on the cranckshaft? If so, where can one get this info?

     

    Cheers

    Ambrogio

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 9 years ago in reply to amgalbu

    when inject the fuel

    That's another subject as well.

     

    Depending on the methods of distributing the fuel it can be different.

    Usually it is distributed with the incoming air stream as the piston goes down approx. 360 deg after the ignition/TDC.

     

    Direct injection can be during the compression stroke but requires a much higher injection pressure as it need s to deliver more fuel into a pressurised cylinder.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jack.chaney56
    jack.chaney56 over 9 years ago in reply to mcb1

    Hi Mark,  Sorry for not getting my response sooner, but I was doing a whole bunch of church stuff this weekend.

     

    Fuel is going to be a separate set of discussions, that will follow.  Dealing with issues of air:fuel mix, fuel type, fueling strategy, compression ratio, exhaust oxygen levels, and Tau-X factors are planned for inclusion.  Remembering,.eating an elephant is best done one bite at a time. With that in mind, so we are starting slow, and just dipping in with an electronic ignition system. No fuel yet. Our system will be a simple throttle body operation, with mechanical valve timing.  I also should note, I won't be covering any of the nuances of calibration. I can get a car to run, and to start consistently, but improving performance, and getting that extra horsepower out of a motor, I leave to the proper specialists.

     

    So, ignition timing first, then fuel.  I am really grateful for the feedback. It shows there is a genuine interest in me continuing with my brain dump.

     

    Jack

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 9 years ago in reply to jack.chaney56

    I never expect replies instantly ... we all have other lives. ...:)

     

    I have seen this applied to a ride-on lawn mower, which overcame the simple carburetor that caused headaches in the varying temperatures.

    This might be an ideal application, as you also apply some rev limiting and other things to it.

     

    The response re fuel was more Ambrogio.

     

    Looking forward to see how this pans out ... no sure about eating elephants though....

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • mcb1
    mcb1 over 9 years ago in reply to jack.chaney56

    I never expect replies instantly ... we all have other lives. ...:)

     

    I have seen this applied to a ride-on lawn mower, which overcame the simple carburetor that caused headaches in the varying temperatures.

    This might be an ideal application, as you also apply some rev limiting and other things to it.

     

    The response re fuel was more Ambrogio.

     

    Looking forward to see how this pans out ... no sure about eating elephants though....

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • jack.chaney56
    jack.chaney56 over 9 years ago in reply to mcb1

    Me too... I heard it tastes a little like chicken image

     

    Second part (part 2) is out now.

     

    Carburetor setting is a voodoo process, which is more art than science.  (close down to set, open 2 1/2 turns, get the motor started, then dial it in for low and high speed operation, I had an old VW).

     

    The intent is to make the system have significant flexibility so it can be tuned easily, by someone that knows what their doing.  Designing to stay small and cheap. Most of the operation will be presented so the individual can make any improvements they think will be of benefit.

     

    Jack.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 9 years ago in reply to jack.chaney56

    Proper carburettor designs adjust the mixture based on airflow and the velocity.

    They are always a compromise.

    Usually the carburettor is blamed when the actual problem is ignition or other factors.

     

    In electronic controlled systems they sniff the exhaust gas to make adjustments which results in better fuel management.

     

    I started reading version 2 but got called away.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jack.chaney56
    jack.chaney56 over 9 years ago in reply to mcb1

    The component of the equation you are talking about is called Volumetric Efficiency (VE). To simplify, it is how effective the system is at pumping air, and the displacement is the total volume that is moved through the system on a single cam cycle. These are used in the fueling equation along with things like cylinder temperature, and pressure. The result comes down to a pV=NrT equation providing us with a value for fuel mass. But that is when I get to the fueling part.

     

    My plan for the series (several entries), is to develop a generic engine controller. It will be using an Arduino for a hardware development platform, but I will be dumping the Arduino interface in favor of a more appropriate interface for this case. Several of the entries are going to cover controller methods that can be used in any application as well, because I will be dealing with interrupt management, and A/D conversion. Mostly because when you are trying to run a motor, you need to get your information quickly.

     

    Need to start working on part 3: timing and scheduling.  (an engine controller is much like a multi tasking O/S)

     

    Jack

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 9 years ago in reply to jack.chaney56

    VE isn't the only factor.

    The velocity of the mixed gas affects the fuel drop-out which affects the fuel/air ratio.

    This then changes the speed of the burn.

     

    Personally I wouldn't use an 328 based controller, I'd be looking for more computing power to make the task easier.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jack.chaney56
    jack.chaney56 over 9 years ago in reply to mcb1

    ...ooh, I love the challenge.

     

    The controller's fueling portion will be using injectors, either manifold or throttle body. The injector has a rating for mass in pounds per hour. The process will set the pulse width of the injection to provide the proper amount of fuel. Then the feedback from downstream sensors will help to balance the quantity needed using a target A:F ratio and a PID loop.

     

    I have a 328 (Arduino Nano) running a Porsche 4 cyl, so all things are possible.  We are using IGBTs on a kludge board to handle the coils and injectors.  We are using a peak-hold circuit (again a kludge) to manage the injectors.  16MHz is plenty fast. Bench testing had it up to 8000RPM with no engine, just signals. Still working on the physical version.  The goal was to make it as cheap and accessible as possible, and the Arduinos are real easy to obtain.

     

    Again, all things in time.

    Jack

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jack.chaney56
    jack.chaney56 over 6 years ago in reply to mcb1

    rereading the thread. You said VE isn't the only factor... I propose, it is possible to get away with a whole lot if you plan it correctly. VE is used in the fueling equation which when I explain the fueling calculation, becomes more understood.

     

    I would like to point out, the case of the Neon (Chrysler), that only used a MAP sensor, and CAM and CRANK signals, to run everything.

     

    Jack.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 6 years ago in reply to jack.chaney56

    I would like to point out, the case of the Neon (Chrysler), that only used a MAP sensor, and CAM and CRANK signals, to run everything.

    O2 sensor as well perhaps.?

     

    Carburettors got away with dumping fuel based on the vacuum for years.

    The mixture was a bit of an optimisation and was probaby only correct at one temperature, one load, and one altitude.

    So sure you can make things work using less.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jack.chaney56
    jack.chaney56 over 6 years ago in reply to mcb1

    Hi Mark,

    First off, thank you so much for responding.

     

    Usually the O2 feed is used as a balancer, with a PID loop.  I was going to get into that stuff at the right time.  Interesting that everyone that has been responding is so focused on fueling, when in fact fueling as it relates to time is very flexible. The only time it is critical is if you are using direct injection, like with diesel. My experience with engine controllers is with high performance (upward of 700hp). In that realm, the focus is on accuracy of ignition and capability of maintaining timing at higher RPM.  Fueling primarily focuses on solving the pV=nRT problem and maintaining the proper balance so it doesn't burn too hot or too cold (just right). The balance being maintained using a target A:F ratio, and feedbacks from O2.

     

    My intent, (and the successful implementation), is to present a solution using an Arduino Nano as a core, and adding some resistors and capacitors to provide A/D inputs for sensors, a dual comparator for cam and crank signals, and external IGBT and MOSFET for ignition coils and fuel solenoid driving. The software was going to start off with something to just get the motor started and running, then address the issues of acceleration and performance.  Keeping the elements simple, hopefully will make this a project that people out there can actually try without being paralyzed with apprehension.

     

    Jack

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 6 years ago in reply to jack.chaney56

    Usually the O2 feed is used as a balancer, with a PID loop

    Correct ... it more the Chrysler neon you mentioned, and I wondered if they did most of their correction based on the feedback from that.

     

    Interesting that everyone that has been responding is so focused on fueling

    Probably because there are a number of different ways to do it, each with advantages and disadvantages.

    Fuel timing does matter to reduce the fuel dropout and stop it washing the walls of the intake.

    It's not as bad with a rough surface as it tends to reatomise, but with rough surfaces also comes drag.

     

    AFAIA you can have a perfect F/A ratio and produce a lot less power from a motor simply because the timing is delayed.

    So you're quite right that they all interact and go hand in hand to provide the optimum output from any motor.

     

    Mark

    BTW having a tool that can show pre-detenation and optimum F/A ratio would go a long way to helping people 'experiment' safe in the knowledge they aren't destroying their motor.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube