About a week ago, I got an ESP8266 to broadcast analog television.
It was a lot of fun.
If you're curious you can click on that video now... but if you're not or you've already
seen it, keep watching.
Like the video before, I'm outputting the NTSC video broadcast on Channel 3 ver the
RX pin of the ESP8266.
That's because the high speed pin is wired up to a high speed I2S bus that I can control
at 80 MHz.
One of the other differences with this though is that I have had to unplug the antenna.
I've actually disconnected the capacitor that links it to the antenna.
I have no idea why that took it from barely working at all to working really well with
the network, but that was one big difference.
One of the other notable differences is that now that I'm able to transmit a much clearer
picture, at least much closer to the carrier is that I can have my transmitter here and
all the way over here is the receiver.
This TV is tuned to channel 3 and the signal is a lot clearer.
Another cool thing is this big set here which has much more stringent timing requirements
is completely happy with this signal.
There is a little bit of a difference with this signal, though.
Now, I'm able to encode Chroma.
You may not be able to see it very clearly on this screen, but that's actually color.
I'm still able to get the same resolution.
sort of.
But, uhh I'm having to play some tricks to get it.
One of the other things is it does use a little bit more CPU, so I can only display.
I dunno.
How many is that?
It's only 20 balls on the screen instead of 25.
But, now, the next screen looks really cool.
Now I'm able to put color in anywhere that I would have previously only had black and
white.
COLOR?!
You ask, but HOW?
Well, color isn't that hard to encode.
The problem is you have to both get the main carrier, which for NTSC is 62.
61.25 you also have to encode a chroma signal.
Now it turns out if you just do that the TV receives it.
It's a little more complicated to get it to go, because you have to have the colorburst
and other things set up right, but by encoding the main signal and at the right times, encoding
the chroma signal we can now get glorious color.
Look at those colors.
Look at them.
They're different between this TV and this TV.
Why is that?
Why is NTSC Never The Same Color?
Look at that purple there.
Look at that red there.
Why?
Like before, I'm able to run this website here, running on the ESP8266.
I'm connected directly to it as is the default when you first get it.
Even though it's outputting this NTSC video, the new ESP IOT SDK such better performance
I can get in upwards of 900 Hz over this websockets interface.
If you're curious about this websockets interface, you can click here now.
Anywhere now I have a new tab.
This NTSC tab.
It lets me do actually useful things like setting it to specific screen numbers, so
I can arbitrarily just say "you know what?"
"go back to screen 0" or for this video, let's go to screen 11.
This is a test screen.
This one allows me to try different colors.
You can see right here, there's a fourier analysis of a specific color that I'm going
to be playing with.
So, in this screen here, there's some code.
what this does is it creates two sinewaves.
One at 61.25 MHz for the Luma.
And other one at 61.25 Mhz plus the Chroma carrier.
So, right now this one is outputting at some luma and some chroma. 0.9 and 0.5.
And it's outputting this to color number 6.
It is the second color on the right, from the right second one down, so third one from
the left.
It's the blue one, right there.
It has .9 luma and .5 chroma.
And, a phase off set.
I can change that phase offset, and in real time, just by changing this code here, it
updates the value on the ESP for the chroma outputs.
And that's kinda neat.
What's going on here is this code, this javascript is being executed in a webworker, behind the
scenes.
Where it's also computing a DFT of the signal.
So, I can change things here.
I can say 'let's get rid of the chroma carrier' Let's make the power output very small.
So, now, all of a sudden, because it's very small, it's just bright white.
Say, that's a gray, the higher power we make it, the darker it will be.
That's just because of how the NTSC standard works with broadcast.
You can also see here, a DFT here of what the signal looks like.
So, right now there's just a peak at 61.25 MHz.
But, if we increase the chroma, like that.
Now, we see another peak at 61.25 plus the chroma carrier.
That is how we get color.
So, one of the things that a lot of people might be asking, and I was asking since the
previous video is "how does this output something at 64.8 MHz if its clock is at 80 MHz?
Nyquist states that you cannot do this because it's more than 1/2 the carrier frequency.
So, if we go back and we take a look at this.
Zero to 40, which is the range that we should be able to transmit.
Yes, there are interesting things going on all over the place going up to 40.
It's because this is outputting a square wave over the I2S port.
But, if we look up to 80 MHz, we're not just getting multiplications of lower waves, we're
not getting overtones, and things like that...
What we're actually getting is the wave is mirroring around half of the carrier.
So, as you can see this wave up here, at 64 and etc MHz, these are mirror images of what
is below.
That's how the frequencies go that high.
If we drop the carrier.
I don't know.
Let's make it 51.
Now, we can see that the carrier moves down here.
or 50 or 48 or 45 or 44.
3 2 1 0.
How cool is that?
That they're mirror images.
So all we care about is 60 to 66 is because that's where our actual signal is.
That's how we get red.
One of the other interesting things is you can see a lot of dot crawl on these images
here.
So, the dot crawl is pretty pronounced and that is because this isn't producing a really
nice wave.
This is producing a very very nasty wave that the TVs happen to be able to interpret as
NTSC video in color.
Which kinda blows my mind that TVs are nice enough to accept that, but you know, I'll
take it.
When you look at this signal, you can see that it looks really clean on the screen but
the TV interprets it as really dirty.
That's because at exactly 1408 bits the frequencies work out just perfectly as multipliers to
make everything work out just perfectly to make everything work out perfectly, but the
TV doesn't take an entire slice of 1408 bits at 80 MHz, it takes much much smaller slices.
So, if we change the window down to 100 here, then we can kinda get a figure for what the
TV's really seeing.
It's seeing these itty bitty ups and downs and changes in frequency and all of that,
so as the TV scans across, it's getting all of those ups and downs and everything inbetween.
So, even though we're sending overall about the right frequency, because we are trying
to dither this 1 bit DAC, the signal is just so poor, the TVs, well, it's just a dead giveaway
when you try to encode the color.
One of the things we've really been looking at is this in frequency domain.
And, that's great for understanding how things are being represented or kinda understanding
a shot over time.
But that's not how we're outputting the signal.
We can't just output a signal at 40 MHz and that's just one signal and output one at another
frequency.
What we're actually doing is outputting one bit at a time, with an analog value of 0 or
3.3V. One at a time, outputting it out to the pin.
So, let's take a closer look at what that would be.
First let's make this a nice 20 MHz signal, and make it so if it's on the positive end
it's plus, and if it's on the negative end it's minus, so there's no offset.
And, let's take a look at this.
So, in here we can see it goes -1 -1 1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 1 1.
It's periodic.
And it's cycling at 20 MHz.
That's because each one of these is 1/80th of a or 1/80 millionth of a second.
And, so if you put 4 of them together, you get 1/20 millionth of a second.
Say we don't want to make the signal as strong.
Right now it's realtively strong.
What we can do is demand that it's above some other value, like .6.
And so this will now decrease the amount that signal is on.
Let's take a look at one of them.
So, now we can see that it's -1 -1 -1 1 -1 -1 -1 1 -1 -1 1 and what this does is it makes
it so the signal is less strong.
What we can also do to look at this is say change the frequency to something that doesn't
divide evenly.
Let's make it 30 MHz.
So, now, instead of it being a really nice pattern, like -1 -1 1 1, now we have -1 1
1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1.
So what you're getting is where there actual frequency is being stippled out.
So, this even though it's not a nice repeating patten, which would be really convenient.
It's still I guess nicer than something else it could be, but it's kind of averaging between
the samples what frequency is being output.
So, we can see this, this graph here.
It's in absolute power.
It's not in DB.
I personally don't really like the dB scale, but that's okay, I'll just accept it.
Any rate.
You can actually see there's a lot of nodes all over the place.
So, let's take a look at this here.
This is frequency spectrum analyzer.
And, it's actually one of the coolest ones I've ever used.
You might as "well, why is it so cool?"
The reason it's so cool is cause it was like ten dollars.
This cute little SDR here.
Look at that thing.
It's just a funyk little white box you plug into your laptop that's ten dollars and it
gives you this amazing signal.
So, any rate, right now I'm centered on 61 point well 3 MHz.
And, you can see that that is where there's a lot of signal.
So, we can also bump it up some, say here.
We're seeing another lobe at 63.5 something but there's really not very much chroma in
that area there.
That's because there's not really a lot going on that's that bright in the chroma spectrum
on the TV.
But.
What I can do is I can Jam a certain color.
So, what I'm going to do is jam color 6.
TV doesn't know what to make of that.
That's just because it's just.
Nothing to it.
It's just this repeating pattern but the SDR knows.
So, right now I'm transmitting some at 61.25 and some at 64.8.
But I'm transmitting this signal continuously.
But now we can go over here and see yep.
There's still a signal at 61.25.
And, there's actually some side lobes.
It's kinda neat.
You can see them.
There's this one here that little lobe there.
And the little lobe there.
You see a little lobe there and a little lobe there.
bump it up some.
And there's also that and whatever.
There's also this signal here, the Chroma signal at 64 MHz.
And you can see that one matches right there along with this other little node right there.
So, these signals that we're outputting, though they are just a bitstream of 1's and 0's,
the effect that we're having in real life by looking at this spectrum analyzer is exactly
the same as we would predict based on the FFT of the signal.
I say FFT, I really mean DFT.
And, that's kinda how all of this works.
If you have any comments or questions or anything comment below, and I'll try to get around
to answering all the questions.
I hope you guys enjoyed this follow up video.
One thing I forgot to mention was all of this code is available on github along with a fairly
comprehensive readme file.
So, if you want to check it out please just go over and check out the github link available
in the description.
So you can see.
Well.
Uuhhh uuh.