Battery Charger/Spark unit controller?

So, I’m working on an ambitious first project! I’ve got a background in PLC programming, so aside from a different language, I hope it will go well. :slight_smile:

I’m upgrading the electrical system on a 1979 Honda CB650. Option 1 is to spring for $350+ worth of OEM or equivalent parts to drop in, knowing they’ll work, but also knowing that the electrical system was a bit of an Achilles heel on these bikes since day one. Option two is to build my own replacement parts for around $100, using all upgraded components. I think I have the hardware down, but now it comes to programming, and I’m lost. I guess the first question would be before I purchase all this, is the Arduino Uno R3 capable of handling the processing load I intend to put on it, or will it start to lag?

First, the arduino will be running a PID loop, regulating the system voltage to 13.5VDC, by firing a PWM pulse on the gate of a MOSFET, supplying excitation current to my alternator.

Second, there will be a current limiter on my battery charging circuit, so I can limit the charge rate to a maximum of 1.5A, to avoid damaging the battery. Likely use another reverse acting PID loop firing a MOSFET here; 100% duty cycle until near 1.5A then starts to respond.

Finally, the spark units are shot. Looking at the basic diagram (Page 3 of link) is under construction I’m pretty sure all its doing is timing the spark signal based on the pulse from the pulse generator. I intend to have optical isolators feeding the pulse into two digital inputs, I just don’t know where to begin writing the code for the processing, or if my understanding of this circuit is even correct.

As far as my first two functions go, I don’t think I’ll have too much trouble, just a matter of learning how to scale the analog inputs to engineering units so I can program in a real value as the setpoint. The third function, replacing the spark units is where I’m really boned. Can anyone provide some insight?

Thanks!

Your right on the first part. It should be pretty easy to control the charging system. You don't really need a micro to do it, but what the heck.

As for the ignition system. When Transistor 3 turns on current builds up in the coil. The current increases relatively slowly because of the low voltage (~13V) and high inductance in the coil. When Transistor 3 turns off, the current decreases very fast. The Zener diode voltage is large and the high voltage creates a large di/dt which causes a very large voltage on the secondary causing a spark in the spark plug.

The Pulser is used to turn the transistor on for a fixed engine rotation before the desired spark timing. The advance mechanism will mechanically move the rotor forward and back to adjust the spark timing. If I am mis-reading the document please let me know.

You can control the transistors with a microprocessor, but you will need to control the turn on, and especially the turn off relative to the crankshaft position. In a typical automotive application it will be controlled +/- 1uS. In motorcycles and race cars it is done much more accurately since their engines run faster. You can probably do it with an Atmel micro (we used to do it with 6800's) but it will take some work. You would need a position sensor on the crank with at least a few pulses per rev and you will have to calibrate it with a timing map because the delay times in the sensors and drivers will have more of an effect at higher speeds.

The final transistor and zener are high voltage parts, typically 300 volts but 600V are not uncommon. Since this is an older bike it is probably more like 100-300V.

If you do this, I want to see a build log. I'm thinking of home-brewing EFI for my Karmann Ghia. But, while I'm relatively green with electronics, I'm super green with automotive stuff. (Therefore, this is a long term project goal, subject to feasibility.)

kilowattcommando:
First, the arduino will be running a PID loop, regulating the system voltage to 13.5VDC, by firing a PWM pulse on the gate of a MOSFET, supplying excitation current to my alternator.

On cars this is normally done using a simple analog control circuit built into the alternator. Don't bike alternators use the same approach? Without some kind of voltage regulator it wouldn't be safe to use an alternator. Doing this digitaly using a microcontroller and PWM controlled MOSFET feels like using a sledge hammer to crack an egg.

PeterH:
On cars this is normally done using a simple analog control circuit built into the alternator. Don't bike alternators use the same approach? Without some kind of voltage regulator it wouldn't be safe to use an alternator. Doing this digitaly using a microcontroller and PWM controlled MOSFET feels like using a sledge hammer to crack an egg.

The voltage regulator/rectifier unit is actually under the seat on this bike. There's a five wire cable running from the alternator (three phase AC and DC excitation)

It is overkill I know, but hope to have the controller for other features later on, so why not just start here, and just add new features as modules? I also want an LCD display with some basic OBD tools, such as battery charge/discharge rate, system voltage, alternator current, spark issues, as well as more important driving tools, like a compass to display your heading, average speed, distance travelled, clock. Easiest way to get all this information is just let the microcontroller manage it from the start rather than interfacing it with a different system.

Well, it's your bike at the end of the day, but that argument doesn't persuade me at all. I prefer to go for the most appropriate approach to each problem. For an alternator which can be controlled by a simple and robust piece of electronics that is cheap and easy to buy, building your own microcontroller makes no sense. For some things, a microcontroller is a sensible solution. That doesn't mean that just because you have one on your bike, you have to use it for everything.