Custom Engine Contol Unit

Hi, so the main reason I got in the Arduino world is this project. I'm trying to make the Arduino control the ignition of 4 spark plugs, 4 injectors and a servo to open the throttle body. It would read a signal from the pickup coil, a temperature sensor, an oxygen sensor and an air mass sensor, and the speed from both wheels. Aditionally there would be a 3-position switch (1-2-3) to allow for on the go map changes.

The spark plugs are connected to 2 ignition coils, so each pair sparks at the same time (one is compressed, the other has finished the exhaust phase and will start intake). I thought of writing to the EEPROM information on what's the next pair of plugs to go off, after each cycle - I'm not sure if this is possible.

That information could also be used to know what's the next injector to open.

I'm a bit lost on how to connect the pickupcoil, because ideally it would give me a digital 0/1 value, so that as soon as it turned 1 the cycle would beging, but it operates at 12v so I can't connect it directly to a digital pin.

Also, the wheel speed sensor would send a signal up to 5kHz (at a bit over 210mph). Can the Arduino read this properly? Will this affect the code? Can I convert the signal to a variable voltage input (0Hz=0V; 5kHz=5V)?

This is a very basic (and very inclomplete) sketch of the idea, without the wheel speed sensors or any of the injection related stuff - so this would only provide a ride-by-wire functionality, the 3-position switch and control the ignition pulses.

So, my doubts are:

Wheel speed sensor outputing 5kHz, is this a straigh connect of the signal cable to an analog pin?

Pickup coil, works on 12v and I don't have any idea on how to process the signal.

Can the code write to EEPROM? How do I save information from getting erased on reset?

I thought of writing to the EEPROM information on what’s the next pair of plugs to go off, after each cycle - I’m not sure if this is possible.

It is possible, but why? Surely, the next pair of plugs to be fired is not going to matter when the Arduino is reset.

but it operates at 12v so I can’t connect it directly to a digital pin.

Google voltage divider. 25 cents at your local Radio Shlock.

Can the Arduino read this properly?

If you write the code properly.

Will this affect the code?

No. The pulsing of the sensor will not cause code rot.

Can I convert the signal to a variable voltage input (0Hz=0V; 5kHz=5V)?

This doesn’t make sense. You can perform any kind of mapping you like, but the time between pulses is a piece of data. The relationship between that and voltage is not at all clear.

Wheel speed sensor outputing 5kHz, is this a straigh connect of the signal cable to an analog pin?

The frequency of pulses has nothing to do with the voltage of the pulse. THAT is what determines whether it can be directly connected to a DIGITAL pin. Why are you planning to connect it to an analog pin?

Pickup coil, works on 12v and I don’t have any idea on how to process the signal.

First step is to learn what the signal looks like.

Can the code write to EEPROM?

Of course it can.

How do I save information from getting erased on reset?

Gee, I don’t know. Maybe you could write it to EEPROM.

tiago_duke: I thought of writing to the EEPROM information on what's the next pair of plugs to go off, after each cycle - I'm not sure if this is possible.

If you mean writing to the EEPROM between every spark sequence the answer is NO. The EEPROM can only take a limited number of writes - about 100,000 I think - so you would quickly wear it out.

What's wrong with saving the information in a regular variable in SRAM?

This project is probably perfectly doable but it is far from trivial. How much Arduino programming experience have you got?

Have you got an oscilloscope so that you can check that things are working properly?

...R

I'd recommend looking for a schematic of a stock or replacement CDI for your bike. Mine works with the 90V generating coils on the stator. Other bikes use 12V. This determines a lot of the components in your electronics. Your ignition coils are wound to use a particular input voltage.

Are you sure your pickup coil works on 12V? The voltage for the timing pulse can be different from the voltage going to the coils. Since it was going to an analog CDI box, the pulse needs to trigger a semiconductor which takes about 0.7V. If it passes through a diode first it'll need to be about 1.4V. Inside the CDI box are semiconductors to controll the higher voltages (12V? 90v?) to your coils. It would be overkill for the mfr to generate 12V to then divide it so it doesn't fry a semiconductor then amplify it again. I used an oscilloscope to look at the pulses from the various timing coils. The signals I wanted to use are about 1V and other signals were about 2V. Simple to use those directly on an Arduino digital pin.

A CDI box that uses AC to power the ignition will probably use an SCR to trigger the spark. Starting from DC would probably need a transistor.

My DCI box was "advanced" for 1978 but too complex. The mfr simplified it after a couple years so the engine I have needs one from a short run that's not compatible with later bikes. They're unobtainable. Now that mine's kaput, I'm free to have some fun. The kaput CDI has 6 timing inputs form the stator (full retard pulse, advancer pulse, and full-advance pulse) plus the full compliment of ground, kill switch, and 2 different high-voltage inputs.

With my project, I'm working from the full-advance pulse. This does mean the code has to be fast. With a redline just under 10,000 that means a revolution is 6ms. A single degree of rotation is 17us or 267 processor cycles at 16MHz.

I breadboarded a CDI with components of the same spec as the stock CDI (as reported on the always-reliable interwebs). I had spark from my CDI for a while. Then it changed to sparking only the first few cranks and last few cranks. (Plugs out and grounded; squirting lots of oil on top of the pistons.) I have confirmed that the Arduino still functions and I have seen the ignition pulse still looks the same. I tried putting PNP transistors on the inputs (since I'm working from a negative pulse) and it functions exactly the same with 5V going into the digital pins. The schedule for building a house has pre-empted my work on this ignition. (And I got new knobbies on a dual-sport. Too many bikes, but what'cha gonna do?)

The ignition was supposed to be a winter project anyway, but it's been fun so far. Writing this post has helped clarify some thoughts, but the house really will take precidence for a few months.

EDIT: Why do you want to write to EEPROM? (Not that it's my business.)

MORE EDIT: Pic:

My bike has 4 cylinders. When I turn off the bike the Arduino needs to know wich piston to fire. It's either 1/4 or 2/3 in my case.

Each cylinder fires between 720º of the crankshaft, and all of them fire between 180º from each other.

1 fires - 180º - 2 fires - 180º - 4 fires - 180º - 3 fires - 180º - it starts again

From this I assume I'll have 2 pulses from the pickup coil, separated by 180º.

BUT - probably both pulses (180º and 360º) look the same to the Arduino. When I start the bike (not the engine, just the electronic part of the bike) - and the Arduino starts at the same time - the Arduino has no idea if the firts pulse it receives when I start the engine is at 180º or 360º.

For the first time I do this I will be able to tell Arduino wich is it, but after that it has to know on its own, because it is suposed to work seamlessly with the bike: just turn the key and press the starter button.

From this I assume I'll have 2 pulses from the pickup coil, separated by 180º.

probably both pulses (180º and 360º) look the same to the Arduino

You really need to look at how your existing system that came with the bike works.

It seems inconceivable that the existing system would be setup at the factor with a record of the crank position, stored inside the electronics, and if it ever got out of sync e.g via a loose wire that the bike would be unusable and would have to be returned eg to the dealer to reset the configuration.

I'd check that there isn't some other sensor that will tell when 1 is at TDC

Put the signal for cylinders 1 and 4 on Arduino D2 and the signal for cylinders 2 & 3 onArduino D3. That way the Arduino can tell them apart. My 4-cyl bike has the same firing order, crank layout, and shares coils like yours.

I suspect that you will need finer control and more events to correctly manage the length of time each fuel injector is open. For my ignition working with half-recitified 90VAC to the main capacitors, the dwell is everything after the first half-wave of AC. In other words, I turn on the SCR and it turns itself off without any instruction from the Arduino. For your FI you'll need to turn the fuel on then turn it off at a particular moment to maintain your 14:1 ratio.

Yours is an ambitous project. It would be easier to develop this on separate Arduinos for ignition and FI or perhaps moving it to an Arduino Due (84Mhz, 32bit about 20 times faster when using long variables). With separate maps you probably want "rain" and "sport" or whatnot. Reading both wheels says TC? You can make a soft rev limiter with only the advance curve.

My project is to have an ignition that simply follows what the engine RPM dictates. It looks like you want far more control. Is it possible to have your ignition simply follow and use your maps (and wrist) to control the butterflies and FI?

I agree with rC that you need to identify all the signals available to you. I bought a $100 Arduino oscilloscope specifically for my project and it has provided much entertainment.

I also made a spreadsheet with engine RPM in the first column then showing various timings in other columns. Surprise, calculating the time to fire the plug at idle is more complex than firing through the advance curve. You have more events to coordinate and a spreadsheet might help manage them.

Good luck!

I really liked that idea of putting the 1/4 cyl. in the D1, and the 2/3 in the D2, but I only have one pickup and 2 magnets at the crank.

The pickup just sends a signal when of them passes. I’ll get an osciloscope and then report back.

tiago_duke: . . . one pickup and 2 magnets at the crank.

Oh. Wow. :~

EDIT: The fuel injector really HAS have more information about the piston position and what cycle it's on. The magnets on the rotor and the single pickup may signal the time to spark, but information about which cylinder is about to fire is there somewhere. You'll still have a wasted spark system since that's how the coils are set up. (But you knew that.)

I know this is old post.
Reason i found it is cause i’m looking to make something like this project but on two cylinder motor.

But i can give you an idea if you have not solved your TDC issue.

Diamond Star Motors (Eagle Talon, Mitsubishi Eclipse, Plymouth Laser {all 2.0l}) have 4 cylinder motor with wasted spark ignition ( running like 2 cylinder etc… )

here is CAS (cam angle sensor)

That big cut out tells ECU TDC and rest of the smaller cut outs are to tell where the motor is since it knows how many of them and where the TDC was . That sensor has the IR led and receiver in curtain years other years of the DSM is hall effect ( as i’m told ).

Since this is used on Camshaft this spins half the rotation as the crank. So you need to somehow attach it to the camshaft and you will have TDC 1 instead TDC 1-4 if attached to the crank.

BTW this is from 1990-1994 cars so good luck finding it in the junk yard.
Oh and this sensor runs on 5v ( I THINK , it’s been YEARS since i played around in my car)