Author Topic: Make use of an old CGA monitor  (Read 32380 times)

0 Members and 1 Guest are viewing this topic.

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Make use of an old CGA monitor
« on: May 12, 2015, 03:10:51 pm »
Hi,

I have an old CGA monitor from a 16 bit XT. I also have the video card. I couldn't throw it in the trash - it's from my first PC. No one wanted it for making an oscilloscope. I know it's easier to put a small SPI LCD than driving this monitor but I wish I use it for something. My question is:
Should I try to use the 8 bit ISA CGA video card by driving the ISA bus or I should try to drive the monitor directly. It has 9 pin CGA connector with H-sync, V-sync and RGBI (1 bit each) inputs. Of course it's a black and white (or I should say green) monitor, so it'll only show gray shades. But I might only use it as monochrome anyway. I wish I can drive the ISA bus because the video card will save me some CPU time (at expense of a lot of space and power consumption). So if someone can give me links to 8 bit ISA specification, timing diagrams or whatever can help me I would be grateful.
I hate wasting time, but I just could let this one go...
 

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16672
  • Country: 00
Re: Make use of an old CGA monitor
« Reply #1 on: May 12, 2015, 03:21:25 pm »
I wish I can drive the ISA bus because the video card will save me some CPU time (at expense of a lot of space and power consumption).

Add another CPU :-)

(which is what your ISA card really is...)
 

Offline German_EE

  • Super Contributor
  • ***
  • Posts: 2399
  • Country: de
Re: Make use of an old CGA monitor
« Reply #2 on: May 12, 2015, 03:33:28 pm »
You should be able to connect this to a PC:

1) Using a modern monitor set your PC to 640 x 480. This step is needed because a monitor this old cannot automatically negotiate a connection.

2) Horizontal and vertical sync connect as normal.

3) As you have a monochrome monitor connect the red, green and blue outputs through 75 ohm resistors to the monitor. This is just for safety, I feel a little uncomfortable with the R, G and B signals directly shorted together at the monitor.

Your only problem is going to be making up the 15-pin to 9-pin cable
Should you find yourself in a chronically leaking boat, energy devoted to changing vessels is likely to be more productive than energy devoted to patching leaks.

Warren Buffett
 

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16672
  • Country: 00
Re: Make use of an old CGA monitor
« Reply #3 on: May 12, 2015, 03:37:16 pm »
You could drive it from an Arduino.

There's lots of info on doing that out there on the web.

(Actually they usually do VGA...CGA will be a fun hack)
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Make use of an old CGA monitor
« Reply #4 on: May 12, 2015, 04:58:28 pm »
Hi,

I have an old CGA monitor from a 16 bit XT. I also have the video card. I couldn't throw it in the trash - it's from my first PC. No one wanted it for making an oscilloscope. I know it's easier to put a small SPI LCD than driving this monitor but I wish I use it for something. My question is:
Should I try to use the 8 bit ISA CGA video card by driving the ISA bus or I should try to drive the monitor directly. It has 9 pin CGA connector with H-sync, V-sync and RGBI (1 bit each) inputs. Of course it's a black and white (or I should say green) monitor, so it'll only show gray shades. But I might only use it as monochrome anyway. I wish I can drive the ISA bus because the video card will save me some CPU time (at expense of a lot of space and power consumption). So if someone can give me links to 8 bit ISA specification, timing diagrams or whatever can help me I would be grateful.
I hate wasting time, but I just could let this one go...

8-bit ISA is exactly the pins you would find on the original 8086/8088 chips, consult those if you need help.

Just for fun, if you dare, you can put the OpenCores 80486 reimplementation onto a FPGA, clock it at 133MHz core frequency and  and drive your ISA video card and CGA screen using that, running some kind of DOS. ;)
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #5 on: May 13, 2015, 12:25:31 pm »
You could drive it from an Arduino.

There's lots of info on doing that out there on the web.

(Actually they usually do VGA...CGA will be a fun hack)

Yes, I found lots of VGA stuff. But VGA is more complex because often they have a bios that initializes the card and it's an i386 (or at least x86) code. Making an x86 interpreter is not an easy job. But I couldn't find any CGA video card driving attempts on the net...
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #6 on: May 13, 2015, 12:29:54 pm »
8-bit ISA is exactly the pins you would find on the original 8086/8088 chips, consult those if you need help.

Just for fun, if you dare, you can put the OpenCores 80486 reimplementation onto a FPGA, clock it at 133MHz core frequency and  and drive your ISA video card and CGA screen using that, running some kind of DOS. ;)

I don't quite have that much of experience on x86 architecture. If I had I wouldn't have problems of driving simple 8 bit ISA slot. And the 486 has a ton of pins. Won't be easy to write it. So I don't dare.
I'm not aware of those OpenCores CPUs. Are they something like system on chip with built-in ram and other controllers or a bare CPU?
 

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16672
  • Country: 00
Re: Make use of an old CGA monitor
« Reply #7 on: May 13, 2015, 12:30:06 pm »
You could drive it from an Arduino.

There's lots of info on doing that out there on the web.

(Actually they usually do VGA...CGA will be a fun hack)

Yes, I found lots of VGA stuff. But VGA is more complex because often they have a bios that initializes the card and it's an i386 (or at least x86) code. Making an x86 interpreter is not an easy job.

They drive the monitor directly from the Arduino pins. No graphics card needed.

CGA is much easier because it has TTL inputs, not analog.

Edit: Take a look at TVout to get an idea: https://code.google.com/p/arduino-tvout/

CGA will be slightly easier because the horizontal/vertical sync are on separate wires.
« Last Edit: May 13, 2015, 12:33:58 pm by Fungus »
 

Offline Lightages

  • Supporter
  • ****
  • Posts: 4314
  • Country: ca
  • Canadian po
Re: Make use of an old CGA monitor
« Reply #8 on: May 13, 2015, 12:32:59 pm »
If you really want to just make use of the monitor then bypass the CGA logic and use the analog inputs inside. Some of these monitors have a normal RGB input inside with a CGA front end tacked on.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #9 on: May 13, 2015, 12:43:03 pm »
I wish I can drive the ISA bus because the video card will save me some CPU time (at expense of a lot of space and power consumption).

Add another CPU :-)

(which is what your ISA card really is...)

Good point! I kinda though about this right after I wrote that sentence. But I still haven't made the calculations of what resolution can I get from a MCU. If I were more into the FPGA stuff I would make a video card that I can talk to with a MCU, but MCU themselves are not that good of driving fast signals and taking commands at the same time. I've seen people over the net getting an NTSC video signal out of atmel MCU, but at quite coarse resolution.

I'm still holding back on this until I have some more information. I'm willing to waste some time, but not too much. I kinda miss the green, eye burning stuff from my childhood.

If you really want to just make use of the monitor then bypass the CGA logic and use the analog inputs inside. Some of these monitors have a normal RGB input inside with a CGA front end tacked on.

Well yes, but why? CGA is actually easier to drive than RGB (or whatever it's called in B/W monitors). There is no much difference if I just want monochrome. One reason to bypass it is to make an oscilloscope or something like this. But that's a game for ones that doesn't already have one. I'm not sure what else can I make from fully analog drive of a CRT.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #10 on: May 13, 2015, 01:24:07 pm »
Ok. Let me ask more specific questions. Info I find on wikipedia:
http://en.wikipedia.org/wiki/Color_Graphics_Adapter
shows 60Hz vertical frequency, which I understand as 60 frames/sec. and 15.75kHz horizontal frequency, which I translate as 15750 rows a second. That's 262.5 rows per frame. Now my best guess is that the time for displaying 62.5 rows should be the time for the beam going back to the top of screen...?
Am I thinking correctly? I don't really have any experience with TVs ...

So is the H and V sync output from the monitor?

Let me calculate dot frequency for 320x200. 15.75k*320 = 5.04MHz, except that you might need to wait for the beam to go back to the left side after drawing a row. Sounds hard to achieve. Maybe with a SPI I can throw series of 5MHz 8 bits and make a character display ...
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21688
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Make use of an old CGA monitor
« Reply #11 on: May 13, 2015, 01:47:08 pm »
CGA modes were 320x200 and 640x200 (yeech, the aspect ratio!).  And also oddballs like 160x200 and 160x100 that you could coax with register abuse (occasionally used in Demoscene programs), providing a few more colors.  Text was 40x25 or 80x25 characters, with pixel resolution same as above.

In any case, the refresh rates were largely the same, as noted.  So, the extra 60ish lines went to retrace and overscan, and ditto for the extra horizontal pixels.  Master clock on those systems was usually something like 4.77MHz I think?

Sync comes from the PC; the monitor synchronizes its internal oscillators based on this.  (It usually takes a few cycles before the oscillator locks onto a new signal, or a sudden change, hence why it can take some time for vertical sweep to roll and lock, or twitch out and stretch or compress momentarily, when switching resolutions on multiscan monitors.)  Occasionally, register abuse could also produce inconvenient sync pulses, which under or over-clock the monitor, leading to "fatal poke" or 0xf00f commands.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16672
  • Country: 00
Re: Make use of an old CGA monitor
« Reply #12 on: May 13, 2015, 02:04:02 pm »
my best guess is that the time for displaying 62.5 rows should be the time for the beam going back to the top of screen...?
Am I thinking correctly? I don't really have any experience with TVs ...

You're not far off.

I think CGA has some unused lines as 'border' as well as vertical blanking.
 

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16672
  • Country: 00
Re: Make use of an old CGA monitor
« Reply #13 on: May 13, 2015, 02:06:12 pm »
Maybe with a SPI I can throw series of 5MHz 8 bits and make a character display ...

Yes, the Arduino TVout library I mentioned earlier uses SPI to output the bits.

(it's the only way to have zero gap between each block of 8 bits).
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #14 on: May 13, 2015, 02:45:00 pm »
:) starting to get some data ... So, monitor locks to the sync signals of the PC. Good. I wander how much can I underclock it. I probably can't make it run at half the H-sync frequency, can I? It would be too easy. 160x100 might be doable with enough CPU time left. I'll have to find some free time to play with that. I might also use the back trace of the beam to do some communication.

Well, I don't know why I feel more comfortable with using the CGA video card. Maybe because you can write whenever you want and it won't complain it's busy with tracing right now.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #15 on: May 23, 2015, 08:38:57 am »
Does anyone know the timing length of CGA V and H sync pulses? This guy measured it for VGA:
http://www.gammon.com.au/forum/?id=11608
But I don't have working CGA hardware.
« Last Edit: May 23, 2015, 08:43:57 am by npelov »
 

Offline rob77

  • Super Contributor
  • ***
  • Posts: 2085
  • Country: sk
Re: Make use of an old CGA monitor
« Reply #16 on: May 23, 2015, 10:53:16 am »
i would connect the graphics card to a micro/arduino (however arduino's digitalwrite might be dead-slow to drive the ISA signals)..
here is a nice description of pinout, signals and also timing diagrams and transfer modes...

http://pinouts.ru/Slots/isa_pinout.shtml

it should be doable because there are some implementations of ISA ethernet + micro out there.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8276
Re: Make use of an old CGA monitor
« Reply #17 on: May 23, 2015, 12:59:05 pm »
Bit-banging a VGA signal with a single microcontroller: http://www.linusakesson.net/scene/craft/

It shouldn't be too hard to do the same for CGA.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #18 on: May 23, 2015, 01:40:04 pm »
Well, I did actually use VGA H and V sync pulse width for CGA. After all there is a CGA to VGA cable made.
So it works. I made H-Sync, V-Sync and Line signals - I light up every other line. I left 30 black lines after V-Sync and there should be about 30 black lines after line number 200.
« Last Edit: May 23, 2015, 01:42:19 pm by npelov »
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #19 on: May 23, 2015, 02:25:32 pm »
And that's the resolution you can get without using SPI. I'm toggling pixel data, leaving every 8 lines off. So it's something like chessboard. The width of a block is the pixel width!!! The height of a block is 8 lines. So you can get a resolution 42x200. Of course if you have to get real data to display ... that'll go down on X. So next step - the SPI.

@rob77 Using isa is actually faster than trying to output the video signal directly, because you send the pixels to the video card and you can then do whatever you want while the video card is rendering the dispaly. Thanks for the link. I'll read it.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21688
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Make use of an old CGA monitor
« Reply #20 on: May 23, 2015, 03:41:52 pm »
What MCU platform and toolchain are you using?

I should think it's possible to get >= 256 monochrome pixels by bit-banging from something like AVR at a clock over 6MHz.  With maximum 16 to 32MHz available (between MEGA and XMEGA), there should be enough time to refresh registers between lines and read in more RAM/ROM, maybe not allowing completely fresh image data per line, but I can imagine repeating lines or slowly changing data (including possible compression methods).

Microcontrollers have very little onboard RAM anyway, so it might be very worthwhile to investigate e.g. abusing SPI RAM as a video generator, maybe with a little outboard logic (shift registers to buffer and re-align poorly timed frames?).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8276
Re: Make use of an old CGA monitor
« Reply #21 on: May 23, 2015, 03:46:30 pm »
Great, now write a demo for it. :)
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #22 on: May 23, 2015, 04:04:01 pm »
@T3sl4co1l I use PIC18F45K22. It's running at 16 MIPS at 64MHz. I know AVR instructions have some advantages, but I think you are overstating the power of AVR. 6 MHz with instruction clock (if I remember correctly) of 3 MHz  -> that's 330ns per instruction. The H clock is 15.625 kHz (rounded) - that's 64us per line. You have about 10-20% dead zone - that's at most 57us per line. So you are telling me that with 6 MHz clock, which is 0.33 us you can get 256 dots. 57/0.3333 is 171. And that's only if you have 1 instruction per dot. Can you read 171 bits and output them to a pin in 171 instruction cycles? I don't think so.

The best would be if you have SPI hardware with output shift register double buffered. Unfortunately PIC only has double buffering for receive register. And even then you are pretty limited of what you can do with the rest of the CPU time. I would prefer if I can make the ISA card working, but my knowledge of x86 arch. is not that good.

Attachment is showing usage of SPI at 4 MHz. There is 1 instruction deadtime - vertical black lines. I think I can run the SPI at 8 MHz if I optimize the quickly written code or even write it in assembler, I can do nothing to get rid of the deadtime.
 

Offline npelovTopic starter

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: bg
    • Microlab.info
Re: Make use of an old CGA monitor
« Reply #23 on: May 23, 2015, 04:20:13 pm »
Great, now write a demo for it. :)
I don't think so. A demo means "I spent a month of trying to squeeze all the juice from my MCU to create a funny, useless animation. Making this monitor work is also waste of time because you can display something cheaper, easier, faster, more energy efficient with today's displays. But if I'm going to spend that time I'll want to have something useful. Like 80x25 character display.

There is one problem though. The thing is screaming with 16 KHz and my head is going to explode soon. I wonder can you reduce the noise... Is it coming from the beam deflection coils? Can I pot it with resin?

P.S. It's consuming 39W. Not that bad. My LCD is consuming 32W.
« Last Edit: May 23, 2015, 04:25:13 pm by npelov »
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21688
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Make use of an old CGA monitor
« Reply #24 on: May 23, 2015, 06:09:27 pm »
@T3sl4co1l I use PIC18F45K22. It's running at 16 MIPS at 64MHz. I know AVR instructions have some advantages, but I think you are overstating the power of AVR. 6 MHz with instruction clock (if I remember correctly) of 3 MHz  -> that's 330ns per instruction. The H clock is 15.625 kHz (rounded) - that's 64us per line. You have about 10-20% dead zone - that's at most 57us per line. So you are telling me that with 6 MHz clock, which is 0.33 us you can get 256 dots. 57/0.3333 is 171. And that's only if you have 1 instruction per dot. Can you read 171 bits and output them to a pin in 171 instruction cycles? I don't think so.

AVR is single cycle (reg-reg instructions).  RAM is usually slower, and instruction store to reg, even slower (also branches, if taken).

My baseline idea would be, fill up all 32 byte registers with the next line, and transmit each one in sequence to the desired pin.  Which might look something like,

PA0 = output, others = junk

Code: [Select]
MACRO FOR N = 0 TO 31

    MACRO REPEAT(8)
        OUT PORTA, r{N}
        LSR r{N}
    END MACRO
END MACRO

where "REPEAT" means, write this out 8 times, and FOR does the same thing but incrementing "N".  Compile-time macros, so, the code space to write out one single line becomes huge (each instruction is one WORD, so you'd need 8 x 32 = 256 WORDs (512 bytes) to do it!).

But hey, when you have 64k of program memory and only 2k of RAM...

AVR has the nice feature of having 32 x 8 bit registers, so you could potentially store 256 bits in the registers, all at once.  Maybe more, depending on how desperate you want to get -- don't forget that all those IO ports are registers too, even the FLAGS register.  You could do some seriously demented stuff to the peripherals, which is fine because who needs 'em anyway? ;D

You probably would not be able to read in much RAM/ROM during horizontal retrace, so you'd want to figure some way to make the lines change only a few bytes at a time.

Or since we're just writing all this damn stuff out as code anyway, the refresh instructions could be generated by an image compression routine that converts line-to-line changes into limited register updates, or varies the actual 'copy register to port' instructions in the program (which could take tremendously more code space as a result, however).  In other words, something very much in the style of the PC-XT "full speed video" demo: https://x86dc.wordpress.com/ Which is a pretty awesome bit of design, I must say.

Now, PIC sucks for not having registers -- but if you're going at 16 MIPS anyway, and that includes memory read/write at no cost, then it might not be too bad.  In fact the faster RAM access would be to your advantage, though still limited by however much RAM there is inside.

Possible methods for loading entire pictures at a time, for either platform, might include "streaming" (continuous SPI?) from external memory, and buffering that onboard -- even going so far as to write onboard Flash so the data can be stored as instructions, if necessary.  It would be slow, and it would thrash the ROM, but such drastic methods are hardly beyond the realm of the "demo" -- hiding load times (from slow peripherals such as cassettes, floppies or hard disks) has always been part of the challenge.

And again, not that you're *trying* to make an entire demo or anything... but the inner nuts-and-bolts are what count here, and I find that fascinating.

Quote
The best would be if you have SPI hardware with output shift register double buffered. Unfortunately PIC only has double buffering for receive register.

That's what I meant by "a little logic" -- you might double-buffer it yourself.  It would of course be advantageous to use full port widths, too -- all you'd need is the functional opposite of a 74HC595: a latched parallel-loading register with serial out!

For working with SPI, there may be an existing 1-bit FIFO/synchronizer part that can simply be added on; clock it with the video clock, keep feeding it data, and boom, your SPI's blank pulse disappears.

There is one problem though. The thing is screaming with 16 KHz and my head is going to explode soon. I wonder can you reduce the noise... Is it coming from the beam deflection coils? Can I pot it with resin?

Heh heh... at least you know your ears are still working!....for now... :P

That, or the FBT.  Probably more likely to succeed by adding acoustic damping foam inside the case, if you can.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf