BMOW title
Floppy Emu banner

Everything But The Kitchen VSYNC

I’ve decided to do whatever it takes to fix the VSYNC problem with BMOW’s video, and right now it looks like that means ripping out and redesigning a decent portion of the video address circuitry. Things are fine when displaying a static image, but not when the image is changing. When trying to animate something, or scroll a screenful of text, the VSYNC signal often gets fubared. This causes the monitor to throw up its hands and go into power-saving mode. It takes about 5 seconds for it to come back again after VSYNC stabilizes, and the constant pattern of scroll, lose sync, wait, regain sync is infuriating.

I did quite a bit of investigation of the problem using the oscilloscope. The proximate cause is that a miscount occurs in the GAL named VERTHI, which maintains the upper 5 bits of the row count. The low 4 bits of the row count and the 9 bits of column count are all fine. I can’t say why VERTHI is going wrong, but it’s presumably something related to noise or a race condition. There is a fair bit of noise observed with the scope. I tried rewiring the clock wires using a few different topologies in an attempt to reduce noise, without success. I also tried two more completely different clock sources for the row counter: the inverted high bit of the column count, and the HBLANK signal. HBLANK introduced some other timing problems but didn’t help with the loss of sync. The high bit of the column count made the loss of sync far worse. I also tried replacing the GAL with another one, and replacing the other parts that send signals to the GAL.

I wish I had a better explanation, but at this point I’m convinced I just shouldn’t use a GAL for the row counter. Instead I’m planning to use a regular hardware counter like a few 74163s or 74393s, and use the GAL to buffer the row address and generate VSYNC and other derived timing signals. Unfortunately that means eating up more of what little board space is left, dimming the prospects for a future audio system. It also means ripping out gobs of my painstakingly-wrapped wires and replacing them with new ones. I just hope it actually fixes the problem!

Read 17 comments and join the conversation 

17 Comments so far

  1. Steve - October 29th, 2008 9:49 pm

    So… it seems that the chips heard me threatening them, and decided to behave. I made a minor change in preparation for replacing the row addressing logic; I changed one signal from active high to active low, so it could double as a row-counter clock. Suddenly it all works great? I monkeyed around with things for half an hour, and it didn’t lose sync once.

  2. Dave H - October 31st, 2008 1:50 pm

    I’ve followed your progress for a while Steve, well done on getting it syncing. I know the pain of having to redo what should, on paper, work fine. It’s nearly always something minor and something that defies logic. I’ve made a similar video circuit, all be it b&w, for an old Commodore VIC 20, this syncs fine on a VGA CRT screen but puts an LCD screen to sleep. You’ve inspired me to look at getting it working. Wire-Wrap tool at the ready!

    Really fantastic project you’ve got going there. Be great if you could fit in a nice audio circuit. Go on, it deserves a voice.

    Cheers
    Dave

  3. Steve - November 2nd, 2008 6:06 pm

    Thanks, Dave! Any further luck with your VIC-20 video project? Are the designs online somewhere? How are you connecting to the VIC-20 hardware?

    The only real difference I know of between a CRT and LCD display is that the CRT displays a true analog along the horizontal dimension, whereas the LCD samples the analog signal at a fixed number of specific points, depending on the horizontal resolution it expects. This caused some scaling artifacts for me, but I don’t think it would put a monitor to sleep.

    More likely your HSYNC and VSYNC are slightly out of spec somehow, with the CRT monitor being more forgiving than the LCD. Assuming they’re both at the right frequencies and with the right duty cycles, the only other thing I can think you might want to check is when HSYNC changes state relative to VSYNC. I discovered through trial and error that HSYNC should be asserted beginning about 75% of the way through a row, and de-asserted about 87% of the way through the row. That means it’s about 4.17 microseconds from the de-assertion of HSYNC to the assertion of VSYNC. At one point I had them changing state simultaneously, but my monitor turned up its nose.

  4. bro - November 3rd, 2008 2:01 am

    Hi. I usually check your great posts!. Thanks!
    btw I have a question. you said that osc 25.175MHz is needed to work on VGA (640×480 16color).
    then Is your cpu’s clock on 25.175MHz?
    I heard TTL 74 LS isn’t work on over 20MHz (but I don’t know exactly)..
    Thank you!

  5. Steve - November 3rd, 2008 8:05 am

    BMOW has two clocks. The CPU clock is 2 MHz, and the video system clock is 25.175 MHz. You’re right that 74 LS parts may not work at that speed. Try 74 HC or 74 HCT parts instead. If you’re not sure, do a web search for the datasheet of a part you’re considering, and check the timing data. I used 74 HCT and high-speed programmable GALs for BMOW.

    By the way, a 25.175 MHz clock oscillator can be difficult to find. You can also use a 25 MHz oscillator with a few adjustments, although the results won’t be quite as good. At 25.175 MHz, the clock period is 39.72 ns, and with 800 dots per line (of which only 640 are visible), each line is 31.78 us. With a 25 MHz clock, if you generate 795 dots per line, each line will be 31.8 us per line, which is close enough.

  6. Ben - November 3rd, 2008 8:26 am

    @Steve

    Haven’t posted here before, but I’ve been following the project for a while now. You’ve done a fantastic job! I am in fact currently in the early stages of designing my own CPU, although mine will use custom PCBs and surface mount components, to give me a chance to use my new hot-air rework station.

    @bro

    I think he’s using a 2mhz system clock. The 25.175 crystal is just for the video subsystem (known as the pixel clock or dot clock)

    As far as the maximum speed of individual logic gates, it depends on numerous factors, but mostly the family. For instance 74AC/ACT is much faster than 74HC/HCT or 74LS, and there exist even faster families such as 74ABT. Usually logic manufacturers provide an fmax rating in the component’s datasheet.

    Of greater importance in sequential systems however is the concept of propagation delay. There is a small delay from the time an input signal changes state to the time when any outputs dependent on it change. Propagation delays are additive, so you have to be careful that you choose a clock speed slow enough for all your signals to propagate through the entire signal path in the period of your clock pulse. Propagation delays can vary widely, but datasheets always include maximum and minimum values for each component.

  7. bro - November 3rd, 2008 3:20 pm

    Thank you. Steve and Ben. It’s really helpful for me.
    yes. it’s hard to get 25.175 MHz osc.. also wire wrap board, too..
    I bought several 20v8 GALs after reading your post for control path and video stuff (if I can).

    regards.

  8. John Honniball - November 3rd, 2008 4:49 pm

    One source of 25.175MHz oscillator modules is surely old VGA cards! They’d need to be old enough to have separate oscillators for each set of scan rates, as opposed to the newer type with a single crystal and a frequency synthesiser chip.

  9. Dave H - November 10th, 2008 3:28 pm

    Hi Steve,

    RE: my DIY VIC-20 graphics card. It connects via the cartridge port and is 100% stand alone, no DMA or IRQs to the VIC, the VIC addresses it just like RAM. The VIC takes over the bus whenever it reads or writes so there’s screen corruption unless the software is timed to the V/H Syncs. No character generation, just a full bitmapped screen set at 256 x 256 pixels with each pixel using 1 byte (for future 256 greyscale or 256 colours per pixel), RAM is 2 x 62556 70ns 32K SRAMs, addressable 8k at a time to the VIC. All the logic is in 74HCTxxx with a lot of timers and registers. Could be done better using GALs.

    I do plan to put this design online but it has been a slow five year + project and I need time to tidy it up. I also have a circuit for an 8×8 pixel sprite on the board. This isn’t quite working as it kills Hsync when the sprite is moved close to the edge of the screen. I don’t have a working oscilloscope so it’s hard to do any diags on that issue.

    Anyway, I got the circuit working today on an LCD screen, you were right, I was turning HS and VS on at the same time. This worked ok(ish)on a CRT but the LCD went to sleep. Now with just a 500ns delay between HS and VS it works! I can extend the dealy up to 4ms and the LCD is fine with it, more than that puts it to sleep again.

    Now it’s working, and I don’t have to keep a CRT screen on my desk, I will do a tidy up and get the design on the internet.

    Thanks again for sharing your very interesting project with us all.

    Cheers
    Dave

  10. Steve - November 11th, 2008 7:03 am

    Dave, congratulations on getting the VIC-20 video working, that’s fantastic! I’m looking forward to more details as you finish up.

    My Hewlett-Packard 1631D is a combination oscilloscope and logic analyzer, and was only $50 on eBay. I wrote about it previously here. It’s not something I use often, but for problems like your sprite killing hsync, it’s a life-saver.

  11. bro - November 12th, 2008 4:55 am

    I found HP 1651B logic analyzer on some sites.
    http://cfs11.blog.daum.net/image/1/blog/2008/11/10/18/17/4917fbb6e00ef&filename=AgilentHP1651BLogicAnalyzer.JPG
    but it hasn’t probe(?) or gripper(?), only there is analyzer box.
    Is that still available if I buy stuff like below ?
    http://www.soriaudio.co.kr/zboard/data/m_eqp/42265.jpg
    (HP 16550A 102CH logic analyzer module and strange cables).

    Thank you…

  12. Steve - November 12th, 2008 7:19 am

    It’s probably best to keep looking for one that has all the parts. The probe means oscilloscope probe, I assume. That should be easy to replace with a generic one. The grippers are used to attach the logic analyzer to the signals you want to examine. For my 1631D they are practically impossible to replace.

    That 16550A looks like it’s supposed to fit into some other piece of equipment. I think you want an all-in-one unit.

    Try this one, if the shipping to Korea isn’t too expensive: http://cgi.ebay.com/HP-1631D-Logic-Analyzer-w-Pods-Leads-Grabbers_W0QQitemZ270295698585QQcmdZViewItemQQptZBI_Analyzers?hash=item270295698585&_trksid=p3286.c0.m14&_trkparms=72%3A1205%7C66%3A2%7C65%3A12%7C39%3A1%7C240%3A1318

  13. bro - November 12th, 2008 3:02 pm

    Steve, Thank you. 🙂
    Now it’s clear for me by your advice. That’s what I want to know .
    I will try to get bidding stuff on your hyper-link.
    best regards

  14. Ben - November 13th, 2008 9:31 am

    bro,

    You will have to fight me for that 1631D Steve linked above. (I am the bidder)

    Also, if you are from Korea, you might want to email the seller before bidding. From the item description: “This item is not for sale or export outside the United States!”

  15. Ben - November 13th, 2008 10:03 am

    bro,

    You might be interested in:

    http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=200275099952

    Listed as “Ships to: Worldwide”

  16. bro - November 14th, 2008 7:07 pm

    Thank you, Ben.

    It’s so hard to get 1631D from Korea.
    I will keep trying..

    have great weekend! 🙂

  17. Steve - November 14th, 2008 7:54 pm

    You don’t need a 1631D specifically, of course, that’s just the model I happen to have. Do you need something that’s a combination oscilloscope *and* a logic analyzer? If you only need an oscilloscope, older analog models are fine for hobby use and are pretty inexpensive.

    For logic analyzers, there are many more older models from HP like 1630A and 1630D, 1650, 1651, 1660, and others. Tektronix also had many similar models.

    If I could only have an oscilloscope or a logic analyzer, I would definitely choose the oscilloscope.

Leave a reply. For customer support issues, please use the Customer Support link instead of writing comments.