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

In summary, the zero crossing pulses are being sampled twice when they are low, which causes the anomalous spikes in the graph. The increased sampling rate fixes the problem.
  • #1
Wrichik Basu
Science Advisor
Insights Author
Gold Member
2,138
2,713
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.
 
Last edited:
  • Like
Likes atyy
Engineering news on Phys.org
  • #2
How wide are the zero crossing pulses?
What is the sample rate of the serial plotter?
 
  • #3
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.
 
  • #4
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
  • #5
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
  • #6
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

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

What is Arduino and how does it relate to zero crossing and non-uniform spikes in interrupt signal?

Arduino is an open-source microcontroller platform that allows users to create interactive electronic projects. It can be programmed to read and control various sensors and devices, making it useful for tasks such as measuring zero crossings and detecting non-uniform spikes in interrupt signals.

Why is it important to detect zero crossings and non-uniform spikes in interrupt signals?

Zero crossings refer to the point where an AC signal changes from positive to negative or vice versa. Detecting these points is important in applications such as power measurement and control. Non-uniform spikes in interrupt signals can also indicate issues with the circuit or signal, making it important to detect and address them.

How does Arduino detect zero crossings and non-uniform spikes in interrupt signals?

Arduino can use its built-in analog-to-digital converter (ADC) to measure the voltage of the signal at specific intervals. By comparing the voltage values at these intervals, it can detect zero crossings and non-uniform spikes in the interrupt signal.

Can Arduino be used to filter out non-uniform spikes in interrupt signals?

Yes, Arduino can be programmed to filter out non-uniform spikes in interrupt signals by setting a threshold for the voltage values. Any voltage values above this threshold can be considered as spikes and can be ignored or smoothed out in the data analysis process.

Are there any limitations to using Arduino for measuring zero crossings and detecting non-uniform spikes in interrupt signals?

Yes, there are some limitations to using Arduino for these tasks. The accuracy of the measurements may be affected by the sampling rate of the ADC and the processing speed of the microcontroller. Additionally, external noise and interference can also affect the readings. It is important to consider these factors when using Arduino for these purposes.

Similar threads

Back
Top