Pin names
Data (image) signal
Synchronization signal
Ground
Operation
The resolution of the simulated PAL TV is 768x576 pixels, and the aspect ratio is 4:3. PAL video uses analog signal. The signal is carried over the air or using a cable. One of the common cabling standard is Composite video, which combines the pixel data together with the synchronization signals and the color data on a single wire. Wokwi TV does not support color information, and separates the pixel data from the synchronization signals. The separation of the signals makes it easier to generate the image using a digital microcontroller. Use the IN pin for the pixel data, and the SYNC pin for the synchronization pulses. The Arduino TVout library can drive these signals for you.Signal timing
The simulator mimics the standard PAL timings for the signals at 25 frames per second. The frame are interlaced: each frame is divided into two parts, called “fields”. The first field contains the odd lines, and the second field contains the even lines. Each frame takes 40ms, and each field takes 20ms (half the duration of a frame). Each frame is divided into 625 time slots of 64uS. Each time slot contains the pixel data for a single line, but some of these lines are empty - their only use is for synchronization. The simulator expects every field (half-frame) to start with at least one ~30uS synchronization pulse. This means you have to hold the SYNC line low for about 30uS. The PAL standard dictates a specific series of synchronization pulses, but the simulator is pretty lax: it’s happy even with a single ~30uS pulse. Each line should also start with a short, 4uS synchronization pulse. Keep the DATA signal low during these synchronization pulses. The Logic Analyzer is very helpful in debugging the PAL TV signals.Physical TV Connection
The PAL standard uses an analog signal. When running in the simulator, you don’t have to worry about this, but if you want to run your game on a physical TV, then you’d need to generate the following voltage levels:- 0V for sync signals (HSYNC/VSYNC)
- 0.3V for black pixels
- 1V for white pixels
- SYNC pin through a 1KΩ* resistor
- DATA pin through a 470Ω* resistor
- Optionally, another 75Ω that goes to the ground (the resistor is usually already built into the TV receiver circuit).
Voltage divider calculation
We implement a simple voltage divider to generate the required voltages, based on the two digital pin levels:| SYNC | DATA | Output Voltage | Calculation |
|---|---|---|---|
| High (5V) | High (5V) | 0.95 | (5*75)/((1/(1/1000+1/470))+75) |
| High (5V) | Low | 0.304 | (5*(1/(1/75+1/470)))/(1000+(1/(1/75+1/470))) |
| Low | Low | 0 | 0 |
Arduino code example
A simple example that draws a circle using the TVout library:Simulator examples
- TVout demo reel
- Flappy Cat game - Use the blue button to jump
- Arduino Pong for Wokwi TV
- Conway’s Game of Life