There comes a time... (DIY Electronic Ignition)

Sonreir

Oregon
DTT SUPPORTER
I'm pretty sure we've all experienced this at some point: We're piecing together our project within our own minds and have finally arrived at a decision as to which direction we wish to go. So we start doing some research on the Internet only to find that our idea cannot be realized because no aftermarket solution yet exists. We're now stuck with a bit of a problem... Do we compromise our design? Unfortunately, that does seem to be the most common solution to the problem.

However, every now and again we're not willing to do that and so we begin to look into ways in which we can solve our own problem and implement our own solution.

For me, this has been the lack of a FULLY electronic ignition system for my motorcycle, a 1977 CJ360. After countless hours of searching forums and putting Google to work, I've only found a few offerings. Some systems use rotating disc and laser to simulate the points while others maintain the points as a signalling system to a transistor which then triggers the coils. Unfortunately, both of these systems maintain the mechanical advancer. This is good enough for some, but to me, good enough just isn't.

And so I began to do research of another sort. Mechanics, electronics, and computers have almost always fascinated me. I truly love systems of increasing complexity. I adore how simple gears, switched circuits, and single lines of code can be combined in new ways to achieve new goals. I set out to learn a bit more about electronics and how different components are used and how they interact. With a good deal of help from some more electronically minded friends and some adaptations to existing (similar) circuits I was able to find on the web, I've been able to piece together a rough diagram on how I want my electronic ignition to work.

The thing is, I'm no electronic engineer. I'm not always sure how to recreate, within electronic circuitry, the tasks I wish to complete. I am, however, a computer programmer and I began to look for software solutions to my problem. After discarding much of my existing programming knowledge as unsuitable for the task I began to look to lower-level solutions to the issue. Enter the PIC Microcontroller. This simple device is an extremely low-level computer processor. It (or variations of it) run nearly every single robot in existence and can be found in multiple places within existing automotive applications. I'm hoping I've made a good decision with this one. So now that I've selected the brain of my ignition, it's time to take a look at the components.

Picking the components (to me) is really more of a thought process rather than any sort of real step. I like to glance over the big picture like looking upon the cover of a jigsaw puzzle box. Once I've gotten a general idea of how the pieces are meant to look after they're assembled, this seems to give me a better idea as to which pieces I need. First up, the microcontroller I've selected (the venerable 16F84A) runs between 2.5V and 6V and the outputs are the same voltage as the inputs. This presents me with two initial problems to solve:
1.) My bike runs on 12V and so I can't power the microcontroller directly from the bike without some modifications.
2.) As the outputs of the PIC are going to be less than 6V, I can't run anything directly from the outputs of the microcontroller.

Fortunately, both of these "problems" are so common within electronics, it's not even funny. Enter solution to problem #1:
432241_10150644248955159_734955158_11067188_1770024351_n.jpg
5VDC Solid State Voltage Regulator

This is a diagram I've made of a solid state voltage regulator. The 7805 voltage regulator is happy to accept up to 30V and will step it down to a smooth and steady 5V. The downside is that the 7805 kicks out a fair amount of heat and will definitely need a heat sink when I get it all together.

So what about problem #2? This one turns out to be pretty simple as well. Instead of triggering the 12V directly from the microcontroller, the PIC can switch a 5V relay. The relay then operates as an electronic switch that can handle much higher voltages and currents:
401065_10150644299855159_734955158_11067294_114383969_n.jpg
5VDC Relay

OK... so there's part of the problem moved over into the solution pile. Or at least, so I thought. As it turns out, the high voltage that's released by the coil isn't unidirectional. That is, when the coil fires, not all of the power goes through the HT lead and to the plug. It turns out a significant portion of this returns through the points and condensers. Most of you probably know about this already if for no other reason than you've seen the points sparking during operation. So the next step in being able to electronically fire the coils is to ensure that backlash of high voltage isn't going to come back through and cook all the silicon. I readily admit that this is the circuit I'm still trying to get my head around. I found a diagram online and a friend said it should do the trick. I'm going to take it on faith that this will fit my bill. If it doesn't, I'll go back to the drawing board and try something else:
424083_10150644248920159_734955158_11067187_1978822769_n.jpg
Solid State Electronic Condensor

The TIP162 in the diagram above needs a heat sink as well. The backlash coming from the coils generates a lot of heat when you have that much voltage to dump.

So where are we now? We have a voltage regulator that gets a steady 5V to our microcontroller which, in turn, provides a 5V output to each of our relays. Each relay triggers each coil, but first passes through an electronic condenser. Sounds good.

One very important part we're missing though: We need an input signal to the 16F84A to let it know when to trigger each coil. As it turns out, timing something electronically is also a fairly common task. I'm making use of something called a Hall Effect Sensor. What this does is it transmits a small digital voltage spike every time a magnet comes within proximity. By installing a magnet at TDC on the end of my crank shaft and then placing the HES in a position so that the magnet will pass by it on every rotation, I need only count the number of clock cycles on the PIC to determine the RPM.

430277_10150644248840159_734955158_11067185_145212515_n.jpg
Hall Effect Sensor

Once I know the RPM, calculating out time and degrees will be relatively simple. For instance... I know my PIC is operating at 4Mhz because that's not only it's default speed, but I plan to attach a quartz crystal to its oscillator pins to ensure it's fairly accurate (within +- 20 microseconds of error for every full second that passes). As I mentioned earlier, the PIC is a pretty simple device and so it carries out commands at a rate of one command per cycle. Or, if you prefer, four million instructions per second. As an example, lets say that I'm currently counting 16,000 processor cycles between the pulses I'm receiving from the HES. First step, divide 4,000,000 by 16,000 to get my rotations per second. This leaves me with 250. Multiply by 60 to convert seconds to minutes and we see the engine is turning at 15,000 RPM.

For argument's sake, let's say I want my engine running at 38° of advance at this RPM and so I now need to calculate how many processor cycles passes in 322° (360° is a full circle, minus 38° of advance I want for the next firing of the coil). Well, we already know that 360° of rotation is taking 16,000 cycles, so simple division tells us that a single degree of rotation is taking about 44.5 cycles. Multiply this by 322° and we know the next time to trigger the coil is is 14,311 processor cycles. So after counting to 14,311 our microcontroller will open the relay for the left coil. I'm running 180° firing and so count another 8,000 cycles and then open the relay for the right coil. Recalculate RPMs the next time the HES triggers and then do it all again.

But I digress... that's more of the software side I have yet to implement. All of this math, however, did get my mind wandering off to other uses for the PIC. I've come up with a couple of other features I plan to include.

First up, I'm going to implement an electronic redline. At 12,000 RPM (and above) the PIC will no longer trigger the coils to fire. No spark means no power and so the engine can't/won't exceed 12,000 RPM.

Next, I've been wanting to run an external oil pump and so I plan to install one and control it from the PIC. At 6,000 RPM one of the outputs from the microcontroller will signal another 5V relay to switch on the oil pump. At less than 6,000 it will switch off again. I may adjust this limit later, but I only want the pump on in the higher RPM bands so that it's not sucking too much power. The charging system isn't great on my old CJ and the oil pump is expected to draw about 40 Watts, a full third of what my alternator is capable of putting out. Gotta keep those RPMs high for full power output.

Third, will be shifting lights. At 9,000 RPM, I'll trigger an LED to light up to indicate that it's time to shift when I'm going balls to the wall.

403057_10150644371650159_734955158_11067500_1013314992_n.jpg
The Full Monty

The best part (at least I think so) is that this device should work with any two or four cylinder motorcycle as the ignition curve is fully programmable.

Thoughts? Suggestions? Concerns?

This is a first for me and I'm hoping to get some idea as to your guys opinions. Any technical additions would be extremely welcome.
 
Re: There comes a time...

It's funny how when you're first starting off on something, the task seems so daunting. But as you progress, things start to become a little easier and you're able to pick up some bits and pieces of those that have come before. It's not surprising that a person would want to control an ignition coil electronically and it's equally unsurprising that major chip manufacturers have already created a transistor for this specific function.

During the course of my research it was suggested to me that I investigate something called an IGBT or Insulated Gate Bi-Polar Transistor. This transistor is a simple switch made to handle high voltages and medium current at a set duty cycle. They are used in automobile manufacturing for cycling fuel injectors and ignition coils. I happened across an IGBT made by Bosch called the BIP373. Unfortunately, they only sell them at a retail level through a single distributor and that guy wants almost $10 per chip. After looking over some available datasheets, I've settled with the IRGB14C40L instead. It costs only $4 and simplifies my circuit a great deal.

With the use of the IGBT, I'm able to remove both the 5V relays and the Electronic Condensors from my circuit replacing them with a single transistor and current limiting resistor:

422009_10150649352380159_734955158_11081987_725706417_n.jpg


So my main diagram now looks like this:
426350_10150649402955159_734955158_11082060_1946856934_n.jpg


You'll note that I've left the 5V relay in place for the oil pump. This is because the IGBT is not designed to operate at a 100% duty cycle. It can only carry current for a short amount of time and something like an oil pump that could be potentially running for minutes at a time will cook the transistor.
 
Re: There comes a time...

Holy cow. My brain melted 2 paragraphs in.
 
Re: There comes a time...

Seems pretty straight forward.

Your hall effect sensor calibration is probably the trickiest bit.

And then you have to figure out how to effectively mount/epoxy encapsulate and retain an outside interface.

Now you are part of the way to your own EFI as well...
 
Re: There comes a time...

Great stuff. Really interesting.

A small query, do you know the lag of your system, from when your chip sends the pulse to when the spark actually arrives at the plug tip?

Surely there would be a measurable delay, maybe you could pick this up empirically with a timing light when the system is running?

Or you could work it out theoretically somehow???
 
Re: There comes a time...

Bozz - That'll be stage 3 of my build. ;D

ako - The nice thing about replacing the relays with the transistor is that the lag time is now measured in nanoseconds. It's effectively negligible. As mentioned in the original post, the PIC operates at 4MHz and so the reaction time of the PIC (time between instructions) is 250 nanoseconds. Theoretically, I could open and close the controlling transistors about five times in that span. Of course the coil takes about 5,000,000 nanoseconds just to charge, so there's not much point. ;)

I think the trickiest part of this project is going to be programming the PIC. I'm leaning toward Assembly language as it provides a lot more control, but Embedded C is a lot easier to use. I think the control provided by Assembly is going to be necessary because it's (for the most part) one instruction per cycle and so when I tell the chip to do something I know it's taking 1/4,000,000 of a second. With that in mind, I can calculate how much time is being spent processing commands and not alter the timing. For instance, lets say it takes me 700 instructions to calculate out the RPM of the engine and determine the advance in degrees and then translate that back into how many processor cycles need to pass before triggering the spark. That 700 instructions is the same as 700/4,000,000 seconds, or almost 16° of rotation at 15,000 RPM. So you see, keeping tracking of processing time is extremely important, especially at higher RPMs. Basically, ako is correct. Lag time is a serious factor here, but the lag is all in the chip and not the transistors.
 
Re: There comes a time...

It's been a long time since I've touched Assembly (but still have a book on my shelf!) and I've never touched Embedded C. Heck, it's probably been 10 years since I've messed with C or C++ even. But it sounds like a fun and interesting project. I don't know a lot about electronics but I've poked around a little here and there - I do know what a 7805 is, used them a few times in messing around with old video game consoles. Everything you've come up with so far looks sound to my mostly untrained eye, I look forward to following along. Best of luck to you!
 
Re: There comes a time...

PS A strobe light will definitely be necessary for the fine tuning of this system. Placement of the Hall Effect Sensor will alter the signal I'm receiving and so my program running the microprocessor will need to include a "trim" value to negate this effect. As to the actual delay of the operations, I'm hoping I can negate any processing time by accurately accounting for the processing cycles I'm spending on calculations. A change in timing (either a delay or an advance outside of specified values) as the RPMs change will be a good indicator of whether or not my program is accurate. In theory, if I'm not tracking the processing cycles correctly the timing will fall out (again, either as excessive retardation or advance) the higher the RPMs go. The trim effect for the Hall Sensor should manifest as a static difference. That is, if the sensor is misaligned it will be out the same degrees at 1200 RPM as it will at 9000 RPM. That's all theory though and we know how that usually stacks up with practice, so we shall see.
 
Re: There comes a time...

Good on ya for not giving up. To often I hear "It cant be done" or "too much work". I know if I can draw it I can make it. If I don't know how I talk to people, learn new skills, google the shit out of it. I like this site because so many people are putting ideas together that some would never dream of and others get inspired by. Keep it up.
 
Re: There comes a time...

Nice work!

I would use a bipolar transistor (or Mosfet) to turn on the oil pump. More reliable and takes less space than a relay.
Because the circuit switches a coil (The winding of the oil pump.) you would need a diode or two to protect the transistor from the transient voltages on starting and stopping the pump.

Keep it up...
 
Re: There comes a time...

Forgot to add this:
Contrary to what you may have read, a transistor won't burn out if the pump is turned on for extended time.
The transistor dissipates the least heat when it is either fully on or fully off.
It's the "in between" time (the switching time) that generates heat. For a slow application like this, the on and off times are much longer than the switching time, so no worries.

I have a 1976 Yamaha XS500 (it's also a 180 twin) that I'm thinking of converting to electronic ignition.
So I'm very interested. I have an electronics background.

You have some great ideas going!

Bernie
 
Re: There comes a time...

berniebee said:
Forgot to add this:
Contrary to what you may have read, a transistor won't burn out if the pump is turned on for extended time.
The transistor dissipates the least heat when it is either fully on or fully off.
It's the "in between" time (the switching time) that generates heat. For a slow application like this, the on and off times are much longer than the switching time, so no worries.

I have a 1976 Yamaha XS500 (it's also a 180 twin) that I'm thinking of converting to electronic ignition.
So I'm very interested. I have an electronics background.

You have some great ideas going!

Bernie

Thanks, man! The extra info is definitely appreciated! The expected draw of the pump is between 3A and 4A at 12V, so I'll hunt around for a transistor that'll do the trick. Maybe a simple 2N3055?
 
Re: There comes a time...

You are an inspiration! great work already, keep it up! ;D


I know not much on electronics, but I love to learn about stuff, so i'll be following closely to how you do this!
 
Re: There comes a time...

To Sonreir (You've gotta explain that handle!)

A 3055 won't work.

Looking at the spec sheet :http://www.datasheetcatalog.org/datasheet/stmicroelectronics/4079.pdf

The maximum ratings section shows the the max current and max voltage ratings to be ok for this application.

BUT

The electrical characteristics section shows the hfe (conditions Ic= 4A ) to be 20. This means that if we want to switch on a 4 A pump, we need to drive the transistor with 4A/hfe =4A/20 = 200 mA.
The 16F84A output pins can supply only about a tenth of that. So no go.

A Mosfet or a darlington transitor would likely work.
 
Re: There comes a time...

Thanks, man. I'm still learning what a lot of all these different numbers mean in "real world" terms and it's great to have someone to explain it.

If I'm correct, then a TIP120 should do it?
 
Re: There comes a time...

OK... I like getting all this stuff down on "paper" and so here's what I have for the shopping list so far:

  • 1x HC-49S 4Mhz Quartz Crystal Oscillator (+- 20ppm) - $0.38ea
  • 2x 7805 5V Voltage Regulator - $0.69ea
  • 1x .33µF Capacitor - $0.56ea
  • 2x .1µF Capacitor - $0.14ea
  • 2x 22pF Capacitor - $0.15ea
  • 2x IRGB14C40L Transistor - $3.63ea
  • 4x 100Ω Resistors - $0.09ea
  • 1x TIP120 Transistor - $0.68ea
  • 1x 16F84A PIC Microcontroller - $4.90ea
  • 1x 2SS52M Hall Sensor - $3.93ea (I'm using this instead of the A1302 because it has digital output. I'm also considering a reed relay, but I'm unsure how it would hold up. I'm not married to this selection just yet).

Total cost - Around $20. Maybe this should get moved into the $50 mod thread? ;D

I'm also going to need some circuit boards which I can etch the circuit onto, some assorted wiring, a new/better soldering iron (mine sucks), and a PIC programmer. That'll probably all come to another $100 or so, but I won't have to shell out for the programmer or the soldering iron more than once.

As far as the feature set goes, here's what I'm aiming for in the first version:
  • Fully programmable ignition curve with circa 30 stepping points (slope will be simulated using stepped points instead of a line)
  • Programmable redline
  • Programmable dwell in microseconds (default to 5,000)
  • Two latchable outputs (for the LED shift light and external oil pump in my own application)
  • Specify to run from cam or from crank with wasted spark
  • Include "trim" value to account for real-world hall sensor placement in relation to true TDC
  • Programmable phase for 360°, 180°, and "other" firing orders)

Possible enhancements for future versions (yeah, getting ahead of myself, I know):
  • Enable four cylinder usage without wasted spark and two cylinder usage from crank without wasted spark
  • RPM and/or MPH display onto a display of some sort display
  • Accept SD card input for timing parameters (allow end-user programming instead of "burning" the values into the chip)
  • Conversion to CDI
  • Immobilizer
 
Re: There comes a time...

Sonreir,

I just checked out your CJ360 thread. (1977 Honda CJ360T Build - Café SOS)
Forty two pages, I'm slack jawed! I especially liked the painted side cover (stator) and the instrument face design.
A beautiful effort.
 
Re: There comes a time...

Thanks, man. Stage 1 on the CJ is winding down so I guess I'm starting this part just in time. ;D
 
Back
Top Bottom