RGB to HDMI using a Pi Zero and a small CPLD

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
User avatar
BeebMaster
Posts: 3063
Joined: Sun Aug 02, 2009 4:59 pm
Location: Lost in the BeebVault!
Contact:

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

Post by BeebMaster » Sun Mar 22, 2020 5:53 pm

Thanks to everyone who helped me fix it!

I just rushed those captures out to show it was working, but I've set 50Hz now and a few other things. The image frame is very wide, 960 pixels in modes 0 and 1 so there are "vertical black bars" on either side of the picture, can I reduce that a bit?

I had to auto-calibrate and save when changing from the Beeb to the Master, is it normal for each different Beeb to need a fine-tune?

I'm going to start using it for my screen captures very soon, as my DVD recorder let me down again last week after I spent an hour setting up a single screenshot.

Can the Captures directory be shared over USB (or similar)?
Image

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

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

Post by hoglet » Sun Mar 22, 2020 7:15 pm

BeebMaster wrote:
Sun Mar 22, 2020 5:53 pm
I just rushed those captures out to show it was working, but I've set 50Hz now and a few other things. The image frame is very wide, 960 pixels in modes 0 and 1 so there are "vertical black bars" on either side of the picture, can I reduce that a bit?
I'll let Ian answer that, but it would help to know what resolution your monitor is.
BeebMaster wrote:
Sun Mar 22, 2020 5:53 pm
I had to auto-calibrate and save when changing from the Beeb to the Master, is it normal for each different Beeb to need a fine-tune?
Yes, that's normal. Especially between a Beeb and a Master. And especially in Mode 7.
BeebMaster wrote:
Sun Mar 22, 2020 5:53 pm
Can the Captures directory be shared over USB (or similar)?
Sorry, that's not possible.

Because *everything* is bare metal, driver support is very limited, and USB is one of the most complicated peripherals.

Dave

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

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

Post by IanB » Sun Mar 22, 2020 9:04 pm

BeebMaster wrote:
Sun Mar 22, 2020 5:53 pm
I just rushed those captures out to show it was working, but I've set 50Hz now and a few other things. The image frame is very wide, 960 pixels in modes 0 and 1 so there are "vertical black bars" on either side of the picture, can I reduce that a bit?
...
I'm going to start using it for my screen captures very soon, as my DVD recorder let me down again last week after I spent an hour setting up a single screenshot.
The captures are 960x540 with black bars because they are taken from the screen buffer which is 16:9 aspect ratio and intended to be displayed on a 1920x1080 monitor and the beeb's output is 4:3.

However it looks like you want to make use of the captures separately on your website in which case the bars are not that useful. There is a workaround and that is to switch to 1600x1200 which will give 4:3 aspect captures but the video output will obviously look wrong when displayed on a 16:9 monitor so you should only change to that resolution when doing captures and switch back to use it normally for video display.
I'll look at the possibility of adding an option to just capture the beebs 4:3 area instead of the whole screen which would always give 4:3 captures.

There are a couple of options in the preferences menu which affect captures:
Screencap scaling: Off/On
When off captures are at half resolution (i.e. 800x600 on a 1600x1200 monitor)
When on captures are at the monitor resolution (i.e. 1600x1200)

Teletext Scaling: Even / Uneven
These affect the scaling of teletext which isn't square pixels so try both options and see which captures you prefer.

(There is also progressive scaling but that should be left on Even)

Use save configuration to save any settings you prefer.
BeebMaster wrote:
Sun Mar 22, 2020 5:53 pm
I had to auto-calibrate and save when changing from the Beeb to the Master, is it normal for each different Beeb to need a fine-tune?
If you are switching between bbc and master frequently, you could make a copy of the profile and rename it to master so you can save a set of configs for each one and just change profile to switch between them.
i.e.
Go into /Profiles/Legacy_3BIT on the SD card and make a copy of BBC_Micro_v21-v23.txt
Then rename it to Master_v21-v23.txt
After rebooting you will now have the additional profile and can run the auto config on both of them and save the results to each one using the save configuration option in the main menu. Then all you have to do is change profile when changing machine.
You will need to run auto config in both modes 0 and 7 on both profiles before saving.

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

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

Post by BeebMaster » Sun Mar 22, 2020 9:21 pm

I'll have a play about with resolutions etc. Cutting off the black bars would be handy, I wonder if it's possible I could set up some sort of batch auto-crop with ffmpeg or convert or something if I get really stuck and need to process a whole load of captures, I haven't looked into that yet.

I was thinking separate profiles for different machines, I'll do that when I get the capture sizes sorted.

The monitor is a Ferguson 22" 1920x1080 TV, one of these:

https://fergusontv.com/shop/tvs-by-size ... iew-t2-hd/

I'm backing British industry! I hope they get more stock, I'd like another one eventually, it's the best hundred quid I've ever spent!
Image

User avatar
BigEd
Posts: 2862
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 » Sun Mar 22, 2020 9:41 pm

(If you've got 'convert' from Imagemagick I'm pretty sure you could use that to auto-crop screenshots.)

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

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

Post by IanB » Mon Mar 23, 2020 9:24 pm

BeebMaster wrote:
Sun Mar 22, 2020 3:33 pm
With this 8GB card, I get the first tranche of output commencing with ***RESET*** at power-on (up until the next ***RESET*** where I've had to press the button) so it's doing something.
Can you try the attached file with the problem 8GB SD card to see if it makes any difference:
kernelrpi.zip
(117.43 KiB) Downloaded 3 times
Unzip and overwrite kernelrpi.img

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

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

Post by BeebMaster » Mon Mar 23, 2020 11:08 pm

No sorry, same thing: nothing happens till reset is pressed. Shall I rig up a debug?
Image

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

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

Post by BeebMaster » Mon Mar 23, 2020 11:30 pm

I think it looks best at 1600x1200 with scaling on, although I'm still experimenting.
capture23.png
capture24.png
capture25.png
Image

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

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

Post by KenLowe » Fri Mar 27, 2020 12:59 am

Any idea why my BBC Micro with IntegraB might be doing this clipping (in Mode 7 only)?

Resolution is set to 1920x1080 50Hz to match TV resolution.
Attachments
capture3.png

aotta
Posts: 221
Joined: Fri May 26, 2017 8:57 am
Location: Italy
Contact:

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

Post by aotta » Fri Mar 27, 2020 8:37 am

I solved simply adjusting x and y offset in geometry setting for mode 7, and saving configuration.
But mine wasn't the native resolution, and I have that cropping only with older board and sw, if I remember fine.

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

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

Post by KenLowe » Fri Mar 27, 2020 9:57 am

aotta wrote:
Fri Mar 27, 2020 8:37 am
I solved simply adjusting x and y offset in geometry setting for mode 7, and saving configuration.
But mine wasn't the native resolution, and I have that cropping only with older board and sw, if I remember fine.
That didn't seem to work for me. From memory, the default Horizontal Offset was set to 4. Reducing this to 0 made no difference, and reducing further rolled the value back to 255, and it was just a whole lot worse when that happened.

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

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

Post by IanB » Fri Mar 27, 2020 11:01 am

KenLowe wrote:
Fri Mar 27, 2020 12:59 am
Any idea why my BBC Micro with IntegraB might be doing this clipping (in Mode 7 only)?

Resolution is set to 1920x1080 50Hz to match TV resolution.
That usually indicates a mismatch between the software profile and the CPLD version

What software release are you using?
What CPLD version is programmed?
What PCB issue?

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

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

Post by KenLowe » Fri Mar 27, 2020 12:15 pm

IanB wrote:
Fri Mar 27, 2020 11:01 am
KenLowe wrote:
Fri Mar 27, 2020 12:59 am
Any idea why my BBC Micro with IntegraB might be doing this clipping (in Mode 7 only)?

Resolution is set to 1920x1080 50Hz to match TV resolution.
That usually indicates a mismatch between the software profile and the CPLD version

What software release are you using?
What CPLD version is programmed?
What PCB issue?
I think I do probably have a mismatch between software profile and CPLD. I'll modify the board this afternoon so I can upgrade the CPLD via the PI and report back.

RGBtoHDMI Version: 20200320 8436521
CPLD Version: Legacy_3BIT v1.0
PCB issue: Not sure. It's an early one.

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

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

Post by IanB » Fri Mar 27, 2020 12:38 pm

KenLowe wrote:
Fri Mar 27, 2020 12:15 pm
CPLD Version: Legacy_3BIT v1.0
That CPLD is very old but it should work with the "BBC Micro V10-V20" profile
(There are several different profiles in legacy mode for different CPLDs prior to v3 so you need to make sure you have selected the one to match your CPLD)
KenLowe wrote:
Fri Mar 27, 2020 12:15 pm
I'll modify the board this afternoon so I can upgrade the CPLD via the PI and report back.
That's the best idea as so many improvements have been made.
Modification details here:
https://github.com/hoglet67/RGBtoHDMI/w ... rogramming

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

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

Post by KenLowe » Fri Mar 27, 2020 1:19 pm

That's me updated the CPLD. In the end, I just went with the Xilinx programmer and iMPACT in a Windows 7 virtual environment, and it all worked fine.

I still needed to make an adjustment to the Horizontal Offset, but I had sufficient range to bring in the cropped edge. All good now.

Thanks

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

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

Post by hoglet » Fri Mar 27, 2020 1:28 pm

KenLowe wrote:
Fri Mar 27, 2020 1:19 pm
I still needed to make an adjustment to the Horizontal Offset, but I had sufficient range to bring in the cropped edge. All good now.
What value did you end up needing to use for H Offset.

This shouldn't really have been necessary, so it does make me wonder if the IntegraB is somehow having an effect. Is there a schematic somewhere I could take a look at?

Dave

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

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

Post by KenLowe » Fri Mar 27, 2020 1:43 pm

hoglet wrote:
Fri Mar 27, 2020 1:28 pm
What value did you end up needing to use for H Offset.
I'm using the BBC Micro v21-v23 profile, and I set H Offset to 100 (I think it was set at 126 by default).
hoglet wrote:
Fri Mar 27, 2020 1:28 pm
This shouldn't really have been necessary, so it does make me wonder if the IntegraB is somehow having an effect. Is there a schematic somewhere I could take a look at?
The IntegraB board doesn't touch the video hardware. I think it's the IBOS (IntegraB OS) ROM that's making the adjustments. I'm not sure why it does that.

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

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

Post by hoglet » Fri Mar 27, 2020 2:12 pm

KenLowe wrote:
Fri Mar 27, 2020 1:43 pm
I'm using the BBC Micro v21-v23 profile, and I set H Offset to 100 (I think it was set at 126 by default).
And what version of the CPLD did you program?

The latest for the 3-bit hardware is v66:
https://github.com/hoglet67/RGBtoHDMI/tree/dev/vhdl_bbc

Dave

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

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

Post by IanB » Fri Mar 27, 2020 3:01 pm

KenLowe wrote:
Fri Mar 27, 2020 1:43 pm
I'm using the BBC Micro v21-v23 profile, and I set H Offset to 100 (I think it was set at 126 by default).
If the offered profiles have versions, you are still stuck in legacy mode with a very old CPLD version.
KenLowe wrote:
Fri Mar 27, 2020 1:43 pm
The IntegraB board doesn't touch the video hardware. I think it's the IBOS (IntegraB OS) ROM that's making the adjustments. I'm not sure why it does that.
Would the IBOS be changing the 6845 registers for some reason?

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

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

Post by KenLowe » Fri Mar 27, 2020 3:51 pm

I managed to download v2.1.

The link on the Wiki page is pointing to a dead location, so I just went with the file in the Master branch.

I'll pull the file from the dev branch instead, and try again.

I do believe that IBOS is making changes to the 6845 registers. I'm not entirely sure why. I did start a reverse engineer of the IBOS ROM some time ago that might have shed some light on it, but that's still very much a work in progress. It's only in certain 'OSMODES' that I'm seeing this issue. When set to OSMODE 0 (which is standard Beeb mode) the problem goes away.

Edit: Right, that's CPLD v6.6 installed. It's now working fine without having to make any adjustment to H Offset. Profile is also now just BBC Micro.

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

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

Post by hoglet » Fri Mar 27, 2020 4:31 pm

KenLowe wrote:
Fri Mar 27, 2020 3:51 pm
The link on the Wiki page is pointing to a dead location, so I just went with the file in the Master branch.
This is now fixed.

(If you, or anyone else, comes across dead links on any of my Wiki pages, do let me know and I'll correct them straight away)

Once we have have a final release, I'll merge everything back to master, then it should be less confusing.

Dave

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

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

Post by BeebMaster » Fri Mar 27, 2020 8:54 pm

I found that mode 7 was being clipped on the left during some of the experimentation I was doing, but cycling through the TV ratio options until it got back round to 4:3 fixed it.

I think the mode 7 picture I posted above looks a bit stretched horizontally, I've been trying with uneven Teletext pixels which gives a 1200x1200 picture (in 1600x1200 50 Hz mode):
capture65.png
But now I think that looks a bit stretched vertically, as it's an exact square picture rather than 4:3.

Also I've noticed that because I use *TV 255 to fix the picture on my Sony Trinitron TV of universal ABug acclaim (well, 3 different people said they liked it) the bottom pixel row is missed off the screen:
capture41.png
Not sure if that's the correct behaviour when using a TV 255 setting.
Image

User avatar
tricky
Posts: 4039
Joined: Tue Jun 21, 2011 8:25 am
Contact:

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

Post by tricky » Sat Mar 28, 2020 3:39 pm

My guess would be that it is using integer scaling of 4X to make 256 high into 1024 and as the screen is only 1080 high, that leaves room for 7 pixels above and below and hence moving it down by 8 looses one off the bottom (and presumable *TV1 would loose one off the top).

PS Some ramblings about display area and reasonable capture areas:
I believe to show everything that could be seen on a CRT, you need to show 52us = 416 mode 1 pixels by 305 lines / mode 1 pixels.
There is one demo that puts colour beyond this to "mess" with the black levels and get some very un-beeb-like colours.
There is also at least one demo (mine ;))that uses a screen 388 wide to try to hide the edges of the displayed area. This is because 384 was visible on 3 of my 4 test CRTs, but 388 worked on all 4. To be as faithful as possible, 384 would be a good compromise but to be X4 4:3 @1080, 360 would work.
Last edited by tricky on Sat Mar 28, 2020 5:48 pm, edited 1 time in total.

aotta
Posts: 221
Joined: Fri May 26, 2017 8:57 am
Location: Italy
Contact:

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

Post by aotta » Sat Mar 28, 2020 4:11 pm

My 6bit board stopped working.. since in this version there is a bit more space, is possible to design a plcc44 socket instead of the 10VQG44C? the price is similar, but it will be super easy to solder, and replacing if something wrong!
I'm not good in using kicad, but i think it should not be a difficult change, and i'll appreciate it very much.

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

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

Post by hoglet » Sat Mar 28, 2020 5:58 pm

As far as I'm aware, the PLCC44 package is now discontinued by Xilinx, and is very hard to find.

Dave

aotta
Posts: 221
Joined: Fri May 26, 2017 8:57 am
Location: Italy
Contact:

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

Post by aotta » Sat Mar 28, 2020 6:47 pm

hoglet wrote:
Sat Mar 28, 2020 5:58 pm
As far as I'm aware, the PLCC44 package is now discontinued by Xilinx, and is very hard to find.

Dave
i just bought five for a few pounds.. i don't know if i can post links, but i found many seller on a famous chinese site:
xl9572.jpg
xl9572.jpg (15.14 KiB) Viewed 274 times
but, i am afraid the board size should be enlarged to fit that socket and re-engineered

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

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

Post by IanB » Mon Mar 30, 2020 8:30 pm

BeebMaster wrote:
Fri Mar 27, 2020 8:54 pm
Also I've noticed that because I use *TV 255 to fix the picture on my Sony Trinitron TV of universal ABug acclaim (well, 3 different people said they liked it) the bottom pixel row is missed off the screen:
You would get a few pixels clipped with *TV255 on a 1080p screen as it won't fit, however if you always intend to use it with *TV 255 you can adjust the V Offset in the geometry menu to compensate and re centre the image (save config after adjusting). After making this adjustment, the image will no longer be centred with *TV0 until you set V Offset back to default.

Can you try the following update:
kernelrpi.zip
(117.79 KiB) Downloaded 2 times
Unzip and overwrite the file on the SD card as before.

This contains two changes:
1. It might work with the problem 8GB SD card
2. The Screencap scaling option has been changed to "ScreenCap Size" with four options:

Normal - captures with screen aspect ratio usually at half size
Full Screen - captures with screen aspect ratio at full screen size
4:3 Crop - captures with 4:3 aspect ratio usually at half size
Full 4:3 Crop - captures with 4:3 aspect ratio at full screen size

This should allow you to get 4:3 captures on a 1080p screen. If the screen is already 4:3 there will be no difference between the 4:3 options and the normal ones.

User avatar
BeebMaster
Posts: 3063
Joined: Sun Aug 02, 2009 4: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 1:10 pm

Thanks, that works in the rogue 8GB Kingston card!

I'm still experimenting with the new options, I still can't get anything that matches the DVD screen captures in Mode 7 that I've been using for years.
Image

User avatar
BigEd
Posts: 2862
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 1:19 pm

I'm agog - what software change brings this troublesome SD card back into play?

User avatar
IanB
Posts: 474
Joined: Sun Sep 04, 2011 7: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 1:38 pm

BigEd wrote:
Tue Mar 31, 2020 1:19 pm
I'm agog - what software change brings this troublesome SD card back into play?
It was a total kludge.

From previous logs, Beebmaster was getting:

Code: Select all

Sat,21 Mar 2020.20:29:56.595247 Initialised Framebuffer
Sat,21 Mar 2020.20:29:56.595379 Size: 1920x8192 
Sat,21 Mar 2020.20:29:56.595425 Pitch: 1920 bytes
as the response to a frame buffer resize request on power up with the 8GB card. You also get that response when no HDMI lead is connected so I though the most likely explanation was some difference in boot time between the 8GB and other cards which meant the HDMI interface was not ready on powerup when the frame buffer resize was issued.

As a workaround, the software now detects that specific size response and reboots the Pi so it's basically doing what Beebmaster was doing manually but it has the additional advantage that you can now hot plug a HDMI connector into an already powered up interface which previously resulted in a blank screen until reset was pressed.

Post Reply