more VGA debugging - Page 1
Forum section: electronics / projects

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 27, 2018, 06:58:19 am
content: Ok, I've gotten a little more progress with my homebrew VGA controllerI can now turn the entire screen a desired color. 3 bit color anyway.Basically, I have my sync pulses running, and am just hardwiring the color channels so they are either always on or off.To the best of my 1054z's ability to measure, all aspects of timing (pulse widths, pulse timing, front and back porches) are correct.My total time between Vsyncs is 10 us shorter than it should be, and I believe that is why the monitor is reporting 59 Hz mode, rather than the desired 60. I can probably tweak this somewhere if its related to my problem.Ok, my problem is that there are evenly spaced vertical dark lines in the picture. on my 16" LCD, the lines are about 1/16" wide, and 1/8" apart. Every fourth one is a little darker, and ~ every 32nd one is darker yet. The image is completely stable. This LCD works fine hooked to other equipment. I'm certain its my board.As mentioned in other posts, the whole thing is done with 74HC logic, and is clocked with a 25.175 MHz crystal oscillator.Every thing I can think of to look at on the scope checks out, except for the barely too long (10 micro seconds) time between Vsyncs. I feel like a Vsync problem would cause horizontal lines though.Any ideas?

author: james_s
author_rank: Super Contributor
timestamp: January 27, 2018, 07:14:10 am
content: What do the signals on the RGB pins look like? Normally a sync problem will result in a picture that's the wrong size or position or display an error (on an LCD monitor) or it may roll or flip rapidly on a CRT.

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: January 27, 2018, 10:02:26 am
content: Those are very likely noise/interferences, you've got to use a separate GND for the sync pulses (pins 5 and 10) and another for the analog R,G, and B signals: pins 6,7 and 8. And don't use the same GND wire for everything, use at least two one for sync and another for the analog signals.HC/HCT logic is quite fast and puts large spikes on the power supply lines, use 0.1 uF caps better one per chip and as close to them as you can and with low impedance paths.Then choose wisely where to feed the rgb signal and analog GNDs from. Somehwere that you know has no or little noise.

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: January 27, 2018, 10:17:55 am
content: You don't say how many lines there are per frame. What is the hsync frequency? What you're seeing is the noise of the HC spikes as they count pulses until the next hsync. Do the math and I bet you'll see that those columns are spaced at integer multiples of 1/25.175 MHz.

author: Leo Bodnar
author_rank: Frequent Contributor
timestamp: January 27, 2018, 01:33:28 pm
content: Make sure all RGB signals are off during VSYNC, HSYNC and pedestal periods.Leo

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: January 27, 2018, 03:48:12 pm
content: You think these set the black level as in composite monitors?

author: BrianHG
author_rank: Super Contributor
timestamp: January 27, 2018, 04:25:58 pm
content: #1: What is your exact clock counts per horizontal line, from the beginning of one H-Sync to the beginning of the next H-Sync?#2: # of clock cycles for each H-Sync?#3: # of clock cycles between the end of the H-Sync and the beginning of the active video?#4: # of clock cycles during the active video?Please show me a scope close-up grab, including your 25MHz clock with #2 & #3. (To make counting pixels easier, you may divide the 25MHz by 2 or 4. Trick makes it easier to read & count your pulse sizes..)#5: What is the exact number of lines from the beginning of your first V-sync to the beginning of the next V-Sync?#6: # of lines of each V-sync is active for?#7: # of lines between the end of your V-Sync and the beginning of your active video?#8: # of lines of active video?Please show me a scope close-up grab #6 & #7 of the active vertical and active horizontal video flags, including the H-Sync as your vertical clock reference.

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 27, 2018, 07:17:49 pm
content: Alright, I separated the grounds with no change. I did send the analog ground to a "better" spot, but I can probably do better yet and give it a dedicated line straight to where the power supply comes in. The thing is spread across a bunch of the PCB's that are laid out like a breadboard, so not ideal by a long shot. I want a working prototype before I do a proper PCB with ground plane and what not.I'm gonna try and fulfill all of BrianHG's requests. Standby!

author: Leo Bodnar
author_rank: Frequent Contributor
timestamp: January 27, 2018, 07:26:00 pm
content: Quote from: Dan Moos on January 27, 2018, 06:58:19 amAre your RGB levels on during blank periods?Have you tried manually adjusting pixel clock/phase on your monitor?Average LCD screen wants to lock to incoming pixel clock to attempt to display crisp image and it needs to know image horizontal resolution to properly scale the image. Without any image features (pixel transitions or proper frame borders) it will fail to do so and the result might be design-dependent and might completely screw up its logic. One sure way of doing this is keeping colour signals on during blank periods.CRT are so much easier in that regard.Leo

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 27, 2018, 07:53:53 pm
content: Quote from: BrianHG on January 27, 2018, 04:25:58 pmOK...Number of 25.175 MHz clock ticks from Hsync to Hsync = 800.Number of clocks between Hsync pulse and active video = 45Number of clocks during each Hsync pulse = 95Number of clocks during active video =640Lines from Vsync to Vsync = 528Vsync pulse is LOW for 2 linesLines between Vsync pulse, and active video = 32Lines of active video = 480here's the picsfirst pic -- Blue is Green channel, yellow is Hsync pulsesecond -- Blue is Green channel, yellow is Vsyncthird -- same as second, but zoomed4th, Dark blue is clock divided by 4 , light blue is green channel yellow is Hsync

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 27, 2018, 07:54:59 pm
content: I'm gonna edit that post to annotate those pics

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 27, 2018, 08:00:54 pm
content: Pic 4 seems to show my problem I think. Digital noise on my rails!That's gonna be tough to filter on my dodgy prototype setup I think

author: John Heath
author_rank: Frequent Contributor
timestamp: January 27, 2018, 08:13:58 pm
content: Quote from: Dan Moos on January 27, 2018, 07:54:59 pmBy vertical you mean up and down and in the middle. The good news is this locates the problem to your home brew VGA card as there are no pulses in the middle of the screen being sent. With the video being in the 1 volt range it would not take a lot of cross coupling for that pulse coupling to get in the video. You can use the monitor as if it were a scope by flipping over in your head what you see in the grey scale to a wave form on a scope. This way you will have a picture of what the interfering waveform looks like when you return to the VGA card. Do you have a picture of your VGA board ?

author: BrianHG
author_rank: Super Contributor
timestamp: January 27, 2018, 08:53:34 pm
content: Those numbers are not VGA 640x480@60Hz.HS to HS is ok at 800.VS to VS should be 525, not 528. <- this one needs to be changed...Pixel clock should be 25.200MHz, not 25.175MHz, though this should be close enough.HS size should be around 96 pixels. HS back porch should be 54 pixels. Front porch = 8 pixelsVS can be 2 lines. Vs back porch should be 41 lines. Front porch should be 2 lines.Note your numbers should work on most monitors, it's just that some modern LCD screens can be finicky if they don't auto-align the screen size and don't have the exact number of vertical lines and sync polarity as a cheap means of determining source video mode when analog sampling VGA.

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: January 27, 2018, 09:39:32 pm
content: VGA 640*480 aka 480p60http://tinyvga.com/vga-timing/640x480@60Hz.To check if it's the noise what you're seeing you could try to feed the rgb from a cell thru a divisor :-) Not being a composite signal I don't think it really needs a front/back porch or blanking.

author: BrianHG
author_rank: Super Contributor
timestamp: January 28, 2018, 02:24:39 am
content: Quote from: GeorgeOfTheJungle on January 27, 2018, 09:39:32 pmFront and back porch is needed for DC restoration/black level clamp circuitry used in the monitor's ADC. RGB analog is allowed to be an AC signal, or fed through a series cap. It's just that many video cards have a DC biased output DAC for ease of design.As for the analog noise, VGA is so low res, even a 47pf cap to GND right at the VGA connector on each line, R,G,B, and HS, VS, will clean up the noise you see and still produce a sharp clean video. Remember, there are 3 GNDs on a VGA plug, 1 for each color, then there is a GND for the syncs. If you wired this up by solder wire + leads to a bread board, wire each GND with it's own separate wire. If probing, GND clip your probe at the appropriate GND for each signal. If you add the 47pf caps, wire each one between it's appropriate GND and color/sync signal. This is probably the best practice to minimize noise when dealing with a breadboard circuit without a PCB & GND plane.

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 28, 2018, 03:41:56 am
content: Ok, I altered my timing for my vertical circuit. Monitor now reports 60 Hz 640 x 480, instead of 59 Hz. I'll call that a win of sorts.still have the lines. Will try the mentioned caps.I currently have the sync ground on its own wire, and the color channels share a separate ground. Do I really need a line for each color channel?also, there is a fourth ground (pin 5) who's purpose I'm unsure of. I currently have it tied to the sync ground.also, what is proper procedure with pin 9? I see images on the net showing it too grounded.Thanks for all the detailed help guys!

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 28, 2018, 04:37:14 am
content: Ok, improvementindividual ground wires for everthing, and individual 47pf caps from each color channel to its own ground pin, soldered directly to the jack.lines are much less obnoxious.I'm now convinced it's a signal integrity issue, since those changes made such a difference.Right now, I could almost live with it, knowing the dodgy prototype setup is most of the problem.I am going to alter my power supply scheme. Right now, I have the whole thing running off a single 7805 regulator. I'm gonna give the analog portion its own separate regulated supply. I'll let you know if it helps.

author: BrianHG
author_rank: Super Contributor
timestamp: January 28, 2018, 05:04:10 am
content: Improvements are good to hear. When I breadboard, with mixed signal audio & video circuits, I used to place 100uf electrolytic or 10uf tantalum through hole caps ontop of each IC wired directly into the same holes as the IC VCC and GND. It really helped a ton... Reserve 1x 7805 just for your output RGB/HV driving buffer logic, and nothing else. Your driving logic should be 74HC574 clocked D-Register buffers (THIS INCLUDES THE H-SYNC as the monitor's PLL circuitry depends on this being clean unlike an analog CRT where you can get away with roadkill), or a true DAC for the cleanest picture. Place a 100uf right ontop of the IC's VCC&GND.

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 28, 2018, 05:26:53 am
content: Dedicated voltage reg made a quantum improvement. Probably as good as I'm gonna get on this setup.Thanks a ton for the help. Now for the fun part. Bridging the thing to the homebrew 6502 computer. I have 64k of dual ported SRAM. Gonna try and do some trickery so the 6502 can address as if it was in its normal address space.Not sure if I'm work on text or graphics first. They both present different problems. Text is pretty much solved in my head. Graphics is tougher because any way I cut it, some trickery is needed with how the 6502 will address so much memory outside of its natural address space. Also, I imagine if I pack more than one pixel in a byte, it gets even more fun, but since 8 bit pixels seems pretty extravagant, that's prpbably gonna have to happen.I'll definitely give reports!

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: January 28, 2018, 11:54:58 am
content: Quote from: Dan Moos on January 28, 2018, 03:41:56 am5 and 10 are hsync and vsync gnd, look here:https://en.wikipedia.org/wiki/VGA_connectorQuoteThat's +5v provided by the host, some monitors use it, most do not.Quote from: Dan Moos on January 28, 2018, 05:26:53 amcool! :-)QuoteYou said 3 bits per pixel? That's 640*480*3/8= 115200 bytes. But the 6502 address space is 64k. How are you going to do that? Switching banks? I think 640*480 is perhaps too much for a poor 6502. How about 320*240?QuoteAnd the 6502 isn't a exactly a speed demon... :-)The code to go from (x,y) to (address, bits) has to run fast because you've got to go through it for ~ every pixel you want to paint. And dividing by three is not as easy as dividing by 2 or 4 (CLC, ROR). And having pixels sitting across bytes is a pain in the ass. I would say first design this code the way you'd like it to be then make the hardware do whatever it takes. Address= frameBufferBase+ (y*bytesPerLine)+ (x/pixelsPerByte)In the late 70's and the beginning of the 80's there were lots of people thinking about these things :-)

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 28, 2018, 03:48:17 pm
content: Yeah, a form of paging is what I have planned. There are a few methods out there that have been tried and true that I am exploring. Lots of pretty experienced folks in 6502.org to chat with too.Probably my planned max resolution is 320*240. I figure I'll step through video memory at half speed (about 12 MHz), and paint each line twice to get half of my native 640x480.The supposed max clock speed of a modern 65C02 is 14 MHz. I've had my breadboard built computer running at about 4.5 MHz before instability came up. My final PCB version's speed is still too be decided, although 8 MHz is probably my max.Sent from my E6830 using Tapatalk

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: January 28, 2018, 06:21:08 pm
content: Quote from: Dan Moos on January 28, 2018, 03:48:17 pmYou'll need pretty fast memory to make that work, read this:http://laughtonelectronics.com/Arcana/Visualizing%2065xx%20Timing/Visualizing%2065xx%20CPU%20Timing.html

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 28, 2018, 06:48:25 pm
content: Well, like I said. I ain't going for the full 14. 8 Tops. 4 for sure. My memory decoding scheme is very friendly too. Usually just one gate's worth of propagation delay to get through.Sent from my E6830 using Tapatalk

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: January 28, 2018, 06:57:19 pm
content: Naaah, pedal to the metal! 25.175 MHz /2 -> 12.58MHz

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 28, 2018, 08:38:10 pm
content: Quote from: GeorgeOfTheJungle on January 28, 2018, 06:57:19 pmHa! Naw, definitely clocking the CPU separately. I want to at least give lip service to the era the 6502 was popular, so 4-8 seems like as much as I'd want to go. Right now, the breadboard computer is running on a 2 MHz crystal. 6502 makes pretty efficient use it each cycle, so that helps.Sent from my E6830 using Tapatalk

author: GeorgeOfTheJungle
author_rank: Super Contributor
timestamp: January 28, 2018, 09:13:33 pm
content: Quote from: Dan Moos on January 28, 2018, 08:38:10 pmYou do as you like of course. In the breadboard it can't run much faster than that.... but once in a proper pcb, with ground planes, short traces and decoupling caps everywhere... hmmm, you'll be temptedQuoteYes if you compare it to the cpus of its era, a z80, 8080, 6800 an so on, but no, not at all compared with today's (even the smaller) ones. And the instruction set is a disaster, just ask Sophie Wilson why... Mind you, I still program it sometimes, nowadays, just for fun (Apple II).

author: BrianHG
author_rank: Super Contributor
timestamp: January 28, 2018, 09:56:06 pm
content: You can always switch to 27Mhz for video and 13.5 for CPU. Then for the video, switch to 720x480 and you can use the broadcast standard 16:9 480p mode. Note that you can create a valid VGA 640x480 at 2x 14.31818MHz, or 28.63636MHz which is a multiple standard of NTSC's color clock.

author: Dan Moos
author_rank: Frequent Contributor
timestamp: January 28, 2018, 11:25:23 pm
content: This project is pretty open ended. Who knows what I'll do.6502 is the only assembly language I've used, but I've loved it. In higher level languages I've always found my self fighting with the nuances of the language, rather than spending most of my time on the algorithm.That said, my one wish for 6502 assembly is a little more options and flexibility with indirect addressing methods.Sent from my E6830 using Tapatalk