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

Click For Summary

Discussion Overview

The discussion revolves around the detection of zero crossing signals using an Arduino, focusing on the occurrence of non-uniform spikes in the interrupt signal. Participants explore the implications of sampling rates, pulse widths, and the behavior of the circuit in detecting these signals.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Experimental/applied

Main Points Raised

  • One participant describes their circuit setup for zero crossing detection and notes that while most spikes reach zero, some do not, raising questions about their detection as interrupts.
  • Another participant inquires about the width of the zero crossing pulses and the sample rate of the serial plotter.
  • A participant expresses uncertainty about the pulse width due to the lack of an oscilloscope and mentions that interrupts are triggered on voltage transitions.
  • One suggestion is made that the spikes may not be observed properly due to their narrow width relative to the Arduino's sampling resolution.
  • A later post indicates that increasing the sampling rate to 38400 baud resulted in a more uniform graph, suggesting an improvement in the detection of zero crossing pulses.
  • Another participant notes that some zero crossing pulses are sampled multiple times while others are only sampled once, indicating variability in the detection process.

Areas of Agreement / Disagreement

Participants express differing views on the causes of the non-uniform spikes and the effectiveness of the sampling rate. There is no consensus on the underlying reasons for the observed behavior of the interrupt signals.

Contextual Notes

Limitations include the lack of an oscilloscope for precise measurement of pulse widths and the dependence on the Arduino's sampling resolution, which may affect the detection of narrow spikes.

Wrichik Basu
Science Advisor
Insights Author
Gold Member
Messages
2,186
Reaction score
2,694
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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: Borek and Wrichik Basu

Similar threads

Replies
7
Views
3K