Pages: [1]   Go Down
Author Topic: Detection of saw tooth or square wave  (Read 797 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 600
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Isn't there a FFT library for Arduino?

I wonder if it would keep up.


Logged

Facts just don't care if you ignore them.

Montreal
Online Online
Faraday Member
**
Karma: 27
Posts: 2566
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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". smiley
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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: