Buzzcoil using arduino

Hi all!

I recently got an UNO R3 board (never worked with one before) , i am trying to find an alternative to the circuit i use as a spark generator for the ignition system of an old 2 stroke 2 piston engine (image called active) ,attached are image files of the two options i have simulated on TINA TI called 1pf and 2sf.

I wanted to ask for help regarding the following:

Where can i find instructions on how to write a code for the UNO board that can turn 1 pin (pin1) of it into a square wave generator (75% duty cycle) and (1.2KHz frequency) ?

Should the pin programmed as a square generator be wired for example pin 1 to my circuit either 1pf or 2sf as shown ,and ground from the pin side of the UNO to the same ground as my MOSFET and coil , or just the pin 1 to my circuit without ground from the pin side of the UNO being connected?

According to the simulations, circuits 1pf and 2sf will work , will they?

Thank you for your time!

Here's code that should generate the waveform you want, using output compares on TC1:

//#define MEGA    1           //comment out for Uno R3

#ifdef MEGA
const byte pinSpk = 12;      //OC1B PB6 on the Mega2560
#else
const byte pinSpk = 10;     //OC1B PB2 on Uno R3
#endif

    
//clkIO = 16MHz == 62.5nS/tick
//
//  1.2kHz -> 833.33uS
//      /62.5nS     13333   /1 prescaler OCR1A
//
//  OCR1B
//  Values
//      TOn arbitrary at 250 ticks
//      75% of 13333 is ~10000
//          - TOff at count Ton+10000
#define TON     250
#define TOFF    (10000+TON)

void setup() 
{
    pinMode( pinSpk, OUTPUT );

    //TCCR1A
    //76543210
    //00010000
    TCCR1A = 0x10;

    //TCCR1B
    //00001001
    //WGM3:0 = 0100         //
    //CS12:0 =  001         // /1 prescale
    TCCR1B = 0x09;
    
    //set up output compare values
    OCR1A = 13333;          //repetition rate
    OCR1B = TON;            //start of pulse ticks
    TIMSK1 = 0b00000100;    //enable OC1B interrupts;

}//setup

void loop() 
{
}//loop

ISR( TIMER1_COMPB_vect )
{
    //when pin is high, set next OC ~10000 ticks from 
#ifdef MEGA    
    if( PINB & 0b01000000 )     //PB6 of Mega2560
#else
    if( PINB & 0b00000100 )     //PB2 of Uno
#endif
        OCR1B = TOFF;
    else
        OCR1B = TON;
        
}//ISR_COMPB

In your circuit drawing the MOSFET is oriented incorrectly. I fave the second in principle but the source of the FET should be tied to ground, the output of the coil connected to the drain.

If the 12V battery has some capacity consider adding a 5A (estimate) fuse; if the MOSFET fails in the shorted condition or the Arduino hangs and leave the FET on you'll have a risk of fire or burned wiring.

You may need to add some snubbing to protect the MOSFET when the coil turns off; a sizeable diode across the coil primary (cathode to the battery-side) should serve that purpose.

As with all spark-ignition stuff, shielding and power-supply quality to the Arduino will be important to avoid RFI-related glitching and failure.

Thank you very much for the info Blackfin, i've updated the diagram for the second alternative according to your advise,(image called 2sf_1), only the fuse is missing cause i don't know how to draw it on TINA TI.

Regarding how to connect the UNO board to the circuit , is it correct to connect output pin to gate and the UNO pin collumn GND to the ground of my circuit, or does the UNO behaves like a 1 terminal square wave source?

engelsheidt:
Thank you very much for the info Blackfin, i've updated the diagram for the second alternative according to your advise,(image called 2sf_1), only the fuse is missing cause i don't know how to draw it on TINA TI.

Regarding how to connect the UNO board to the circuit , is it correct to connect output pin to gate and the UNO pin collumn GND to the ground of my circuit, or does the UNO behaves like a 1 terminal square wave source?

Yes, definitely connect the grounds together.

But you need to be careful with ground paths to ensure good operation; you want your ignition circuit to have its own low-impedance ground connection back to the battery ground. For example, the cylinder head should have a reasonably thick, many-conductor braided connection to the chassis. The battery GND would be connected to the chassis through its own dedicated wire.

The Arduino grounds will also return to the battery; a short GND to the chassis is okay as long as its run is separated from the plug ground. You want to keep the "noisy" stuff physically separate from the sensitive stuff as you don't want spark RFI getting into the power, ground or signal wiring from the Uno.

Hi,
Ops last circuit.


Tom.. :slight_smile:

Hi,
Putting D1 across the coil primary will clamp the performance of the ignition coil.

They do not have D1 in electronic ignition systems, the protection is built around the switching BJT or MOSFET or IGBT.

The MOSFET you have selected, is only rated to 75V Drain to Source breakdown.

If you google

electronic ignition schematics

You will see various circuits and the switching transistor that they use.

Tom... :slight_smile:

Update: Thanks TomGeorge!

I swapped the MOSFET for an IRF740, the other parts i used are also on the diagram , with the following code the DIS behaves like a buzzcoil.

void setup() {
pinMode(3, OUTPUT);
pinMode(11, OUTPUT);

}

void loop() {
// put your main code here, to run repeatedly:

TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM20);
TCCR2B = _BV(WGM22) | _BV(CS22);
OCR2A = 180;
OCR2B = 50;
}

// i got the code from https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM

How can i make the spark stronger ?

Did your engine originally have a magneto ignition?

Paul

You need that transistor to turn off quickly to generate a strong spark. With a fairly significant input capacitance and a 10K resistor from an Arduino pin, I'm guessing its turn-on and turn-off are fairly sloppy.

You're also only driving the gate to 5V. Although the transistor's Vgs(th) is 4.0V max, it doesn't really turn on "hard" until 10V. Combined with the inductance of the coil, you're probably not close to saturating the coil.

You might consider a low-side MOSFET driver between the Arduino and the FET. For example, the Microchip TC4421AVPA (Digikey P/N TC4421AVPA-ND). That can source/sink the considerable current requirements of the gate during switching.

You might also consider using an IGBT in place the FET but use care in choosing one that the Arduino can drive.

Paul_KD7HB:
Did your engine originally have a magneto ignition?

Paul

Hi!

No , it's a Fairmont RK B 2 piston engine

Blackfin:
You need that transistor to turn off quickly to generate a strong spark. With a fairly significant input capacitance and a 10K resistor from an Arduino pin, I'm guessing its turn-on and turn-off are fairly sloppy.

You're also only driving the gate to 5V. Although the transistor's Vgs(th) is 4.0V max, it doesn't really turn on "hard" until 10V. Combined with the inductance of the coil, you're probably not close to saturating the coil.

You might consider a low-side MOSFET driver between the Arduino and the FET. For example, the Microchip TC4421AVPA (Digikey P/N TC4421AVPA-ND). That can source/sink the considerable current requirements of the gate during switching.

You might also consider using an IGBT in place the FET but use care in choosing one that the Arduino can drive.

Hi!

I understand! Would a Fga25n120 be a better option?

I've read that the FGP3440G2_F085 works well with Arduinos:

Blackfin:
You need that transistor to turn off quickly to generate a strong spark. With a fairly significant input capacitance and a 10K resistor from an Arduino pin, I'm guessing its turn-on and turn-off are fairly sloppy.

You're also only driving the gate to 5V. Although the transistor's Vgs(th) is 4.0V max, it doesn't really turn on "hard" until 10V. Combined with the inductance of the coil, you're probably not close to saturating the coil.

You might consider a low-side MOSFET driver between the Arduino and the FET. For example, the Microchip TC4421AVPA (Digikey P/N TC4421AVPA-ND). That can source/sink the considerable current requirements of the gate during switching.

You might also consider using an IGBT in place the FET but use care in choosing one that the Arduino can drive.

The part about my UNO driving the gate to 5V got me thinking. So i measured the voltage input that feeds my UNO board (9.31 V) and then the voltage output of the board (pin11 + GND) and it was just 2.48 V, is that normal or is my multimeter wrong?

A standard voltmeter won't give you much info about a pin switching like this because sometimes the pin is high and sometimes it's low which can cause the meter to sort of "average" the reading, but not really.

When I mentioned 5V, that's what the pin output would be when the IGBT/FET is "on" but that's only part of the cycle. You need an oscilloscope to be sure of the switching and levels.

Is your pin 11 ALWAYS set high? Never goes low? Bet you are measuring alternating high and low.

Paul

Paul_KD7HB:
Is your pin 11 ALWAYS set high? Never goes low? Bet you are measuring alternating high and low.

Paul

Indeed the pin is PWM output, so the only way to measure the real V is to just turn it on all the time instead of on and off and then measuring?

engelsheidt:
Indeed the pin is PWM output, so the only way to measure the real V is to just turn it on all the time instead of on and off and then measuring?

Yes, unless you are using an oscilloscope that will give you the voltage on the "high" part of the trace.

Paul

Update

Instead of the MOSFET i installed the IGBT model NGD8201ANT4G, the diagram remains almost the same as 2fs_2.

The UNO board runs the same code as 2fs_2.

The spark seems to be stronger, i don't know how to measure the spark's V.

If a conventional 12v car battery is used instead of the MP-EL12V5A could be necessary to add a ballast resistor between the battery's + and the DIS coil +.

Edit: Changed MP-EL12VA to MP-EL12V5A

Hi.
OPs new circuit;


Did the ignition coil originally have a ballast resistor?
If not, then you don't need it.
Ballast resistors were used when coils were made with 10V primary, so that you could get a good spark when the battery voltage dropped when starting.
These days it is not necessary as coils and batteries are better designed.

Tom.... :slight_smile:

TomGeorge:
Hi.
OPs new circuit;


Did the ignition coil originally have a ballast resistor?
If not, then you don't need it.
Ballast resistors were used when coils were made with 10V primary, so that you could get a good spark when the battery voltage dropped when starting.
These days it is not necessary as coils and batteries are better designed.

Tom.... :slight_smile:

Hi!

When i used a relay in the circuit , the coil could only generate sparks if 2 ballast resistors in series were wired between the car battery and coil +, if the circuit was connected to the MP-EL12V5A would instead only need 1 ballast resistor. (active.png)

The primary of my DIS coil has a resistance of 0.6 Ohms and the ballast resistor i use is 1.6 Ohms.