6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 7:03 am

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Tue Nov 13, 2018 4:10 am 
Offline
User avatar

Joined: Sun May 20, 2018 7:20 pm
Posts: 20
Hey All,

Recently I bought an oscilloscope and measured the NTSC signal pumping out of an NES' composite video output. It was an interesting experiment, and the thing that really surprised me is how clean the colour burst and associated colour signals were. I half expected something blocky but somehow working because of the relative form of the signal or something, but I was pleasantly surprised. Actually, comparing the NES' signal with a Raspberry Pi I had laying about, I noticed that the Pi had a much messier signal, where the "NTSC signal" was really being formed out of a much higher frequency waveform. (though NES outputs black as 0 IRE, which is totally wrong; it seems televisions must not have minded so much?)

So I have a few things that confuse me I guess about all this. And I apologize, because I am stretching here a bit posting this question here, but I'm hoping I'll maybe find help because the VIC had Luma and Chroma outputs (might be worth learning how the VIC does it). My first guess would've been some kind of voltage divider mechanism to produce parts of the analog signal, or at least that may make sense for the Luma signal; but I'm not super convinced about what kind of conversion mechanism would've been used, because I've read that resistors are very large when we try to shove them into a chip die (not that they get larger, just that they are harder to "shrink" and so in a small IC die they take up a lot of room if required). I am aware of some basic techniques for DAC like R-2R ladders, but what is actually used at an IC level like a VIC chip or otherwise? The next mystery to me is how a smooth waveform like the colour burst signal is produced. My thinking here is maybe clever clock usage and capacitor placing drawing voltage up/down to make a "smooth" signal out of a square one, but I honestly lack the electronics skill to really know if this is practical. (One of the nice things about NTSC encoding though is that you only need a smooth waveform of the frequency of the colour burst to make any colour - saturation is controlled by the amplitude, and hue by the phase-shift, so I could see this as being reasonable since the same waveform needs to be produced for any colour, just at different phases.) However, as I understand pure sine wave generators were expensive and complicated at the time, which is why most audio was square/triangle/etc. My thinking is, as mentioned, maybe a general-purpose sine wave generator (with parameterization and all that) is difficult, but producing the same signal without changing? Maybe not so difficult.

Here is a list of the key questions I have brought up:

1. For these small ICs, what is the general mechanism by which an analog signal is produced? (if there is one that most ICs use, even.)

2. How is such a smooth sine wave constructed for the colour burst and colour intensity value for the Chroma signal output?

3. How do we control things like the phase-offset for the chroma signal, so that we can produce different colours?

and...

4. Has anyone attempted to reverse-engineer the VIC chips past just stitching pictures of the die shots?
I know visual6502 provides die shots of them, but wondering if we have any vector map like we do with the 6502? Or better yet markup with notes and such? I did some searching on Google, and found some people talking about reverse-engineering it, but all their notes and documents are no longer online because the host has since gone down. If not, I was going to play with doing some reverse-engineering by identifying the pins and working backwards from the part I was interested in, but just wondering if that work has already been done.

I'm investigating much of this currently (reading, collecting notes, practicing electronics circuits, etc.); but it's taking me a while to get to the point where I feel knowledgeable enough to ask this question without it just being a shot in the dark. So I'm kind of biting the bullet here and just asking before feeling "ready to ask", uhh - taking that "shot in the dark", unfortunately. I figured it wouldn't hurt to ask, and if the question isn't a wise one (or I should just continue about my learning) I could go back and get more information then come back with better questions. :)

Anyways, let me know if anyone has any knowledge or information about this. Am I overthinking it? I just have this feeling like a basic implementation like an R-2R ladder wouldn't work, and I don't know how we get the smooth waveform... It seems like magic to me!


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 13, 2018 8:21 am 
Offline
User avatar

Joined: Thu May 14, 2015 9:20 pm
Posts: 155
Location: UK
I do not know much about the VIC chip used in Commodore machines. So I can’t say how this did analogue signals. I also don’t know anything about how the NES works.

But I can tell you that analogue chips existed long before digital chips. And chips with both analogue and digital circuitry were certainly in use during the 1980s. Some values of resistance can be easily to create on chip. Larger value capacitors and inductors are the components that have to be external.

Single fixed frequency oscillators built using crystals can produce reasonable sine wave outputs if analogue circuitry is used. Indeed some designs using ‘standard’ digital inverters actually use resistor(s) to push a digital chip into a kind of analogue mode of operation.

The trick with sine wave oscillator circuits is keeping the positive feedback at a level that is just enough to keep the oscillator running, but not too much otherwise the waveform becomes too large and will become distorted as it gets near to the supply voltages. With the availablity of many transistors and transistors that are closely matched. And closely matched resistors that are possible on a chip, this actually makes designing an analogue oscillator a bit easier. The fixed frequency also helps.

Mark


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 13, 2018 8:37 am 
Offline

Joined: Mon May 21, 2018 8:09 pm
Posts: 1462
You can make a pretty clean sine wave using a square wave at the correct frequency and a resonant filter - good enough for NTSC colourburst, anyway. That's *probably* what the VIC-II does, but I haven't examined the schematics for a C64. Then all you need is a DAC to produce the squarewave with an appropriate magnitude and phase shift, which is easy enough to do with a resistor network.

The other way to do it is with oversampling, so that you make something that looks fairly like a sinewave from the beginning. Depending on the application, you might not even need to filter it afterwards.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 13, 2018 9:01 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
It's worth noting[1] that even the squarest square wave contains a sine wave within it - and a lot of higher frequency harmonics as well. All you need to do is remove enough of those higher frequencies and the result will look rather like a sine wave. You won't get a purist's sine wave with no distortion, but in this case you probably don't need that: the colour burst detector circuit is surely already built to be very sensitive to the target frequency and is tasked mainly with determining the phase.

Acorn's ULA chip for the Electron contains output circuitry to construct a stepped coarse sine-ish waveform for the audio cassette data storage. (Edit: see here.) I think that's done by switching in pull-ups and pull-downs of appropriate strengths - you can think of that as a programmable voltage divider. I think it's a trick which wasn't anticipated by Ferranti, who made the chips, but I could be wrong.

Looking at the VIC chip layout should be able to illuminate this question. The SID chip too contains analogue circuitry: it's true that resistors and capacitors are large compared to minimal-sized transistors, but they are not impossibly large. The pads and the pad drivers are already very large compared to the interior transistors - but you only need 40 of the big ones at most, and you have 4000 of the little ones, to within an order of magnitude.

[1] See this thread:


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 13, 2018 9:30 am 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 336
1) The transistors used in digital circuits are analogue components. If you arrange for them to be saturated, they'll look digital. But there's nothing stopping you building analogue circuits like opamps from them.
2) Feed a square wave through a low pass filter, and you get a sine wave. It doesn't have to be a terribly good one. I suspect you could use a square wave directly and it would work well enough. It won't actually be square though - there's enough resistance and capacitance around in an NMOS chip to naturally filter it to some extent.
3)
a) Start with four times the colourburst frequency.
b) Divide it down, giving four clocks (still nominally square) of the desired frequency, at 0, 90, 180, and 270 degrees in relative phase.
c) Select two of them: either 0 or 180, and either 90 or 270.
d) Filter each of them to make them vaguely sinusoidal.
e) Feed each through a resistor divider to give the right amplitudes for this colour.
f) Add them together.
This will give a signal of the right frequency, at any amplitude you want, and any phase: Asin(wt+b) = Bsin(wt) + Ccos(wt) for appropriately chosen B and C.

VIC won't use a DAC as such (it has no need of one), but SID does.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 13, 2018 6:07 pm 
Offline
User avatar

Joined: Mon May 25, 2015 2:25 pm
Posts: 693
Location: Gillies, Ontario, Canada
In my system (pure 74 Logic Based) I start with a square 3.579545MHz square pulse derived by a PLL phase locked to the PH2 clock output of the 6560-101 in my VIC-20.

I need to sync with the 6502 clock in my design since I am overlaying new video on top of the original VIC-20 output to add Sprites and other graphics.

I then pass the 3.579MHz Color Burst signal through a chain of 32 buffers, each with an 8ns propagation delay. Each "tap" can be selected to offer one of 32 different phases of the Color Burst.

After selection, I use an RC filter to "round off" the square wave into more of a sine wave, and that signal then modulates the output of the Luma DAC in order to overlay the color carrier.

The Luma DAC is just resistors of an R2R network driven directly by 74HC gate logic.

In my pure logic system, I generate a 360x240 NTSC signal with 8192 colors and overlay it with the original output from the 6560-101 in the VIC-20. Overlay is optional as well since my video generator is also fully capable of its own sync pulses.

Besides the 2N3904 transistor in the Luma / Chroma mixer, I use no analog components.
My NTSC is exactly to spec, as long as you count progressive scan as legal.

Brad


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 15, 2018 3:48 am 
Offline
User avatar

Joined: Sun May 20, 2018 7:20 pm
Posts: 20
Thank you all!

I'll continue to investigate and see if I can't figure out what the VIC (or NES, even) does specifically, but some of this information is really great to help direct me in understanding how the signal could be formed. I'll also try building a little play circuit to see if I can't create and phase shift a sine wave from a square wave on a breadboard (it'll all be super manual, but it'll be a good learning experience) - sounds like it might be fun.


Top
 Profile  
Reply with quote  
PostPosted: Thu Nov 15, 2018 1:33 pm 
Offline
User avatar

Joined: Mon May 25, 2015 2:25 pm
Posts: 693
Location: Gillies, Ontario, Canada
Here is a link to one of my very old builds.
It's NTSC done in logic...

http://www.lucidscience.com/pro-lazarus-64%20prototype-1.aspx

It generated ok video...

https://www.youtube.com/watch?v=MQO-aXIFvFs

The DAC & Chroma Phase Delay section are the same as what I am going to use on my new project.

Brad


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 17, 2018 12:36 pm 
Offline
User avatar

Joined: Mon Dec 08, 2008 6:32 pm
Posts: 143
Location: Brighton, England
Just remember

Things like the colour burst and the chroma sub-carrier do not need to be sine waves. Square waves would have their harmonics stripped off by the filters in the TV set anyway and so would have no significant effect on the picture.

_________________
Shift to the left,
Shift to the right,
Mask in, Mask Out,
BYTE! BYTE! BYTE!


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 17, 2018 4:59 pm 
Offline
User avatar

Joined: Mon May 25, 2015 2:25 pm
Posts: 693
Location: Gillies, Ontario, Canada
In the numerous systems I built, here is what I found regarding sine vs square chroma...

1) If the pixel clock is a divisible multiple of the chroma clock, then a square wave chroma signal actually enhances the image, creating a sharp edge between pixels. This makes a small improvement when using a resistor DAC.

2) If the pixel clock is not a multiple of the chroma clock, then a sharp chroma transition looks terrible. You get all kinds of moire patterns and interference lines. Chips like the AD723/724 do this, which is why they produce video that looks sub par to anything I have done on a breadboard.

Even when considering system configuration (1), full square wave chroma is not optimal as it produces too much of a sharp edge, which is noticeable when not changing colors during every pixel transition. I have found that a little rounding of the square pulse using an RC network does wonders to keep the video crisp without too much hard edge.

When I start posting videos of my new NTSC project, I will show the difference. It is easy to see.
I also have an AD724 IC, and will show how much worse non-synchronous luma / chroma looks.

Brad

PaulF wrote:
Just remember

Things like the colour burst and the chroma sub-carrier do not need to be sine waves. Square waves would have their harmonics stripped off by the filters in the TV set anyway and so would have no significant effect on the picture.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 31, 2018 1:08 am 
Offline
User avatar

Joined: Sun May 20, 2018 7:20 pm
Posts: 20
Just in case anyone finds this and has the same questions - I thought I'd add that the audio generation is in fact simply some resistors. Or at least, I'm assuming this is a resistor chain DAC each with 4-bits of precision. The video makes sense logically to me after the explanations here, but I have yet to really dig into the 2C02 or the VIC to learn how that works in finer detail on the actual chip.

Square Waves (x2):
Attachment:
File comment: NES Square Wave Channels (2 of them)
square-waves.jpg
square-waves.jpg [ 23.54 KiB | Viewed 3366 times ]


Triangle Waves (x1):
Attachment:
File comment: NES Triangle Waves (1 of them)
triangle-waves.jpg
triangle-waves.jpg [ 9.95 KiB | Viewed 3366 times ]


Attached you can find pictures of the resistor chains in the NES. I don't exactly understand the physics of this, but I imagine it's something like how a transistor avoids allowing current to pass until a certain voltage is applied to the gate. Perhaps in this case current may pass as noise or something (or none at all?), but applying a charge to the metal above the resistor allows far more current to pass through it from +5v (which is connected at the other side of the resistor).

---- Signal ---v
+5v ---> Resistor ---> Sound Out

Any thoughts or explanations to this? Is this making sense or am I misunderstanding something fundamental here?

Regardless, thought it'd be nice to follow-up with the DAC in the NES since originally I was incorrectly believing such a DAC wasn't possible. As I have continued to read, it seems the issue is once you get past so many bits it becomes hard to construct a DAC in this manner in ICs.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 31, 2018 8:19 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
The usual pattern is to use transistors with the gate tied high - the metal is being used to supply that voltage and you can see the contact cuts in it next to each transistor. An on transistor will act like a resistor, more or less, with resistance controlled by the width and length but generally in the range of 10k ohms. By using various numbers of same-sized transistors, the composed resistance should match quite well to the desired 1x, 2x, 4x values.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 70 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: