ADVANCE RETARD IGNITION USING ARDUINO. NEED HELP!!!!!!!!

hi everyone. i’ve been working on CDI ignition system. i have made everything except for one thing which is a ignition advance retard using microcontroller. there is a square pulse coming out from the engine flywheel which tell us at which time the ignition coil should produce spark (which is driven by a mosfet ). but the problem is that the pulse comes out is 40 degree before the top dead center (assume top dead center at zero degree) which is compulsory when engine is running at HIGH RPM. But when we intend to start engine at this advance timing(40 degree before) it can cause harm the engine or doesn’t start which is obvious. because the fuel blast occur before the piston reaches the top and that blast pushes piston back so no rotation of engine. SO my main motive is put a delay according to the engine RPM . at zero RPM the delay should be about 5mS max and decrease to zero at 14000RPM in a LINEAR way or adjustable points. it seems quite complicated for me so if anyone can help that would be appreciated

Not an easy project. I assume this is a bench project and not going into an automobile. You have to account for the charging time of the coil as well. The spark occurs when the primary of the coil is opened. You have to determine whether it is the rising or falling edge of the pulse you want to work with from the flywheel. You can generate an interrupt at that point. Another consideration is the number of cylinders. How many times does it fire per revolution and if it is every other (4 cycle) how do you know you are on the correct rotation. I have a hard time with 14,000 RPM, from my memory Gasoline automobile engines typically will have a redline at around 5500 to 7000 rpm. If this goes under hood and on the engine you have a lot more to do. The engine operating temperature range for most cars is between 195 to 220 degrees Fahrenheit. The optimum operating temperature is around 218 degrees Fahrenheit. Hopefully this gives you a starting point.

You can do this with and interrupt and the hardware timers of the Arduino. You pick up the lead or trailing edge of the flywheel pulse at the 40 degree advance position with an interrupt. That interrupt can also be used to determine the rpm of the engine. Use that interrupt handler to start a timer which will trigger the spark after the appropriate time. The delayed trigger time is dependent upon the rpm.

You will need a look up table or formula to determine the delay as a function of rpm.

You may get some ideas from the AC phase control sketches which use a hardware timer to trigger a driver after a period of delay from a zero crossing interrupt.

https://playground.arduino.cc/Main/ACPhaseControl/

The first car I had had a mechanical vacuum advance mechanism and my first motor bike had a centrifugal timing advance mechanism. Now things are a bit more complicated. The timing can be dependent on engine speed and load (based on air pressure at the inlet manifold). If you are interested in using only engine speed to determine the timing it becomes less complicated. Incidentally 14,000 RPM sounds quite fast.

Anyway, google for this search string: arduino advance retard engine
You'll find several projects related to ignition timing.

Engine.JPG

Engine.JPG

Then there was my International Scout 4-cyinder with, I believe, Chrysler Corp. Multifire ignition. Multiple sparks going to each spark plug. Drove the emissions testing people crazy trying to pickup the ignition pulse for their RPM measurement.
Paul

gilshultz:
Not an easy project. I assume this is a bench project and not going into an automobile. You have to account for the charging time of the coil as well. The spark occurs when the primary of the coil is opened. You have to determine whether it is the rising or falling edge of the pulse you want to work with from the flywheel. You can generate an interrupt at that point. Another consideration is the number of cylinders. How many times does it fire per revolution and if it is every other (4 cycle) how do you know you are on the correct rotation. I have a hard time with 14,000 RPM, from my memory Gasoline automobile engines typically will have a redline at around 5500 to 7000 rpm. If this goes under hood and on the engine you have a lot more to do. The engine operating temperature range for most cars is between 195 to 220 degrees Fahrenheit. The optimum operating temperature is around 218 degrees Fahrenheit. Hopefully this gives you a starting point.

Thanks for your valuable reply. You imagine several things wrong my fault i forget to explained. I have a 160CC bike engine (Single cylinder) . Running On the "TCI SYSTEM" (in which we open coil primary to produce spark at output. (stock 12000rpm max rev range). You have said that i would have to open the coil primary to produce spark but the scenario is different here cause im using custom made CDI system where a capacitor charges at 400V DC. Its One wire connected to coil Pri and other wire to mosfet . When i gets the signal the mosfet ground that wire and by this the charged capacitor gets across the primary and create spark on scndry at same time. The same time i receive 40 degree advance pulse at the same time i gets spark. Im a beginner to the arduino. And its timing functions are quite difficult. It was quite difficult to make the 400v DC CDI and now stuck at this position.

6v6gt:
The first car I had had a mechanical vacuum advance mechanism and my first motor bike had a centrifugal timing advance mechanism. Now things are a bit more complicated. The timing can be dependent on engine speed and load (based on air pressure at the inlet manifold). If you are interested in using only engine speed to determine the timing it becomes less complicated. Incidentally 14,000 RPM sounds quite fast.

Anyway, google for this search string: arduino advance retard engine
You'll find several projects related to ignition timing.

Engine.JPG

Hi there. The graph you provided seems to be taken from a car engine. Cause most of the cars run at 8000rpm but i was talking about a bike engine 160cc SC. Somehow i managed to start my bike at 40 degree advance pulse. But it was terrible at 1500 or below rpm and engine stops due to poor ignition timing. But once you set the idle for upto 2200 its throttle response like a buttery smooth. Hit the rev around 13800.

cattledog:
You can do this with and interrupt and the hardware timers of the Arduino. You pick up the lead or trailing edge of the flywheel pulse at the 40 degree advance position with an interrupt. That interrupt can also be used to determine the rpm of the engine. Use that interrupt handler to start a timer which will trigger the spark after the appropriate time. The delayed trigger time is dependent upon the rpm.

You will need a look up table or formula to determine the delay as a function of rpm.

You may get some ideas from the AC phase control sketches which use a hardware timer to trigger a driver after a period of delay from a zero crossing interrupt.

Arduino Playground - ACPhaseControl

Im just a beginner to arduino cant handle that advance timer functions. First i thought to do it with a RPM based delay. But the problem comes out that most of the RPM measure program use delays which cause malfuction for the critical ignition time. I got a pic16f84 code, but thats impossible for me to understand and its limited to 12000RPM. if you can manipulate it so i can share it here for you.

ALL THE CODING AND SCHEMATICS INFORMATION IS IN THE ATTACHED TXT FILE

PIC16f84 Ignition.txt (22.4 KB)

OK. You have built that project according to the schematic CDI Ignition which has a PIC16F84 processor and are attempting to adapt the code to handle an an increased RPM range and the advance/retard characteristics of your engine ?

Unless you want to increase the scope of the project to involve a PIC16F84 to ATMEGA328P (or similar) "upgrade", you may be better off using a PIC forum.

What is that bike engine, incidentally, which you've said is a 160cc single cylinder? Is it a 2 stroke? 14'000 RPM sounds remarkably high.

Edit


From the comments in the code, it does appear to support the engine speed range you require.

; Therefore maximum retard at 1200 RPM = 5mS after the firing
; point is reached. This figure remains constant down to 0 RPM.
;
; At a engine speed of 16000 RPM, maximum advance will have been reached,
; and ignition is immediately after the firing point is reached.
;
; The intermediate values will be looked up in an advance table map
; and will correspond to engine speed from 1500 RPM to 16000 RPM.
;
; As the engine RPM increases above 1500, the retard value becomes
; progressively lower until 5000RPM is reached, then increase until
; 16000 RPM is reached, whereby the retard value will be 0.
; Under 1500 RPM the retard value is fixed at 12ms

6v6gt:
OK. You have built that project according to the schematic CDI Ignition which has a PIC16F84 processor and are attempting to adapt the code to handle an an increased RPM range and the advance/retard characteristics of your engine ?

Unless you want to increase the scope of the project to involve a PIC16F84 to ATMEGA328P (or similar) "upgrade", you may be better off using a PIC forum.

What is that bike engine, incidentally, which you've said is a 160cc single cylinder? Is it a 2 stroke? 14'000 RPM sounds remarkably high.

*the answer of your first question is "YES"
*my bike has a Four Stroke 160CC Single cylinder engine
i can go with pic programming but i'd beter to go with arduino. the code i provided so you guys can get the logic out of it which can further fit into arduino based system like nano . arduino is easy to program by any means but with pic id have to buy special programmer or you can tell me the program for advance retard ignition directly on the arduino that would be literally appreciated .

The timing formula is quite straight forward:

1 degree of advance/retard = 1000.0 / ( 6.0 * RPM ) milliseconds

so, for example, if you want a 20 degree advance at 5000 RPM, the time would be 20 * 1000.0 / ( 6.0 * 5000 )
which equals 0.667 milliseconds (or 667 microseconds)

But there is still a considerable reverse engineering task and a lot of experimentation before you get good results. You can simulate some of the logic just using a basic Arduino on a bread board with a hall effect sensor just writing to the serial console. Maybe with another arduino to generate test signals simulating engine rotations up to 14,000 RPM (~230Hz)

6v6gt:
The timing formula is quite straight forward:

1 degree of advance/retard = 1000.0 / ( 6.0 * RPM ) milliseconds

so, for example, if you want a 20 degree advance at 5000 RPM, the time would be 20 * 1000.0 / ( 6.0 * 5000 )
which equals 0.667 milliseconds (or 667 microseconds)

But there is still a considerable reverse engineering task and a lot of experimentation before you get good results. You can simulate some of the logic just using a basic Arduino on a bread board with a hall effect sensor just writing to the serial console. Maybe with another arduino to generate test signals simulating engine rotations up to 14,000 RPM (~230Hz)

i have got a new code which i can adopt. but the author didnt mention which one is input pin which one is output for two pins. one pin would be a signal pin coming from the engine and other one pin would be assign to trigger gate of SCR/MOSFET. after a long time of searching i found something useful and now the poor guy mentioned both pin as a signal pin. in arduino it is quite simple to find out which one is output pin just by reading the digital write line and analog read function as a input pin, but i dont know what command is used in reading/input , writing/output in c language of pic uc. i can post that code i hope you can find out.

this is the code

KAWASAKI 600 ignition.txt (19.6 KB)

That is still PIC assembly code and is for a 4 cylinder Kawasaki GPX 600. I can't see how this is likely to be any more relevant to your 160cc 4 stroke single machine. Anyway, I can't help with the PIC code. I don't even know which forum to recommend for any help you may need. Sorry.

If, however, you start attempting to convert the code to Arduino C++ then you'll certainly get a good response here, though.

6v6gt:
That is still PIC assembly code and is for a 4 cylinder Kawasaki GPX 600. I can't see how this is likely to be any more relevant to your 160cc 4 stroke single machine. Anyway, I can't help with the PIC code. I don't even know which forum to recommend for any help you may need. Sorry.

If, however, you start attempting to convert the code to Arduino C++ then you'll certainly get a good response here, though.

so i am done now with pic microcontroller. this should be good if i wont depress myself with pic junk. anyway you are talking about the conversion of that code to arduino. is it can happen? if yes so i would like to do it but im worried about that functions is they exist in arduino also?

If you want to implement such a project to duplicate the functionality of that CDI unit with say an Arduino Nano you would probably start by identifying the feature list of that device. What I can see is :

Detect engine position using Hall effect sensor.
Trigger thyristor after delay based on engine speed.
Switchable test mode to generate sparks at 4Hz or 140Hz

Then you have to start breaking the project down into simple and testable steps. Nothing is difficult and the chip on the Arduino Nano can do everything that PIC processor can, at least for this project.

Why not start with the implementing the test mode ?
Write a simple program which generates sparks at 4Hz ? It reads the state of a pin at system start to determine if it is in test mode then, every 250ms triggers the thyristor.
Once you have done that, maybe write a simple program to detect the Hall sensor and switch a led when triggered.
Then move onto the more advanced part to measure engine speed (find a simple frequency counter sketch).
Then go onto making a variable delay between detecting a trigger from the Hall sensor and sending a pulse to the thyristor.

Most of this can be modelled in a simple test environment.

this project may be of some help in understanding the coding for your project using port manipulation of timers et al ..............Aeroduino Ignition – Anders Aircraft & Automation

6v6gt:
If you want to implement such a project to duplicate the functionality of that CDI unit with say an Arduino Nano you would probably start by identifying the feature list of that device. What I can see is :

Detect engine position using Hall effect sensor.
Trigger thyristor after delay based on engine speed.
Switchable test mode to generate sparks at 4Hz or 140Hz

Then you have to start breaking the project down into simple and testable steps. Nothing is difficult and the chip on the Arduino Nano can do everything that PIC processor can, at least for this project.

Why not start with the implementing the test mode ?
Write a simple program which generates sparks at 4Hz ? It reads the state of a pin at system start to determine if it is in test mode then, every 250ms triggers the thyristor.
Once you have done that, maybe write a simple program to detect the Hall sensor and switch a led when triggered.
Then move onto the more advanced part to measure engine speed (find a simple frequency counter sketch).
Then go onto making a variable delay between detecting a trigger from the Hall sensor and sending a pulse to the thyristor.

Most of this can be modelled in a simple test environment.

My requirements are

  1. stable rpm calculater
  2. reading the Input pulse
  3. putting a delay
  4. output
    (I dont need the test run circuit just the advance retard system would be fine)

Please suggest me some code for counting RPM. Cause i have found some codes but they are not stable as i said earlier

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.