Download MegaCoiler - DIYAutoTune.com

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Spectral density wikipedia , lookup

Heterodyne wikipedia , lookup

Pulse-width modulation wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Dynamic range compression wikipedia , lookup

Oscilloscope history wikipedia , lookup

Analog-to-digital converter wikipedia , lookup

Rectiverter wikipedia , lookup

Spark-gap transmitter wikipedia , lookup

Ignition system wikipedia , lookup

Opto-isolator wikipedia , lookup

Transcript
www.EFI.lv
MegaCoiler
User's Manual
(c) EFI.lv 2005, V2.0 rev A
Table of contents
INTRODUCTION.............................................................................................................................................................. 3
APPLICATION .................................................................................................................................................................... 3
FUNCTIONS ....................................................................................................................................................................... 4
HISTORY ........................................................................................................................................................................... 4
DESCRIPTION .................................................................................................................................................................. 6
HARDWARE ....................................................................................................................................................................... 6
MegaCoiler inputs ........................................................................................................................................................ 6
MegaCoiler outputs ...................................................................................................................................................... 7
Coil power modules ..................................................................................................................................................... 7
Prototype area............................................................................................................................................................... 7
Connections to the PCB ............................................................................................................................................... 8
Mounting in the Megasquirt case ................................................................................................................................. 8
PCB dimensions ........................................................................................................................................................... 9
SOFTWARE ...................................................................................................................................................................... 10
Signal decoding with 36-1 teeth timing wheel ........................................................................................................... 10
Signal decoding for Audi with 135 teeth timing wheel.............................................................................................. 12
Error correction .......................................................................................................................................................... 14
Smart Dwell mode...................................................................................................................................................... 14
Code execution flow................................................................................................................................................... 15
Files in the distribution............................................................................................................................................... 16
PARAMETER CONFIGURATION .............................................................................................................................. 17
WORKING WITH THE WIZARD .......................................................................................................................................... 17
Welcome dialog ......................................................................................................................................................... 17
Configuration dialogs for a V8 engine with 36-1 teeth wheel.................................................................................... 18
Finish dialog............................................................................................................................................................... 26
MEGASQUIRT SETTINGS .................................................................................................................................................. 26
CONFIGURATION EXAMPLES ........................................................................................................................................... 26
PROGRAMMING THE PIC .......................................................................................................................................... 27
USING THE BOOTLOADER ............................................................................................................................................... 27
Programming process................................................................................................................................................. 28
USING A PROGRAMMER ................................................................................................................................................... 28
2
Introduction
MegaCoiler is an accessory signal processing circuit that translates complex engine position
sensor inputs for and adds coil on plug functionality (outputs) to EFI computers using simple
(single) RPM input and coil output. Initially MegaCoiler was created to supplement the
Megasquirt ECU (MS), but it can be used with any ECU that utilizes similar triggering signals.
MegaCoiler uses complex sensor signals to create a simple trigger output that is used by the
ECU as a base reference for engine speed and position. MegaCoiler also keeps track of the firing
cylinder and distributes the ECU's spark signal to the appropriate coil. If Smart Dwell mode is
enabled, the coil dwell signals are also calculated and created by MegaCoiler. Otherwise, the
ECU's dwell control is used.
Application
MegaCoiler’s function set and flexible configuration parameters allow it to be used with various
OEM timing wheel setups and ignition systems. MegaCoiler supports applications with missing
tooth wheels, dedicated crank Zero signals, and cam wheel signals. Special applications are also
supported, such as the Subaru 6/7 tooth wheel setup.
MegaCoiler is meant to be used with multi-tooth wheels. If a dedicated crank Zero signal is
used, there should be at least two teeth for every cylinder. For missing tooth wheels, the
recommended minimum tooth count is 20 for each missing tooth. For example, MegaCoiler
supports 36-1, 60-2, and similar wheels, but 4-1 will not work.
MegaCoiler can work with every Megasquirt version known to date - Megasquirt'n'Spark,
Megasquirt'n'Spark-Extra, Megasquirt-II, and (if the decoding function only is desired) the
original Megasquirt code.
Some application examples:
• Audi 5 cylinder engines with 135 tooth timing wheel, dedicated crank Zero position (both
on flywheel starter gear), and engine cycle (camshaft) signals.
•
Engines with 36-1 and 60-2 timing wheels, either direct fire or wasted spark ignition
systems.
•
Subaru 6 tooth crank and 7 tooth cam timing wheels, either direct fire, or wasted spark
ignition systems.
•
Subaru MY01 and newer 36-2-2-2 tooth crank and 2 tooth cam timing wheels, either
direct fire, or wasted spark ignition systems.
3
Functions
Wasted-spark ignition systems
Supported
Direct fire (COP, CNP) ignition systems
Supported
Distributor ignition systems
Supported1
Coil outputs supported
2-12
Max current for coil and trigger outputs
25mA
Max current for error indication output
650mA
Maximum wheel teeth supported
255 for each coil output
Input conditioners
2 for VR signals
1 for Hall signal
Dedicated crank zero position signal
Supported
Missing tooth timing wheel
Supported2
Special timing signal decoders
Subaru 6 teeth crank and 7 teeth cam setup
Dwell overlap
Supported with Smart Dwell mode3
Serial communication
TTL-level reusing 2 cylinder outputs
1
Wheel decoder only.
2
Only missing tooth wheels with multiple teeth are supported. The space between two adjacent teeth
should not exceed 20-30° of wheel rotation angle to avoid timer overflow at cranking RPMs. A 36-2
wheel might work, but 4-1 won't.
3
Smart Dwell mode is not compatible with ECU features that change the spark advance very rapidly
or drop entire spark events – Launch Control, rev limiter with spark cut, etc. See Smart Dwell section
for more info.
History
MegaCoiler was born when we started installing Megasquirt on more and more Audi 5 cylinder
turbo cars at our shop. Since the timing wheel in the distributor of these cars has only one
window, the timing wheel has to be changed for standard Megasquirt use to one with 5
windows, which is quite difficult and expensive. Rather than make this inconvenient change to
each car, it was decided to create a decoder board which could use the OEM signals, produce a
trigger signal for Megasquirt, and distribute spark signal to coil-on-plug coils. The very first time
such a system was used on a car was in April 2005. Since then it has been very successfully
installed on tens of cars and new features have been added to support more OEM setups,
correct tooth errors, indicate problems, etc.
The MegaCoiler hardware was designed to introduce as little delay as possible to the signals.
The initial design had some drawbacks; Coil dwell could occur only while the current cylinder
was active, more ignition advance shortened available dwell time even more possibly causing
4
coil charging problems for engines with 6 and more cylinders at higher RPMs, and coil output
count was limited to 6.
Considering these drawbacks as well as the intentions to publish the project, major
modifications were done to the hardware and code to add more flexibility and simplify the
configuration and installation. Thus, the version 2.0 was introduced.
5
Description
Hardware
The MegaCoiler hardware is composed of input signal conditioners, a PIC18F2480
microcontroller, output circuits, and an indication LED (Heartbeat).
MegaCoiler inputs
Designator
Description
X1
Input for the variable reluctance (VR) sensor. It is used to count the teeth
of the main timing wheel. The PIC triggers on the falling edge.
X2
Input for the variable reluctance (VR) sensor. It can be used to either sense
the dedicated 'Zero' position tooth of the main trigger wheel, or for the
'Cyl1 SYNC' signal of a camshaft sensor. PIC triggers on the falling edge.
X3
Input for Hall sensor. It is used for Cyl1 SYNC' signal. PIC triggers on the
falling edge.
X4
Spark signal input. It is connected to the ECU spark output. Spark is at the
falling edge.
+12V
Input for the onboard voltage for reference. It is used in the Smart Dwell
mode to compensate the coil dwell time.
+5V
MegaCoiler power supply.
GND
MegaCoiler ground.
6
MegaCoiler outputs
Designator
Description
X5
Trigger signal for the ECU. Signal timing and length are determined by the
configuration parameters.
X6
Error indication output. It is amplified by a transistor and provides max
current of 600mA. Can be connected directly to a 4W incandescent bulb.
Y1-Y12
Y9-Y10, CAN
Y11-Y12,
Serial
D4
Coil signal outputs. Max current 25mA.
Outputs for CAN protocol. Not implemented.
Outputs for Serial protocol. They are used for RS232 communications when
loading the embedded code using a bootloader. A RS232 (MAX232 or
similar) chip is needed to provide TTL level communications of the PIC.
Indication LED on the PCB. At this time, it is used to indicate that the
program in PIC is running.
Coil power modules
Most 5 volt logical trigger (3 pin) coil modules fire when the input current is around 2-3mA.
Typically the input impedance of these coils is high enough that the firing current does not
exceed 5-6mA at 5V. Since the maximum output current of the PIC outputs is 20mA, the
current limiting resistors are not needed in most cases. If they are, it is convenient to mount
them in the prototype area of the PCB.
Prototype area
The prototype area of the PCB is suited to mount any additional circuits to aid in the installation – CAN interface IC's, PIC programmer, additional I/O circuits, etc. Along the sides of the
area is mounting space for up to 8 power transistors in TO-220 packages.
WARNING! It is not recommended to mount VB921 (or any other coil power chips) inside the
ECU case. Such installations are NOT supported. Even OEMs very rarely mount igniters inside
the ECU – the nearer they are to the coils, the less EMI is produced and fewer problems occur
in the sensitive circuits of the car.
The prototype area can easily be separated from the rest of the board. This may be useful when
mounting MegaCoiler outside of the Megasquirt case and the prototype area is not needed. The
separation should be done very carefully to save the MegaCoiler circuit tracks. The easiest way
to do this is to fasten the board by the prototype area in a vise and carefully saw the board
along the perforation line using a hacksaw.
7
Connections to the PCB
Mounting in the Megasquirt case
The MegaCoiler board fits in an empty slot of the MS case. The board should be fastened to the
case, for example, using hot glue to avoid vibration damage and electrical shorts.
You MUST shield the VR input signal wires to avoid interference. It is convenient to connect the
shields to MegaCoiler's power supply ground pins near the signal input pins. The shield should
be grounded only at one end.
The Megasquirt DB37 connector may be short of free pins to bring the coil signals out of the
case. In this situation, mount another connector in the case to provide sufficient outputs. The
coils should be connected with output Y1 to the 1st coil, Y2 to the second, and so on. The actual
firing order is set using the code parameters.
The MegaCoiler error indication output is amplified by a transistor, allowing a 4W incandescent
bulb to be connected directly to it. Connection options are shown in the picture below.
8
PCB dimensions
9
Software
Signal decoding with 36-1 teeth timing wheel
Let's look at how MegaCoiler decodes the 36-1 wheel setups. The signal diagrams and
descriptions below are for a 4 cylinder engine with direct fire ignition. This is very typical setup
for many OEM cars.
Typically the 36 tooth wheel is missing one tooth right after cylinder 1 TDC. MegaCoiler detects
it by comparing the time between every tooth – if it is 1.5 times longer than expected, the
missing tooth is detected and the 'Zero' flag is set. However, to fully synchronize to the position
of a 4-stroke engine, a camshaft position signal is required. In the code it is called 'Cyl1 SYNC',
and it typically arrives somewhere during the compression stroke of cylinder 1 before the 'Zero'
signal is received.
Note. For wasted spark ignition setup, the 'Cyl1 SYNC' flag is active at all times. This means
that synchronization is acquired as soon as the 'Zero' signal arrives.
Synchronization is acquired on the next tooth after the 'Zero' and 'Cyl1 SYNC' flags are both
set, and a tooth counter for the 1st cylinder is started. If the 'Zero' signal arrives without the
'Cyl1 SYNC' set, it is ignored.
The tooth counter keeps incrementing until its value is bigger than the tooth count for one
cylinder. Then the counter is set to 1 again, and the next cylinder is set active. For example, in
the case of 36-1 the duration for one cylinder is 18 teeth.
Note. From here on the term 'active cylinder' refers to the one from MegaCoiler's point of view
rather than the cylinder’s number in the engine. The cylinders in the code are activated
sequentially – beginning with the 1st, then the 2nd, and so on until the last for the particular
configuration is reached, then 1st again. Actual firing order of the engine typically differs from
this sequential order, and it is controlled by the MegaCoiler output configuration parameters.
The diagrams show that the 1st cylinder output is actually activated after the 1st cylinder of the
engine has already started its working stroke. This means that the firing order in the output
configuration dialog has to be shifted by one. For example, if a typical firing order for 4 cylinder
engines is 1-3-4-2, then the outputs should be configured like this:
MegaCoiler cylinder
Ignition coil
Cylinder1
Coil #3 (Y3 output)
Cylinder2
Coil #4 (Y4 output)
Cylinder3
Coil #2 (Y2 output)
Cylinder4
Coil #1 (Y1 output)
The trigger signal for the ECU is formed by setting tooth numbers at which the signal should
activate and deactivate. Following MSnS recommendations, the trigger signal should activate at
least 5° before the maximum ignition advance. You can achieve more accurate crank timing by
setting the trigger signal to deactivate 5-10° BTDC with 'Cranking timing' set to 'Trigger Return'
mode in Megatune. In the diagrams below, the trigger is activated on tooth 10 (70° BTDC) and
deactivated on tooth 16 (10° BTDC).
Each incoming coil dwell and spark signal is copied to the active cylinder output. The entire
signal must arrive while it’s corresponding cylinder is active. If a dwell or a spark signal is
active during the change of cylinders, the output signals become corrupted. This is more likely
to occur with 6 or more cylinder engines (where the time between cylinders is too short for
complete dwell to take place). Smart Dwell mode must be used for these engines.
10
Signal diagrams for engine with 36-1 timing wheel, 4 cylinders, and direct fire ignition
Signal decoding for Audi with 135 teeth timing wheel
Now, let's look at how the OEM signals for an Audi 5-cylinder turbo setup are decoded. The Audi
setup has a 135 tooth main timing wheel (with no missing teeth), a dedicated sensor for
reading a Zero pin on the crankshaft, and a single window Hall sensor in the distributor
(powered by the camshaft).
The 'Zero' signal arrives at 62° BTDC. In the default configuration, MegaCoiler would start the
tooth counter for the 1st cylinder here, but 62° is not enough time to charge the coils at higher
engine speeds. This means that we need to shift the cylinder activation point to a better
location to allow the coil to begin charging earlier, which can be done by setting the offset
parameter. The offset parameter determines at which tooth after the 'Zero' signal the 1st
cylinder is activated. For the Audi setup, the most convenient place is 26 teeth after the 'Zero'
pin. Note that the cylinder change occurs approx 8° ATDC providing a timing reserve to tune
features that require retard such as Launch Control.
Since the offset parameter can only be positive, the coil outputs have to be shifted by one
position. The firing order for Audi 5-cylinder engines is 1-2-4-5-3 and the outputs should be
configured as following:
MegaCoiler cylinder
Ignition coil
Cylinder1
Coil #2 (Y2 output)
Cylinder2
Coil #4 (Y4 output)
Cylinder3
Coil #5 (Y5 output)
Cylinder4
Coil #3 (Y3 output)
Cylinder5
Coil #1 (Y1 output)
Signal diagrams for Audi 5-cylinder engine with dedicated crankshaft 'Zero' signal
Error correction
Interference and input signal corruption can introduce tooth detection errors, which in turn may
cause the code state to not reflect the engine’s actual position. If these errors are not detected
and corrected, they can add up and change the overall spark position considerably, which can
cause damage to the engine (especially if it uses forced air induction).
An error is detected when 'Zero' and/or 'Cyl1 SYNC' signals arrive at unexpected positions.
MegaCoiler has the following error handling modes:
Error handling mode
Description
Resynchronize
Try to resynchronize the code state with engine state after an
error is detected and while the operation continues. If the error
is very big (many teeth), the output signals could be corrupted
for a given engine cycle. Nevertheless, this is the recommended
option for most installs. Errors are indicated using the error
output (X6).
Reset
Completely reset the code state and try to resynchronize again.
Ignition and trigger outputs are reset and are not fired after an
error. Errors are indicated using the error output (X6).
Ignore
After synchronization to the timing wheel is acquired, any
subsequent inconsistencies of the signals are ignored. The engine
could run with the wheel signal alone, but it won't start again.
MegaCoiler has a dedicated error indication output which can be connected directly to a 'Check
Engine' bulb in your dash. To help detect repeating errors, there is a mode available that blinks
the error indicator every time an error is detected.
Smart Dwell mode
The duration of one cylinder on engines with fewer cylinders is sufficient to charge the coil and
apply ignition advance. For high revving 6 cylinder and especially 8 cylinder or larger engines,
however, that time is too short. In these cases, the dwell signal has to be activated for the next
cylinder while the current one is still active. This is called dwell signal overlap.
Smart Dwell mode allows dwell signals to overlap. Since a spark signal from the ECU can not be
used for dwell in such a case (because the ECU has only one ouput line), it is calculated and
activated by the MegaCoiler itself.
•
Calculating the starting point and duration of the dwell signal
To calculate the starting point of the dwell signal, information is required about the dwell
duration and desired spark point. We know that dwell should start at 'dwell duration' before
the desired 'spark point', but since MegaCoiler has no information about the forthcoming
spark event, it tries to make an appropriate prediction using previous events. Dwell duration
is calculated using an internal table.
Let's look at the dwell calculations for the duration of two cylinders (see diagram below).
The number of outputs allowed to overlap is controlled by a 'Dwell Depth' parameter. This
also determines how far in advance the next spark point is predicted. The further in advance
the prediction occurs, the more prediction error is possible. It is recommended to keep the
'Dwell Depth' as small as possible to minimize this error.
At every spark event a new dwell timer DT is calculated and started. When it expires, the
dwell is started for respective cylinder. The DT is calculated like this:
DT = DwellDepth * T – D – DD,
where: DT – dwell timer, T – time between two subsequent sparks, D – dwell duration,
DD – dynamic dwell correction.
Dynamic dwell correction DD, which helps to predict the next spark event, is the difference
between the current and previous period between sparks:
DD = C * DwellDepth * (Tprev – Tcurr),
where C is a coefficient dependant on the accelerating/decelerating state of the engine. C is
set as a constant in the code.
•
Correction against the onboard voltage.
The time needed to charge a coil (dwell time, D) depends on the voltage applied to it. The
formula for required dwell is:
D = (-L/R) * Ln(1 - (R * I / U))
where L is the inductance of the coil, R is the resistance, I is the current, and U is the
system voltage. MegaCoiler measures the onboard voltage and uses a simplified version of
this formula to apply a correction to the running dwell duration.
•
Increasing dwell duration during cranking.
During cranking the crankshaft's angular speed may vary significantly. To compensate for
the spark timing errors in such a situation and because cranking does not occur long enough
for excessive dwell timing to overheat the coils, the dwell during cranking may be set
considerably longer than the running dwell. Setting it 2-3 times the running dwell should
suffice.
Important! Smart Dwell mode is not compatible with ECU features that change the ignition
timing very rapidly or drop entire spark events – i.e. Launch Control, rev-limiter with spark cut,
etc. This is because MegaCoiler tries to predict the next ignition event – something which is
virtually impossible to do if the input signal varies widely, such as in these cases.
Code execution flow
[To be prepared]
15
Files in the distribution
The most important files are listed in the table below:
Filename
Description
Wizard.exe
Configuration wizard
Wizard.ini
Settings file for the configuration wizard
MC.asm
MegaCoiler embedded code
MC.hex
Binary file for the programmer
MC.err
Compilation error messages
CodeCnfg.inc
Include file with the code configuration.
DwellTbl.inc
Include file with the dwell duration table.
MPASM.exe
Compiler
tinybldWin.exe
Bootloader GUI
tinybld.ini
Settings file for the bootloader GUI
16
Parameter configuration
Working with the wizard
In Megacoiler versions 1.x the configuration parameters were changed by editing the
'constants' section of the source file. This required substantial knowledge of the code as well as
some hand calculations. Starting with v2.0, a configuration wizard was introduced that
automatically calculates and checks these values, making the configuration much simpler and
less prone to error. Various templates are available to choose from when configuring a new
timing wheel setup, and any created configurations can be saved for future use.
When you finish the wizard, it generates the configuration include files 'CodeCnfg.inc' and
'DwellTbl.inc'. If the 'compile' checkbox is selected, the wizard will run the compiler to generate
the 'MC.hex' binary file as well.
Welcome dialog
The welcome dialog allows you to load either a template, or a previously saved configuration.
To delete an entry from the saved settings list, select it and press <BACKSPACE>.
17
Configuration dialogs for a V8 engine with 36-1 teeth wheel
•
Engine parameters.
'Number of cylinders' determines the number of outputs that will be used. If you are going
to use the wasted spark system, only half of the outputs will be used. Note that 4-stroke
engines with an odd cylinder count CAN NOT use the wasted spark system.
The Engine stroke selection is not used directly by the code, but is included to ease the
parameter setup. If '2-stroke' is selected, you cannot use the 'Cyl1 SYNC' signal.
•
Wheel and SYNC signals.
'Tooth Count' is the number of teeth on your timing wheel, either on the crankshaft or the
camshaft, including one count for each missing tooth.
The 'Cyl1 SYNC' signal can be decoded in the following ways:
Option
Description
Don't care - Wasted spark
Do not use the 'Cyl1 SYNC' signal – it's a wasted
spark system.
Use X3 Hall cam signal
(single-tooth)
The engine cycle is determined by the X3 Hall
signal input. There may be multiple teeth as long
as they all arrive between two 'Zero' signals with
no tooth before the next (third) 'Zero' signal.
Use X2 VR cam signal (single-tooth)
Same as above, except uses X2 VR signal input.
Subaru 7 tooth cam wheel, COP
Special decoder for Subarus with 7 tooth cam
wheel for direct ignition. Uses X2 VR signal input.
Subaru 7 tooth cam wheel,
Wasted spark
Special decoder for Subarus with 7 tooth cam
wheel for wasted spark. X2 VR signal input is still
used.
Note. The tooth count on the wheel should be compatible with other settings, i.e. tooth
count per cylinder must be a whole number, and less than 255. Tooth count per cylinder is
18
computed like this - if the 'Cyl1 SYNC' signal is used, the tooth count on the wheel is
multiplied by 2, and then it is divided by the cylinder count that you selected. Otherwise the
tooth count per cylinder is the total number of teeth on the timing wheel (crank aka wasted
spark or camshaft mounted) divided by the cylinder count.
•
Zero signal.
Note. This page is not shown when the Subaru special decoder is selected.
This and the offset parameter (next dialog) determine where the next cylinder is activated namely on the next tooth after the chosen zero position event plus offset.
Option
Description
Missing tooth
The missing tooth sets the 'Zero' flag. Enter the missing
tooth count to keep track of the timing wheel position.
Multiple Missing tooth groups
Multiple missing tooth groups are used for wheels like
36-2-2-2. The spacing of the MT groups should be
asymmetric, and the count of the missing teeth should
be the same in all groups. Zero is detected when the
current MT event is 'Multiple MT Zero' teeth after the
previous MT event. In the case of a Subaru WRX
36-2-2-2 wheel it may be set to either 1 (preferred),
13, or 16.
Use X2 VR signal (single-tooth)
'Zero' flag is set by the X2 VR sensor input.
19
•
Offset.
This is by how many teeth to offset the 1st tooth from the zero position - either the X2 Zero
signal, or Missing teeth/tooth occurrence.
This is most useful when Smart Dwell is not used and the dwell is controlled entirely by the
input signal X4 (aka Megasquirt spark output). You could think of it like a distributor that
you 'rotate', or offset, to provide more time for the dwell to take place. Since the offset can
be only a positive value, you may have to 'shift' the firing sequence of the outputs.
For example, on Audi 5 cylinder engines the Zero signal activates at 62 deg BTDC. 62 deg
does not allow enough time to charge the coil and apply an ignition advance at higher RPMs.
The solution is to set the offset to 26 teeth (appx 69 crank degrees) and set the 'Cylinder 1'
output to second firing coil, 'Cylinder 2' to third, and so on, with 'Cylinder 5' set to the 1st
firing coil. Doing this yields almost all of the 720/5 (144) deg window to charge the coil and
apply the advance.
Note. When offset is used together with a Missing tooth wheel, the trigger output signal
activation/deactivation points must be set very carefully to avoid setting them on the tooth
that's missing.
20
•
Trigger output.
In this dialog you set up how the trigger signal is formed. The trigger activation point
directly affects the 'Trigger Angle' parameter in the MSnS's spark setting dialog. If you set
the MSnS to spark at 'Trigger return', the deactivation point determines the spark moment
during cranking. Do not set to the tooth that is missing.
If you connect the Trigger output X5 directly to the Megasquirt CPU input pin, the signal
should be inverted.
21
•
Smart Dwell (1 of 3).
The Smart Dwell function provides fixed dwell time and allows the spark outputs to overlap
when charging. If Smart Dwell is not used, the dwell is controlled by the input signal (MS
spark output), and you may have to set up the Offset parameter for correct operation.
WARNING! The Smart dwell mode is not compatible with Megasquirt features that rapidly
change the spark signal - spark cut, launch control, etc. To use these features, switch off
the Smart dwell to use the dwell provided by Megasquirt.
Enter the estimated maximum RPM for your engine to calculate the recommended Dwell
depth (on the next screens).
•
Smart Dwell (2 of 3).
The running dwell is corrected against the onboard voltage - the lower the voltage, the
higher the dwell. The entered value is at 12V.
The Cranking dwell is used when RPMs are below the set threshold. Setting it 2-3 times the
running dwell value may help to avoid misfires caused by spark arriving earlier than
expected when cranking the engine.
22
•
Smart Dwell (3 of 3).
This determines how many outputs can be active (charging) at the same time, overlapping
each other. This value should be as small as possible to reduce the dwell start prediction
error. It is unlikely that a 4-cylinder engine will need a Dwell depth of more than 2, but
high-revving 8-cylinder and especially 12-cylinder engines may require the maximum, which
is 4.
The recommended value is calculated based on running dwell at 12V and estimated max
RPM.
•
Firing order.
The code fires 'Cylinder 1', then 'Cylinder 2', then 'Cylinder 3', and so on. If you wire Y1 to
the 1st coil, Y2 to the second, and so on, the firing sequence here should match the firing
order of the cylinders in your engine.
Depending on the previous settings and the timing signal setup, you may have to shift the
firing sequence to ensure correct operation.
23
•
Error handling.
An error is detected if the 'Zero' (X2 or Missing teeth) and/or 'Cylinder 1' (X3) signals arrive
at unexpected wheel positions, or are not received when they should be. You may choose to
detect, correct, or indicate such errors.
•
Error indication.
Check this if you want the error output (X6) to blink on every new error. This allows
detection of repeating errors and is particularly useful if the error output is connected to a
warning light in the dash.
Note. The blinking rate may not reflect the actual frequency of errors. Each state of the
output is made long enough to observe the blinking by naked eye.
The error output is amplified by a transistor, so it can be connected directly to a
incandescent bulb. To use a LED instead, you will need to wire a resistor in a series with it.
24
•
Other.
The heartbeat indicator (D4) blinks whenever the code is running. This can sometimes help
to troubleshoot problems. The heartbeat output (D4) is meant to be connected to a LED.
•
Notes.
Here you can save notes about your setup for future reference. If you have loaded the
settings from a template, here you will find the recommended Megasquirt settings.
25
Finish dialog
After pressing 'Finish', the .INC files are generated and, if selected, the settings are saved for
future use and the code is compiled. Remember to check the 'MC.err' file for any compile
errors.
Megasquirt settings
[To be prepared]
Configuration examples
[To be prepared]
26
Programming the PIC
Many of the MegaCoiler code functions and parameters are organized as compile-time conditionals – it makes the code very efficient because no clock cycles are wasted to check various
configuration conditions. At the same time, it means that the code has to be recompiled after
every configuration change. This is not a big drawback, however, because the configuration of
the MegaCoiler tends to be very static – once configured there is nothing more to tune.
There are two ways to update the embedded software, either by a serial interface bootloader,
or by using a PIC programmer. MegaCoiler is distributed with a bootloader already loaded in the
PIC.
Using the Bootloader
In the MegaCoiler project, a 3rd party bootloader is used which is called a 'Tiny PIC Bootloader'.
More information is available in the homepage:
http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm. The package contains:
•
Embedded bootloader software which runs on the PIC to receive new code via serial
interface and program it in the flash memory.
•
Programming GUI which reads the binary files and hardware configuration settings from
disk and sends them via serial interface to bootloader in the PIC.
The structure of the bootloader is shown in the picture below. After the PIC resets, the control
is given to the bootloader code which initializes the serial interface and awaits a special input
sequence for about 0.5s. If nothing is received, the control is passed to a user (in this case the
MegaCoiler) program. Otherwise, the bootloader receives the code and hardware configuration
options and saves them to the flash. When it's done, the control is passed to the freshly loaded
user program. The programming GUI prevents the bootloader code from overwriting itself.
There were some small changes made to the bootloader code to support the PIC18F2480. The
biggest drawback of the bootloader is a 0.5s delay when it waits for input before the actual
MegaCoiler code starts. The solution would be to change the bootloader code so that it uses the
H1 jumper on the PCB. This is not implemented yet, so for now if you want to avoid the delay,
you have to use a programmer to delete the bootloader and program the new code directly.
To make a RS232 connection between a computer and the MegaCoiler, a DB9 connector and a
signal leveling IC are also required. Since every Megasquirt already has them, we only have to
connect MegaCoiler pins Y11 and Y12 to the appropriate MS CPU socket pins (see below).
27
Programming process
To send a new binary file to the PIC using the bootloader, do the following:
1. MegaCoiler must be mounted in the Megasquirt case with the power wires connected. Do
not apply the power for now.
2. Pull the Megasquirt CPU out of its socket.
3. Connect two jumper wires from MegaCoiler pins to the MS CPU socket pins as follows:
Signal
MegaCoiler pin
MS CPU socket pin
RX
Y11
U1 13.
TX
Y12
U1 12.
4. Connect the computer to the Megasquirt DB9 connector using the same cable you use to
configure the Megasquirt.
5. Start 'tinybldWin.exe' from the MegaCoiler home directory, select the COM port and
check that other settings correspond to those in the picture below:
6. Push the 'Write Flash' button. The program is tries to connect to the PIC for a configured
amount of time (10 seconds). To change the time, select Options tab and change the
value of 'Search Delay'.
7. Immediately turn on the power to the Megasquirt box. The code should load very
quickly, and the Heartbeat LED should start to flash. If it does not load, switch the
power off, check the electrical connections, RS232 cable, and COM port settings, and try
starting from step 6 again.
8. Switch off the power to the Megasquirt.
9. Take off the jumper wires and push the Megasquirt CPU back in the socket.
10. Programming is finished.
Using a programmer
Using the programmer to load the PIC’s code is the most convenient method, allowing you to
avoid the bootloader delay on startup. Practically every Tait parallel port programmer can be
used with the PIC18F2480 if the socket pins are connected in the correct way. The one tested is
described here: http://www.bobblick.com/techref/projects/picprog/picprog.html, schematics
are here: http://www.bobblick.com/techref/projects/picprog/f84pgmsc.pdf.
Note. There are many designs on the Internet that describe a 'very simple serial PIC
programmer'. Most of them get the power from the serial port communication pins. This is why
these programmers do not work with some computers. If you're not sure about your computer,
we recommend you to not waste your time with these.
There is a program called 'WinPIC' that works very well with the Tait programmer and 18F2480
PIC. More information: http://people.freenet.de/dl4yhf/winpicpr.html.
28