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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
Ben Heck Featured Content
  • Challenges & Projects
  • element14 presents
  • element14's The Ben Heck Show
  • Ben Heck Featured Content
  • More
  • Cancel
Ben Heck Featured Content
Forum Engine Management
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Ben Heck Featured Content to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 63 replies
  • Subscribers 48 subscribers
  • Views 4658 views
  • Users 0 members are here
Related

Engine Management

jack.chaney56
jack.chaney56 over 9 years ago

Hi Ben,

I am a programmer with a very small amount of skill with circuits, and am looking to create a platform for an engine management system, using an Arduino Mega 2560. I had done a bit of the coding, when I ran into some timing issues with the built in Arduino manager, so I switched over and started using AVR Studio and a programmer to go directly to the chip itself.  The code looks like it should work ok, but now I need some additional circuits to handle the energy levels of coils and injectors (Something like IGBTs). Sensors are being run through simple dividers (no protection yet), and cam and crank inputs are through a simple comparitor

 

Let me know what you think,

Jack

  • Sign in to reply
  • Cancel

Top Replies

  • jack.chaney56
    jack.chaney56 over 7 years ago +2
    Back again... After a bit of time away seeking enlightenment (and a steady paycheck), I am ready to get back to work on my project. I have continued to play around with the code and a number of components…
  • jack.chaney56
    jack.chaney56 over 7 years ago +2
    I want to start this thing right, so the shopping list for people that want to play along at home: Raspberry Pi - version is not significant if you don't mind a slow response when using Eclipse, but 3B…
  • jack.chaney56
    jack.chaney56 over 7 years ago +2
    Start off with two things. First, I forgot (neglected) to provide instruction on how to get the compiled code onto the Nano. Fault of familiarity; having done the process so many times, I had shifted to…
Parents
  • jack.chaney56
    jack.chaney56 over 7 years ago

    A little dental work, or what to do about missing teeth.

     

    The more advanced timing wheels on motors have high tooth count and also throw in areas where teeth are deleted, in order to provide sub-timing to catch ignition in less than one full crank. It is my observation, this is overkill, because, the increase in processing needed for high level detection, often results in missing the special event, and it still requires multiple rotations to capture timing.  However, because they didn't listen to me, and implemented missing teeth anyway, coding must be made to mitigate the event.

     

    There are two processes that must be implemented, first is detection of the missing tooth event. The second is compensating for the event.  Detecting the event requires notification of the potential for a missing event, so a calibration value of missing teeth is needed. Missing teeth is not the total number of missing teeth. It is the number of missing teeth together. Meaning it is possible to have a missing tooth at 10 degrees and a second at 100 degrees, even though in total, there are two missing teeth, the value of missing teeth in calibration is still one. I hope that is clear enough.

     

    The detection of a missing tooth event, is; first, is there a missing tooth (missing > 0), and when the measured Diff value tmpDiff (current) is greater than 1.5 times the previous Diff (crkDiff). Because the change in crkDiff from tooth to tooth is relatively small, if the change in crkDiff is greater than 1.5 times, it is the indication of a missing tooth event. Once the missing tooth event has been detected, a correction to operating variables is required. First, update the cam angle, then correct for error, repeating once for each missing tooth. This operation is performed in the crank interrupt. Because it only requires comparison and addition, the impact is very slight.

     

        if (isInt0Low() ^ isCrkRising()) {
            tmOut = QUART_SEC;
    /**************************************************************************************************
      use the cam signal to locate the tooth
    **************************************************************************************************/
            if (isCamDet()) {
                setCamDet(false);                       /* cam detected so clear the flag */
                camAngle = 0;
                camError = 0;
            } else {
    /**************************************************************************************************
            Because tooth angle may not be an even division, an error correction is performed
            at each update. If the error exceeds the threshold, the angle value is incremented,
            and the threshold value is removed from the error.
    **************************************************************************************************/
                camAngle += toothAngle;
                camError += toothError; if (toothError >= teeth) { camAngle++; camError -= teeth; }
            }
    /**************************************************************************************************
            Special case op for missing tooth, if no missing tooth, then skip this whole part.
            The detection of an event is both there is a missing tooth, and the DIFF is longer
            than 1.5 of the previous event DIFF.
    **************************************************************************************************/
            if ((missing > 0) && (tmpDiff > (crkDiff + (crkDiff / 2)))) {
    /**************************************************************************************************
            Missing tooth detected, so correct the angle for one missing tooth (at least)
    **************************************************************************************************/
                camAngle += toothAngle; camError += toothEr; if (camError >= toothCt) { curAngl++; camError -= toothCt; }
    /**************************************************************************************************
                If more missing teeth, correct again for each (math runs fast, so little or
                no impact)
    **************************************************************************************************/
                if (missing > 1) { camAngle += toothAngle; camError += toothEr; if (camError >= toothCt) { curAngl++; camError -= toothCt; } }
                if (missing > 2) { camAngle += toothAngle; camError += toothEr; if (camError >= toothCt) { curAngl++; camError -= toothCt; } }
    /**************************************************************************************************
                If there was a missing tooth the value of tmpDiff is extended, so replace
                tmpDiff with the old value of DIFF to prevent calculation problems.
    **************************************************************************************************/
                tmpDiff = crkDiff;
            }
            crkTime = tmpTime;
            crkDiff = tmpDiff;

     

    The value of "missing" is read from calibration at engine stop.

     

    /* Calibration value in future, but for now just provide a constant */
    SWord getCrankToothCt(void) { return 4; }
    SWord getCrankToothMissing(void) { return 0; }
    
           missing = getCrankToothMissing();

     

    TTFN,

    Jack

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • jack.chaney56
    jack.chaney56 over 7 years ago

    A little dental work, or what to do about missing teeth.

     

    The more advanced timing wheels on motors have high tooth count and also throw in areas where teeth are deleted, in order to provide sub-timing to catch ignition in less than one full crank. It is my observation, this is overkill, because, the increase in processing needed for high level detection, often results in missing the special event, and it still requires multiple rotations to capture timing.  However, because they didn't listen to me, and implemented missing teeth anyway, coding must be made to mitigate the event.

     

    There are two processes that must be implemented, first is detection of the missing tooth event. The second is compensating for the event.  Detecting the event requires notification of the potential for a missing event, so a calibration value of missing teeth is needed. Missing teeth is not the total number of missing teeth. It is the number of missing teeth together. Meaning it is possible to have a missing tooth at 10 degrees and a second at 100 degrees, even though in total, there are two missing teeth, the value of missing teeth in calibration is still one. I hope that is clear enough.

     

    The detection of a missing tooth event, is; first, is there a missing tooth (missing > 0), and when the measured Diff value tmpDiff (current) is greater than 1.5 times the previous Diff (crkDiff). Because the change in crkDiff from tooth to tooth is relatively small, if the change in crkDiff is greater than 1.5 times, it is the indication of a missing tooth event. Once the missing tooth event has been detected, a correction to operating variables is required. First, update the cam angle, then correct for error, repeating once for each missing tooth. This operation is performed in the crank interrupt. Because it only requires comparison and addition, the impact is very slight.

     

        if (isInt0Low() ^ isCrkRising()) {
            tmOut = QUART_SEC;
    /**************************************************************************************************
      use the cam signal to locate the tooth
    **************************************************************************************************/
            if (isCamDet()) {
                setCamDet(false);                       /* cam detected so clear the flag */
                camAngle = 0;
                camError = 0;
            } else {
    /**************************************************************************************************
            Because tooth angle may not be an even division, an error correction is performed
            at each update. If the error exceeds the threshold, the angle value is incremented,
            and the threshold value is removed from the error.
    **************************************************************************************************/
                camAngle += toothAngle;
                camError += toothError; if (toothError >= teeth) { camAngle++; camError -= teeth; }
            }
    /**************************************************************************************************
            Special case op for missing tooth, if no missing tooth, then skip this whole part.
            The detection of an event is both there is a missing tooth, and the DIFF is longer
            than 1.5 of the previous event DIFF.
    **************************************************************************************************/
            if ((missing > 0) && (tmpDiff > (crkDiff + (crkDiff / 2)))) {
    /**************************************************************************************************
            Missing tooth detected, so correct the angle for one missing tooth (at least)
    **************************************************************************************************/
                camAngle += toothAngle; camError += toothEr; if (camError >= toothCt) { curAngl++; camError -= toothCt; }
    /**************************************************************************************************
                If more missing teeth, correct again for each (math runs fast, so little or
                no impact)
    **************************************************************************************************/
                if (missing > 1) { camAngle += toothAngle; camError += toothEr; if (camError >= toothCt) { curAngl++; camError -= toothCt; } }
                if (missing > 2) { camAngle += toothAngle; camError += toothEr; if (camError >= toothCt) { curAngl++; camError -= toothCt; } }
    /**************************************************************************************************
                If there was a missing tooth the value of tmpDiff is extended, so replace
                tmpDiff with the old value of DIFF to prevent calculation problems.
    **************************************************************************************************/
                tmpDiff = crkDiff;
            }
            crkTime = tmpTime;
            crkDiff = tmpDiff;

     

    The value of "missing" is read from calibration at engine stop.

     

    /* Calibration value in future, but for now just provide a constant */
    SWord getCrankToothCt(void) { return 4; }
    SWord getCrankToothMissing(void) { return 0; }
    
           missing = getCrankToothMissing();

     

    TTFN,

    Jack

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
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