Go Down

Topic: Detection of saw tooth or square wave (Read 898 times) previous topic - next topic

cprovost

Does anyone know a basic circuit I could make so I could determine if a signal is either a saw tooth or square wave? Should I judge voltage peak to peak of a wave or the pulse? Is there a simple way to do such a thing? The frequency is on the order of 100 kHz, 10mA current source, RMS of signal is 5V.


RuggedCircuits

Can you listen to it on headphones or speaker? You can tell what type it is from the sound.

Or do statistical sampling: take N samples of the waveform and see how many "in-between" values there are. If there are fewer than Q, it's a square wave (which should have no "in-between values") else it's a sawtooth.

--
The Ruggeduino: compatible with Arduino UNO, 24V operation, all I/O's fused and protected

cprovost

Would I need some type of circuit to actually do the sampling or could I do it all in code? Do you have an example?

BillO

Isn't there a FFT library for Arduino?

I wonder if it would keep up.


Facts just don't care if you ignore them.

Magician

FFT would be fine, problem could be with ADC,  100 kHz is too much for its, as also too much to peak up "by ear". :)
The only way I'd suggest, use arduino input capture hardware. If signal is exactly 5V and duty cycle of square wave 50% , probably, would be little difference in pulse duration, as default digital hysteresis close to 2.2 - 2.4 V. But it easy to set a divider ( 70 % let say), than voltage 3.5 V will trigger input capture in different proportion,  saw tooth create shorter pulses, and even shorter with higher divider ( 55 - 60 %).
Other option, use input capture + analog comparator.
For code, look here : http://interface.khm.de/index.php/lab/experiments/frequency-measurement-library/
Or "copy-paste" from: http://fftarduino.blogspot.com/2011/12/arduino-laser-3d-tracking-range-finder.html

cprovost

Thanks, I will try it this week. If you come up with any other ideas let me know.

Go Up