Choisissez votre langue | Select your language |Bitte Sprache wählen



16F84 based digital ignition

- Version PCM5.4 -



Synoptic.



Principle.


The part CDI (Capacitive Discharge Ignition) is described in the page "fixed ignition". The PIC receives the pulses from the 36° sensor and:

Let us see this in details...

Pulses coming from the 12° pickup directly trigger the SCR via D7 R7 C10.
(If the bike has only one pickup, connect it to the 36° input and leave the 12° input unconnected)

At the same time, the pulses coming from the 36° pickup are limited to 5 volts by the Zener D9 then drive the PIC (pin 10).
( The PIC input detect a tension higher than 1.8 Volts.
That mean that pickup signal must be > 2 volts)

At each good pulse received from sensor 36°, the green LED D1 blink.

A delayed pulse, according to the programmed advance curve, is available on pin 8 and trigger the SCR T1 via D2,R7,C10.

A +5V output is available at RA2 (in example to drive a LED) when the maximum RPM is reached.

RA3 provide a inverted signal (revcoil)

Ways of the 12 and 36deg signals:


Zoom.

There are 2 sparks by revolution: one before the TDC (from the 36deg pickup)
and another at TDC (from the 12deg pickup - if connected)
This second spark is supernumerary.




Max Ignition Frequency 730Hz.

 

Warning! If there is one spark loose, the max rpm is divided by 2

IE: 88000tr/mn with ONE spark by rotation and 44000tr/mn with TWO sparks by rotation (as on the XT)




Compatibility with others pickups.

This ignition need either
2 pickups:
or only one pickup
1st pickup at 36° BTDC:


and 2nd pickup at 12° BTDC:
Positive than negative:
But not negative than positive!


If your pickup signal is negative than positive (ie: Honda,Suzuki...), you must invert the trigger!
You can build this interface to invert the negative pulse and suppress the postive one.

Principal functions of the program


Easy kickstart


At the beginning of the program, the advance is fixed at minimum:
movlw 0xff ; rpmhi = FF initially
movwf rpmhi

Coil protection


After 0,5 seconde without pulses, the PIC consider that the engine is stopped, and reinitialise the ignition. ; if rpmcount > 1400h, 5120 x 100us=0.5 Sec, then it is assumed that the
; motor has stopped. Reinitialize system.
movlw 0x14
subwf rpmhi,W
btfsc STATUS,Z ; rpmhi - 14 = 0 ?
goto start ; yes

RPM Limitation:


Over 8000 RPM, the delay between the pickup signal and the spark is fixed to 0ms maxadv clrf rtdset ; > 8000RPM retard value = 0ms
bsf rpmmax ; turn led on

Under 1000 RPM, the delay between the pickup signal and the spark is fixed to 5ms

maxret movlw 31h ; < 1000RPM
movwf rtdset ; retard value = 31h (~4.9ms)
bsf rpmmax ; turn led on

(You can set another RPM limitation in your 131 advance values too)

Advance calculation:


Between the maximum and the minimum RPM, the PIC measure the duration between 2 pick up pulses [the number of 100us (hundred microsecondes) period between two pulses] to deduce the speed engine.
According to the speed, the PIC calculate the position in the map.

caladv movlw d'74' ; rpmhi/lo - 74
subwf rpmlo,F ; rpmlo = rpmlo - 74
btfss STATUS,C
decf rpmhi,F

; divide result by 4

bcf STATUS,C
rrf rpmhi,F
rrf rpmlo,F ; / 2
;
bcf STATUS,C
rrf rpmhi,F
rrf rpmlo,F ; / 4

The value of the delay (variable retlw) is extracted from a table of 131 values 

map org h'200' ; store map at 200h
addwf PCL,1 ; add W + PCL
; *********** INSERT YOUR OWN VALUES HERE *******************
retlw 31h ;4,9ms 1000rpm
retlw 30h ;4,8ms 1016rpm
retlw 2Fh ;4,7ms 1023rpm

The choice between 2 maps is made by the jumper.
no jumper = map N° 1 at h200
jumper on = map N°2 at h300

btfss table ; is table select low?
bsf PCLATH,0 ; yes,then select table N°2 at h'300'

The PIC receives the pulse from the sensor at 36°.
It waits until a time = retlw * 100us, then after this delay, a pulse (fixed at 2ms) is sent to the thyristor.
;****************** YOU CAN MODIFY THE DWELL VALUE BELLOW ********
movlw .20 ; 20 X 100uS = 2mS
movwf dwell ; set dwell time

Duration of the spark:


The duration of the spark cannot be adjust on a CDI, it depend of the capacitor value and the coil value. After all we can adjust the duration of the pulse that trigger the thyristor. This pulse duration (called: dwell time) can be change for some slow thyristor but without impact on the spark duration:

A reverse output is available pin8 to drive a revmeter:

Example:
The pic measure the duration between 2 pick up pulses. So it's able to calculate the engine speed.
If the speed is 1000RPM ,the PIC search into the 131 lines for the FIRST line.

Why?
At 1000RPM, the duration between 2 pulses is 60ms with one wasted spark.
(without wasted spark the duration would be 120ms
Convert in microsecond: 60ms = 60.000us

I said (see higher) that the PIC count in 100us loops. 
At 1000RPM, the PIC count 600 loops of 100us between 2 pickup pulses.
Than the pic use the formula :

;       rpmhi/lo count - 74
; 131 - -------------------
;             4

The formula become:

;       600 - 74
; 131 - -------- = 0
;         4

The formula gives Zero, so the Pic take the very first line of the map (the pic add 1 everytime)
the first line return:   retlw 31h     ;4,9ms   1000rpm
(As you know it: semicolon prefix a comment and h mean Hexadecimal)
31 (hexadecimal) = 49 (decimal)

So the pic will wait 49 loops of 100microseconds.
49 x 100useconds = 4900useconds = 4,9 milliseconds
then the PIC will wait 4,9 ms after the pickup pulse, before providing a spark.

 
If the speed is 1015RPM ,the PIC search into the 131 lines for the SECOND line.
Why again!
At 1015RPM, the duration between 2 pulses (with one wasted spark) is 59,1ms
Convert in microsecond: 59.1ms = 59100us

We knows that the PIC count in 100us loops.
At 1015RPM, the PIC count 591 loops of 100us between 2 pulses
Than the pic use the formula witch become:

;       591 - 74
; 131 - --------
;          4

;       517
; 131 - ---
;        4

;
; 131 - 129,25 = 1,75 = 1 (we use the integer)
;
The formula gives ONE, so the Pic take the second line of the map (1+1)
It get:   retlw 30h
30 (hexa) = 48 (decimal)

The pic will wait 48 loops of 100microseconds.
48 x 100useconds = 4,8 milliseconds
so the PIC will wait 4,8 ms after the pick up pulse, before providing a spark.

And so on until 8000RPM and the LAST line where the pic get retlw 0h
Meaning that it must wait 0 x 100us = no delay
so the PIC providing a spark immediately. (Restriction: Even if you write "retlw 0h" the lower retard is 100us (0.1ms). That mean you cannnot have a spark EXACTLY at the same moment of the pickup pulse)

You dont really think so?
At 8000RPM, the duration between 2 pulses (with one wasted spark) is 7,5ms
Convert in microsecond: 7,5ms is 7500us
At 8000RPM, the PIC count 75 loops of 100us between 2 pulses
Using the formula:

;       75 - 74
; 131 - -------
;         4

;        1
; 131 - ---
;        4

;
; 131 - 0,25 = 130,75 = 130 (integer part)
;
The pic get the number of line (130+1)=131. The last line
The curve is thus defined by 131 points, authorising a tuning. But the accuracy is rough:
+/- 1° à 1660tr/mn
+/- 5° à 8330tr/mn
That only comes from "the measuring unit" used for measuring the duration between 2 pulses and to set the delay before the spark. Those durations are counted in 100us unit.
100us units is small enough at low RPM but is not at high RPM!
(A 10us unit would be more accurate but in another hand, the table would be ten time larger,
and a 8Mhz clock doesn't improve the accuracy)


How to change the curve

2 ways: manualy or with the help of a excel sheet.

Manually:

To modify the delay value, you can alter the hexadecimal values directly into the map

Example:

Supposing that you want to wait during 7.9ms between the pickup pulse and the spark at 1000rpm:

map org h'200' ; store map at 200h
addwf PCL,1 ; add W + PCL
; *********** INSERT YOUR OWN VALUES HERE *******************
retlw 31h ;4,9ms 1000rpm
retlw 30h ;4,8ms 1016rpm
retlw 2Fh ;4,7ms 1023rpm
retlw 2Fh ;4,7ms 1030rpm

The map is now:

map org h'200' ; store map at 200h
addwf PCL,1 ; add W + PCL
; *********** INSERT YOUR OWN VALUES HERE *******************
retlw 4Fh ;7,9ms 1000rpm
retlw 30h ;4,8ms 1016rpm

etc etc....

Or with the help of a excel sheet:

please look at the Tutorial 

Create your own curve with this Excel 2003 sheet :

This sheet use
DECHEX (french)
or DEC2HEX (english,greek,finnish,portuguese)
or DEC.N.HEX (dutch,nl)
function providing by the Analysis toolpak.

[ sweeden ] = "DEC.TILL.HEX"
[ russian ] = "ÄÅÑ.Â.ØÅÑÒÍ"
[ spanish ] = "DEC.A.HEX"

You may install the Analysis ToolPak and Solver by clicking on the Tools menu and selecting Add-Ins. If the Analysis ToolPak is not listed in the Add-Ins dialog box, click Browse and locate the drive, folder name, and file name for the Analysis ToolPak add-in, Analys32.xll - this is usually located in the Microsoft Office\Office\Library\Analysis folder - or run the Setup program if it isn't installed (you will probably need your Microsoft Office CD-ROM for this). Select the Analysis ToolPak and Solver check boxes and click OK.

If it doesn't work,  give the working of the function DEC2HEX a try. In a new cell, write:   =DEC2HEX(24)   does it work?

If yes, "refresh" the cell F17 
(copy the formula from F17, delete it, than paste it in F17)
to force Excel to calculate the formula again.

 (It seem that when excel got a error, it doesn't calculate it anymore)

excel file


  1. Enter the position of the pick up into cell D6 (ex: 32 BTDC)
  2. Enter the RPM limitation into cell D8 (ex: 6200)
  3. Enter the 131 advance values that you want into column C
    (ie: 8 for 500RPM     8,7 for 625RPM and so on...) 
  4. Edit the curve with the "graphic map" tab: point and select one value then move it up or down
  5. You can move the entire curve up or down by entering a "shift" value into cell D10
  6. Once the curve is draw, select and copy the 131 blue values beginning by retlw ..... (column E)
  7. Edit the source file .ASM with a good editor like ConTEXT (freeware) 
  8. Paste this 131 lines beginning by retlw, in the map
  9. map org h'200' ; store map at 200h
    addwf PCL,1 ; add W + PCL
    ; *********** INSERT YOUR OWN VALUES HERE *******************
    retlw 31h ;4,9ms 1000rpm
    retlw 30h ;4,8ms 1016rpm
    retlw 2Fh ;4,7ms 1023rpm
    . . . .etc etc . . . . . .
    retlw 0h ;0ms
    ; *********** END OF YOUR OWN VALUES *******************
    retlw 31h ;in case of overlap
  10. Save the file .ASM


Extra advance:


It's possible to get more advance without changing the pickup position

What is "Extra advance"


PIC programming.


  1. Compile the .ASM file with MPASMWIN :

    • Install and open mpasmwin.exe.
    • Choose the PIC
    • Browse and select the .ASM file (ie: C:\cdi\bikeign.asm)
    • Assemble the file (= transform to .HEX according to the processor type).
    • Compiled file is available into C:\cdi\bikeign.hex
  2. Insert your 16F84/16F628 in a PIC programmer. The one I use
  3. Transfer .HEX file in the PIC with ICPROG
  4. Insert your PIC 16F84/16F628 in the ignition board.

On animation below, one can see (in white), the signal coming from the pickup (connected to PIC input pin10)
and the signal for the SCR (PIC output, between D2 and R9) at various speeds between 1300rpm to 6000rpm :

scale (5ms/div 2v/div)

We see:
At high rpm, the output signal is provided at the same time as the pickup signal, therefore before the TDC.
at low rpm, the output signal is provided after the input signal, therefore at the TDC.


Software.



PCM5.3 .HEX
PIC16f84 CDI
for XT400-550

(2600-6500rpm)

sotware
PIC16f84 CDI
for XT600

(1920-7320rpm)

PIC16f84 CDI
for SR500

(1920-7320rpm)

PIC16f84 CDI
for 2 strokes

(3170-10900rpm)

PIC16f84 CDI
for 2 strokes

(3446-13020rpm)


Sources

PCM5.3 .ASM
PIC16f84 + quartz

(1000-8000rpm)

Source 16f84
PIC16f84 + quartz

(1500-16000rpm)

Source 16f84
PIC16f628 no quartz

(1000-8000rpm)

Source 16f628


Schema.

PCM5.3 Schema PCB Componants Part list
CDI for
XT400-550-600
Schema.PDF circuit.PDF componants.PDF liste.TXT


Printed Circuit Board.

Zoom Zoom

Realization.

Zoom Zoom

Zoom Zoom

pin 3 +12Vcc (battery) brown
pin 2 spark coil orange
pin 1 Alternator red
pin 4 Kill switch white/black
pin 8 12° pickup white/green
pin 7 36° pickup white/red
pin 5 pickup common ground green
pin 5 CDI ground black
pin 6 alternator ground brown

Revue Technique


Tests.




Versionning.