Capacitor Discharge Ignition Using The Angular Timer
Capacitor Discharge Ignition Using The Angular Timer
Capacitor Discharge Ignition Using The Angular Timer
Piston
HV Supply
Magneto
(AC CDI)
Spark
HV Supply 300-400V Capacitor Plug
DC-DC (DC CDI) HV Supply
12V Battery Converter SCR
SCR Gate
+ Control
Pick-up signal Signal
from ƉƵůƐĞƌcoil Conditioning -
Thermistor
Throttle MCU
Ignition Coil
The capacitor is connected to an ignition coil or step-up
pulse transformer which produces a very high voltage,
in the range of 40 kV or more.
High-Power Switch
The switch is used to connect the capacitor to the pri-
mary of the ignition coil. The switch is fired when the
microcontroller gives a pulse at the gate of the switch. SINGLE PIP SYSTEM
The sudden rush of current in the primary of the coil In a single PIP system, the pulser coil provides one
produces a very high voltage in the secondary, which positive pulse followed by a negative reference pulse,
generates the spark to ignite the air-fuel mixture. Thus, as shown in Figure 3. The angle between the pulses
the microcontroller controls the firing angle of the and the angle between the negative pulse and the TDC
switch for generating the spark. are fixed. The firing of the spark should be done at a
A Silicon-Controlled Rectifier (SCR) is most commonly specific angle based on the engine operating tempera-
used as a high-power switch in CDI. It is highly durable ture, the throttle position and the RPM. This angle is
due to the higher operating voltages and current usually between the positive and the negative pulses.
ranges with moderate frequency response. The disad- The negative pulse is a reference point for firing the
vantage of the SCR is that it is a one-sided switch (i.e. spark at very low RPM. The firing angle changes to an
the switch can only be ON). It will automatically go to angle between the pulses for higher RPM.
Spark
300-400V Capacitor Plug
DC-DC HV Supply
12V Battery Converter SCR
Ignition
Coil
PWM
PWM
+ CCP CCPRx
Pick-up signal Signal (Capture)
from pulsĞr coil Conditioning -
INT
SCR Gate
CDI LOGIC
Thermistor Control
ADC Map
Throttle RPM Calculation
Selection
RPM
Firing Angle to
Firing Angle
Timer Counts
Calculation
Conversion
CCP
I/O
(Compare)
PICΠ MCU
Timer1 CLK
f = -----------------------------------------------------------------------
signal Timer1 Prescaler CCPRx
Timer1 CLK
RPMEngine = ----------------------------------------------------------------------- 60
Timer1 Prescaler CCPRx
Where: Timer1 CLK = Clock input for Timer1 using T1CON register = Fosc/4 = 32/4 = 8 MHz
Timer 1Prescalar = Timer1 clock prescaler selected in T1CON register = 1:8 = 8
CCPRx is the captured value of Timer1 at falling edge of fsignal
fsignal is input signal frequency of the pick-up signal
60 scalar value is multiplied to convert Hz to RPM, RPMEngine = fsignal * 60
Rev. 10-000245A
ATxRES 1/21/2015
15
Set PERIF
SSEL Divide by Period
ATxRES+1 Counter
R R
ATx_perclk
PRP
LC4_out 111
PREC 15
LC3_out 110 ATxMISS
LC2_out 101
+ Divide by 2
LC1_out 100 Sync ATxsig LD ATxPER Difference
ZCD1_out 011 (2 Clocks)
-
15
C2OUT_sync 010 1 0 APMOD
C1OUT_sync 001
PPS 000 MPP ATx_missedpulse
Comparator
ATxINPPS
PHP
PS 1 Clock
CS Delay
ATx_phsclk
HFINTOSC (16 MHz) 1 Divide by Phase
Prescaler ATxclk
FOSC 0 ATxPER+1 Counter
R R Set PHSIF
ATxclkcc
10
To Capture/
Compare
Instruction
LD ATxPHS
Clock
Period
fsignal
AT Phase Pulse
ATxPER
AT Period Pulse
360°
ATxPHS
0°
SINGLE-PULSE MODE
In Single-Pulse mode, every external pulse is a period pulse which determines one complete cycle or rotation of 0 to 2π
(360), as shown in Figure 7. The phase pulse output depends on the previous period value, since the period register
(ATxPER) only updates once every period.
The AT uses the clocks in Equation 2 for the period and phase counter.
EQUATION 2: AT CLOCKS
AT clock
AT = -------------------------------
periodClock ATxRES + 1
AT clock
AT = -------------------------------
phaseClock ATxPER + 1
The instantaneous values of ATxPER and ATxPHS in Single-Pulse mode can be calculated as shown in Equation 3.
EQUATION 3: ATxPER AND ATxPHS IN SINGLE-PULSE MODE
AT periodClock ATxCLK
ATxPER = ---------------------------------------- = -----------------------------------------------------------------------------------------------------
f AT ATxRES + 1 f
signal Prescalar signal
ATphaseClock ATxCLK
ATxPHS = -------------------------------------- = -----------------------------------------------------------------------------------------------------
f AT ATxPER + 1 f
signal Prescalar signal
ATxPHS = ATxRES = AR – 1
max
Where: ATxPHSmax is maximum value of the AT phase register.
ATxRES is value configured in the AT angle resolution register.
AR is the desired angular resolution.
32000000
ATxPER = ----------------------------------------------- = 355.55555555556 355 and
1 359 + 1 250
32000000
ATxPHS = ----------------------------------------------- = 359.55 360
1 355 + 1 250
MULTI-PULSE MODE
In AT Multi-Pulse mode, the input signal contains more than one pulse per cycle, as shown in Figure 9 as fsignal.
Rev. 10-000246A
ATxRES 1/21/2015
15
PREC ATx_perclk
LC4_out 111 PRP
15
LC3_out 110 ATx_missedpulse ATxMISS
ATxperiod
LC2_out 101
+ Divide by 2
LC1_out 100 Missing ATxsig
ATx_in
Pulse Period LD ATxPER Difference
ZCD1_out 011 Trigger -
15
C2OUT_sync 010 1 0 APMOD
C1OUT_sync 001
PPS 000 MPP ATx_missedpulse
Comparator
ATxINPPS
PHP
PS 1 Clock
CS Delay
ATx_phsclk
HFINTOSC (16 MHz) 1 ATxclk Divide by Phase
Prescaler
FOSC 0 ATxPER+1 Counter
R R Set PHSIF
ATxclkcc
10
To Capture/
Compare
Instruction
LD ATxPHS
Clock
Period
fsignal
AT Phase Pulse
AT Missing Pulse
AT Period Pulse
ATxPER
360°
ATxPHS
0°
To determine the period of input signal, the signal must Since the ATxPER value resets every external pulse
have at least one missing pulse. As indicated in except for the pulse after the missing pulse, the ATx-
Figure 9, there are five signal pulses with one missing RES should be chosen so that ATxPHS should not
pulse which makes it six pulses per period. A missing cross the maximum count of 1024 (10-bit register which
pulse is generated by the AT when no pulse is detected is 210).
after the fifth one. After the missing pulse, the first rising A Multi-Pulse mode example, Example 2, shows
edge on fsignal gives the AT period pulse output. Hence, choosing the resolution register (ATxRES) value for the
the missing pulse and the period pulse have exactly the required angular resolution (AR).
same length. The ATxPER register updates on every
rising edge of the external pulse, except for the pulse The instantaneous values of period and phase regis-
immediately following the missing pulse. This helps ters in Multi-Pulse mode can be given as shown in
ATxPHS to correct itself according to ATxPER after Equation 5.
every rising edge in order to output phase pulses
correctly within the same period.
ATxCLK
ATxPER = --------------------------------------------------------------------------------------------------
AT f ATxRES + 1
Prescalar pulse
ATxCLK
ATxPHS = -------------------------------------------------------------------------------------------------------------------------
AT f ATxPER + 1
Prescalar Mis sin gPulse
fpulse
ATxPHS = ATxRES -------------------------------------
max f mis sin gPulse
As a result, the value of ATxRES will be different for the same angular division or angular resolution (AR) in the Multi-
Pulse mode compared to the Single-Pulse mode. See Equation 7.
Using the above value of ATxRES and Equation 5, the values of ATxPER and ATxPHS can be calculated as indicated
in Example 2.
250 360
ATxRES = 360 ------------ – 1 = --------- – 1 = 36 – 1 = 35
2500 10
32000000
ATxPER = ----------------------------------------------- = 355.55555555556 355
1 2500 35 + 1
32000000
ATxPHS = ----------------------------------------------- = 35.955 35
1 250 355 + 1
Spark
200-400V Capacitor Plug
DC-DC HV Supply
12V Battery Converter SCR
Ignition
Coil
PWM
SCR Gate
Control
CWG I/O
Angular Timer
Capture
+
Phase
Pick-up signal Signal Compare
from pulser coil Conditioning - CLC AT
Input ATxCCy
AT Period Pulse
Firing Angle
SMT SMTxCPR
CDI LOGIC
Thermistor
ADC Map RPM
Throttle Selection Calculation
RPM
Firing Angle
Calculation
Math Accelerator
PIC16F161x MCU
RPM Calculation
The RPM of the engine can be calculated from the
external signal frequency fsignal as shown in
Equation 8.
TDC
+5to15V +ve
Period
Advance
pulse
Pick-up Signal
Pulser output -ve
Reference
-5to15V pulse
Input signals +5V
to p_PIP
MCU After
signal +5V
n_PIP
conditioning
AT Period Pulse
SMTxCLK
fsignal = ------------------------------------------------------------------------
SMT Prescalar SMTxCPR
SMTxCLK
RPM = ------------------------------------------------------------------------ 60
Engine SMT SMTxCPR
Prescalar
Where: SMTxCLK = clock input for SMT using SMTxCLK register= Fosc = 32 MHz.
SMTPrescalar = SMT clock prescaler selected in SMTxCON0 = 1:8 = 8.
SMTxCPR is captured value of SMTxTMR at window input event.
fsignal is input signal frequency to AT and SMT.
60 scalar value is multiplied to convert Hz to RPM, RPMEngine = fsignal * 60.
y 2 – y1
y = y + x – x -----------------
1 1 x –x
2 1
Where: y is the instantaneous value of the firing angle to be calculated, which is in between y1 and y2.
x is the instantaneous value of engine RPM which is known and in between x1 and x2.
(x1, y1) and (x2, y2) are the successive points in the graph between which a line is drawn these are
shown as row 1 and row 2 in the firing map table, respectively.
x1 and x2 represent values of Engine RPM of two endpoints. y1 and y2 represent the values of the
firing angle of two endpoints of a straight line curve.
1 1
FOM = 100 --------------- = 100 ------- = 500
Error 0.2
ATxCLK 32000000
----------------------------------------
ATxRES = -------------------------------------------------------------------------------------------------------------- – 1 = 1 500 166.66- – 1 = 383
max AT
Prescalar
ATxPER f
min signal_max
ATxCLK 32000000
ATxPER = ------------------------------------------------------------------------------------------------------------------ = ----------------------------------------- = 533.33
AT Prescalar ATxRES + 1 fsignal_max 1 360 166.66
Suppose ATxCLK = 32 MHz, ATxRES = 60, ATxPER max = 32767 (15-bit counter), hence fmin is calculated as
shown below:
ATxCLK
f min = -------------------------------------------------------------------------------------------------------------------
AT Prescaler ATxRES + 1 ATxPERmax
As a result, for the case above with ATPrescalar = 1, fmin is 16.27 Hz or 976 RPM.
To include lower RPM, if ATxCLK = 16 MHz and ATPrescalar = 8 are selected, the value will be calculated as
follows:
16000000
f min = ------------------------------------ = 1.017 Hz 60 RPM
8 60 32767
SCR/IGBT FIRING
The calculated firing angle is loaded into the AT com-
pare register. When the value in the compare register
matches the AT phase counter, a compare interrupt is
generated and IGBT or SCR is fired, as shown in
Figure 13. In case of IGBT, another compare register is
used to switch off the firing.
TDC
+5to15V +ve
Period
Advance
pulse
Pick-up Signal
Pulser output -ve
Reference
-5to15V pulse
AT Period Pulse
360°
ATxPHS
Phase Counter
0°
Advance Angle ΘA
FIRMWARE
Firmware flowchart is shown in Figure 14.
Start
Initialize
NO
SMT1 Int? & ADC Int? & AT period Int? NO AT1CC1 Int? NO AT1CC2 Int?
NO NO FAU = 1? NO
FAU = 3? FAU = 2? & FAU = 0?
NO
YES YES
Y ES YES YES YES
YES
Calculate RPM Select Firing Map Ignition coil Ignition coil
from SMT timer Mode = Mode = using Temperature Set Switch ON Switch OFF
NO
Thermister? Throttle? and Throttle AT1CC1 = On Firing Angle
AT1CC2 = Off Firing Angle
Set FAU = 2
YES YES
Get ON and OFF
Convert ADC to Convert ADC Set FAU = 3
firing angles
Temperature to Throttle
from MAP
Set FAU = 1
Note 1: FAU is a firing angle update variable which keeps track of the firing angle calculation step number.
When it is done, update the ON and OFF firing angles.
2: The ADC will sample the engine temperature and the throttle position for each AT period pulse. These
will be taken as current parameter values, and a firing map is selected based on these values.
Table 4 summarizes the performance comparisons of the two methods for CDI implementation.
CONCLUSION
CDI systems can be implemented using PIC16F micro-
controllers either through the conventional method or
by using CIPs, such as AT, CLC, SMT, Math Accelera-
tor, and CWG. However, using the CIPs greatly
improves the overall performance and implementation
of CDI.
The AT successfully divides the input signal to angular
division without CPU intervention, which helps to boost
performance by removing the need for firing angle con-
version from degree to equivalent time. These angular
divisions are also very accurate and constant through-
out the input signal range. As shown in the comparison
tables (Table 2 through Table 4) of this document, the
performance of the CDI system can be greatly
enhanced using the AT, with significant CPU bandwidth
remaining for other calculations. In addition, with the
use of the Math Accelerator, the calculations are now
more accurate and faster. The SMT with its inherent
high-bit resolution helps in tracking low engine RPM
and taking necessary action, without the need for large
computations. Albeit being outside the scope of this
application note, a similar implementation technique
can be extended to other systems, such as inductive
discharge ignition (IDI), that use the same CIPs.
ATxCCy = –
y = y1 + x – x 1 m
Where: m = (y2–y1)/(x2–x1).
m is the slope of straight line between
(x1, y1) and (x2, y2).
RPM 10000
f = ------------- = --------------- = 166.666667 167
60 60
f 167
f = -------------- 32767 = --------- 32767 = 10687.21461 10687
Q15 f MAX 511
25
= ---------------- 32767 = ------ 32767 = 13002.77778 13002
Q15 MAX 63
Applying the above formulas, Table 1 can be written as Table B-1 below.
EQUATION B-2:
y1 + x –x m
Q15 Q15 1 Q15 MAX
y = -------------------------------------------------------------------------------------------------------
Q15
MAX
By using the values given in Example 3 and performing Q15 calculations, the following results are obtained.
RPM 1915
f = ------------- = ------------ = 31.91666667 32
60 60
f 32
f Q15 = -------------- 32767 = --------- 32767 = 2046.6 2046
f MAX 511
10
Q15 = ---------------- 32767 = ------ 32767 = 5201.111111 5201
MAX 63
Hence, from Table B-1 and the above calculated values, the results are shown here:
y1Q15 = 5201, xQ15 = 2046, x1Q15 = 1924, m = 37, Q15 MAX = 32767. Using Equation B-1 y can be calculated as
shown:
Engine = 2 f signal
V = r
Engine Engine
Where: VEngine is the linear velocity or speed of
the engine piston in meters/second
r is the radius which is equal to half of the
distance between the TDC and BDC
position of the piston in meters
V Automobile = V Engine G
To install MCC, go to Tools Plugins Available Plugins MPLAB X Code Configurator Install. To start and use
the MCC after installation, go to Tools Embedded MPLAB Code Configurator.
After all the settings are selected in MCC, click the Generate Code button to generate the peripheral code, and create
a header and a C file for every peripheral separately. Figure E-2 shows the files created and arranged under the MCC
Generated Files folder for CDI implementation using AT. The programmer should add the code wherever it is required
in these files.
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
QUALITY MANAGEMENT SYSTEM Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
CERTIFIED BY DNV Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
== ISO/TS 16949 == devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.