Hold low signal for short amount of time

I have a AC signal fed into a opto coupler, and the output of that has a pullup resistor.
The resulting signal goes into a MCP23008 (I2C IO expander) which is read by the photon.

Problem is the signal being AC only triggers the output for a part of the cycle time, so I need to hold the signal low long enough for the next cycle to catch it, since reading the MCP is a bit hit and miss currently, and using the interrupt system on the MCP only works for one pin at time (I need 4).

I have figured out a solution using a small microprocessor to handle and hold the signals, but before I go down that route, I would like to to know if anyone knows an off the shelf IC that actually does the same thing ?

Working example code of my delay system, for just one input.
(It wont actually be running on a photon, but it was the fastest way to proto it :smile:)


int cnt = 0;

void setup()
    pinMode(D4, OUTPUT);
    pinMode(D0, INPUT);

void loop()
    if (digitalRead(D0) == LOW)
        cnt = 1000; //Just over 10ms

    if (cnt > 0)
        digitalWrite(D4, LOW);
        digitalWrite(D4, HIGH);

Are you sure the interrupt can only be enabled for a specific pin? According to the data sheet I looked at, the GPINTEN and INTF registers are bit fields - so you can trigger on any inputs you want, up to 0xFF for all of them. It’s been a while since I’ve used the chip, but that’s how I remember it working.

True, I can register multiple pins for the interrupt event, but there is only one interrupt pin.
So once the interrupt happens I can read INTCAP/INTF register to see which pin caused the interrupt and reset it.

But if I have 4 inputs at 50hz, the interrupts will happen much too fast to catch them all that way, however I am not actually interested in counting pulses, only that a input is active, so a bit clumsy solution could be to enable interrupt for one pin, wait 100ms, then enable for pin 2, and so on, not very stylish though :slight_smile: