Hello, i have been doing some development of a VHDL implementation of a NES on an FPGA and have an almost finished PPU and have been doing some experimentation with a composite video interface trying to mimic the original output. I have the interface up and running on my television screen with a hardwired palette demo to check colors and saturation and have some findings that does not quite agree with the information on the wiki.
The first thing i discovered is that the colorburst does not seem to use color 8 for synchronization as the wiki suggests. Actually the phase used for synchronization is not 100% available from the 12 square color waves. Studying the patent document for the PPU I found out that the actual video signal is generated by a separate circuit from color burst and sync and have drawn some conclusions from this. During my first attempts i just used a square color wave as the color burst signal, this proved to be pretty unsuccessful and unstable on my crt tv's which i guess is because the synchronization circuits need something more of an actual sinusoid to be able to synchronize correctly.
To compensate for the reference signal being a square wave I applied a simple low-pass filter to the da-converter using a capacitor the monitors were able synchronize and display all the colors, or actually not entirely correct, instead of the regular nes colors they were somewhat off, especially the brown/yellowish color showed as green, resulting in four different shades of green instead of three.
Based on this finding i figured out that the nes is probably using one of the square waves for color burst, and low pass filters it to provide a trianglular sinusoid for synchronization that can be mixed with the actual video data which uses the other square color waves. Since i'm using a single dac for signal generation i thought i was out of luck but then i figured out that i should be able to the low-pass filtering digitally using a FIR-filter. This proved to be very successful, a simple 6-tap filter turned my square reference signal into nice looking triangle wave, and voila, the first of the four green then turned into the brown/yellowish color that i expexted. As a result the colors were shifted around a bit because of the added phase shift to the burst reference signal, so when adjusting for that i actually ended up using the square wave from color A as reference. So according to my finding the wiki information is incorrect and the color reference signal should use color A, anybody else who has any thought on this?
This post turned out to be a lot longer than i had originally thought, but anyways, on to my question as well. When studying the information about sync timing on the wiki as well as looking at the visual 2c02 simulator, the sync seems to be offset differently, they have the same pulse length but according to the wiki the pulse starts at pixel 276 while according to the simulator it should start at pixel 280, the same applies to where the color burst and borders are applied, except that the duration of left and right borders are swapped between the simulation and the wiki, which of the two would actually be the most correct information source? I would like to think that the visual 2c02 is an accurate representation of the ppu so that the information from there should be correct.
Ok, now i'm done, hopefully some people think that this is interesting information.
I think it's going to be hard to convince anybody either way without some hard evidence (= data from a scope).
Of course the data from wiki doesn't have any indication as to where it came from, either...

First, use one common DAC is wrong.
Second, you should look at
PPU schematic to understand how magic is done.
Third, equivalent schematic for basic phase shifted frequencies looks like this, and generated 12 phases:


Forth, according this schematic, final color phase will be:

Code:
Color ID : Used phase(s)
H 3 2 1 0 : P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12
0 0 0 0 0 : . . . . . . . . . . . .
1 0 0 0 1 : . . . . . . . . . . . .
2 0 0 1 0 : . . . . . . . . . . . .
3 0 0 1 1 : X . . . . . . . . . . .
4 0 1 0 0 : . . . . . . . X . . . .
5 0 1 0 1 : . . X . . . . . . . . .
6 0 1 1 0 : . . . . . . . . . X . .
7 0 1 1 1 : . . . . X . . . . . . .
8 1 0 0 0 : . . . . . . . . . . . X
9 1 0 0 1 : . . . . . . X . . . . .
A 1 0 1 0 : . X . . . . . . X . . .
B 1 0 1 1 : . . . . . . . . . . . .
C 1 1 0 0 : . . . X . . . . . . . .
D 1 1 0 1 : . . . . . . . . . . X .
E 1 1 1 0 : . . . . . X . . . . . .
F 1 1 1 1 : . . . . . . . . . . . .
At this moment I don't figure which phase used in color burst, but I find it out soon.
PS Another way is see it at oscilloscope. I have such PD ROM and I hope do some test very soon.
Thanks for the input, i know that a common DAC is wrong in the sense of doing an exact replica, but as long as i can reproduce the correct voltage levels i'm happy, especially since it is a lot simpler to hook up an r-2r DAC than a resistor ladder with pass-mosfets, and i guess it's pretty hard to figure out the resistor values from the die shots as well.
I also get how to generate the phases, as far as i can tell that circuit you attatched is the equivalent of a johnson counter, where the outputs along with its inverted outputs generate the exact same wave diagram that you attached, that is at least what i used for my design. So i think that we are saying the same thing. 12 square wave signals with 50/50 duty cycle and a phase shift of 30 degrees.
The way i figured out which phase to use was trial and error since i didn't get it down correctly with the info from the wiki, so it is by no means hard evidence, but it at least got me curious as to wether someone else had any input on the subject. So if you can determine it by a more scientific method that would be awesome.
In the patent document
http://www.google.com/patents/US4824106 there is a schematic of how the color phase and luminance is selected on page seven, and explained in the text is also that color burst and sync is generated from other circuitry and mixed before passed to the output pin. I guess that nintendo didn't deviate too much from this design either.
About the filtering of the color-burst into a triangle wave, i'm sure i've read somewhere, perhaps on this forum that someone measured the signal on an oscilloscope and saw that the colorburst was triangular instead of square, but i haven't been able to find it again. I have some plans to hook it up on a scope, but i don't have access to one right now so if you beat me to it, if you want to i would be interested to know if the color burst is actually triangular and if the color waves in the video-signal are still rectangular.
pyroholic wrote:
About the filtering of the color-burst into a triangle wave, i'm sure i've read somewhere, perhaps on this forum that someone measured the signal on an oscilloscope and saw that the colorburst was triangular instead of square, but i haven't been able to find it again. I have some plans to hook it up on a scope, but i don't have access to one right now so if you beat me to it, if you want to i would be interested to know if the color burst is actually triangular and if the color waves in the video-signal are still rectangular.
I remeber that,
it was me. :3


But, then
I was discovered that apparently PPU have a high-resistance output. And triangle signal is wrong. It still almost square.


Haha, awesome, so that was you

So are the first two sets of pictures are from the ppu-output pin? Were the color subcarrier in the video still square then, i couldn't really determine from that thread? Anyways since the color burst seems integrated inside the ppu, unless the color subcarrier is integrated in the same way, the phase of the color burst would be offset from the color subcarrier, and any additional phase-shifting in amplifier circuitry would not alter the phase relationship between color-burst and color subcarrier.
By the way, i did som calculations on my low-pass filter and got a phase shift of -75 degrees for 3.579 MHz so in that case color burst ends up between two adjacent phases, and since i use color B's phase (not A as i said before), the resulting phase ends up exactly between colors 8 and 9.
A quick test in Visual2C02 confirms that colorburst does use phase P5, the same as colors 08, 18, 28, and 38 - what's actually happening is that colorburst forces the palette into "monochrome" mode (forcing the 4 chroma bits to zero) but also forces the upper bit high (by grounding /3 at t2225), thus using an effective chroma value of 8.
Ok, so you mean that color burst and sync uses the same dac as the video signal, so that would mean that color burst oscillates between super black and one of the other values, or basically output color 0x08? or have i missed something else?
pyroholic wrote:
Ok, so you mean that color burst and sync uses the same dac as the video signal, so that would mean that color burst oscillates between super black and one of the other values, or basically output color 0x08?
Similar to, but not the same as color 0x08; it's closer to color 0x08 with the attenuation bit set all the time. It's actually a little brighter than that: the high half phase is closer to color 0x2D than 0x00.
There are
about ten different taps on the PPU's DAC. The active picture uses the levels that correspond to colors $00, $10, $20/$30, $0D, $1D, $2D, and $3D. The blanking period uses separate taps for sync, color burst low, and color burst high, as well as
$0D $1D.
Ok, so i have been checking the schematics as well, mainly from the link from HardWareMan, and it seems the color-burst output uses its own pass mosfets for the signal voltage levels, as well as synch signal as tepples said. So the resulting voltage on the video out pin is still a mix from three components (video, colorburst and sync). I've also been doing some experimentation with my set-up, as filtering only color-burst signal (color burst will be out of phase from any of the color signals) and also filtering the entire video out signal (color burst in phase with color 8). When filtering the entire signal and using color 8 the colors don't seem to match entirely but pretty close, and while filtering only the color-burst signal the colors are much closer to what a real nes is outputting, still somewhat off though.
So my theory is that the output signal from the color burst mosfets suffer from higher capacitive loads, which would result in the signal appearing more like a triangle wave. I have made a simple picture to try and explain what i'm saying.

The top signal is an ideal square wave, the second an ideal triangle wave.
Now third is how the square wave would look like when passed through a low-pass RC filter with the cut-off frequency at the base frequency of the square wave signal, and finally the fourth signal the same as the third but with a cut-off frequency lower than the base frequency of the square wave, the resulting signal starts to appear as a triangle wave at the cost of signal attenuation.
Also, none of the signals in the chart are at the same phase, if the square wave is set as reference signals, all the other signals will be lagging in phase, with the triangle signal beeing off by most. In the scope pictures posted by HardWareMan it is clear that the color burst is a heavily attenuated signal, and that is why the signal is appearing as a triangle, as in fourth signal in the pic. I'm going to try and get access to a scope next week to verify, but my theory is that the color wave-form in the video part of the signal is more like the third signal in the pic.
If anyone is interested i can take a picture of the monitor when using the different set ups.
There's also a phenomenon called
slew rate, where low amplitude signals look more like the third example from the top (exponential rise to high level and fall to low level), whereas high amplitude signals look more like the fourth or even the second (a triangle wave). This happens when certain components in an amplifier produce a maximum rate of change of the output voltage. It causes the phase to depend on the amplitude: large signals lag more.
ReaperSMS mentioned slew rate before.
tepples wrote:
There are
about ten different taps on the PPU's DAC. The active picture uses the levels that correspond to colors $00, $10, $20/$30, $0D, $1D, $2D, and $3D. The blanking period uses separate taps for sync, color burst low, and color burst high, as well as $0D.
Actually, the blanking period does not use color $0D - it only uses the "sync" voltage (which is actually GND inside the PPU) for both horizontal and vertical sync, outputting color $
1D (which is the same as $xE/$xF) during most of the other periods.
Looking at visual2c02, vertical blank lasts for 3 scanlines, and it simply extends the HSYNC pulses during scanlines 244-246 by an additional 293 cycles (so they end at cycle 257 on the next scanline instead of cycle 305 on the current scanline).
tepples wrote:
There's also a phenomenon called
slew rate, where low amplitude signals look more like the third example from the top (exponential rise to high level and fall to low level), whereas high amplitude signals look more like the fourth or even the second (a triangle wave). This happens when certain components in an amplifier produce a maximum rate of change of the output voltage. It causes the phase to depend on the amplitude: large signals lag more.
ReaperSMS mentioned slew rate before.
Yup, slew rate is basically an RC effect why the results is the same as for a filter. The series resistance through the mosfets channel and source/drain capacitance basically form an rc circuit, so if nintendos goal would be to turn the square reference color burst into a triangular signal they could simply shorten the channel width of the pass mosfets for color burst and drive strength would decrease, so slew rate/cut-off frequency would decrease and the square would turn almost triangle. Along with wider transistor channels for the video the square would be more like a square instead of the triangle in the burst. This is just my theory but i think it seems reasonable.
I saw on the topic you linked to that there were discussions on the duty cycle of the main clock as well, this should however only offset every second wave but might also cause differences.
PPU DAC interesting thing. Its basis is a chain resistance between the VCC and GND supply, which sets the voltage level between different types of signals. Total 10 levels, designated as L01..L10. Each of these levels comes to switch that transfers selected voltage level to the output at the right time. Here is a table of different signal levels:
Code:
LEVEL : SYNC : BURST : LUMA0 : LUMA1 : LUMA2 : LUMA3 :
VCC : : : : : : :
L10 : : : : : : : < EMPHASIS CONTROL
L09 : : : : : H : H :
L08 : : : : : . : L :
L07 : : : : H : . : :
L06 : : : H : . : . : :
L05 : : : . : . : L : :
L04 : : H : . : . : : :
L03 : H : . : . : L : : : < BLACK LEVEL
L02 : . : . : L : : : :
L01 : . : L : : : : :
GND : L : : : : : :
Every signal oscillates between "L" and "H" levels, except for B/W luma signals, that seems to be used only static "H" level. Of course, we cannot discover value of L01..L10 levels by DIE shot, but we can judge their relative positions. L10 is used to turn off the video output by shunting to GND, thus video pin have zero voltage level. I don't know right now what condition causing that, but it doesn't matter for now.
HardWareMan wrote:
L10 is used to turn off the video output by shunting to GND, thus video pin have zero voltage level. I don't know right now what condition causing that, but it doesn't matter for now.
If it's what I think you're talking about, L10 (t5865 in visual2c02) is actually for
color emphasis - the transistor is very small (and thus can't sink as much current), and it's connected to the VCC end of the resistor ladder through a long and thin strip of diffusion (which increases resistance), so all it does is reduce all of the other voltage levels (by about 25%, as observed by others on real hardware).
Basically it should be possible to determine the length between the taps on the resistor and determine some relative value, and get some idea what the voltages would be on each tap, then there would also be an additional voltage drop over the pass transistors but i assume that there is not much current so it should be small except when the transistor has just turned on and current is flowing into capacitive elements.
I guess it is the tint transistor that HardWareMan is mentioning, although there is also a transistor that grounds video out as well.
The output levels measured by kevtris should only be an offset of those voltages caused by the voltage drop over the bipolar transistor he measured the output on. Since the color burst seems to be triangular the peak voltages on the output are most likely attenuated so the actual voltage from the taps on the resistor for color burst should be lower/higher to achieve that shape.
pyroholic wrote:
although there is also a transistor that grounds video out as well.
That would be the "sync" voltage. I've just updated some of the node names in visual2c02 to more clearly identify the logical video voltage levels.
Quietust wrote:
HardWareMan wrote:
L10 is used to turn off the video output by shunting to GND, thus video pin have zero voltage level. I don't know right now what condition causing that, but it doesn't matter for now.
If it's what I think you're talking about, L10 (t5865 in visual2c02) is actually for
color emphasis - the transistor is very small (and thus can't sink as much current), and it's connected to the VCC end of the resistor ladder through a long and thin strip of diffusion (which increases resistance), so all it does is reduce all of the other voltage levels (by about 25%, as observed by others on real hardware).
Indeed, there are resistor between L10 and transistor. I was baffled TINT connection to the management of colors and one PPU register, but now everything has fallen into place.
I hooked my pal nes up to an oscilloscope today and checked the video-out pin from the ppu, the color burst and regular color waves seem to be equally attenuated so there should be no phaseshift between them. Anyway, what i found interesting was that since the attenuation is pretty high and the waves are almost ideal triangle waves the video signal for colors are pretty far off from the peak values, color 00 resulted in a voltage of 1270 mV, 0d 448 mV and colors 0x oscillated between 576mV and 904mV, and sync was 88mV above ground. I made some quick measures on the output from the video-amplifier while connected to a tv as well, and it seems that low frequency signals retain their amplitude while high frequency signals are amplified so the end result is a pretty nice sinusoid oscillating at a higher amplitude than the triangular one from the PPU. I didn't get any good measurements done since i was running out of time for today and only held the probe agains the soldering point for the av-out video connector. I made measurements of all the voltage levels if anyone is interested about pal version of the PPU.
Can anyone tell me what's the value of each resistor found in the DAC of the PPU? (The resistor ladder)(
PPU Patent #4,824,106, FIG. 8)
pyroholic wrote:
I made measurements of all the voltage levels if anyone is interested about pal version of the PPU.
I don't know how I missed this.
If they differ from the the 2C02 voltages, we'd love to have them.
Sorry about my ignorance, but why do I think the multiplexer diagram from the PPU Patent is wrong in some parts? (Missing NOT gates in some places)
EDIT: Yes, yes, we'd love to have these voltages!!!
Ok, sorry for the late response, but here is all of the data from the measurement. The voltages are measured directly on the video pin on the PPU.
Code:
Gray scale:
00 : 1270 mV
10 : 1670 mV
20 : 2200 mV
30 : 2200 mV
0d: 448 mV
1d: 640 mV
2d: 1150 mV
3d: 1780 mV
Colors:
0x-low: 576 mV
0x-high: 904 mV
1x-low: 848 mV
1x-high: 1220 mV
2x-low: 1380 mV
2x-high: 1720 mV
3x-low: 1880 mV
3x-high: 2010 mV
Color burst:
low: 360 mV
high: 1440 mV
sync: 88 mV
The lows are supposed to be the same as xD and the highs x0. You might be seeing some low-pass filtering.
The numbers given, once normalized such that color $20 is 1 and color $1d is 0, are equivalent to the NTSC voltages (except for colorburst, but for reason Tepples gave I'm not certain these are trustable)
tepples wrote:
The lows are supposed to be the same as xD and the highs x0. You might be seeing some low-pass filtering.
Yes, both NTSC and PAL nes suffer low pass filtering, that's why the output are triangle waves instead of square. The PAL color burst frequency is also higher (almost 25%) than NTSC so that is why the color waves are more attenuated than for NTSC.
The oscilloscope probe should not have any noticable effect on the measurement so it should only be the parasitic capacitances of the driver transistors in the video dac as well as the base capacitance of the emitter follower transistor that causes the low pass effect.
Outputting several pixels of a given color/gray is a good way to avoid capacitance effects
That'd help with grays ($x0 and $xD). But even if the test were done with full screen solid colors, capacitance would still affect the rises and falls that encode the color.
Yes, that is also what i did, 32 pixel wide bars. That is why the difference is so clear between grays and colors. It was also clear on the scope that it took more than half a period for the different grays to settle.