
ESP8266 Analog Broadcast Television Interface - nkurz
https://github.com/cnlohr/channel3
======
kaoD
> You may say "But nyquist says you can't transmit or receive frequencies at
> more than 1/2 the sample rate (40 MHz in this case). To a degree that is
> true. Some people thought it may be overtones, but what happens in reality
> something stranger happens. Everything you transmit is actually mirrored
> around 1/2 the sample rate (40 MHz).

For anyone interested this is called aliasing.

If you've ever noticed wheels going backwards in racing or train footage, this
is exactly what's happening: the wheel's angular velocity is above half the
sampling rate (i.e. the camera's FPS), producing a mirrored version which in
turn appears to rotate backwards.

~~~
mkesper
Note this is probably illegal in several countries, though.

------
pjc50
Neat. Note that this technique will work on _any_ system that has a high-speed
I2S bus that can be operated by DMA, which these days is quite a lot of
microcontrollers.

See also Fabrice Bellard's DVB-T broadcast using XWindows:
[http://www.bellard.org/dvbt/](http://www.bellard.org/dvbt/)

It's a kind of reverse "TEMPEST": rather than detecting a computer's
accidentally radiated emissions, deliberately radiate emissions in a
particular pattern to produce a radio signal.

------
SEJeff
Isn't this the same little chip they're doing a kickstarter for micropython
on?

[https://www.kickstarter.com/projects/214379695/micropython-o...](https://www.kickstarter.com/projects/214379695/micropython-
on-the-esp8266-beautifully-easy-iot)

This is really impressive.

~~~
nivla
Yes and you can also run Lua, Javascript, Arduino/C on it.

However I thought there was already a micropython firmware for it [1]. What
extra does this kickstarter bring in?

[1] [https://learn.adafruit.com/building-and-running-
micropython-...](https://learn.adafruit.com/building-and-running-micropython-
on-the-esp8266/overview)

~~~
SEJeff
A whole lot of testing and functionality. I've used micropython on a few of my
esp boards, and while it works, it is exceedingly buggy. I write most of my
apps for esp boards in the Arduino IDE in C, which is totally fine, but it is
easier to prototype in Python, so I backed it.

------
xt00
Would be cool to see an spectrum plot of the output signal.. the explanation
of why the signal is picked up seems a bit too vague for me.. Since the
transmitted signal will be a square wave I imagine, I would expect to see some
side-bands that are pretty significant above and below the 80MHz.. And then
the 61MHz signal that the TV would normally receive should be actually
received using some local oscillator that I would guess is down around like
10MHz or something.. so would love to get a more detailed explanation on this
stuff if anybody knows what actually is happening beyond "some people think
its blah, but really its blah!! huzzah!" type of explanation..

~~~
cnvogel
First, a 80MHz square wave does _not_ have side bands that are significant
below 80MHz, only above! And if it's configured for alternating 0/1 bits, a
serial port at 80MBaud creates a square wave of exactly 40 MHz.

Furthermore cnlohr doesn't use a fixed square-wave but a variable sequence of
pulses. And a single pulse of (1/80Mhz)=12.5ns will have a sinc spectrum. sinc
f=(sin f)/f. For an infinitely sharp-edged pulse, this sinc-spectrum basically
extends to infinity, for real-world pulses you can expect to see a few
harmonics.

[https://www.wolframalpha.com/input/?i=fourier+transform+box+...](https://www.wolframalpha.com/input/?i=fourier+transform+box+function)

cnlohr basically uses the synchronous serial i2s interface, running at
80Mbits/s as a 1bit DAC with a zero-order hold (stretching out a constant
voltage over the bit time), so this DAC will recreate anything between
0..40MHz correctly (within the capabilities of its pretty poor quantisation
noise and within the first lobe of the sinc-spectrum).

[https://en.wikipedia.org/wiki/Zero-
order_hold](https://en.wikipedia.org/wiki/Zero-order_hold)

[http://www.ee.ic.ac.uk/pcheung/teaching/ee2_signals/Lecture%...](http://www.ee.ic.ac.uk/pcheung/teaching/ee2_signals/Lecture%2013%20-%20Sampling%20&%20discrete%20signals.pdf)
(last slide)

But, any signal you recreate will, because it's made up of the single pulses
with the sinc spectrum, not only have energy between 0...+Fs/2 but also
between N-1/2 and N+1/2 times the sampling frequency. There's a obvious trick
involving the fact that convolution in the time domain corresponds to
multiplication in the frequency domain, but unfortunately I can't really
recall it correctly now... so you have to just take my word for it ;)

And that's why, if this "DAC" outputs 1MHz, you also get 79 and 81.

[http://www.analog.com/media/en/training-
seminars/tutorials/M...](http://www.analog.com/media/en/training-
seminars/tutorials/MT-017.pdf) (here's a nice graph)

Conversely, when you try to output a sharp pulse on your soundcard, e.g. an
audiofile consisting of {zeroes, one sample of 32000, zeroes...}, the output
to your headphones will be something like a sinc pulse. The Fourier transform
of this since pulse in the time domain will be a box function from 0..half the
sample rate in the frequency domain, and hence no higher harmonics will be
output.

~~~
xt00
Ah ok, this is great thanks. Yea so outputting a string of 11001100.. would
produce a 20MHz waveform, so, then the 3rd harmonic of that is 60MHz, right,
so that's what is being picked up? Yea you are right about the harmonics of
the ideal square wave, but I was thinking along the lines of a distorted
version of the perfect square wave that you get from a typical RF type signal
that I've seen on spectrum analyzers many times -- typically you don't have
this perfect delta function sitting at your carrier frequency -- it has some
extra stuff going on next to it above and below (other than the modulated
signal -- not nearly as far away as the F*2 or F/2 type range), but hey I'm
not an RF engineer, so I'll just stop speculating in that area. I'm an EE, so
I get what you are talking about but thanks for the details--I'm sure plenty
of people will benefit from it. Still would love to see a PSD spectrum plot of
the output signal from 10MHz to 160MHz or something like that kind of range.

------
mkj
Nice work. The author's non-euclidean ray tracing engine looks crazy and cool
too.
[https://www.reddit.com/r/gamedev/comments/2jjug9/i_wrote_a_s...](https://www.reddit.com/r/gamedev/comments/2jjug9/i_wrote_a_strange_realtime_raytracing/)
(watch the video and imgur)

