Newbie making an ignition timer


Closed Thread
Results 1 to 18 of 18
  1. #1
    Join Date
    Jul 2006
    Posts
    36

    Default Newbie making an ignition timer

    Hello to everyone,
    I am a newbie. A rather OLD newbie....but ambitious. I am working on a project of converting a 4 stroke gasoline engine to Hydrogen ( a personal project - no I'm not in school) and my task is this:
    Hydrogen combusts FAST, so I need to change the current magneto ignition to one that I can adjust for a LATER (retarded) ignition spark.
    The flywheel has a permanently mounted magnet and the magneto will not be able to be repositioned. SO, I want to:
    1) Read an input pin to sense the edge of the magnet on flywheel rotation using an Allegro Hall Effect sensor (Output is 2.5V - will PIC see that as "on?")
    2) Read a pot to control the "Delay Amount" so I can adjust and experiment.
    3) Either just turn on a pin after the determined delay (to turn on current to an ignition coil,) or PWM the same (I wonder if that is necessary considering the time the magnet will be sensed at, say, 3600RPM.)

    I've been scouring the examples and they are either way more complicated than I need and over my head, or too simple. Any thoughts will be appreciated.

    My experience with PICs thusfar, so you get an idea of where I'm at:
    I have successfully programmed a PIC and created a circuit as a PWM generator and have also made a PIC look at the state of certain pin conditions and change PWM duty cycles appropriately (opening water injectors.)

    Now then, I would like to do this on a 12f683 with a 20Mhz crystal, but could do it on another configuration if necessary.

    Before I try to recreate the mold, does anyone have any snippets that would get me started? Or perhaps a more proper place to search?

    Thanks in advance,

    Chris

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Maybe I am missing something, but when you mount the sensor could that be made adjustable?

    2.5 volt input will need to use comparator on chip.

    Why not just use a LM324? 4 channels. One could be used as a comparator out put to another channel via RC network for the delay. Out put from here to a IGBT for speed and power to the coil.

    Get all of this working and then tie into a PIC for auto retard/advance control for different loads on the engine.

    ???
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Thumbs up Engine management information

    Hi Chris,

    Ambitious project for a newbie... but don't let me deter you. Sounds like you are an old "gas head" like me! I want to do something similar to you (one day) but more important PIC designs keep getting in the way i.e. work oriented or ones that make some income.

    I have to ask - how are you making the hydrogen? I've entertained ideas a long time ago of doing something similar but with diesels as a supplementary fuel but the problems are many...

    I'm experienced with PICs but still learning as well, my vehicles have all been modified turbo types necessitating engine management changes so I know what you are talking about and your requirements, although hydrogen is a new one for me. When you say it burns fast I gather you mean it is a lower octane - my understanding is low octane fuels are more explosive so need less time to complete the combustion process and make peak cylinder pressure so this being the case then a later or retarded spark event is correct. Sounds like you are also into water injection (something I also want to try) so you are probably also aware that the fine water mist will lift the octane rating (slow the burn) if you wish. What are you using to inject the water or are you using fine mist nozzles?

    With programmable engine management it is usual (and more conveniently accessible) to mount a steel plate on the front of the engine's harmonic balance pulley. This plate has a number (one per cylinder) of equally spaced teeth and an additional tooth spaced about 10 deg's prior to number 1 cyl tooth. These rotate to a closely positioned pickup (coil and magnet) which generates a pulse as the engine/plate rotates. A double pulse is generated when the number 1 cylinder goes by and it is up to the management to sync to this and generate timing from this reference.

    The engine is timed by statically setting the maximum advance you want (zero delay in your code to fire the coil) and progressively delaying it in order to retard the spark. Sneaky huh?

    At the speeds you are going to be running your PIC would need to use a fast crystal (say 20Mhz) with the incoming pulses from your pickup triggering an interrupt (and deriving rpm from that) while also accessing a lookup table to determine the delay (retard). Expanding on this would be relatively easy if you wanted to make a 3D table by introducing another parameter (say boost or throttle position).

    With the interrupt stuff I've only just begun using some of this myself and can recommend you do a search for Darrel Taylor's Instant Interrupts on this forum. He's a Guru on this stuff and a nice guy who will help if asked politely.

    Let me know if I can help some more in my limited way and I will try. This is an interesting project and one that could be of great benefit to many, good luck!

    Bill

  4. #4
    Join Date
    Jul 2006
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    The engine that I am currently working on for this project is a simple, one cylinder Briggs and Stratton based generator. SO, it is a constant RPM motor at 3600RPM. Therefore, I don't think I need anything really in the way of lookup tables, etc. It is statically timed now, so that's all I need for electronic control. I just want to be able to adjust the delay manually. I'll handle idle control mechanically.

    The reason for using software instead of physically moving the position of the sensor is really just one of flexibility. When I get it working on this, then it will work on ANY motor with a static timing by simply mounting the Hall effect sensor on the leading edge of the magneto.

    As for Hydrogen: Compared to fossil fuels it's heaven BECAUSE it burns so fast and in such a wide range of ratios (07%-74% Air to fuel.) In an internal combustion engine, that fact makes it more efficient because it doesn't need time to "get going" like petrol. It should be ignited at almost top dead center and will have done it's work and completed combustion before the valve opens. Additionally, and this is huge, we don't need to throttle the AIR intake. It always runs "lean," wide open air intake! We simply meter the amount of fuel. That fact itself has great consequences on efficiency. Furthermore, since there is no time for heat to transfer to the surrounding cylinder head, etc BEFORE TDC, the engine runs very cool, for zero Oxides of Nitrogen emmissions - the exhaust is cleaner than the air that went in to it (the stuff we breathe.)

    I'm sure I could make a solid state ignition circuit to replace the magneto, but I would like to do it with software to reduce hassles with positioning the sensor.

    As you can see, I Love talking about this stuff. Don't EVEN get me started about what Hydrogen can do mixed WITH fossil fuels. Gas, diesel, veggie oil, propane, turpines, all run in a standard engine with Hydrogen injection. It's true.

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    I am glad to hear experts talk. I do not have much knowledge about engines except how the IC engine works; but 2 stroke/4 stroke is going a little deep for me. However, I like to hear you folks talk about alternate fuels and TDC and BDC concepts. I had to work on a CNG timing kit a while back, though this was totally in hardware; no microcontroller.

    From your concept Chris, I think Bill has suggested right. You need to use the PICs interrupt capability to get it to respond to the magneto pulses reliably. If you sense in a loop (Polling) you may miss pulses now and then and lead to major knocks in the engine (perhaps, since you are talking H2)

    As for catching the 2.5V on signal, it will be a bit out of spec for the PIC if it drifts up / down. I suggest you to level shift the signal if you can before giving it to the PIC.

    Off hand I do not have any snippets / links to offer, but I know every bit / byte matters.

    Cheers
    Jerson

  6. #6
    Join Date
    Jul 2006
    Posts
    36


    Did you find this post helpful? Yes | No

    Default My first code

    Thanks for the encouragement. Here's my first attempt at making something other than just thinking about it. I realize there is a lot wrong with this. Just please be gentle with me. I know I don't have a clue what I'm doing, but I want to try. Assume a 16f877 for now.
    (And how do I put it in a scrollable window like I see in other posts?)

    DEFINE ADC_BITS 8 'Number of bits in ADCIN result
    DEFINE ADC_CLOCK 3 'ADC clock source (rc = 3) ***WHAT IS THIS?
    Define CLOCK_FREQUENCY = 20
    DEFINE ADC_SAMPLEUS 50 'ADC sampling time in microseconds
    DEFINE OSC 20 'Oscillator speed in MHz

    TRISA = %11111111 ' Set PORTA to all input
    TRISB = %00000000 'Set Port B to all outputs
    ADCON1 = 2 ' PORTA is analog '****Is this necessary?

    sensor var porta.0
    coil var portb.0
    delay var byte 'Set variable "delay" as one byte

    ON INTERRUPT GOTO spark: ' When hall effect is sensed, go make a spark
    INTCON = %10010000 ' Enable RB0 interrupt ***I don't know what value goes here to make it listen to porta.0..???**

    loop:
    ADCIN 0, delay ' Read channel 0 to the variable "delay"
    ADCON ?? 'Convert it to decimal???
    delay = delay * 2 'A multiplier to make the ADC input result in
    'something meaningful in microseconds(2-510us)
    coil=0
    goto loop:

    spark:
    DISABLE ' Disable interrupts in handler

    pauseus delay ' This delay retards the spark
    while dwell=1 coil=1 ' This turns on current to the coil while the
    ' hall effect is sensed
    RESUME ' Return to main program
    ENABLE ' Enable interrupts after handler
    Goto loop: 'I don't know why I put this here - not needed right?
    end


    I'm embarrased to even post this considering the expertise here, but I want to learn and most importantly, I want it to work.
    Thanks,

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi ChrisHelvey,
    The Briggs magneto has both a moving magnet and under the flywheel you have a set of conventional contact points. When the points open the magneto fires.

    Automotive computer ignition systems typicaly have 2 input sensors to detect crankshaft position, one provides a TDC reference signal and the other is ofset so as to provide the signal to fire. The second signal actually is several degrees in advance of tdc and is the signal which gets delayed, but never later than the tdc signal.

    I think a good approach would to be to follow that example. You could build a lookup table to provide an advance curve, based upon RPM.

    A small disc with 1 or 2 holes could be used to trigger 1 or 2 photo transistor sensors, installed in place of the contact points. I say 1 or 2 because you could use 2 sensors and 1 hole or 1 sensor and 2 holes to get 2 distinct signal pulses.

    Home Machinest Magazine had an pic controlled gasoline engine featured a few months back which had solinoid valves instead of a camshaft and was equipped with electronic ignition. Here is a website featuring the authors engine: http://rbowes1.11net.com/dbowes/
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  8. #8
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wjsmarine View Post
    I have to ask - how are you making the hydrogen?
    The next gas station is at Cape Canaveral in Florida!

    * * *

    Hi,

    How do you produce hydrogen?
    Where do you get hydrocarbon fossil fuels to produce hydrogen?
    Or where do you get the energy to produce hydrogen? (Electrolysis).
    Are these methods cost effective and sustainable for the environment?

    Although hydrogen has a higher specific energy, the volumetric energetic
    storage is still roughly five times lower than petrol, even when liquified.

    Best regards,

    Luciano
    Last edited by Luciano; - 8th April 2007 at 10:35.

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink Real time and PbP ... take care !!!

    [QUOTE=ChrisHelvey;35917]

    ON INTERRUPT GOTO spark: ' When hall effect is sensed, go make a spark


    Hi, Chris

    That single line hurts me as a "BASIC" interrupt ...

    This means the program ALWAYS will complete the task ( Statement) it is currently doing ... before entering the interrupt stubb.

    You Have to use Assembler interrupts if you want precise and repetitive timing ...

    Now, you want to use 12F683 ... why not !!! have a look to what the CAPTURE module of the PIC can do for you ...

    generate the detect interruption ... Measure the rotation period ( TMR 1 ) ... and also measure the real computing time ... for example !!!

    a second 16 bits timer will be necessary ... if spark has to occur AFTER the hall effect is detected ( TMR1 cleared !!!) ... so you'll have to build it "manually" !!! 12F683 only has one ( 16F877 ... too ) !!!


    Alain
    Last edited by Acetronics2; - 8th April 2007 at 15:36.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  10. #10
    Join Date
    Jul 2006
    Posts
    36


    Did you find this post helpful? Yes | No

    Default Time to give up

    OK. This thread has been very useful to me, because I have to know when I am in over my head on something and this is it. You have saved me a lot of time failing. (It is clear that it CAN be done, just not by me.) Thank you.
    There are pleanty of ways to time ignition using Electronic Ignition modules and clever placement of the sensor (which is really all I was trying to avoid.)
    So, I think I'm going to scrap this idea and approach it more mechanically (precise PLACEMENT) instead of with software. (It'll be easier for me to fabricate metal than to write this program.)

    As for your questions on Hydrogen...there is no free lunch unless you make Hydrogen using Solar...and that isn't free either. BUT, we make up a lot in EFFICIENCY as a product of our efforts. And figuring gas engines are VERY wasteful, there is a lot to be gained even though we have to make it (Hydrogen.)

    I'll try to keep in touch. I'm sure I will have plenty of other practical or hair-brained ideas for a PIC to do...I think they are so cool!
    Thanks again,

    Chris

  11. #11
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Talking The third Thermodynamics Law ....

    Quote Originally Posted by ChrisHelvey View Post
    OK.

    And figuring gas engines are VERY wasteful,

    Chris
    Hi, Chris

    THE one and only question ...

    IS our giant waste of time an energy really necessary ???

    ( being here and there at the speed of light, use electric tools when not really needed, use computers to add 2 and 2 ... ( LOL !!! ) ... and so on ... )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  12. #12
    Join Date
    Jul 2006
    Posts
    36


    Did you find this post helpful? Yes | No

    Default The FOURTH law of thermodynamics

    Although it was asked with humor...it's a great question.
    After this, I think they'll shut us down because it's off-topic, but...

    It has been suggested by many that the survival of a species or social organization will depend on its ability to most efficiently direct available energy into channels favorable to the preservation of the species.

    So, this becomes about USEFUL energy transformation.

    And then, in my opinion, we should be able to waste as much as we want as long as we don't trash our environment doing so.

    So, is ANYTHING really necessary?

    Hmmmm.....

  13. #13
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Hi, Chris

    YES ...

    Preserve life !!!

    Easy to say ... no so easy to do !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  14. #14
    Join Date
    Jul 2005
    Location
    Palmdale, CA
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Newbie making an ignition timer

    I'm curious if this project ever came to fruition. I'm currently designing an ignition system for a vintage triumph engine for Bonneville Salt Flats. I started out using an AVAGO encoder because it was small and cheap and provided a digital position via SPI. I machined a replacement for the factory "distributor" to mount the encoder. I missed something on the data sheet however. The specs said the encoder was capable of clocking the SPI at 1MHz. Plenty fast enough. However, after fiddling with it I noticed it had a sample rate limitation of 10kHz. You can clock the data out at a bit of 1MHz but you can only sample it at one reading every 100uS. Not fast enough for high RPM. At 8,000 RPM, the device only gives a reading every 4 or 5 degrees (48,000 deg/sec x 100uS = 4.8deg). I wanted to have at least 1 sample for every degree of rotation. So I tried to interpolate between readings. I kept track of 2 successive readings to get the rotational velocity ((current reading-last reading)/(100uS)). When I was within 1 delta reading of the ignition point I used the velocity to extrapolate the actual desired ignition point to fire (turn off) the coil. Nice theory anyway. I couldn't get the code fast enough to make the interpolation within the 80uS remaining after sampling the encoder. So I tried to pick an arbitrary point well enough in advance if the ignition point to give the PIC enough time for the calculations. The problem with that was interpolating the ignition point from a greater distance caused greater error. This was largely because this simple method does not take acceleration into account. I chose to do a steady state interpolation ignoring acceleration figuring that if I was within 4.8 degrees of the desired ignition point, there would be minimal error due to accelleration. However when moving the point of interpolation way in advance there is plenty of time for the rotational velocity to change significantly.

    I gave up on the digitizing encoder and switched to a quadrature encoder with an index. The one I plan on using gives 2000 pulses/rev with a zero index. It should be easier to reference the index and count pulses. I'm currently machining the distributor to try it out. If anyone is interested, I can post the results later.

    Ed

  15. #15
    Join Date
    Jul 2005
    Location
    Palmdale, CA
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Newbie making an ignition timer

    Oh yeah, I was using a PIC16F1824 at 32 MHz.

  16. #16
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Newbie making an ignition timer

    Hi enauman,

    I would be curious of how you make out with this. I am trying to do something similar with gas model airplane engines. So far I have some code that works,but I think it could be better.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  17. #17
    Join Date
    Jul 2005
    Location
    Palmdale, CA
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Newbie making an ignition timer

    Hi Charlie,

    I have a couple of questions for you. What type of encoder are you using? Are you planning on making the advance dynamic or static? Didi you do your coding in PIC basic or assembly? Would you be willing to share your code with me? My interest is purely academic and not commercial.

    Ed

  18. #18
    Join Date
    Jul 2006
    Posts
    36


    Did you find this post helpful? Yes | No

    Default Re: Newbie making an ignition timer

    Hello Enauman,

    No, I never finished this project and it was a simple Magneto type lawn mower engine. The necessary inputs for an engine with dynamically changing loads and speeds would be overwhelming to me AND I found that commercial engine management systems on the market have caught up to the tech and can do just about anything. More expensive, yes, but much less time investment. I am talking about MSD products and their accessories.

    In any case, about your code, there was a gentleman on this list who DID successfully create a PIC based ignition system for an airplane (full sized.) It was quite impressive but WAY over my head. Do a search on my threads and I think he posted. I'll see if I can find him.

    Good luck with this, I wish you well.

    Chris

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. High Resolution Timer & Speed Calculator
    By WOZZY-2010 in forum Code Examples
    Replies: 4
    Last Post: - 7th February 2010, 16:45
  3. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 07:56
  4. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  5. timer interupt help 16f73
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd July 2005, 08:41

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts