Maker Pro
Maker Pro

Digital programmable CDI ignition for 2-stroke engines

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
hello you guys. i just found this site on doing a google search for a 'homemade cdi ignition system.'

and by the existing title is read '2-stroke' . right now i'm writing an assembly code program for
a yamaha xt225 4-stroke. in MPASM v. 8.92 . its about 2/3 done. its been a project part time
for over a year now. learning assembly language is a steep learning curve. with some hefty
hurdles along the way. the present one is taking the timer module value for rpm's and locating
it on the timing curve. as until that is done the amount of delay until a 'fire' signal is sent
to the cdi circuit is not known. i think its all downhill after getting this licked though.

it does remain to be seen if the code will fit a 12F508 with its 512 ml's or a 12F509 w/ 1024.

the motive for making this digital ignition circuit replacement is the yamaha parts are
costly. hundreds of dollars. and they have
no way of testing the new cdi module to assure me it is any good. and electronic parts are not
returnable. thus they can sell me a bad part and i have to take the risk. and the loss.

also the winding on the coil plate that energizes the old cdi analog module that goes inside
the flywheel is bad. and i could not find any info on how to rewind it. one cant simply replace
this one coil. you have to buy the entire circle of coils. hundreds more for that.

the programmer is a Pickit-3 . and the test board is the LPC one that Microchip sells.
together they cost less that a hundred. the uC's and parts came from Digi-Key

Bob
 

dR.eXntriK

Jun 5, 2014
25
Joined
Jun 5, 2014
Messages
25
Hey guys, long time since I came back to this thread to ask dumb-ass n00b questions. Thank you for tolerating me all this while and I request you to kindly do so even this time.
I've just found a analog ignition circuit for an old motorcycle. I was wondering if you guys could give me inputs on how I can convert this analog circuit to a digital circuit such that a set of sensors determine the position of the piston in the cylinder and a controller determines when the spark has to be generated.
Kindly help me with these you Noble men and women
I've provided the link to the image below

http://imgur.com/sQaW8Tb
 

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
dr eXntrik -

hi. what you are trying to do is a project i have been with for my motorcycle
for the past year.

its a 225 yamaha and the analog ignition circuit died. and is being updated
with a digital one. the hard part is coming up with a coded micro-controller
to handle the spark plug firing. this has become a DIY matter. as none of
any other postings anywhere were enough help to understand / get me going.

this has had me dive into learning Microchip assembly language. MPLAB IDE
v. 8.92 is the s/w ... and its been a slow process. an enjoyable one though.

the cdi circuit board to handle the spark was bought as a kit. and it will just
need some work to fit the available space on the bike.

my estimate is another month or two for the code to be finished.

for any other engine the code will have to be edited to fit that engine's
timing curve. and once you get how the code works it wont be too much
of a problem.

there are so many details to a project of this sort. and i will be happy to
share what has been learned. let's start with what you think is the place where you
want to begin


regards.

bob

the 003.jpg shows the flywheel and 2.5 " magnet that generates the
reference timing signal when it passes a fixed sensor coil every rev.

006.jpg shows the sensor coil as seen inside the flywheel cover
 

Attachments

  • 003.JPG
    003.JPG
    46.3 KB · Views: 490
  • 006.JPG
    006.JPG
    46.4 KB · Views: 382

dR.eXntriK

Jun 5, 2014
25
Joined
Jun 5, 2014
Messages
25
dr eXntrik -

hi. what you are trying to do is a project i have been with for my motorcycle
for the past year.

its a 225 yamaha and the analog ignition circuit died. and is being updated
with a digital one. the hard part is coming up with a coded micro-controller
to handle the spark plug firing. this has become a DIY matter. as none of
any other postings anywhere were enough help to understand / get me going.

this has had me dive into learning Microchip assembly language. MPLAB IDE
v. 8.92 is the s/w ... and its been a slow process. an enjoyable one though.

the cdi circuit board to handle the spark was bought as a kit. and it will just
need some work to fit the available space on the bike.

my estimate is another month or two for the code to be finished.

for any other engine the code will have to be edited to fit that engine's
timing curve. and once you get how the code works it wont be too much
of a problem.

there are so many details to a project of this sort. and i will be happy to
share what has been learned. let's start with what you think is the place where you
want to begin


regards.

bob

the 003.jpg shows the flywheel and 2.5 " magnet that generates the
reference timing signal when it passes a fixed sensor coil every rev.

006.jpg shows the sensor coil as seen inside the flywheel cover


Hey bob,
This is exactly the thing that I had in my mind.
I have a Yamaha 100cc motorcycle, a Honda 100cc moped, a 175cc, 250cc motorcycles (Yamaha, sort-of). All 2-strokes and very old.
As you would know the common problems with these are over-heating, loss of power, drop in efficiency etc. all because of the ignition. That is the main reason why I want to introduce all these beauties to the digital age.
I've had the same plan as your's i.e learn MPLAB, program a PIC etc. but since its a steep learning curve, I've been avoiding it since a long time. I have friends who are like experts in this stuff (academically) but they don' share a similar passion and they don't have the "time" to help me out.

Your idea seems to be perfectly in sync with mine. Could you tell me more about the components that you plan to use for the project?
Like PIC, circuit diagrams of the boards etc.
I'll take a look and try to work on it from my angle and post results.
Thanks a lot
 

dR.eXntriK

Jun 5, 2014
25
Joined
Jun 5, 2014
Messages
25
dr eXntrik -

hi. what you are trying to do is a project i have been with for my motorcycle
for the past year.

its a 225 yamaha and the analog ignition circuit died. and is being updated
with a digital one. the hard part is coming up with a coded micro-controller
to handle the spark plug firing. this has become a DIY matter. as none of
any other postings anywhere were enough help to understand / get me going.

this has had me dive into learning Microchip assembly language. MPLAB IDE
v. 8.92 is the s/w ... and its been a slow process. an enjoyable one though.

the cdi circuit board to handle the spark was bought as a kit. and it will just
need some work to fit the available space on the bike.

my estimate is another month or two for the code to be finished.

for any other engine the code will have to be edited to fit that engine's
timing curve. and once you get how the code works it wont be too much
of a problem.

there are so many details to a project of this sort. and i will be happy to
share what has been learned. let's start with what you think is the place where you
want to begin


regards.

bob

the 003.jpg shows the flywheel and 2.5 " magnet that generates the
reference timing signal when it passes a fixed sensor coil every rev.

006.jpg shows the sensor coil as seen inside the flywheel cover


Hey bob,
This is exactly the thing that I had in my mind.
I have a Yamaha 100cc motorcycle, a Honda 100cc moped, a 175cc, 250cc motorcycles (Yamaha, sort-of). All 2-strokes and very old.
As you would know the common problems with these are over-heating, loss of power, drop in efficiency etc. all because of the ignition. That is the main reason why I want to introduce all these beauties to the digital age.
I've had the same plan as your's i.e learn MPLAB, program a PIC etc. but since its a steep learning curve, I've been avoiding it since a long time. I have friends who are like experts in this stuff (academically) but they don' share a similar passion and they don't have the "time" to help me out.

Your idea seems to be perfectly in sync with mine. Could you tell me more about the components that you plan to use for the project?
Like PIC, circuit diagrams of the boards etc.
I'll take a look and try to work on it from my angle and post results.
Thanks a lot
 

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
dr X ,
hi. gads , you've got a load of bikes to work on. this is going to be one major project for you.

your interest and enthusiasm is most welcome. i was half afraid you'd want to do the code
in C. god forbid. then we'd never be able to move along and understand each other.
lots of people eat that language up tho. a higher level language was ruled out early on as , like
trying to use a basic stamp or the picaxe series ... one just never knows the timeline of
the program execution. while with assembly you know to the microsecond what is going on.
plus the MPLAB IDE s/w even has a timing tool. you can use it to find out how long execution
between 2 points in the code takes.

one thing that came to mind since last writing is that altho my yamaha is a 4-cycle the code
should work on a 2-cycle with no changes. this is due to the code doing the same thing
every rev and firing every rev too. but only one firing does any good. the wasted spark
happens during the exhaust phase.

here's an important link for you :
http://gooligumshopcom.fatcow.com/shop/gooligum/tutorials/PIC_Intro_0.pdf

from the time my yamaha died and i got going with assembly learning was an
agonizing 4 months dealing with the matter of what to do and how. with some
major luck i found an organized series of lessons on learning to code in assembly.
they were well written and bite-size. and progressive too. plus being free didnt hurt
either. the biggest mistake i almost made was to buy somebody's s/w. namely
the 'PicBasic Pro' that melabs.com sells. that would have been further pain added to
a very stressful time.

with david m's lessons , a Pickit-2 programmer and Microchips 'LPC' demo board
i was set. as david's lessons are written for the LPC board. and the training board
that he sells. had i to do over again i'd a bought his pic training board.

8.92 is the version of MPLAB in use now. but it is not the ver started with.
that one was 8.62 i think . not sure now. and it didnt matter anyway.

also his lessons intro you to some 'X' ver of MPLAB. i avoided those pages.
and wish he'd of done a 2'd set of lessons to omit the distraction.

the first lesson in the 'baseline' series , the ones that are free , will intro you
to using MPLAB and creating a program via the wizard feature. this was a big
hurdle for me. and took a month to figure out. even for code that does nothing
more than lite a led.

once you get how to use the MPLAB template files for the lesson 1
pic 12F508 , 509 and write a piece of code, build it , fix errors, then run it
and save the code for later you are on your way.

looking back i think everything i needed to know for the ignition code
program under dvp was learned in the first 4 or 5 or 6 baseline lessons.

my goal then and now has been to do the code with the simplest
pic chip, in a way that is plain jane. and therefore more understandable
by other beginners. later versions can get fancy. and likely will in a
natural way as other methods are thought of and learned.

at this point the final code version will be in either the 508 or 509 pic .
they differ in only program memory space. 512 or 1024 ml's.
since i'm not there yet with a working program it is still an unknown
how many divisions to make of the timing curve. like if the range
is in units of 100 RPM's vs 500 the code will need more room.

this is where testing will have to be done.
and listen to how the engine sounds with these jumps in timing

to stop for now.
next post will include a link to the CDI kit.

all totaled to get the cdi kit, a Microchip LPC demo board or the Gooligum pic
training board and a Microchip Pickit-3
programmer will cost in the 200-300 range.

bw
 

dR.eXntriK

Jun 5, 2014
25
Joined
Jun 5, 2014
Messages
25
dr X ,
hi. gads , you've got a load of bikes to work on. this is going to be one major project for you.

your interest and enthusiasm is most welcome. i was half afraid you'd want to do the code
in C. god forbid. then we'd never be able to move along and understand each other.
lots of people eat that language up tho. a higher level language was ruled out early on as , like
trying to use a basic stamp or the picaxe series ... one just never knows the timeline of
the program execution. while with assembly you know to the microsecond what is going on.
plus the MPLAB IDE s/w even has a timing tool. you can use it to find out how long execution
between 2 points in the code takes.

one thing that came to mind since last writing is that altho my yamaha is a 4-cycle the code
should work on a 2-cycle with no changes. this is due to the code doing the same thing
every rev and firing every rev too. but only one firing does any good. the wasted spark
happens during the exhaust phase.

here's an important link for you :
http://gooligumshopcom.fatcow.com/shop/gooligum/tutorials/PIC_Intro_0.pdf

from the time my yamaha died and i got going with assembly learning was an
agonizing 4 months dealing with the matter of what to do and how. with some
major luck i found an organized series of lessons on learning to code in assembly.
they were well written and bite-size. and progressive too. plus being free didnt hurt
either. the biggest mistake i almost made was to buy somebody's s/w. namely
the 'PicBasic Pro' that melabs.com sells. that would have been further pain added to
a very stressful time.

with david m's lessons , a Pickit-2 programmer and Microchips 'LPC' demo board
i was set. as david's lessons are written for the LPC board. and the training board
that he sells. had i to do over again i'd a bought his pic training board.

8.92 is the version of MPLAB in use now. but it is not the ver started with.
that one was 8.62 i think . not sure now. and it didnt matter anyway.

also his lessons intro you to some 'X' ver of MPLAB. i avoided those pages.
and wish he'd of done a 2'd set of lessons to omit the distraction.

the first lesson in the 'baseline' series , the ones that are free , will intro you
to using MPLAB and creating a program via the wizard feature. this was a big
hurdle for me. and took a month to figure out. even for code that does nothing
more than lite a led.

once you get how to use the MPLAB template files for the lesson 1
pic 12F508 , 509 and write a piece of code, build it , fix errors, then run it
and save the code for later you are on your way.

looking back i think everything i needed to know for the ignition code
program under dvp was learned in the first 4 or 5 or 6 baseline lessons.

my goal then and now has been to do the code with the simplest
pic chip, in a way that is plain jane. and therefore more understandable
by other beginners. later versions can get fancy. and likely will in a
natural way as other methods are thought of and learned.

at this point the final code version will be in either the 508 or 509 pic .
they differ in only program memory space. 512 or 1024 ml's.
since i'm not there yet with a working program it is still an unknown
how many divisions to make of the timing curve. like if the range
is in units of 100 RPM's vs 500 the code will need more room.

this is where testing will have to be done.
and listen to how the engine sounds with these jumps in timing

to stop for now.
next post will include a link to the CDI kit.

all totaled to get the cdi kit, a Microchip LPC demo board or the Gooligum pic
training board and a Microchip Pickit-3
programmer will cost in the 200-300 range.

bw
Hey,
Sounds awesome! Could you please post a link to the tutorial you are following. It would be easier for all the people reading this thread, to just click the link and start learning.
The thing about divisions in your program. I'd recommend that you make it 500RPM because changing timing at every 100RPM doesn't make much difference.
Could you please tell me the full PIC id of the chip you are using? I am a n00b :p :D
As I've told you earlier I have a list of bikes which are in dire need of a digital makeover. You said it was a big project, but I don't think it is. What I am planning to do is make a baseline ignition program, make a few changes to the program to suit a specific vehicle. That way I can easily convert all these beauties to digital.
And the thing about wasted spark, Its actually bad for the engine (while cruising or while trying to zoom) its useful only during a cold start.

The thing is, I know a LOT about the project and its stuff EXCEPT where to begin. :D :p
 

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
hi dr X ,
its good you have a plan. and the attitude that it wont be such a big project. i hope this is how
it turns out for you. and that you are not mistaken with your estimate of the future.

your comments and requests have all combined to push me into doing some fresh thinking.

first is to recognize that i'm a noob too. just a few lessons and some experimental experience further along
the road from others who trudge this path too. or ponder getting going along it

also i recognize that its easy to forget what it was like to be a brand new noob to this assembly / CDI scene.
how it was a period of accumulating no end of information, and hopefully to learn anything about what others
are or have done with the coding, real examples of ignition code with good comments, some guidance
on just what to make of what all can turn up using Google to search. going crazy with conflict what to
spend any money on. totally unsure where to make the commitment. on and on ...
all because you reminded me of that phase of learning process with the last line you wrote.

since then today i've worked on putting together the info you ask for plus a little more.
with a download and install of the mplab ide 8.92 s/w you will be able to begin lesson 1 today.

with more of your comments and ideas as well as more thinking all along the way we
can make this a quality project. and create a place where others interested will want
to join in.

bw

here's whats in the attached *.txt file ... a bunch of links to essential information
at time of creating this file today all these links worked

http://www.microchip.com/pagehandler/en-us/devtools/dev-tools-parts.html
archives for mplab ide 8.92 ; the 8.xx series is now retired , replaced with MPLAB X
the baseline and mid_range tutorial lessons can all be coded and run with 8.xx
its up to you which one to use. all my code is wrote & built using the 8.xx

http://www.sci-experiments.com/HighVoltagePulser/
CDI kit #108 78.95 ; this is the best CDI design in the known universe
for the application of upgrade old stock analog ignition systems with new digital CDI ones.
plus this #108 is an improved design over the #104 kit available when i bought one.
for one thing its more shock proof for when its mounted to your dirt bike
the kit circuit was designed by the dr tony alfrey who runs this site. he has a doctorate
in elect engr, i believe , and knows high voltage circuit design well. and is available to
answer any questions you have . think about how rare a circumstance this is.

http://www.gooligum.com.au/tut_baseline.html
list of assembly tutorial lessons for baseline PIC 12F508 , 509 and a few other uC's
lessons 1 to 6 are enough basis to write some simple yet effective CDI ignition code.
once done it will serve as a reference to modify as new ideas come to mind. both
from the lessons beyond no. 6 and the actual experience of using what you have written

http://gooligumshopcom.fatcow.com/shop/train-dev-boards/base-mid-train-board
trainer board for PIC and baseline & mid-range tutorial lessons 89.00

http://www.microchip.com/DevelopmentTools/ProductDetails.aspx?PartNO=DM164130-9&utm_source=MicroSolutions&utm_medium=&utm_term=&utm_content=&utm_campaign=PICkit 3 Demo Board
the Microchip LPC demo board 25.99 ; spring for the gooligum trainer board if you can ,
it wont matter to you now much but later on you'll be increasingly glad you did

http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=PG164130
Pickit 3 programmer at Microchip site 47.95
the older Pickit 2 will work too for the coding you'll be doing. find one cheap on ebay.
beware the chinese clones ... they may not have identical USB connectors or come with
a suitable length cable. the savings is not worth it.

http://ww1.microchip.com/downloads/en/DeviceDoc/41236E.pdf
data sheet for PIC12F508/509/16F505 ; it looks pretty formidable at first ... yet over time
you will refer to it often . this is the 'bible' for understanding these 3 chips and how to program them.
you will end up printing out most of it for a folder that is kept nearby as you code and experiment

http://www.digikey.com/catalog/en/partgroup/mplab-pickit-3-debugger-pg164130/20261
Pickit 3 at Digi Key 47.95 ; there is no minimum size order and for just a handful
of spare parts or chips you can specify parcel post to save on shipping and have your
order in just a few days. plus there online tech help is first rate when you need a hand
finding something

http://www.microchip.com/forums/f57.aspx
this is the forum at Microchip for MPLAB 8.xx users. good senior techs provide timely
responses to your problems and questions.
 

Attachments

  • CDI assembly code urls 9_25_14.txt
    2.5 KB · Views: 290
Last edited:

Dabidoh

May 13, 2015
1
Joined
May 13, 2015
Messages
1
Sadly, I'm not chiming in on this seemingly dead thread with miraculous advice. What I am stating is my hope that not only are you successful in this endeavor - but that you also produce something that works on both 12 volt AND 6 volt bikes. I have a Kawasaki AR80 that would benefit from a programmable CDi, but which is also a 6 volt bike.
 

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
an e-mail alert today told me of a new message. from new member Dabidoh.
welcome to this forum.

the thread may appear to be dead. but the work is going on . by coincidence today is when
i will spin up the Yamaha 225 this CDI project is meant for. the purpose is to verify that
the signal from the flywheel timing sensor is still there. and to label the 2 wires that carry the signal.
the CDI circuit is ready to mount on a temporary setup. and the engine should start & idle ok.

the flywheel sensor produces 2 signals every rev. and the latter is at -10 deg BTDC .
this is the amount of advance this 225 engine needs when it idles.

the uC coding needs some finish work. and until that's complete the engine will run but
not speed up any. for that it needs spark timing advance. and that's what the uC does.
coding work got set aside when the CDI circuit malfunctioned this winter. and it took me
a month to figure out what was wrong. to make fixing it easier a bread-board version of
the CDI circuit is being developed. this morning , after a few fixes, it charged C2 to 250 volts
in a split second. like it is suppose to do. the last fix was to add a jumper wire to connect
both sides of the transformer to a common ground.

also a Rigol 1054z scope has been purchased . and is being played with to learn some of
how to use it. capturing aperiodic events is my focus at present. and a nice image i am after
is is a multi-channel one that shows C2 charging and then the comparator sending a signal to
stop the DC-DC action once its reached 250 volts.

as to Dabidoh's inquiry about 6 volt bikes. sorry, the CDI circuit is meant to run on
12 volts. the transformer secondary power n-FET transistor needs this additional voltage on its
gate. so that it is fully turned 'on' when the 200 uSec 'fire' signal arrives.


bw
 

dR.eXntriK

Jun 5, 2014
25
Joined
Jun 5, 2014
Messages
25
Hey @Dabidoh ,
Got an email today about your new reply.
As @bob weir has told you above the thread is not dead its just dormant, but the work is going on. I've started to write some basic programs for a couple of vehicles of my own. I am still trying to improve the circuits and perfecting it by adding various sensors to it. It takes HUGE amount of time and money both of which are in shortage to everyone ALL THE TIME. SO bear with us, I am sure either myself of someone like Bob will come out with a decent working CDI which others can use as a reference and start working from that.
As far as the 6V bikes go, its difficult to give them a CDI and almost impossible to convert them to a 12V, I would suggest that you try other mods on it like exhaust tuning or making air-tight seals around joints to increase windage etc. These create improvements similar to that of a electronic ignition but not as good as it.
Good luck with your project Dabidoh and ALL THE BEST for your project @bob weir . We hope to see some updates soon
 

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
this image is what the 1054z rigol scope captured. one of its 4 probes was connected to the feedback resistors
for one charge cycle. the cycle is done when the C2 cap reaches 250 V. then this feedback 2.5 volt signal
reaches the LF353 comparator '-' input and matches the '+' input so then the 353 output goes low. this
stops the DC to DC charge action. so the C2 now just sits there . and slowly bleeds off its charge via the 2
series feedback resistors.

via the Hz time base of .005 sec / div you can see C2 took about 35-40 ms to charge to 250 V.
each vertical div. is 500mV. 5 div's vertical times 500mV/div --> 2.50 V.

the feedback resistors are a 1M in series with a 10k . they are between the '+' end of C2
and its bottom , grounded end. where they join each other is close to 1% of C2's voltage.
the fixed 2.5 V. zener on the 353 comp is the voltage level to be matched by
the feedback resistors to stop the C2 charging process. 2.5 V is 1% of 250 V.
for any more than 250 V. on C2 the 10k has to be some other larger size.
1M and 10k are simply convenient for this experiment as they were handy sizes.

also the trigger level is about 700mV ... it can be most anywhere in the 0 - 2.5 V. range

next the circuit will be sketched and uploaded. the circuit is on a bread_board for experimenting.
and not exactly what you find via the .sci_experiments.com link . the author has changed
the circuit now posted from what it used to be 2 years ago. improvements

oh , by the way the V+ for this circuit is a common 9V. battery. for testing they cant
be beat. they can deliver over an amp for a few seconds. long enough to verify the circuit is
running. and if there is a short in the circuit somewhere no fuse gets blown. you just mostly
gotta watch their voltage under load. so that it doesnt drop too low. the part most sensitive
to a low V+ is the 353 comparator. if its not right with the V+ it needs the DC to DC action
could over-charge C2

one more thing to mention is that in service for a gas engine the 4410 FET Q2 will need a heat sink.
but for quick bench tests it runs cool.
 
Last edited:

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
here is the 2012 version of the CDI circuit being used for this project. i cant find any way to post it here opened up.
so i guess you'll have to open the file on your PC and / or print it out.
 

Attachments

  • TA CDI ckt diag. dwg Nov 2012.pdf
    502.5 KB · Views: 289
Last edited:

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
this post is to show what the scope sees the voltage on C2 doing when U1 recieves a 200us pulse to drive
the Q1 FET 'on'. there are 2 screen images. qp8 is with a horiz .002 sec per div. and qp11 is 200us/div
qp8 shows how C2 takes about .010 sec to recharge. the probe for C2 is on the feedback resistor string.
not on C2 itself. notice how C2 does not totally discharge in the alloted 200us time. and neither does it
drain all the way to 0 volts. the yellow CH 1 pulse is taken either at U2:8 or U2:1 or U2:6.
the ckt diag .pdf of the last post shows C2 = 2.2uf and that is what was used on my ckt board.

something else of note is visible on qp11 , namely that when the yellow pulse falls to 0v that enables
the dc:dc action to resume. and the result is seen via the band of vertical blue lines rising up off of the
blue curve of the voltage on C2. until it bottoms out, and then they are not seen anymore as C2 charges.

this part of the curve is a mystery . for one thing the Q1 FET is suppose to turn off
once its drive signal pulse drops to 0v. here it appears to still be conducting charge from C2 to ground after
the 'on' pulse ends. despite all that there is a spark . even though it appears the ignition coil is not
getting all the energy stored in C2 to make the spark with.

the 200us pulse width is a result of the R16 , C15 differentiator. it takes all the pulses in the range
about 10 to 50 HZ out of igniter pusler U5 and trims them all in width to about 200us.


DS1Z_QuickPrint8.jpg DS1Z_QuickPrint11.jpg
 

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
today's post will re-visit a foto from last sept. it shows the flywheel on the yamaha 225 with the magnet visible on its top surface.
not shown but next to the flywheel is a 2-wire coil sensor that detects the magnet's field when it comes rotating by. the magnet strip is
about 2" in length and given the flywheel diameter of 4.5" the arc length of the magnet is in the 60 degree range.

a newer picture shown below here is from the rigol scope. one channel is used to capture what the sensor signal looks like when the
engine is cranking via the starter motor. using the screen data of 20ms per div a we can measure a ballpark value
of about .030 sec between the two pairs of +/- peaks and about .140 sec between the two + ones.
.140 sec is the time for one rotation. 1/.14 = 7 hz or 420 RPM

now lets calc. the arc length of these +/- pulses ...... .030 / .140 = ..21 and .21 x 360 = 75 deg.

ok , we learn the physical arc length of the magnet is less than its electrical length. the latter is the one we will
reference our code to. in particular the first + peak. how we interpret its location with respect to top dead center
makes all the difference with the engine being timed correctly for spark firing.

in a later posting will be the timing diagram for this engine. one thing it shows is a -10 deg BTDC for idle up to 2000 rpm
and the - peak was used to run the engine at idle. this one can do without any uC or code. the engine will run but not speed up.
for that it needs to have the firing time advance with an increase in rpm's.

thus, because the engine runs with the - peak i believe that this 2'd peak , the -- one , is at -10 deg. so if the + peak
is 75 deg ahead of it then that makes it at -85 deg BTDC. this then is the reference point for which the assembly code
will delay the firing until the time matches the factory timing diagram. more on this later when some code is posted.

how well the engine runs and sounds with this starting assumption will be the feedback we need for any adjustments to the code.
if it knocks the timing is too soon. if there is no power the timing is too late.

003  fw bigger.JPG DS1Z_QuickPrint3.jpg
 

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
FW -12 -72 foto.jpg TW200 Advance Curve.jpg TW200 Advance Curve.jpg PIC16F84 CDI ign ckt.gif
if you Google " programmable digital ignition cdi" you will find what others have been up to . some of what was found relates
well to what is being presented here. and is offered for reference support and comparison.

three items today are images. the first is another flywheel showing the surface magnet. only this image is marked with the
timing degrees. and the timing degree numbers are very close to mine. also seen in the foto is the sensor coil that produces the timing signals. it is not labeled. its that thing in the upper left corner with
2JA on it

the next image is a timing curve for a 200cc engine. and it just happens to match the timing curve for my 225 engine. note how for RPM's
up to 2000 no advance timing is necessary. timing is a constant -9 deg

a 3'd image is the circuit diagram of a CDI circuit. from the .sportdevices.com website. it uses a PIC16F84 microcontroller.
this chip is in the baseline family of uC's , same as the 12F508 used in my circuit. and is included for study & comparison.

a note here is on the size of the program memory of the 16F84. it has 1024 words of program memory.
thus they have written code for a 1-cyl. gas engine that fits in this much space. when you start to write
code for a project like this as a beginner you wont know its final size. so it is good to learn that someone else got it all to fit in 1024 words. if you start out writing code for one uC chip and your program grows larger than the uC can hold then you gotta switch to another one with more room.

a few key differences with this circuit and my CDI circuit is the fact it gets its energy to charge C2 via the flywheel , not a DC-to-DC circuit, although they call it an 'Alternator'
and the switch to let the C2 energy get to the ignition coil is with a SCR , not a n-FET.
and it includes a switch on the RB2 input for selecting a different timing curve. give that some thought.

next is a text file . it is the assembly code listing of the '84 uC. being able to read it and follow along with what it is doing
comes with experience. oops, this forum apparently does not allow *.asm file uploads. so you are instead given the link.

http://www.sportdevices.com/ignition/ignition.htm

look for ASM Source code : ignition16.asm in the PIC Program section


my next posting will cover the 2 circuits that convert the +/- sine wave shaped timing signals into
digital pulse form that the uC can use. and like the '84 circuit mine will have the -10 deg signal
go directly to the SCR. or in my case go to Q1 , a n-FET. a key thing to get here is that
for each rev of the flywheel at RPM's above 2000 both +/- timing signals turn on Q1. but
only the first signal arrives at the correct time. the 2'd signal tries to fire the spark only by now
the C2 energy is used up. for RPM's below 2000 the uC determines not to send a fire
signal out the RA2 pinj. and the -10 deg one does the job by default
 
Last edited:

bob weir

Sep 10, 2014
235
Joined
Sep 10, 2014
Messages
235
this post is to show how the -10 deg flywheel signal gets converted into a pulse the CDI circuit can use. note that the uC does not use the -10 deg signal.

one image is of the flywheel signal and the 2-transistor circuit that changes the -10 deg half-sin wave to a 0-1-0 pulse.
at the time of this posting this image appears on p. 3 of this forum

the other image is from the scope. it shows 3 traces .
a. CH 1 is the input sine wave. this signal comes from a fct. gen. and not the flywheel. works fine for an indoor bench test
b. CH 3 is the 0-1-0 pulse that comes out of the 2-transistor converter circuit
c. CH 2 is the 200 uS wide pulse out of R17 / C16 and U2:8 on the CDI circuit board.
this 200 uS pulse goes to the mosfet driver U1 which then sends a 200 uS 0-1-0 pulse to Q1.
when Q1 gets this pulse it turns on for 200 uS and this results in the spark plug firing

not shown is a 1-transistor, 2N3904 , circuit that interfaces the 2-Q output pulse to U2:1

the next post will have the -60 deg half-sin signal converter - to - pulse circuit. View attachment 20787 View attachment 20787 DS1Z_QuickPrint7.jpg
 
Last edited:
Top