Complete Newbie - Programming

Good day, complete newbie here with Arduino. I've copied and a pasted small program for my daughters science project and that's the extent of my programming skills.

I'm wondering if an Arduino Nano or UNO could read four analog pins that are switched from input voltage to ground in a certain order then from that signal on each pin spit out a 5V dc logic level signal on four digital outputs? Input voltage could be either 12v or 5v DC. The output needs to be one shot as soon as the input is changed, then reset. Normal state on the inputs are high and the normal state on the output needs to low. Also the logic level pulse needs to be 3.8mS.

Hope this makes sense, ask questions if you don't understand my request.

Thank you

What you describe can be done. More details may be required, and around here we tend to want you to do the work, we assist. Think you could try a first attempt, post it here, and someone will help?

Start by looking through the examples that come with the software.
Questions - why analog inputs? 5v/0v is digital. Why so precise a pulse length, is something particular connected?

curious, what is it?

I'm trying to fire a smart ignition coil by using a timer on my 1916 ford model t. A timer works opposite of a traditional distributor. It grounds the trembler coils to produce a spark unlike modern cars that apply voltage to get a spark. I'm at the end of my project which is adding fuel injection via a Speeduino. The problem is the stock model t coils produce EMF and it interferes with the Speeduino and most of the sensors. I need to use modern coils for this thing to work.

Due to the fact that my engine is hand cranked I cannot turn the engine fast enough to sync and fire the coils (wasted spark). Luckily I purchased a smart ignition timer a few years ago which replaces the mechanical timer with electronics. It works off a hall effect sensor and other gadgets. It mimics the stock timer in every way but it is way more accurate. The timer grounds each coil when the sensor passes their respective post. It runs at half engine speed. Firing order is 1243

I can present an analog input with 6v (with current limiting circuit) then when the cylinder is ready for spark the timer will ground and the voltage applied to the pin will go to zero. After the event a 5vdc pulse of 8.3mS will be created and sent to the smart coil to fire the plug via a digital out pin. The coil is already wired in the car and works when I inject test pulses (5v)

Hope this helps

probably need to drive the output thru a transistor (bjt, mosfet), so active high output

couldn't the output remain active until the next input is detected?

you can probably condition the input thru a transistor with an appropriately sized resistor such that any voltage above some threshold drives the transistor which can pull a digital input LOW.

so when an input goes LOW, it makes the corresponding output got HIGH, enabling its transistor output, as well as making the previous output LOW

look this over

const byte PinOut [] = { 10, 11, 12, 13 };
const byte PinInp [] = { A1, A2, A3, A4 };
const int Ninp = sizeof(PinInp);

int nLast;

enum { Off = LOW, On = HIGH };

// -----------------------------------------------------------------------------
void loop()
{
    for (int n = 0; n < Ninp; n++)  {
        if (LOW == digitalRead (PinInp [n]))  {
            digitalWrite (PinOut [nLast], Off);
            digitalWrite (PinOut [n], On);
            nLast = n;
            Serial.println (n);
        }
    }
}

void setup() {
    Serial.begin(9600);

    for (int n = 0; n < Ninp; n++)  {
        pinMode (PinInp [n], INPUT_PULLUP);
        pinMode (PinOut [n], OUTPUT);
        digitalWrite (PinOut [n], Off);
    }
}

Sounds like a lot of fun, enjoy it. Just FYI the coils still work the same, you have to apply voltage to the primary charge them then when the voltage is turned off the coil collapse and the high voltage is caused by the coils field collapsing. That is what the timer does. Here is a nice diagram: https://www.fordmodelt.net/downloads/Ignition%20Wiring.pdf The modern cars art similar with a coil for each plug. Some use 1 coil for two spark plugs, each end of the coil secondary is used for a spark plug, That style fires on a dead cylinder and the active one at the same time.

will need a flyback diode across any coil to protect the transistor

No coil driver is needed as it's a "smart" coil which means it only needs a 5V logic level pulse. I guess you could call the input logic level. It would pulse high/low, high/low and output low/high low/high. etc.

so can it be made active until the next coil, or is there a max pulse width?

Dwell time for the coil pack I'm using is 3.8mS on time. The digital output has to be low when not triggered because the coil pack will be "on" if it sees a high signal. This will lead to burnt coil windings if left high.

A few years ago there was a system you could buy to do what I'm doing but the guy stopped selling them and I can't find the schematic to his circuit. He used a "smart" coil to do the same thing. I'm guess he used a timer circuit to do the same thing.

I have no idea what this code does at this point.

look this over.
ask questions about what you don't understand

const byte PinOut [] = { 10, 11, 12, 13 };
const byte PinInp [] = { A1, A2, A3, A4 };
const int Ninp = sizeof(PinInp);

int nLast;

enum { Off = LOW, On = HIGH };

unsigned long usecPeriod;
unsigned long usecLst;


// -----------------------------------------------------------------------------
void loop()
{
    // wait for timer to expire
    unsigned long usec = micros ();
    if (usecPeriod && usec - usecLst >= usecPeriod) {
        usecPeriod = 0;                         // disable timer
        digitalWrite (PinOut [nLast], Off);     // turn off output
    }

    // monitor inputs
    for (int n = 0; n < Ninp; n++)  {
        // detect active input
        if (LOW == digitalRead (PinInp [n]))  {
            usecPeriod = 3800;                  // prog timer for 3.8 msec
            nLast      = n;
            digitalWrite (PinOut [nLast], On);  // turn on output
            Serial.println (nLast);
        }
    }
}

void setup() {
    Serial.begin(9600);

    // configure pins
    for (int n = 0; n < Ninp; n++)  {
        pinMode (PinInp [n], INPUT_PULLUP);
        pinMode (PinOut [n], OUTPUT);
        digitalWrite (PinOut [n], Off);         // initialize output
    }
}

I've removed some unhelpful replies.

If you have an alternative way to help the OP then maybe something like:

The code in reply #xx does what you want, but, if you are struggling to understand it, here is an alternative approach that does the same thing.

Some code

Go with whichever you find best, and ask questions if you don't understand.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.