Square wave filtering question! - Page 1
Forum section: electronics / projects

author: demispark
author_rank: Newbie
timestamp: August 21, 2020, 03:28:11 am
content: Hello everyone,I'm currently a senior EE student about to start my senior project. I've been thinking of some ideas and believe I have a promising one however I have a few questions that remain unanswered. I would like to develop a positioning system using inferred light. I will have a source using IR LED's and receivers using phototransistors.Is it possible to filter a particular frequency square wave from other frequency square waves? I can then process these signals individually.My idea is that if i want to use multiple light sources, they should be modulated at different frequencies. Is it possible to decipher which source the signal is coming from with the phototransistor? Is there a filter that can pick out a particular square wave at a certain frequency?Perhaps I am going about this the wrong way. Any feedback is appreciated!

author: bob91343
author_rank: Super Contributor
timestamp: August 21, 2020, 04:58:03 am
content: Recognize that a square wave is composed of many frequencies. If you superimpose two square waves of different frequencies you get a hodge podge of elements. About the only thing that might work is to filter specific components that are unique to each signal.If you have square waves at 1 kHz and 1.1 kHz then you only get a 3 kHz component when the first one is present, and only get a 3.3 kHz when the second one is present. So a narrow filter could tell when a specific wave is present, as long as the spectrum of each is unique.If you have more than two signals you must be careful in selecting the frequency. Of course you can look for the fundamental also.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 21, 2020, 05:21:02 am
content: Sure, use synchronized (coherent) squarewaves and a mixer. This correlates the signal with a reference, rejecting anything out of phase on average -- which is any other frequency than the wave and its harmonics.So you'll still have selectivity at (odd) harmonics, the width of those bands being the passband of the "averaging" filter.In the limit as averaging is done over all time, the bandwidth is zero, and non-harmonic frequencies are orthogonal (fully excluded).Sine waves have the particular orthogonality feature that they are unique (down to sign), i.e. they have no harmonics. All other waveforms have harmonics, and may have nonzero mixing products there. Hence why we're so interested in sinusoidal signals for RF purposes.Over finite time scales, the averaging is just a filtering process, so you need to take some account of what interfering signals may be present, and how much is tolerable relative to your signal strength (in other words the SNR).Tim

author: hamster_nz
author_rank: Super Contributor
timestamp: August 21, 2020, 05:44:31 am
content: I thought about this for a while too once, and came to the conclusion that best luck might be had when the frequencies were relatively prime (e.g 700Hz, 900Hz 1100Hz). What information are you attempting to get? (e.g. time of flight, brightness, phase, a data stream...)Have you considered using a pattern, maybe:"FLASH ALL CHANNEL" "FLASH CHANNEL 1" "FLASH CHANNEL 2" "FLASH CHANNEL 3"with a few milliseconds between channels

author: Marco
author_rank: Super Contributor
timestamp: August 21, 2020, 02:36:30 pm
content: Quote from: demispark on August 21, 2020, 03:28:11 amYou can modulate the burst from each transmitter with a different frequency so you can seperate them out ... you can even do it with square waves, just use power of 2 frequencies and the Hadamard transformer.But doing all that while keeping the signal clean enough to measure edge movement of the squarewave with picosecond accuracy, forget about it.

author: David Hess
author_rank: Super Contributor
timestamp: August 22, 2020, 06:56:53 pm
content: I agree with T3sl4co1l; synchronous demodulation will do exactly what you want to do with the best possible performance. The LEDs could even be modulated with different patterns, or even noise, rather than different frequencies. If different frequencies are used, then they need to be non-harmonically related.Filtering will of course also work if you have no way to synchronize the transmitters and receivers.

author: Marco
author_rank: Super Contributor
timestamp: August 22, 2020, 07:48:56 pm
content: The standard "easy" range detection passes a received square wave with a reference squarewave through an XOR gate and low passes the result for the ADC ... that's a pretty sensitive operation to begin with. The circuitry to make a squarewave of the received signal can very easily introduce significant phase shift based on signal strength. Moreso if you try to stack a whole bunch of different signals.Seperating things in time makes things easier.

author: KT88
author_rank: Frequent Contributor
timestamp: August 22, 2020, 08:50:45 pm
content: Is there a particular reason to use squarewave? It might be easier to implement it on the emiiter side but it would insrease the complexity on the recieve side. A sinewave modulated current source is not hard to do. With a sine wave you also would put all energy into the fundamental frequency and not into the harmonics. With narrow band filtering you could achieve a very good dynamic range if that is of interest.What is the desired frequency range b.tw.?

author: Conrad Hoffman
author_rank: Super Contributor
timestamp: August 23, 2020, 02:55:34 am
content: People have done something similar using sine waves or filtered square waves, and the old 567 tone decoder chips. It appears they're still made.

author: oPossum
author_rank: Super Contributor
timestamp: August 23, 2020, 04:01:33 am
content: Quote from: demispark on August 21, 2020, 03:28:11 amYes - the Walsh transform can do this. It is like the Fourier transform, but uses (1,-1) instead of reals. It can be implemented using only XOR and ADD.I did a DTMF decoder using the Walsh transform with non-orthogonal basis functions. The input audio is clipped to a square wave.

author: ejeffrey
author_rank: Super Contributor
timestamp: August 23, 2020, 05:23:38 am
content: Quote from: KT88 on August 22, 2020, 08:50:45 pmIf you are doing synchronous demodulation square waves work pretty much just as well as sine waves.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 23, 2020, 07:33:30 am
content: Even more generally, any set of orthogonal codes will do -- read up on CDMA for ideas. And it works from both sides, analog and digital -- there arefilters perfectly crafted to optimize digital signal quality.You can dive quite deeply indeed in this field; modern radio communications takes full advantage of the immense processing power available in modern technology. (Typically, a BT, Wifi, 4G, 5G, Lora, etc. chip includes on-chip tuned circuits (filters and amplifiers), baseband or equivalent-time-sampled acquisition (ADC), DSP filtering and demodulation, code/key descrambling, error detection and correction, and some network stack. It's a magnificently complex system, all in the name of performance per dollar!)This is probably getting rather far away from the original purpose though -- distance sensing, sounds like the intent might've been to detect the relative amplitudes of each emitter, being able to separate them by frequency or code. This isn't a great idea, because signal strength can vary fromso many factorsbesides sheer physical distance. Amplitude sensing is one of the least reliable methods of signal reception and detection.A much better system is to use the relative delay between sources, and triangulate position from there. This can be tricky -- fractional nanoseconds must be resolved. But it is eminently solvable. Indeed, fractional nanoseconds are no problem with even a modest PLL and some clever circuitry (maybe something better than a garden-variety phase detector, but that's a good starting point). You might need some advanced analog circuitry or an FPGA to implement the full signal processing chain (for some level of complexity and performance), then probably a MCU to do the trig.FWIW, distance imaging sensors(e.g. Xbox Kinect)typically use a pulsed illumination source, and a coherent (equivalent-time-sampled) image sensor, to resolve the phase shift (per pixel!) into a signal level. The illumination source can be a modest frequency, 10s of MHz for example. Even though the phase shift is small (a few ns), as long as the detection is proportional, that's fine, it's a 2simple matter of signal level. It can also be averaged over many thousands of samples (15MHz makes 250k cycles every 60Hz frame!), giving reasonable SNR even after amplification.Of course, a distance sensor is a monostatic radar system, different from what you're proposing.Tim

author: gf
author_rank: Super Contributor
timestamp: August 23, 2020, 08:14:26 am
content: Quote from: T3sl4co1l on August 23, 2020, 07:33:30 amIt would certainly be nice if they were, but the rather cheap PrimeSense sensors (Kinekt, Xtion, etc.) are unfortunately not time of flight cameras, but are parallax/triangulation-based. They project a static IR pattern onto the 3D-scene, which is captured by an IR camera located a couple of centimeters from the projector (similar to stereo vision, but one of the two cameras is replaced by a projector).

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 23, 2020, 09:41:24 am
content: Ah, not that then. Forget which ones are, but I know they're out there...Tim

author: oPossum
author_rank: Super Contributor
timestamp: August 23, 2020, 11:17:21 pm
content: The second generation of Kinect is TOF. Kinect for Xbox One, Kinect 2 for Windows and Azure Kinect.The first gen was a laser projected grid and an ordinary IR camera.

author: oPossum
author_rank: Super Contributor
timestamp: August 23, 2020, 11:19:19 pm
content: List of TOF camerashttps://en.wikipedia.org/wiki/Time-of-flight_camera#Brands

author: Marco
author_rank: Super Contributor
timestamp: August 24, 2020, 01:02:24 pm
content: Sub-ns ToF measurement for a pulse is harder than sub-ns phase difference measurement for a squarewave.