Understanding assembler languange for ignition system

Discussion in 'Embedded Systems and Microcontrollers' started by eddy123456, Feb 5, 2008.

  1. eddy123456

    Thread Starter New Member

    Feb 4, 2008
    Hi everyone,

    I want to write a program on an ignition system for a 125cc four stroke engine.The purpose of my program is to produce a variable time delay for spark to occur in the ignition system. As the engine starts, pulses from the alternator assembly via the pulser coil(positioned at 36degree BTDC) will be collected. The time from the 1st and 2nd pulse will determined the speed of the engine. By using the speed of the engine, the program will call a suitable delay value for spark to occur. This means that spark will only be produce after the 2nd pulse and one spark is wasted.

    Its been 2 weeks since ive started the project, learning about the ignition system and how to program a PIC using c or assembly. Ive decided to program PIC16F84 with Wiz-C by using assembly language because it is quite easy to understand. So far i was able to do simple task such as flashing LED with a push button.

    *** Details on the ignition system
    Ideally a mixture of air and fuel needs to be burn exactly at the top dead centre(TDC) of the combustion chamber. In reality, a fixed quantity of air and fuel needs a particular time to combust. Although this can be solve by allowing the spark to occur before TDC say at 36 degrees before TDC, the engine however have a range of operating speed. Thus there needs to be a variable delay system(depends on the speed of the engine) where combustion occur before TDC.

    *** Information about my program

    Assume that the engine can run up to 8000rpm.
    At engine speed of 1200 RPM;

    1200 / 60 = 20 revs per second
    1 / 20 = 50mS per rev
    1 rev = 360 degrees

    36 degrees at 1200 RPM = (36 / 360) X 50 = 5mS

    So at max rpm, delay = 0, spark will occur at the instant the pulser is at 36 degrees BTDC.
    at min rpm( 0-1200rpm), delay should be lower than 5mS say 4mS

    The program have 8 set of delay values(just an example, it should be about 100).
    8000rpm= 0mS
    1200rpm or lower =fixed at 4mS

    I came across a website that has an assembly code which is similar to the one that i want. I cant really follow the logic of the code and was wondering if someone can give me a simple assembly code example plus explanation on how to use timers to calculate rpm and use data tables to retrieve corresponding delay output using assembly language. I know this is too much but i really appreciate all the help that i can get.

  2. beenthere

    Retired Moderator

    Apr 20, 2004
  3. Mclovin

    New Member

    Feb 9, 2008
    Hi Eddy

    the title to your thread caught my eye.
    I too started designing an electronic distributer,starting with my bros Datsun 1600 SSS...
    The headaches that project gave me were unbareable,i ditched the project on the third day.I had a limited time to write the program and get a PCB designed before i returned to the UK.The pcb design would take maybe an hour,but it took me two days to come up with an algorithm for the timing,i kinda knew what needed to be done eventually,but the thought of then putting that into assembler was enough to make wish cars and engines had never been invented...and i love cars...normally
    but anyway,unfortunately all my calculations and stuff are probably still on my desk back in SA,so i will have to think a bit about what i had worked out.but at a quick glance (its 2:15am so im feeling a bit tired) you have made the same assumptions as me regarding the timing calculations.I will give it a think over in the morning/later today and see what i can remember about what i had already worked out and get back to you.I am really interested in seeing a project like this work,so i would like to work with you on this one and share what i have learned on the way,because ultimately I plan to build an entire engine management system for my Austin Mini,fuel injection (two injectors only as i there are only two inlet ports) electronic distributer,and a USB or Serial communication with the PIC to my laptop for fine tuning the fuel mixture and ignition timing while the system is running.
  4. eddy123456

    Thread Starter New Member

    Feb 4, 2008
    hi there,
    ill be happy to get any help from anyone.At the moment i am working on the coding and this is suppose to be my university project(due early march).I guess the only thing i can do(if ive finished) is to test it on a oscilloscope.