Shop OBEX P1 Docs P2 Docs Learn Events
Color NTSC with the SX48 — Parallax Forums

Color NTSC with the SX48

BeanBean Posts: 8,129
edited 2007-03-20 17:26 in General Discussion
Okay, I've done numerous black and white NTSC projects. But I gotta tell you, color NTSC is a WHOLE lot harder.
After burning some midnight oil, I finally got color on my composite monitor.

This "first run" attempt was to re-create the color output from the Apple II computer.
I got ahold of the book "Understanding the Apple II" by Jim Sather (an excellent book even though it is from 1983). Man, that Woz was a freaking genius.

I ordered some custom frequency oscillators from digikey (71.590909MHz or 20xColorburst), soldered·3 resistors·to the SX48 protoboard and here is the result. There are 160 pixels across and 192 vertically. The first picture shows 10 pixels of each of the 16 colors (counting black and white). The second picture is 4 pixels of each color, then 2 pixels of each color, then 4 pixels of each color.

Now that I have that working, the next step is to integrate a 32K SRAM to hold the pixel info and make a real 160x192x16 color image.


[noparse][[/noparse]edit] I posted the code. If you use the SX-Key as the clock you MIGHT see color or you might not. It depends on the TV. Also you will see some·random lines across the screen·when the SX-Key is clocking. My monitor will show color, but I have to keep turning it off and on until it does. With the 71.590909 oscillator it works perfectly (as seen in the pictures).

Bean.


·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com

Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com

There are only two guaranteed ways to become weathy.
Spend less than you make.
Make more than you spend.


Post Edited (Bean (Hitt Consulting)) : 9/2/2006 9:44:04 PM GMT
845 x 689 - 69K
753 x 645 - 78K
«13

Comments

  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2006-09-03 01:12
    Holy Cow Beanman

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • ForrestForrest Posts: 1,341
    edited 2006-09-03 05:16
    That looks very impressive - especially with a 32K SRAM. Any chance you're going to write a tile based graphics engine for it like you did with the Black and White version for the SX28?
  • BeanBean Posts: 8,129
    edited 2006-09-03 12:17
    Forrest,
    I don't have the SRAM connected yet. That's the next step.
    I'm sure a tile based engine will be forthcoming.

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • ForrestForrest Posts: 1,341
    edited 2006-09-03 13:05
    Nice - there's a certain Atari 8-bit game written in Basic that I'd like to port.
  • BeanBean Posts: 8,129
    edited 2006-09-03 14:49
    Which game ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • ForrestForrest Posts: 1,341
    edited 2006-09-03 15:13
    Gold Rush, published in Compute! magazine in 1982. It's the first computer program I typed in when I got my first computer - an Atari 800. It uses a redifined character set for the players and playing field. The game is similar to Lode Runner - also a favorite of mine.
  • BeanBean Posts: 8,129
    edited 2006-09-03 21:08
    I'm not·familar with either of those (I'm not a gamer).
    But from the title, I'd say that color 11 (yellow/gold) will be most useful.

    The engine will probably be 8x8 tiles. Each pixel in the tile can freely be any of the 16 colors. The tile placement will be on even horizontal pixels, and any vertical pixel. There will also be at LEAST 2 graphics pages to allow for page flipping (drawing on one page while another page is displayed).

    I'm amazed at how stable the colors are with the oscillator. Thanks to the SX deterministic interrupts (I use the TIMER1 interrupt to trigger each line).

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.


    Post Edited (Bean (Hitt Consulting)) : 9/3/2006 11:08:10 PM GMT
  • ForrestForrest Posts: 1,341
    edited 2006-09-03 22:29
    Hmm, 8 x 8 won't be useful for this game, because the original game was setup for 20 characters per line x 24 lines and each character was bitmapped and could be 1 of 4 colors.

    If you can get the tile engine up to 16 x 16, you could do a reasonably good version of Super Breakout.
  • Brian RileyBrian Riley Posts: 626
    edited 2006-09-04 17:35
    Bean (Hitt Consulting) said...

    I'm amazed at how stable the colors are with the oscillator.
    Bean.

    So, how much did the oscillators cost in what quantity?

    Maybe we could do a group purchase, if there were enough interest. if Bean doesn't want to handle it, I will volunteer since I already have the mechanism in place for my other ventures.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    cheers ... brian riley, n1bq, underhill center, vermont
    See the K107 Serial LCD Controller at
    www.wulfden.org/k107/
  • BeanBean Posts: 8,129
    edited 2006-09-04 18:17
    Brian,

    · I used this part from Digikey: SG-8002DC-SCB-ND
    · I wanted the RoHS part, but it was out of stock.
    · I paid $5.15 for 3 pcs. The prices goes down to $2.94 for 100. So they are not that expensive even in small quantities.

    · For anyone using the SX-Key, try changing the timer R1 and R2 values in these lines:
    · TIMER1 R1, 4560
    · TIMER1 R2, 4560

    · On my monitor is seems that 4561 works better than 4560, you might try 4559 too.

    · I'd like suggestions for making this a product.
    · I'm thinking of using a thru-hole SRAM and making a PCB that will piggyback onto the SX48 Protoboard.
    · And selling it as a kit.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • ForrestForrest Posts: 1,341
    edited 2006-09-04 21:37
    Bean,
    I like the kit idea. Could you make it compatable with the SX52 Prototype board also?

    Here's some things on my wishlist that would make it an excellent gaming board: Add sound output (simple R2R ladder is fine) along with a DB9 port to attach an Atari joystick.
  • Brian RileyBrian Riley Posts: 626
    edited 2006-09-05 01:13
    Bean (Hitt Consulting) said...
    Brian,

    ... I paid $5.15 for 3 pcs. The prices goes down to $2.94 for 100. So they are not that expensive even in small quantities.


    I'd like suggestions for making this a product. I'm thinking of using a thru-hole SRAM and making a PCB that will piggyback onto the SX48 Protoboard. And selling it as a kit.

    Bean.

    Oh, OK! I thought maybe it was like some outrageous figure. I have gotten some pretty wild quotes or qty 1-5 of non-standard frequencies for transmitter.

    I would be up for a kit with a piggy back board for the SX48 protoboard. Keep up the good work ...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    cheers ... brian riley, n1bq, underhill center, vermont
    See the K107 Serial LCD Controller at
    www.wulfden.org/k107/
  • BeanBean Posts: 8,129
    edited 2006-09-05 02:52
    Okay after connecting everything, I have only 3 I/O pins left.

    Does anyone know of a slick way to read an atari joystick (5 switches connected to a common) with only 3 I/O pins ?

    Of course Up&Down cannot be closed at the same time (same with Left&Right).

    Without any extra parts if possible (okay a resistor of two would probably fit, but NO ICs).

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • Robert KubichekRobert Kubichek Posts: 343
    edited 2006-09-05 03:12
    Bean (Hitt Consulting) said...
    Okay after connecting everything, I have only 3 I/O pins left.

    Does anyone know of a slick way to read an atari joystick (5 switches connected to a common) with only 3 I/O pins ?

    Of course Up&Down cannot be closed at the same time (same with Left&Right).

    Without any extra parts if possible (okay a resistor of two would probably fit, but NO ICs).

    Bean.

    Read the switches with decimal to binary chip, with 3 io lines you could read up to 7 switches.....
    Or using the same 1wire circuit for a wind vane you could do a LOT more than just the 5 switches...smilewinkgrin.gif


    Bob scool.gif
  • ForrestForrest Posts: 1,341
    edited 2006-09-05 04:16
    How many pins are you using for the video and how many for audio? 4-bit audio should be ok
  • BeanBean Posts: 8,129
    edited 2006-09-05 11:55
    Forrest said...
    How many pins are you using for the video and how many for audio? 4-bit audio should be ok
    The SRAM requires 26 pins, the video output uses 6 pins, the audio output is 1 pin (but it's a timer output so you can use high speed PWM to make much more than 16 different volume levels).

    I figured out how to do it with 2 resistors by using the different threshold levels to detect which of the two mutually exclusive switches are closed.

    I've almost got the layout done. I will make a prototype on my LPKF, then get some boards made.
    I only expect to make about 20 kits. If response if good, I may make a SMT populated board.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-09-05 14:15
    Hi Bean,

    I am also working on a Sx48 protoboard addon using a 32K sram.
    It is possible to use only 24 pins on the sram when you also have
    an I2C bus. I use the SCL line also as OE for the sram. (sram CS = GND)
    Port C = sram DQ0-DQ7
    Port D = sram A0-A7
    Port E = sram A8-A14, WE
    Port A = SCL,SDA,TX0,RX0
    Port B = application (in attachement is layout example of quad birectional uart).
    That would give you 5 free I/O pins for the buttons.

    For single switches with a common ground you could also use a resistor ladder
    where each button results in a different R value, and then use RC time.

    You could also connect 1k resistors (or resistor network) to DQ0-DQ7 and
    the buttons to these resistors, so that when a button is closed, it pulls
    a DQ line low (sram OE must be high during button scan).

    regards peter
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-09-05 15:10
    Bean,

    ·· Using a 74HC165 you could read 8 or even 16 inputs off those 3 pins using an SPI interface (a.k.a. SHIFTIN).· This would also have the benefit of allowing multiple buttons/joysticks to be used.· Take care.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • pjvpjv Posts: 1,903
    edited 2006-09-05 15:39
    Hi Bean;

    If you wanted to sense 5 buttons to a common without any IC's, could you not simply wire 5 binary weighted resistors, one to each button, and then input that resistance into a single pin virtual ADC? A resolution of 2^5, or one in 32 should be quite achievable.

    That would only use 5 button encoding resistors, one small cap and one more "DAC" resistor. All done with only one I/O pin!

    Cheers,

    Peter (pjv)
  • BeanBean Posts: 8,129
    edited 2006-09-05 16:32
    Thanks for all the suggestions guys.
    The 3 I/O pins are fed directly into the DB9, what the user does with them after that is up to them.
    I guess I'll put Vdd on the DB9 too to make it an "expansion port" also.

    Still haven't seen anything that beats my 2 resistor method for least componets... (wink, wink).

    Here my plan:

    Fire button gets it own I/O

    UP is connected directly to I/O2 and DOWN is connected thru at 12K. Then the internal pulls are enable. When the I/O level is set to CMOS (2.5V) if the pin is low then UP is pressed, if it's low then set the level to TTL (1.4V). If the pin is low at TTL, then down is pressed. If it's still high at TTL level neither UP nor DOWN is pressed.

    LEFT and RIGHT work just like UP and DOWN.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • ForrestForrest Posts: 1,341
    edited 2006-09-05 16:45
    Sounds good. 32K for video memory is a lot more than I had on the Atari 800.
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2006-09-06 03:48
    holy frijoles.... (those are beans in my neck of the woods)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • cbmeekscbmeeks Posts: 634
    edited 2006-09-06 11:47
    Hey cool Bean!

    Can you show us the protoboard?

    The propeller is cool but I think a lot of us are forgetting just how awesome the SX really is.

    Man, I am so pumped about this. My color board used a gillion parts....but I was following Andre's XGS example. No knock on him...he's a genius....but I have to admit I am surprised you got that kind of color with almost nothing.

    Also, I don't have a 2.7k resistor at home ( will be ordering supplies this weekend ). Do you know if other combos would work? I do have plenty of 330 and 1.5k.

    I have an SX52 protoboard but I might order some SX48 boards. That way, I am more "main stream".

    My homebrew is back on! Thanks again Bean.

    cbmeeks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Coders' Hangout
    A place for coders to hangout!

    METROID?
    Metroid Classic

    Post Edited (cbmeeks) : 9/6/2006 12:15:36 PM GMT
  • BeanBean Posts: 8,129
    edited 2006-09-06 12:41
    cbmeeks,
    · Yeah I'm a minimalist kinda guy [noparse];)[/noparse]
    · When I make the prototype boards I'll make two and send you one to "play" with, if you can make a demo or two for it.
    · Deal ?


    Oh, about the 2.7K, just put two 1.5K in series to make 3.0K that should be close enough.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • cbmeekscbmeeks Posts: 634
    edited 2006-09-06 13:59
    Hey, that would be awesome. In fact, I would be the first in line to buy a real board.

    I'm at work now so I can't really study your code but I am curious. How are you changing the colors in software? In other words, how are you spinning the color wheel mid-scanline?

    I've done it in software. I basically just simulated a color burst by sending a square wave whenever I wanted to change color. But then again, I was only running about 8 times color burst.

    On your system, can you make any of the pixels any color? If you can, then you are very close to a real image buffer. The next question is what picture are you going to display first? hahaha

    PS, if you ever want to type up a quick "article/tutorial" on how you did this I would be GLAD to host it....giving you all the credit, praise, advertisement, of course. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Coders' Hangout
    A place for coders to hangout!

    METROID?
    Metroid Classic
  • BeanBean Posts: 8,129
    edited 2006-09-06 14:23
    It works like this:
    Say you were outputting bits at twice the colorburst rate.
    And lets say the colorburst was output as 0,1
    When you draw the screen if you output the same as the colorburst 0,1 you get green.
    If you output the opposite 1,0 you get purple.
    If you output all lows 0,0 of course you get black.
    If you output all highs 1,1 you get white.

    Now let's say you output at 4 times the colorburst rate. (this is what my code does)
    So the colorburst is 0,0,1,1
    Like above 0,0,1,1 = Green; 1,1,0,0 = Purple, 0,0,0,0 = Black; 1,1,1,1 = White
    And 1,0,1,0 & 0,1,0,1 = Gray (the frequency is too high for colorburst so it get's averaged as gray).
    0,0,1,0 is sensed as green with a lower amplitude (dark green)
    0,1,1,1 is sensed as green with a higher amplitude (light green)
    0,1,0,0 is sensed as purple with a lower amplitude (dark purple)
    1,1,0,1 is sensed as purple with a higher amplitude (light purple)

    All other combinations are sensed as a phase shift to the color burst given a range of colors.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • cbmeekscbmeeks Posts: 634
    edited 2006-09-06 14:53
    hmmm...I will have to struggle with that one a bit. I think I see what you are saying.

    Still a little confused on the "4 times the colorburst rate".

    EX: In your code for the active scanline:

    ' Make sync for 17 CBC (colorburst cycles) 17 * 20 = 340 - 8 = 332 / 4 = 83
    



    17 * 20 = 340 - 8 = 332 / 4 = 83

    • 17 is CBC
    • 20 is speed you are running (20 times colorburst) (71.5909 Mhz)
    • 4 ?? Is that number of cycles you get per color clock? Where did he come from?

    Sorry, I am taking 2 minutes between compiles to read your source...i will follow more closely at lunch today. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Coders' Hangout
    A place for coders to hangout!]http://www.codershangout.com

    METROID?
    Metroid Classic
  • BeanBean Posts: 8,129
    edited 2006-09-06 16:45
    "4 times the colorburst rate" just means you are outputing 4 bits during 1 colorburst cycle.

    All the timing·is measure in terms of colorburst cycles. So the Sync pulse is 17 colorburst cycles (or about 4.75uSecs). Since I'm clocking at 20 times the colorburst that is 340 cycles - overhead (8) then divide by 4 to get the count for DJNZ loop. The leftover is NOPs or other instructions.

    The / 4 is because DJNZ X,$ takes 4 cycles.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.


    Post Edited (Bean (Hitt Consulting)) : 9/6/2006 4:54:53 PM GMT
  • cbmeekscbmeeks Posts: 634
    edited 2006-09-06 16:56
    oh yeah...dur.

    man, you get me a color tile engine and I will pump out some demos for you. smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Coders' Hangout
    A place for programmers to hangout!
    http://www.codershangout.com

    METROID?
    Metroid Classic
  • cbmeekscbmeeks Posts: 634
    edited 2006-09-06 23:08
    It worked!

    However, I did get the problems you described. It only works when I turn off the monitor (1084GS) and turn it back on. And I get the lines going down the screen.

    Great work though!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Coders' Hangout
    A place for programmers to hangout!
    http://www.codershangout.com

    METROID?
    Metroid Classic
Sign In or Register to comment.