CDI reprogramming
Version 7 separate the firmware in the ROM (firmware is protected)
from the ignition timing in the EPROM (advance map is not protected).
The ignition timing is stored in the internal data EEPROM meaning that you can change the advance curve yourself as often as you want…
Just draw the new curve in the excel sheet, program values in the PIC’s EEPROM using either the ICSP connector or a classic PIC programmer then restart the CDI. That’s all done!
Draw the advance curve
- Use the Excel sheet (in download section above) to define the curve for your bike:
-
- Only change the yellow cells.
- Enter the Pickup Position (which is slightly more than the max timing advance your bike uses) in cell F5.
- Select the number or cylinders (cell M24) and the number of strokes (cell M25)
(select 2 if the engine is a 4 strokes with wasted spark)
The pulse coming from the PIC that trigger the SCR can be adjusted from 500us until 5ms or in “AUTO” mode (cell M29).
Except for specials needs or lazy SCR, leave the default value of 0.5ms. - Select the maximum RPM by changing the variable TIMER1 in cell B9.
As TIMER1 has only 94 values, if you set the highest RPM to 29297RPM (meaning TIMER1mini = 2), the maximum value of TIMER1 will be 96 (94+2) therefore the minimum RPM still adjustable will be 610RPM. - Play with prescaler value in cell M26 AND with TIMER1 value (cell B9) until the excel sheet displays the RPM range you want, and the advance values you need don’t give “Out of range” errors.
- Set the optional rev-limiter in cell M32. This RPM limit is activated by Jumper JP2.
- To manipulate the points of the curve, type in the advance you want for each RPM in column F.
If you run into “Out of range” error messages column K, try to:
- Change the advance values column F
- Change the RPM range cell B9
- Use another prescaler value cell M26
- Use another step value in cell J5
Play with those steps above until the curve fit in the excel sheet.
Any Excel errors will result in a faulty HEX file that will not work !
When done:
-
- Adjust the advance for low RPM with the help of the multiplier value in cell I2 of the other tab named “advance_at_lowRPM“.
Set this for half of the advance at idle given for your bike, so if advance is 12° then set this around 6°.
This will allow the 12° pickup to be in control and the PIC will take over at the rpm you have 12° set in bottom of “Advance_curve” tab.If the maximum RPM become too low, raise it with cell B9 and so on…
Play with prescaler value (cell M26) and multiplier value (cell I2) to change the low RPM range.
(In this example you can slightly adjust advance between 480 and 1116RPM):
- Adjust the advance for low RPM with the help of the multiplier value in cell I2 of the other tab named “advance_at_lowRPM“.
-
- Once your curve is drawn, there are 2 tables available: Intel 8Hex and Raw data formats.
We will use the Intel 8Hex format.
(Raw = only the values without CRC and addresses) - Save the EEprom data that contain the advance curve into a text file:
- Create a empty file named Eg: c:\eeprom.txt
- Select the Intel 8Hex data [cells O18 to O35] from the excel sheet, right clic | copy
- Paste the content into c:\eeprom.txt, save and close the file.
- Rename c:\eeprom.txt into c:\eeprom.HEX
-
- Launch ICPROG 1.06c
- If you find yourself facing the error message: “Privileged instruction”
– clic OK then Settings › Options › Misc › Enable NT/2000/XP Driver
– then Settings › Hardware › select Windows API instead of Direct I/O
– then restart Icprog as administrator.
– At the question “Ic-prog driver is not installed. Do you want to install this driver now?” clic Yes
– The driver icprog.sys must be in the same directory as icprog.exe
– Anyway this error will not prevent you to build the file you need… - Even if you use another software to program PICs, use Icprog to build a unique HEX file including the firmware AND the Eeprom data.
- Select 16F628A on the upper right of ICPROG screen, “File”, Open File and load my FIRMWARE: ACCDI_16F628_V79RxCx.HEX
(This firmware doesn’t contain any curve inside.) - “Open Data file“ then load your file c:\eeprom.HEX, which is the Intel 8Hex eeprom data file you’ve just created with excel.
(Your eeprom data doesn’t contain any code, it’s only the advance curve)- or simply type in the 95 values of the RAW data [cells Q19 to Q34] in the ICPROG Eeprom Data screen, quite bothersome…
- Now Icprog windows display both my firmware + your eeprom data (=curve) ready to program:
- Once your curve is drawn, there are 2 tables available: Intel 8Hex and Raw data formats.
- Pay attention to:
Device type 16F628A Oscillator IntRC I/O Configuration word Icprog 3F30 for v7.9R19C0FreeTrial Firmware Checksum in Icprog 1.06 and Pickit3 v3.10 C5F5 for v7.9R17C0FreeTrial * (Checksum of the firmware alone, without eeprom data)
- “Save the total .HEX file that now contains firmware + eeprom data:
File”, “Save File As…“ : c:\firmware_and_eeprom.HEX to use with your own programmer… - Now you are ready to burn the PIC with ICPROG, MPLAB, PicKit3.10, WinPic800, others…
PROGRAMMING
- Burn the chip with a serial or USB programmer then insert it on the board:
- or use the ICSP connector to program the chip in situ with PicKit:
(More info on ICSP in comment section)
Some guys seem to run into issues with Pickit3, here are some info that could help them to Troubleshoot Pickit3
Programming check
-
- Always verify the PIC after programming !
- Verify button can read the EEPROM Data, but gives a “Notification of Program Memory failed at 0x00000”
because the Program Memory is protected. It’s normal, don’t worry about it. - Read the PIC 16F628A with your programmer and save the result in a text file.
- Open the text file with your favorite editor, you will see the program memory zone where the code is standing.
- You will see the eeprom data zoom where the advance curve is standing on line 258.
- Compare the reading with your original file c:\firmware_and_eeprom.hex you used to burn the PIC.
- Checkout if the eeprom is populated, otherwise the CDI will not work !
(Example of a working file: dump_pic.doc)