Giter VIP home page Giter VIP logo

pico-composite8's Introduction

sample

pico-composite8

Based on pico-mposite by breakingtoprogram:

A hacked together demo for the Raspberry Pi Pico to output a composite video signal from the GPIO Using a resistor ladder to translate a 5-bit binary number on the Pico GPIO to a voltage between 0v and 1v.

8-Bit R2R Resistor DAC

The input impedance of the Composite Monitor is 75Ω; the output impedance of the R2R ladder is R. In order to get 1V across a 75Ω load with a 3.3V source, R needs to be 2.3 * 75 = 172.5Ω. Closest 'standard' values are 180Ω/360Ω.
Unfortunately using those values doesn't work for 8-bits. The values are low enough that the internal resistance on the Pico GPIO pins becomes important, and causes visible errors on the 7- and 8-bit. Measuring the voltage drop on the pins gives a calculated series resistance of about 40Ω, so you will need to reduce the 2R value by that much to compensate. I used two 160Ω resistors in series:

Wiring

The R2R DAC will draw about 19mA total from the Pico when all the bits are '1', with a maximum of 6.5mA on any single pin. Here's the simulation:

simulation

You can access the simulation here: R2R DAC Simulation

Bitmaps

A portion of the NTSC signal is reserved for SYNC and BLANKing:

NTSC

On a 256 scale, BLACK works out to about 86 (255/140 * 47.5), so the values from 86 - 255 are the range from BLACK to WHITE, or 170 values. The scripts take the 256-gray image, compress it to 170-gray, and shift it up by 86 to leave room for the SYNC.

The 8-bit gray images are created with Gimp:

  • convert to grayscale, 8-bit
  • flatten image
  • scale image and canvas size to get 512x384 image
  • export as raw image data (*.data) File size should be exactly 196608 bytes

Use scripts/bit2h.pl to create an '.h' file which can be included and compiled with the program. There's only enough room for one 512x384 image in memory though. Remove the comment in front of #define TESTPATTERN in cvideo.c to enable that behavior.

The images can also be stored in flash, which has room for about 8 images; for that you'll need to install picotool. Put the *.data files in a directory and run scripts/mkbin.pl. The resulting 'flash.bin' file can be copied to the Pico with scripts/flashbin.sh. The program will step through the images in a slideshow.

Timing

The 640x480 resolution is accomplished by interlacing 640x240 fields with this timing: Timing

The program is doing that and can render the Indian test pattern:

Indian

Note the concentric circles around the 30's and the vertical/horizontal resolution lines.

Compiling/Uploading

Compile using VSCode with the GCC 9.2.1 arm-none-eabi kit (which unfortunately isn't available on the Raspberry Pi (yet)).

To deploy from the development platform (e.g. X86 Ubuntu) to the Pico using SWD, you need a Raspberry Pi running openOCD. The Pico connects to the Raspberry Pi like this:

SWD Wire

On the Raspberry Pi, execute openOCD:

openocd -c "bindto 0.0.0.0" -f interface/raspberrypi-swd.cfg -f target/rp2040.cfg

On the Development Machine, click the Run and Debug icon in the left-side menu - it will execute the .vscode/launch.json included in the project. Click the triangle next to Pico Deploy in the top-side menu, and enter the address of the Raspberry Pi SWD Host in the box to the right:

SWD host

The program will compile, upload to the Pico, and break at main(). You can either remove the programmed Pico, or continue with debug commands, top-side middle menu.

the BUG

The interlace fails and only gives half the vertical resolution unless there's a 30 usec delay in cvideo.c at the start of scan line #0 - before the interlace starts:

Bug

15 usec isn't enough, only 30 usec will work. Other than that, it follows the timing above... Sort of stumbled into it by accident: in an early version there was a memcpy there that took 30 usec to complete. When I took that out, interlace failed until I added an equivalent 30 usec delay. Don't know why...

pico-composite8's People

Contributors

obstruse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pico-composite8's Issues

Add a license to the code

I'm interested in making a derivative of this code for a GPLv3 project of mine, but there is no license.

Would you mind putting it under either GPL3 or some more permissive license?

(I want to cut it down to only 3 bits but using a custom resistor ladder that still hits the sync voltage precisely)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.