RGB to HDMI using a Pi Zero and a small CPLD

discuss both original and modern hardware for the bbc micro/electron
User avatar
BigEd
Posts: 3118
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by BigEd » Tue Mar 31, 2020 2:45 pm

Aha - thanks!

User avatar
IanB
Posts: 573
Joined: Sun Sep 04, 2011 8:28 pm
Location: South Wales
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by IanB » Tue Mar 31, 2020 3:45 pm

BeebMaster wrote:
Tue Mar 31, 2020 2:10 pm
I still can't get anything that matches the DVD screen captures in Mode 7 that I've been using for years.
You won't because the Mode 7 pixels aren't square and the current screengrab code only handles square pixels. You will either get something that is a bit too narrow (Uneven scaling) or a bit too wide (Even scaling).

User avatar
BeebMaster
Posts: 3333
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by BeebMaster » Tue Mar 31, 2020 5:29 pm

I've been doing a bit of shuffling round this afternoon. I decided that Station 129 deserved its own monitor, as it has been sharing the Sony TV with Station 114. I've given it my Dell 1280x1024 monitor, which was itself replaced by the new Ferguson HD TV in January as the Pi4 screen, and plan to use it with RGBtoHDMI.

At the minute I've connected it to Station 114 just for continuity purposes and it looks really lovely except that the message "Cannot display this video mode" appears overlaid on the screen all the time when I use a 50Hz setting. Unfortunately a side effect of this is that the rogue Kingston card has reverted to form, and requires the reset button to be pressed before anything displays.

Also my aluminium Pi4 case has arrived today to replace the official plastic one which fairly melts under all the heat. I still need Fan Shim in there, but so far it's keeping it around 50 centigrade. Whilst I was building that I also took the opportunity to set it up for GPIO serial and put 3 wires on pins 8,9 and 10 and it works just by using cat /dev/serial0 or cat/dev/ttyS0. I've noticed it puts an extra carriage return at the end of every line, which the USB method didn't.
Image

User avatar
BeebMaster
Posts: 3333
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by BeebMaster » Tue Mar 31, 2020 5:41 pm

I think a manual resize will do it. This is one of the Dell monitor pictures, settings shown in the picture, which comes out at 604x540, looking slightly stretched vertically:
capture31.png
If I resize it to 604x512 I think it looks right:
capture31 resized.png
I was liking the larger pictures I got from the Ferguson set, so I may use that mainly for screen captures, I've found that the 1200x1200 pictures if resized to 1200x960 look good.
Image

User avatar
BeebMaster
Posts: 3333
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by BeebMaster » Tue Mar 31, 2020 5:47 pm

Possibly even 604x480, which is near as never mind the same ratio at 1200x960 which works well on the larger captures:
capture31 604x480.png
Image

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Tue Mar 31, 2020 6:56 pm

My PI just arrived, so I'm just connecting it to the beautifully made board from JudgeBeeb.
My fine cable hasn't arrived yet, so I'm trying to program the Xilinx directly.
This worked a couple of years ago when I last programmed my Matchbox CoPro, but iMpact doesn't like the .jed.
When I open it, It pops up two error boxes and a dialog:

Code: Select all

Error Message
ERROR:iMPACT:530 - Unknown JEDEC file!

Code: Select all

Error Message
EXCEPTION:iMPACT:JedecYacc.c:170:1.17 - Data mismatch.

Code: Select all

Assign File
A JDEC file describing an  is about to be assigned to a device previously identified as an xc9572xl.
Are you sure you want to do this?
[Yes][No]
There is a double space between "an" and "is", where I suspect the name that it can't parse should be.
When I tried to update iMPACT from 14.7 (nt64) - I am running Win7ultimate64, it tells me that the server has temporarily moved, but I seem to remember that we had to use 14.7 for some reason. 32bit iMPACT cant find the cable.
Any suggestions welcome.

User avatar
hoglet
Posts: 9248
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Tue Mar 31, 2020 7:01 pm

tricky wrote:
Tue Mar 31, 2020 6:56 pm
My fine cable hasn't arrived yet, so I'm trying to program the Xilinx directly.
I'm not sure I understand what you are saying here. Edit: Actually, skip that, I do understand what you mean.

Detailed instructions for using iMPACT and a Xilinx USB Platform Cable are provided here:
https://github.com/hoglet67/RGBtoHDMI/w ... programmer

Is this what you have been following?

If any steps are not clear, or don't seem correct, then please let us know.
Last edited by hoglet on Tue Mar 31, 2020 7:18 pm, edited 1 time in total.

User avatar
KenLowe
Posts: 1177
Joined: Mon Oct 18, 2004 5:35 pm
Location: Scotland
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by KenLowe » Tue Mar 31, 2020 7:14 pm

hoglet wrote:
Tue Mar 31, 2020 7:01 pm
Detailed instructions for using iMPACT and a Xilinx USB Platform Cable are provided here:
https://github.com/hoglet67/RGBtoHDMI/w ... programmer

Is this what you have been following?

If any steps are not clear, or don't seem correct, then please let us know.
That's the guide I used the other day to update my CPLD. It worked fine for me. I also used that same guide today to successfully program the CPLD on my SCSI host adaptor board :).

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Tue Mar 31, 2020 7:58 pm

Yep, that was the one I was following.
Sorry, wasn't clear about not being ready to add the program from SD patch wires.

Has anyone tried this latest .Jed file with iMPACT 14.7 64bit.

User avatar
hoglet
Posts: 9248
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Tue Mar 31, 2020 8:23 pm

tricky wrote:
Tue Mar 31, 2020 7:58 pm
Has anyone tried this latest .Jed file with iMPACT 14.7 64bit.
Can you check the .jed file looks like jedec, and not like HTML.

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Tue Mar 31, 2020 8:25 pm

I was just going to check, on my way now.
...
EDIT: I had to download the whole repo as a ZIP, otherwise it just kept giving me HTML.
I viewed the file, but there were a few non-text characters (probably tab or LF), so I thought that was safer.
Anyway, all programmed now.
Next step Elgato HD60 to see if I can record some better beeb footage.

User avatar
BeebMaster
Posts: 3333
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by BeebMaster » Tue Mar 31, 2020 8:47 pm

I didn't need to do anything with my JudgeBeeb board except put the firmware on the SD card, does the CPLD definitely need programming?
Image

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Tue Mar 31, 2020 8:53 pm

I don't know, I thought someone said it did, Oh well, it's done now!

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Tue Mar 31, 2020 10:08 pm

And, no good, no HDMI signal, well, there is enough for the TV to recognise to enable the HDMI port, but no picture.
I've been over the board twice and no issues, extremely neat soldering.
I've been trying a few things, but turns out it didn't like the first THREE SD cards that work fine otherwise (all FAT)!
Now it seems to be working as the MODE7 LED is lit and the other is flashing, but the Elgato still doesn't recognise the signal.
Well, not working as neither TV can detect a proper signal either :(

User avatar
hoglet
Posts: 9248
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Tue Mar 31, 2020 10:18 pm

What are the models numbers of the two TVs you have tried?

Dave

User avatar
KenLowe
Posts: 1177
Joined: Mon Oct 18, 2004 5:35 pm
Location: Scotland
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by KenLowe » Tue Mar 31, 2020 11:07 pm

tricky wrote:
Tue Mar 31, 2020 8:25 pm
I was just going to check, on my way now.
...
EDIT: I had to download the whole repo as a ZIP, otherwise it just kept giving me HTML.
Probably not that relevant any longer, but it sounds like you may have missed the step where you need to click on the 'RAW' button before right clicking to 'Save-As...'.

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Tue Mar 31, 2020 11:14 pm

I'll in the morning, but my othere rgb2hdmi that you built worked on both of them.

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Wed Apr 01, 2020 9:31 am

Still not got model numbers, but my old RGB2HDMI doesn't seem to be working, so maybe there is an issue with the three HDMI cables that I have tried!

User avatar
IanB
Posts: 573
Joined: Sun Sep 04, 2011 8:28 pm
Location: South Wales
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by IanB » Wed Apr 01, 2020 6:51 pm

tricky wrote:
Wed Apr 01, 2020 9:31 am
Still not got model numbers, but my old RGB2HDMI doesn't seem to be working, so maybe there is an issue with the three HDMI cables that I have tried!
Are you using a mini HDMI to HDMI cable or an adapter with a normal cable?
I have found some adapters with some cable and monitor combinations result in a very flaky HDMI connection.

Also do you have a TTL to USB serial adapter as that can be used to view the debug info

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Wed Apr 01, 2020 10:37 pm

I have tried a few combinations but haven't found my single cable yet.
I do have a usb2serial adapter that I use for gotecs, but I don't know if it is TTL, I'll have a look in the morning after I have another look for my HDMI to mini cable.

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Fri Apr 03, 2020 7:00 pm

Here is a boring status update.
OK, the magic ingredient was finding my old cable - no adapters and hey presto, it works - well, sort of!
Both my adapters work with my really crappy hdmi capture device.
Neither work with one of my TVs and I havnt tried the other.
The old one on original firmware works at 720x576p50 with the elgato, although it reports it as p25 - to be investigated.
The other is rejected saying that 640x480 is not supported - this is after choosing 720x576p50 and rebooting.
I also can't find a way to set the resolution in a file, but haven't finished reading the wiki.
On the new one with nearly every button press the elgato looses sync and I have to wait 10+ seconds for it to sync again.
Booting with sw1 held to go back to the default resolution I my seems to work about 1 in 4.
I've ordered some more SD cards because some of mine do t work.

User avatar
IanB
Posts: 573
Joined: Sun Sep 04, 2011 8:28 pm
Location: South Wales
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by IanB » Fri Apr 03, 2020 9:22 pm

tricky wrote:
Fri Apr 03, 2020 7:00 pm
Neither work with one of my TVs and I havnt tried the other.
Try 60Hz modes if the 50Hz ones don't work.
tricky wrote:
Fri Apr 03, 2020 7:00 pm
On the new one with nearly every button press the elgato looses sync and I have to wait 10+ seconds for it to sync again.
Try changing the Genlock speed in the settings menu to the slowest setting to see if that helps.
If that doesn't work, try changing "V Lock Mode" from Genlocked to Unlocked.

There are also some HDMI settings that you could try adding or changing such as
hdmi_drive
config_hdmi_boost
and maybe others
Documentation here:
https://www.raspberrypi.org/documentati ... t/video.md

You will have to edit / add these to both config.txt and default_config.txt on the SD card
tricky wrote:
Fri Apr 03, 2020 7:00 pm
I do have a usb2serial adapter that I use for gotecs
If you mean for reprogramming the gotek bootloader then that is a suitable adapter.

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Fri Apr 03, 2020 10:17 pm

Thanks, I'll give them a try.
That page will have to wait, as I tried it on my phone earlier, but it seems too have too much script - not what you would expect from the RPi.

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Sat Apr 04, 2020 10:44 am

One last update, nearly everything is good now :)
I was mistaken, the TV that I was mostly using for testing isn't the one that worked before, I swapped that with my daughters one, so this one has never worked and still doesn't! The non-working one is a Panasonic Viera TX-L32S10BA - I don't want to use it on this TV anyway.
The new PI seems to have a bad connection on the HDMI port, which is what was making the signal breakup and loose sync. I will use this for TUBE or 1MHz bus.
The Elgato now works too, although it was a bit of a paint to set up, with help continually going to the web to pages that didn't help at all. It seems to have a rediculously small set of supported input resolutions and only supports 4 output, so it looks like I will be using 720x576p50 and then using VirtualDub if I want a different resolution. I saw somewhere that it had a built in h264 encoder, but can't find a setting to use it, again would just have been nice, but VirtualDub will do nicely.
Now I just need to solder a new HDMI socket on my monitor so that I can play without a two second lag on the PC - or use composite (9" amber), that is probably better anyway.
Thanks for the help and tips.
PS I was a little confused about the genloc/buffers, unless single buffered=0 buffers, why would 1 be less lag than 0?.

User avatar
davidb
Posts: 2780
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by davidb » Sat Apr 04, 2020 11:19 am

I thought I'd pose a random question which I hope hasn't been asked before.

Would it be possible to decode the output from the last 32 lines of MODE 4 on the Electron and transform it into text that filled the entire framebuffer, or doesn't the Pi have enough bandwidth for anything more than scanline conversion? I was thinking of transforming the last 1K of screen data into MODE 7 style output as the application for this.

User avatar
tricky
Posts: 4364
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by tricky » Sat Apr 04, 2020 1:36 pm

Disclaimer, I no nothing about this specific CPU, GPU or software!
I was going to say, not on the CPU, but it would have nearly 20ms to do it in.
The GPU could, but I don't thing we use that in RGB2HDMI mode.

User avatar
hoglet
Posts: 9248
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by hoglet » Sat Apr 04, 2020 1:52 pm

davidb wrote:
Sat Apr 04, 2020 11:19 am
Would it be possible to decode the output from the last 32 lines of MODE 4 on the Electron and transform it into text that filled the entire framebuffer, or doesn't the Pi have enough bandwidth for anything more than scanline conversion? I was thinking of transforming the last 1K of screen data into MODE 7 style output as the application for this.
I imagine this would be technically possible, but it would be tricky to get right.

Depending on how long it takes to repaint the screen, you might miss the next vsync pulse. This would mean dropping alternate frames, and running at 25Hz rather than 50Hz. Depending on the application, this may or may not be noticable.

The other difficulty would be automatically detecting that you wanted to switch into this mode, rather than displaying the whole MODE 4 screen normally. Some kind of signaling would be required.

Dave

User avatar
BigEd
Posts: 3118
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by BigEd » Sat Apr 04, 2020 1:57 pm

I like this! Presumably it's a bit like the in-band signalling for VideoNuLA emulation: a secret number is in the stream.

And, I think, being a frame (or two) behind matters much less when we're talking about mode 7.

User avatar
davidb
Posts: 2780
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by davidb » Sat Apr 04, 2020 2:31 pm

hoglet wrote:
Sat Apr 04, 2020 1:52 pm
Depending on how long it takes to repaint the screen, you might miss the next vsync pulse. This would mean dropping alternate frames, and running at 25Hz rather than 50Hz. Depending on the application, this may or may not be noticable.
I was thinking that it would run at least one frame too late, plus the amount of time needed to generate a screen for the framebuffer.
The other difficulty would be automatically detecting that you wanted to switch into this mode, rather than displaying the whole MODE 4 screen normally. Some kind of signaling would be required.
Without some kind of out of band signalling - or even a switch connected to a GPIO - I'd thought of doing something with the first or last pixel on the screen to signal that MODE 7 emulation is required. I suppose that you could also look for "MODE 7" in the Electron's video output, but that might be a bit too demanding. :lol:

User avatar
IanB
Posts: 573
Joined: Sun Sep 04, 2011 8:28 pm
Location: South Wales
Contact:

Re: RGB to HDMI using a Pi Zero and a small CPLD

Post by IanB » Sat Apr 04, 2020 2:36 pm

tricky wrote:
Sat Apr 04, 2020 10:44 am
PS I was a little confused about the genloc/buffers, unless single buffered=0 buffers, why would 1 be less lag than 0?.
Single buffered means that one frame buffer is in use which is the buffer that the GPU uses to display the video.
This buffer is simultaneously written to by the PI capture software and read out for display on the HDMI port by the GPU.
When the output is genlocked to the input, these reading and writing processes run at exactly the same speed so they never catch up with each other and to reduce the lag, the phase relationship between the two is arranged so that the reading process runs just a few ms behind the writing process so the overall delay in the system is around 3ms.

Double buffered means the CPU writes to one buffer while the GPU is reading from the other buffer which introduces a 1 frame (20ms for PAL) lag into the system.

Triple and quadruple buffered add additional buffers between reading and writing which introduce further frame delays.

The multi buffer options are only useful if you can't genlock because the input and output frame rates are different (e.g. 50 Hz input to 60Hz display) as they stop any tearing artifacts at the expense of increased lag.

Note that when the menu is on screen, triple buffering is enabled and the video update rate drops to 25Hz as the software spends one frame capturing the video and the other writing the menu on top of it.

Post Reply

Return to “8-bit acorn hardware”