It is currently Sun Oct 22, 2017 6:56 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Thu May 16, 2013 2:40 am 
Offline

Joined: Thu May 16, 2013 1:33 am
Posts: 13
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.


Top
 Profile  
 
PostPosted: Thu May 16, 2013 4:50 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2963
Location: Tampere, Finland
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... :)

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Thu May 16, 2013 5:03 am 
Offline
User avatar

Joined: Mon Jan 01, 2007 11:12 am
Posts: 203
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:
Image
Image
Image
Forth, according this schematic, final color phase will be:
Image
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.


Top
 Profile  
 
PostPosted: Thu May 16, 2013 5:47 am 
Offline

Joined: Thu May 16, 2013 1:33 am
Posts: 13
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.


Top
 Profile  
 
PostPosted: Thu May 16, 2013 6:25 am 
Offline
User avatar

Joined: Mon Jan 01, 2007 11:12 am
Posts: 203
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
Image
Image
But, then I was discovered that apparently PPU have a high-resistance output. And triangle signal is wrong. It still almost square.
Image
Image


Top
 Profile  
 
PostPosted: Thu May 16, 2013 6:47 am 
Offline

Joined: Thu May 16, 2013 1:33 am
Posts: 13
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.


Top
 Profile  
 
PostPosted: Thu May 16, 2013 9:14 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1389
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.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
PostPosted: Thu May 16, 2013 10:12 am 
Offline

Joined: Thu May 16, 2013 1:33 am
Posts: 13
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?


Top
 Profile  
 
PostPosted: Thu May 16, 2013 11:28 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6294
Location: Seattle
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.


Top
 Profile  
 
PostPosted: Thu May 16, 2013 11:42 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
PostPosted: Thu May 16, 2013 12:13 pm 
Offline

Joined: Thu May 16, 2013 1:33 am
Posts: 13
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.

Image

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.


Top
 Profile  
 
PostPosted: Thu May 16, 2013 12:39 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
PostPosted: Thu May 16, 2013 12:42 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1389
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).

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
PostPosted: Fri May 17, 2013 12:37 am 
Offline

Joined: Thu May 16, 2013 1:33 am
Posts: 13
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.


Top
 Profile  
 
PostPosted: Fri May 17, 2013 11:29 am 
Offline
User avatar

Joined: Mon Jan 01, 2007 11:12 am
Posts: 203
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.


Last edited by HardWareMan on Fri May 17, 2013 10:57 pm, edited 1 time in total.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google Adsense [Bot] and 9 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:  
Powered by phpBB® Forum Software © phpBB Group