Decode UHF TV ZX81 signal with SDR

Discussions about Sinclair ZX80 and ZX81 Hardware
Exile
Posts: 64
Joined: Tue Jan 03, 2023 9:50 pm

Decode UHF TV ZX81 signal with SDR

Post by Exile »

Recently I've been experimenting with decoding the UHF TV signal from a ZX81 using a Software Defined Radio (SDR). This gives a way to display the original ZX81 output without the need for either a composite mod, or an older TV.

I'm at the proof of concept stage, but have been able to get a decent image from ZX81s with both ULAs that generate a back porch, and those that do not.

The radio I used was a HackRF One, available for about £69, including P&P and VAT from AliExpress. This is an Open source design, so clones from China are allowed. It took 8 days from ordering to arrive in the UK. I used this model as it can capture the entire UHF channel width. Less expensive SDR radios cannot manage that, and so give a very blurred display.

The (open source) software I used was SDRAngel (https://www.sdrangel.org/). I had to modify and recompile the Analog TV decoder plugin, due to the "non-standard" ZX81 signal.

Some screen shots

The decoded screen from a ZX81 with a ULA not generating a back porch
zx81_image_nbp.JPG
A scope image, showing a signal from a ZX81 with a ULA not generating a back porch
zx81_scope_nbp.JPG
A scope image, showing a signal from a ZX81 with a ULA generating a back porch
zx81_scope_bp.JPG
Hopefully this is useful for people that do not want to open up their ZX81, such as discussed in this threadhttps://www.sinclairzxworld.com/viewtop ... f=7&t=5619

If anyone is interested I can provide more details.
sP1d3r
Posts: 145
Joined: Mon May 16, 2022 9:20 am

Re: Decode UHF TV ZX81 signal with SDR

Post by sP1d3r »

I wonder if this would work with RTL-SDR v3?
The frequency range is a lot less than HackRF One, but it's a capable device and it can do the UHF frequency range.
Exile
Posts: 64
Joined: Tue Jan 03, 2023 9:50 pm

Re: Decode UHF TV ZX81 signal with SDR

Post by Exile »

I wonder if this would work with RTL-SDR v3?
I started my experiments with a RTL-SDR v3. The bandwidth of the RTL-SDR v3 (up to 2.4MHz) gives about 128 pixels horizontally, including the hsync etc. That is enough to see that a K prompt exists, but not enough to resolve an on screen listing.

Since my initial post I've moved on to configure the HackRF One to use a bandwidth of 16 MHz, which does give a very clear image.
sP1d3r
Posts: 145
Joined: Mon May 16, 2022 9:20 am

Re: Decode UHF TV ZX81 signal with SDR

Post by sP1d3r »

Thanks for the info.

No way of avoiding shelling out for a HackRF One, then.
I presume 240 x 192 is the screen size.
User avatar
Paul
Posts: 1573
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Decode UHF TV ZX81 signal with SDR

Post by Paul »

256x192
In theory, there is no difference between theory and practice. But, in practice, there is.
Exile
Posts: 64
Joined: Tue Jan 03, 2023 9:50 pm

Re: Decode UHF TV ZX81 signal with SDR

Post by Exile »

With the HackRF One I now use one vertical pixel per field line, so at 16MHz the resolution is approx 768 by 576.
I am able to fully resolve and display maxtxt and maxdemo (https://bodo4all.fortunecity.ws/zx/maxdemo.html) (i.e. 320 by 240). I can also view the 384 rows in https://www.sinclairzxworld.com/viewtop ... 3&start=20

Currently I'm exploring emulation of a CRT (as apposed to a more modern LCD). It appears that modern LCD typically determine that vsync ends when a sync pulse longer than hsync is detected. CRTs hold the beam at the top of the display until the vsync signal ends. This results is different behaviour for QS Defenda. QS Defenda generates a signal that looks like a very long vsync pulse. When I run it on my composite converted ZX81 connected to my LCD TV, this results in a black bar at the top of the screen. Of course, there is no black bar at the top when running QS Defenda on an original ZX81 with a CRT.

The other thing I am working on is correctly detecting the interlaced fields for ilena and the final part of rezurrection.

I'm away from my PC at the moment, but will post pictures and code when I am back.
sP1d3r
Posts: 145
Joined: Mon May 16, 2022 9:20 am

Re: Decode UHF TV ZX81 signal with SDR

Post by sP1d3r »

Paul wrote: Tue Oct 08, 2024 11:48 am256x192
Sorry, I confused 320 x 240 with 256 x 192.
Exile wrote: Tue Oct 08, 2024 12:07 pm Currently I'm exploring emulation of a CRT (as apposed to a more modern LCD). It appears that modern LCD typically determine that vsync ends when a sync pulse longer than hsync is detected. CRTs hold the beam at the top of the display until the vsync signal ends. This results is different behaviour for QS Defenda. QS Defenda generates a signal that looks like a very long vsync pulse. When I run it on my composite converted ZX81 connected to my LCD TV, this results in a black bar at the top of the screen. Of course, there is no black bar at the top when running QS Defenda on an original ZX81 with a CRT.
I get strange displays on cheap chinese monitors with ZX composite mods, the display seems normal for listing or running a program but when running a game the display isn't centred on the screen, the sort of thing you wouldn't get with CRT.

The theory of this project is interesting, I wonder if the display output from the SDR prog could be ported to an Arduino compatible LCD screen, like this one:
ZX emulator with ST7789 LCD
ZX emulator with ST7789 LCD
Exile
Posts: 64
Joined: Tue Jan 03, 2023 9:50 pm

Re: Decode UHF TV ZX81 signal with SDR

Post by Exile »

Here are some screenshots from the latest version. All are images are created from UHF data captured from the ZX81 RF connector, which has been rendered in real time on a Windows PC. The Windows snipping tool was used to capture the images

320x240 display
maxhrg.JPG
interlacing through offset vsync
ilena2.JPG
Iinterlacing without offset vsync
puzzle.JPG
anni.JPG
Handling the long vsync of QS Defenda
qsdefenda.JPG
As discussed in recent threads, it appears that only ilena.p generates a TV standard interlaced image by generating different vsyncs to identify the odd and even fields. However, other programs that generate an interlaced image without modifying vsync now also display well.
sP1d3r wrote: Sun Oct 13, 2024 9:17 amI wonder if the display output from the SDR prog could be ported to an Arduino compatible LCD screen, like this one
The processing required by the SD Radio is far too great to run on an Arduino. In addition OpenGL shaders running on the PC GPU are post-processing each frame. In theory a ST7789 could be driven via a Pi Pico that is attached to either a PC or a Pi5. The data rate to drive 320x240 at 50 Hz is quite high for I2C, I needed custom drivers on picozx81 to achieve this. This is not something I will personally do, I wanted to use my large PC display, and to be able to capture screenshots using PC tools.
Last edited by Exile on Sun Oct 20, 2024 10:52 am, edited 1 time in total.
Exile
Posts: 64
Joined: Tue Jan 03, 2023 9:50 pm

Re: Decode UHF TV ZX81 signal with SDR

Post by Exile »

If anyone has a Windows PC and a HackRF One radio and would like to try this, here are some installation instructions:

1) Plug in the HackRF One and install the drivers as described on the HackRF One website (or alternatively at https://recolog.blogspot.com/2018/02/in ... r-and.html

2) Connect the ANT socket to the the UHF cable plugged into the ZX81

3) On a Windows PC Install SDRAngel version 7.22.0 from https://github.com/f4exb/sdrangel/relea ... -win64.exe. The version is important, don't take the latest, as it currently does not work with the HackRF One

4) Unzip demodatv.dll from the attached zip file and copy over the installed version (typically at C:\Program Files\SDRangel\plugins\demodatv.dll)

5) Start SDRAngel, select the HackRF One as the sampling device, add the ATVDemodulator as a channel. You should a windows layout similar to this:
setup.JPG


6) Configure the frequency, BBF etc for the sampling device, similar to as shown in the picture above

7) Configure the TV decoder. RF and Video settings should match that in the picture

8) Start the sampler - A TV picture should appear, adjust the frequency as needed

Two display modes have been created for the ZX81. For general use select AllEvenI. This ignores the field information in the vsync signal and displays at 50Hz. For experimenting with interlace effects select GuideI. This combines two interlaces fields to make a full image. This displays at 25Hz.

Some programs (e.g. Rezzurection, QSDefenda, Nova2005) use unusual TV timings. To obtain lock, experiment with adjusting the Min and Max sliders. These effectively change the allowed number of lines in one TV image. They also impact how quickly lock is recovered in FAST mode.

This set-up can also be used to decode signals from other retro computers, however currently it is black and white only.
Attachments
demodatv.zip
(61.62 KiB) Downloaded 107 times
sP1d3r
Posts: 145
Joined: Mon May 16, 2022 9:20 am

Re: Decode UHF TV ZX81 signal with SDR

Post by sP1d3r »

Hello again Exile

Thanks for your response.
Exile wrote: Thu Oct 17, 2024 4:51 pm
The processing required by the SD Radio is far too great to run on an Arduino. In addition OpenGL shaders running on the PC GPU are post-processing each frame. In theory a ST7789 could be driven via a Pi Pico that is attached to either a PC or a Pi5. The data rate to drive 320x240 at 50 Hz is quite high for I2C, I needed custom drivers on zxpico to achieve this. This is not something I will personally do, I wanted to use my large PC display, and to be able to capture screenshots using PC tools.
Although the ST7789 is Arduino compatible, I wasn't implying that an Arduino could handle processing display data from a HackRF One, rather that the Arduino compatible screen could be driven from a Linux SBC with more capability than a Pi Pico, e.g. one with over 2GB ram as an SDR application of any capability needs this at least.
Just a thought, I've got many important priorities currently and I just loved the idea of modulator output to an LCD from a ZX81!
Post Reply