RC Groups

RC Groups
    DIY Electronics
        Discussion Programmable Open Source CD Ignition PIC1840

#1 Nav_Aids Dec 03, 2012 12:25 AM

Programmable Open Source CD Ignition PIC1840
Welcome to the CDI-2012 DIY Open Source Programmable CDI Project using the PIC12F1840.

Is this project for you? Well let's see
- If you want a pre-packaged CDI ignition, then this is not the place for you.
- If you don't want to burn the code into the microprocessor or
- if you don't want to buy a PIC programmer or
- if you don't want to make some of your own parts like a circuit board or maybe a toroidal transformer or
- you don't want to install and somewhat learn the Microchip dev software or
- you don't want to learn some basic 'C' programming or
- you don't want to learn some electronics or electronic theory
Then this is probably not the place for you. You could however follow along and wait until someone makes a pre-packaged unit. There are other projects in the DIY electronics that are far more complicated than this CDI project so don't complain that it is too complicated. The main focus here is to produce a reliable programmable CDI ignition that will allow you to produce an ignition curve that is optimised for your engine and not a universal ignition curve like the RCxel and others do. Having a optimised ignition curve will give you more Hp and less fuel consumption.

This project started out on the RCU forum but problems with that forum has forced us to move here onto RCG. Which I don't mind at all. This project has been around for quite some time now also but, has matured very quickly lately. We are not starting from scratch but, we actually have a fully working setup, mind you right now it is kind of in pieces but, we are trying to straighten it out. Which is one of the reasons I am starting this thread, RCU doesn't allow very many file types to be up loaded and it keeps loosing posts, so here we are.

Since this is the first post I'll try and keep this post up to date with all the latest files as members post them. One thing I want to point out is that this it not a place for custom designs, there are companies for that. We designed basic boards and software that will get you and your engine running. If you want to change the board designs or modify the code then by all means please do so. In fact we encourage it but, be nice enough to post your changes and your results.

As of Dec. 2, 2012 we have a CDI ignition using the 12F683 that will work on a single cylinder gas engine, the timing curve is programmable, it holds 2 curves that you can instantly switch between while running, a kill switch that can be used in-flight, magnet and hall effect sensor, 6.6v or 7.4v battery, timing LED. Why 2 boards? Well it is easier to keep RFI / EMI from interfering with the planes electronics.

I would like to say again that this is a DIY open source project and as such it is up to you to learn how the Timer and HV boards work and how to modify your own code. So it is just like all other DIY open source projects. It is not hard and everything you need for programming is free but the actual PIC programmer, that you have to buy. There are people that will help you if you need help and ask nicely. Remember no one here is getting paid anything so be nice, some of the people have been working on this for more than 10 years. Some are going to be offering DIY kits and others will be offering complete systems fully soldered up. As for the transformer and ignition coil you can wind your own or buy off the shelf.

Some History:
I'm not going to provide links to the very beginning but, to the last main thread on RCU: Original 'CDI gr8flyer55' On RCU. Forgive me if I get something wrong or left out, or someone’s name wrong, if it bothers you let me know and I will make the change/s. The beginnings is somewhat split up but, they slowly converged into a project and I’m still trying to sort it out so I’m going to fast forward it a bit. In the latest thread the ignition actually started off a add on to the CH-Ignition using the PIC12F683. I guess the coordinator of this version is gr8flyer55 (John) who has done a lot of testing, providing parts and info, and pushing us in the right direction. Nyemi wrote the first code for this version in ASM assembly language, not the easiest thing to do, I know I use to do it. He also has provided a lot of testing and suggestions. Gompy has done a lot of testing, board work and suggestions. IMHO jakestew (Jake) really set this project on fire when he ported the firmware from ASM to ‘C’. This made it easier for everyone to read and modify the code, he is also the one that got us to change from the PIC12F683 to the PIC12F1840. The 1840 has a lot more useable features than the 683. The code V1.00 can be used for both the 683 and the 1840 MCUs. There are a lot more people that contributed to this project and you should read the thread on RCU if you want a good history of who did what and when, along with how we got here.

Code numbering; right now the code went from ….. .98, .99 but, V1.00 is the first stable build and it can be used on both the 683 and the 1840. As far as we are concerned the 683 is done and will not be discussed here. As I said the 1840 has a lot going for it but, even it is running out of pins, and IMHO is the perfect MCU for getting your feet wet in embedded PIC design.


#2 Gompy Dec 03, 2012 05:48 PM

Have fun.

#3 Nav_Aids Dec 03, 2012 09:40 PM

Install Microchip's IDE, 8-Bit Compiler, and Getting Started
Getting Started with Modifying the Code.

It’s not necessary to install JAVA and NetBeans for Microchips IDE’s to work but, take it from an experienced computer programmer, if you want fewer problems do yourself a favour and install them first. Why? Well because Microchips IDE’s are written with NetBeans and NetBeans is written in JAVA. Besides most of the time when people have problems, Microchips recommends installing them so I just install them and avoid the problems.

There are 2 parts to the Microchips software, the IDE for coding and the COMPILER for changing your code into something your processor can read (HEX Code). Just some FYI, I have compilers that are specific to the CPU and operating system that makes an executable program (*.exe), most are for Windows (Intel).

You have 2 install choices for the Microchips IDE “Minimum Required” or “Preferred Install” but, Jake and I both use MPLAB X IDE so if you want to use our code or want us to help you with your code it would make things easier to just use the Preferred Install : MPLAB X IDE. NOTE: the hex code will still be the same. Besides the MPLAB X IDE in my opinion is more intuitive and better laid out.

Required When Installing Microchips IDE and XC8 compiler:

1. Install JAVA if you haven’t by now. www.java.com
2. Install NetBeans - NetBeans 7.3.1 CC++ Installer Download: https://netbeans.org/downloads/start...=en&option=cpp
3. Open NetBeans to make sure it works.

Minimum Required: MPLAB IDE

1. Install MPLAB IDE - MPLAB IDE v8.92 or newer - Near bottom of page. MPLAB IDE v8.92
2. Install: Run the installer, click next, accept, next, if the install directory is ok select next or change the directory and then click next, next, finish.
3. Restart computer. The IDE will finish installing and may give an error message but, just ignore it. It should open a dialog box for different plug-in's that are included.
4. Install the MPLAB-XC8 compiler, you can also install MPLAB-XC16 and XC32 but I recommend MPLAB-XC8 for now - Download is on the left side, half way down: http://www.microchip.com/pagehandler...abxc/home.html . Install: Click next, next, next, if the install directory is ok select next or change the directory and then click next, select all the boxes, next, next, after install click next, and then finish.
5. Your ready to go coding.

Note: For instructions and guides for MPLAB IDE go to the bottom of this web page: http://www.microchip.com/stellent/id...&part=SW007002

Preferred Install : MPLAB X IDE

1. Download MPLAB X IDE v1.85 or newer. http://www.microchip.com/pagehandler...abx/#downloads Click on DOWNLOADS and then download MPLAB® X IDE v1.90.
2. Install: Run the installer, click next, accept, next, if the install directory is ok select next or change the directory and then click next, next, finish.
3. Reboot
4. Download MPLAB XC8 compiler v1.20 or newer. If you want you can also download and install XC16 and XC32.
5. Install: Click next, next, next, if the install directory is ok select next or change the directory and then click next, select all the boxes, next, next, after install click next, and then finish.
6. Reboot

Note: For instructions and guides for MPLAB-X IDE go to the bottom of this web page: http://www.microchip.com/stellent/id...&part=SW007002

From Jakes old web site and is for the MPLAB X IDE:

Getting Started with compiling for the PIC...

I've tried to make things as easy as possible, but it still takes a little doing to get your own custom CDI firmware up and running.

Open the IDE and...

-Select File->New Project
-Choose "Standalone Project", click next.
-Select Family -> Mid-Range 8-bit MCUs (PIC12/16/MCP)
-Select Device -> PIC12F683 Click next.
-Debug header does not matter, I usually select the one you can choose, now click next.
-Select "Simulator" under hardware tools, or choose the programming device you use. Click next.
-Select "XC8" under XC8, click next.
-Choose a project name and location. I usually use a more convenient location than the default. You might use "12F683_v0.9b" for the name.
-Check "Set as main project" and click next.
-Copy the source file "12F683_v0.9b.c" into your project directory.
-On the left hand side of the MPLAB X IDE screen right-click on "Source Files" under your project name and select "Add Existing Item".
-Select the source file "12F683_v0.9b.c" and hit OK.
-Double click the 12F683_v0.9b.c source file that now shows up. This should bring up the source code.
-Select Run -> Build Main Project, from the menu. Source should compile with no errors.
-Congrats! You just compiled the code! You know things are working, so any new errors are your own doing.

-Now edit the source file, adding your custom table and the settings you want.
-Use the included spreadsheet to make your advance table and help figure out the settings.
-Build the project again and the .hex file should be in [Project Directory]\dist\default\production
-Now you can program the .hex file into your processor via whatever method you prefer.

NOTE: If you get an error like "JVM creation failed" when you try to launch MPLAB try the following steps...
1. Open "C:\Program Files\Microchip\MPLABX\mplab_ide\etc\mplab_ide.con f" in a text editor.
2. Change "-J-XX:MaxPermSize=384m" in that file to "-J-XX:MaxPermSize=128m", or delete that option alltogether.

Let me know if I made a mistake some where.


#4 Nav_Aids Dec 03, 2012 11:00 PM

Important Links
2 Attachment(s)
Here are some important links:

This link will take you to a web page that has all the attachments and links posted on the RCU forum for the 683 portion of this project. The 683 in IMHO is completed and working fine. The web page has everything listed by coresponding pages to the forum, so if you find something interesting on page 4 then go to page 4 of the forum.
RCU Attachments and Links that are posted there. There is also a ZIP file that has everything.

Jake Stewart's lost his website for now. So I have put his web site up on mine, see below link. He has a pretty good explanation on how to setup MPLab to get you going. Make sure you download the Excel spread sheets to get your timing table values and read the instructions. I find that with Excel 2007 I just right click on a page tab and left click on 'UnHide' then 'Table_Values:

Fixes to the spreadsheet only, no changes were made to the 683/1840 code. Lastest is Dated Jan 01-2013.

Pull-ups are turned off for the switches and the polarities are reversed CDI-2012_v1.0_B-F1.1.xlsm

Revisions and Fixes Jan 1-2013.txt

MPLabX Source Code Editor:
You will need this to modify and burn/flash the MCU.
MPLabX Down Load Page

You will also need the MPLAB XC8 Compiler. The 1840 has room to use the low-optimized free version.
MPLabXC 8 Windows Compiler

While it's free you should also download the XC32++ compiler.
MPLAB® XC32++ Compiler Software

I like to use this program for coding and then copy my code into MPLabX.
TextPad for 'C', 'C++', and 'Java'.

From lovefool (RCU):
To make the PICKit 2 compatible with the 12F1840.
“You need two files, PICkit 2 v2.61 and Device File 1.62.14 (New device support. Compatible with application version 2.61.)”

More to come when testing is finished, which is in the process right now.
'B' Timer Board Layout is at the bottom of post (attachments), why 'B'? well we had a choice between boards and thought 'B' was the best. Thanks Gompy.

How to make your own torrid transformer, click here or go to post 1196

Member links:
Gompy's website (I really like the timing light):

Timing light 1:

Timing Light 2:

A YouTube movie showing an older version of the firmware (0.96):

DIY CDI and software. (1 min 52 sec)

Here's the latest version (1.0) running and showing how the switchable timing works:

CDI-2012_v1.0 (2 min 0 sec)

More coming:

#5 ZAGNUT Dec 04, 2012 02:28 PM

the conversions forum was great back in the day (i was one of those who petitioned for its creation) but lately i just seem to get lost there in endless disjointed threads...this is the right place for that ignition.

being mechanically inclined i just slap on a link between the carb and hall sensor.....BUT, in my dreams (where i know how to write code) a very simple and elegant electronic advance would be mixed as a slave to the throttle channel...between 1.000mS to 2.000mS you would get a certain amount of delay measured in time, so you just set endpoints to determine the advance and then throw in a multipoint curve to tweak it. maybe not as elegant as what's being shown in this thread but still way more advanced than all the off-the-shelf units.

#6 Nav_Aids Dec 05, 2012 09:26 AM

Why a Programmable CDI ?
Why a Programmable CDI ?

Well if you are converting an engine from glow to gas like I am (ASP 0.65FS) then you’re going to need an ignition. Another reason is that most OEM gas engine manufacturers don't set their ignition timing or timing curve to an optimized setting or one that produces max power. Why? Well they have to provide warranty for their products and that costs money. Another reason to have a programmable ignition is that if you change props you are changing the load and how that load is applied, so if you can make your own curve then you can make a more useable power curve. You can even save fuel with the right carb mixture and timing. A leaner mixture needs less timing and a richer mixture needs more timing. So what can the standard CDI-2012 setup do ?

• Can hold 2 different timing curves
• You can switch between those 2 curves in-flight
• Use an Excel sheet to produce your timing curves and the actual code
• Kill switch can be used in flight

We are working on a way to do in-circuit-programming and if you want to help then please do.


#7 Gompy Dec 05, 2012 09:40 AM

: )

#8 SadSack Dec 05, 2012 09:53 AM

: )

#9 Gompy Dec 05, 2012 10:00 AM

: )

#10 Nav_Aids Dec 05, 2012 11:53 AM


Originally Posted by Gompy (Post 23447194)
This code have to be copy / past into the Exelsheet befor you can use it.
I show the code and hope some one will be smart enough to see if I make the right changes.

Set internal resistants OFF (external use)
Set GP4 and GP5 reverse (jumper or switch must be closed - high)
MCLRE_ON (pin4 of the PIC will be a RESET - low)

BTW, the wrong schematic is showing above !

Schematic changed

Yup that's 1 of the problems, we have to sort everything out. I updated the file Gompy.


#11 Gompy Dec 05, 2012 02:48 PM

: )

#12 ZAGNUT Dec 05, 2012 03:51 PM


Originally Posted by Gompy (Post 23449539)
GRompy thank you.

And Gompy quit with this forum.
It'seems to me a playgarden for children.

as opposed to RCU?


#13 gr8flyer55 Dec 05, 2012 04:48 PM

Ray, I was testing the new timer board with my original ignitions with the toroid transformer on it and ran into a snag. There must be a resistor value change or the inverted signal from the optocoupler output will not fire the ignition. If you have the schematic and can re-post it, I will tell you which resistor number it is. I can't seem to find the combo board schematic with the problem resistor. It all boils down to the positive bias with too low of a resistor value. It's a 150 ohm I believe shown in the schematic. This must be changed to a 680 ohm to correct the situation.


#14 gr8flyer55 Dec 05, 2012 06:43 PM

There have been inquiries as to the possibility to switch the table via a connection to the receiver thru a servo function lead. To me, I think it would be possible only with an opto kill switch arrangement to prevent the possibility of the dreaded RFI. Anyone have views on this arrangement?


#15 Nav_Aids Dec 05, 2012 07:31 PM

..... :)

All times are GMT -5. The time now is 09:49 PM.