Pin change interrupt multiple fire

snail71
Posts: 3
Joined: Wed Nov 08, 2017 1:56 pm

Pin change interrupt multiple fire

Postby snail71 » Tue Nov 14, 2017 2:07 pm

I have a pin (34) setup as an input. This pin is connected to a triac opto that generates a clean signal. I have it setup to generate an interrupt on falling edge. This is so I can detect zero crossings that will be used to fire an output triac. The problem I am having is that with each pulse the interrupt is firing MANY times on both rising and falling edges. It is acting like it is seeing bounces from a mechanical switch not from a clean sign wave signal.

Image

Image

Here is some of the code:

#define ZX_PIN 34
#define TRIAC1 26

void zero_cross()
{
// just toggle the pin for now
digitalWrite(TRIAC1,!digitalRead(TRIAC1);
}

void setup()
{
pinMode(ZX_PIN,INPUT);
pinMode(TRIAC1,OUTPUT);
digitalWrite(TRIAC1,LOW);
attachInterrupt(digitalPinToInterrupt(ZX_PIN),zero_cross,FALLING);
}

void loop()
{

}

Who is online

Users browsing this forum: No registered users and 4 guests