Arduino and zero crossing — Non-uniform spikes in interrupt signal

Click For Summary
The discussion focuses on an Arduino circuit designed for zero crossing detection, where the user initially observed non-uniform spikes in the interrupt signal. The spikes sometimes did not drop to zero, raising concerns about their detection as interrupts. After increasing the serial plotter's sample rate from 9600 to 38400 baud, the user achieved a uniform graph, indicating that the issue was related to sampling resolution. The improved sampling allowed for better visibility of the zero crossing pulses, confirming the circuit's functionality. Continuous reading of the input can help analyze the low time from the duty cycle.
Wrichik Basu
Science Advisor
Insights Author
Gold Member
Messages
2,180
Reaction score
2,721
Here is my circuit for detecting zero crossing with Arduino (same circuit as this thread, but with the correction for the interrupt pin):

main_schematic_bb.png
Once again, I am using analogRead(A0) as an oscilloscope.

The interrupts are detected fine, and my Interrupt Service Routine (ISR) is also being called. Here is the graph plotted by the Arduino serial plotter:

interrupt_graph_1.jpg


On the left of the graph, you can see that most of the spikes are coming down to 0 from around 1023, which is very good and what I want. But to the right, you can see some spikes that do not come all the way down. These are marked with red arrows. There is a chance that these will not be considered as interrupt by the Arduino. Any idea why these spikes do not come down to 0?

Also, there are some green arrows in the graph. These arrows point to spikes that occur very close to another spike. These are unexpected. Fortunately these do not come all the way down, so most probably the Arduino won't consider these as interrupts. But why are these occurring, and how to avoid them?

Note that these anomalous spikes are not occurring all the time, but only sometimes.

Edit: Removed unnecessary images.[/size]
 
Last edited:
  • Like
Likes atyy
Engineering news on Phys.org
How wide are the zero crossing pulses?
What is the sample rate of the serial plotter?
 
Baluncore said:
How wide are the zero crossing pulses?
No idea. I don't have an oscilloscope, and it is nearly impossible to conclude about the pulse width from the Arduino graph. I have programmed the Arduino such that the interrupts are triggered every time the voltage falls from HIGH to LOW.
Baluncore said:
What is the sample rate of the serial plotter?
9600 baud.
 
Could be these spikes go nicely all the way to zero, they are just too narrow for being observed/detected properly at the Arduino sampling resolution.
 
  • Like
  • Love
Likes atyy and Wrichik Basu
Borek said:
Could be these spikes go nicely all the way to zero, they are just too narrow for being observed/detected properly at the Arduino sampling resolution.
Increased sampling rate to 38400 baud. This is the graph I get:

1608887231168.png


Absolutely uniform graph. Problem solved. My circuit is fine.

Thanks a lot!
 
  • Like
Likes atyy and Borek
Wrichik Basu said:
Absolutely uniform graph.
You can see now that some zero crossing pulses are being sampled twice while they are low, others are being sampled only once and so have only one point at the bottom.

You can find the low time, from the duty cycle, by reading the input continuously, while keeping a count of the highs, and a count the lows, for a several seconds.
 
  • Like
  • Informative
Likes Borek and Wrichik Basu
Thread 'I thought it was only Amazon that sold unsafe junk'
I grabbed an under cabinet LED light today at a big box store. Nothing special. 18 inches in length and made to plug several lights together. Here is a pic of the power cord: The drawing on the box led me to believe that it would accept a standard IEC cord which surprised me. But it's a variation of it. I didn't try it, but I would assume you could plug a standard IEC cord into this and have a double male cord AKA suicide cord. And to boot, it's likely going to reverse the hot and...

Similar threads

Replies
7
Views
2K