RGB to HDMI using a Pi Zero and a small CPLD

discuss both original and modern hardware for the bbc micro/electron
User avatar
Tony359
Posts: 41
Joined: Fri Jul 28, 2023 11:38 pm
Contact:

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

Post by Tony359 »

IanB wrote: Mon Sep 18, 2023 1:19 pm
Tony359 wrote: Mon Sep 18, 2023 10:16 am That's amazing!
So the //c has a dedicated port I can use, the Apple // and //e need some internal wiring to grab the signals from the motherboard?
The digital connection is slightly better than the analog connection because the 4 lines of text in split text/graphics mode will always be displayed as mono. With the analog connection the 4 lines of text will have colour fringing the same as connecting to any other converter / monitor. (Full screen text is always clean mono)

So to sum up:
Always use the digital connection with the IIc unless you only have an analog RGBtoHDMI.
Use an analog RGBtoHDMI with II and IIe for a totally plug in solution or use internal digital pickup if you want split screen text artifact free.
Thanks for the comprehensive explanation! I do have a composite capture device but I loved what I saw on Adrian's digital basement video, the picture is so crisp! Too bad some signal needs to be taken from the board but it's great that it can be done!

Thanks again!
User avatar
Mince
Posts: 525
Joined: Thu Sep 05, 2019 11:25 pm
Location: Cambridge, UK
Contact:

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

Post by Mince »

IanB wrote: Tue Aug 29, 2023 6:22 pm Here are some alternative profiles to try with your mutant caterpillar ZX81 composite interface.
It is probably a good idea to set the adjustment pots roughly back to the way they were originally if that is possible.

...

You will still have to first adjust the sync and Y Hi levels and run a calibration to get a stable image but one or more of these changes might help to keep the image stable.

...
Thanks for doing these and sorry for not trying these out sooner — I've had other stuff all over my desk and haven't had space to get the ZX81 out. When I did, I managed to give it a quick test but didn't have any luck with the non-clamp one; for the clamp ones, I didn't manage to get a stable picture at all and need to spend a bit of time adjusting things. Before I got round to that things started to go wrong, as I was testing things...

Some of the keys on either side of the keyboard weren't working (like 1 and 0, Q and New Line), after the machine had been on for a few minutes. It's not the keyboard as I replaced that and tested the connections from the membrane and sockets. I think I've traced it to RP3 as some of the resistances are way off 10kΩ (something like 2 or 3kΩ), in particular on the line affecting the keys not working. Unfortunately, I also tried reseating the ULA and stupidly assumed Sinclair would put the socket notch on the notched end of the chip and lazily stuck it in the wrong way without confirming first, and I think I've blown it up as now I only get a white screen.

So, testing is on hold until I get that sorted out. I'll let you know how I get on once that is done (and probably RP3 replaced) — hopefully it's nothing else!

Thanks again, in the meantime!
BBC Master— PiTube 3A+ PiVDU, PicoTube, Pi1MHz, MMFS, ANFS, MultiOS
BBC B — Integra ß, PiTube Zero 2W, Pi1MHz, MMFS, DFS, ADFS, ANFS
Electron — Plus 1 w/ AP6 2V2, AP5, PiTube 3A+, Pi1MHz, PRES AP3+4, Elkeconet or ATI/ABR, ElkSD 64/Plus 1
dantaipan
Posts: 43
Joined: Fri Feb 18, 2022 6:45 pm
Contact:

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

Post by dantaipan »

Just dropping this here for fun. Two RGBTOHDMIs one machine.
IMG_4291.jpeg
mikeh_nz
Posts: 78
Joined: Wed Nov 30, 2022 3:24 am
Location: Seattle
Contact:

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

Post by mikeh_nz »

I was looking at ways to inject audio into hdmi.

Wasn’t a problem on my bbc solution, but possibly a future Atari 2600 using luma code it will be played against a tv.

I see I can buy some hardware that takes hdmi input + 3.5mm line in & outputs hdmi.

Does anyone know:
  • If there’s a simple open source circuit to do this?
  • How hard would it be to supply the audio to the rgbtohdmi raspberry pi and get it to inject the audio? It would be nice if it could take an audio feed.
Not sure if this feature request has been suggested before - but thought I’d raise it…

Cheers
Mike
dantaipan
Posts: 43
Joined: Fri Feb 18, 2022 6:45 pm
Contact:

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

Post by dantaipan »

mikeh_nz wrote: Sun Oct 08, 2023 8:14 pm I was looking at ways to inject audio into hdmi.
So far the cheapest way I have found to do this is to pull the board out of one of these and place it right into the unit and hard-wire the 5v.

https://a.aliexpress.com/_mN8wvxy

The Retro Channel did this with a c64 Kawari build.
If someone has a better solution I am all ears. Specific to your example (TIAdigitizer) I was kind of hoping for something that would take the signal and output analog RGB but that is not appropriate for this thread.
User avatar
IanB
Posts: 1055
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 »

mikeh_nz wrote: Sun Oct 08, 2023 8:14 pm I was looking at ways to inject audio into hdmi.
Wasn’t a problem on my bbc solution, but possibly a future Atari 2600 using luma code it will be played against a tv.
I see I can buy some hardware that takes hdmi input + 3.5mm line in & outputs hdmi.
Many monitors have a 3.5mm audio input jack which can be used to supply an analog audio override when using HDMI for the video. This is either selected in the monitor's menus or it automatically overrides the HDMI audio source when plugged in (it may only work on one of the HDMI inputs).
However if your monitor or TV doesn't have that feature then, at the moment, the only solution is to use a HDMI audio embedder as you indicate or use an external speaker bar.
dantaipan wrote: Sun Oct 08, 2023 11:46 pm So far the cheapest way I have found to do this is to pull the board out of one of these and place it right into the unit and hard-wire the 5v.
https://a.aliexpress.com/_mN8wvxy
That's quite a bit cheaper than the ones I looked at a while ago so it's good to know that it works.
Note you will most likely have to change the HDMI mode in the main menu from 'DVI compatible' to 'HDMI (Auto RGB/YUV)' to ensure it works as DVI doesn't normally support audio. (I plan on auto detecting the monitor type and making the DVI / HDMI setting auto switching in a future update).
mikeh_nz wrote: Sun Oct 08, 2023 8:14 pm Does anyone know:
  • If there’s a simple open source circuit to do this?
  • How hard would it be to supply the audio to the rgbtohdmi raspberry pi and get it to inject the audio? It would be nice if it could take an audio feed.
I'm not aware of any open solution for this but I am looking at getting audio into the Pi using the USB interface and a USB audio adapter.
To do this involves getting the USB interface driver running, writing a USB audio driver and working out how to add the audio to the video in the Pi's HDMI output plus it would likely require a multicore Pi like the zero2W as one core would be needed to manage the USB interface. There isn't much documentation available for doing this in bare metal so don't expect a solution any time soon.

If anyone has any experience of low level USB coding and wants to help, please get in touch.

This is how such an interface would look:
USB audio.jpg

BTW I found some nice thin right angle HDMI and USB cables which mean those wires go in the same direction as the input and result in a more compact layout (see photo)
Like this:
https://www.ebay.co.uk/itm/384772391222
https://www.ebay.co.uk/itm/235131868816
Also from Ali Express, e.g.
https://www.aliexpress.com/item/1005001774422465.html
(Select the right angle variant)
Unfortunately the HDMI cables are only 50cm so may require an extension lead if not positioned near the monitor. (There is a longer coiled version but even that is only 50cm unstretched)
If you are using a DVI monitor then using a DVI to HDMI adapter like this will add 20-30cm to the cable length:
https://www.aliexpress.com/item/1005005077992637.html
dantaipan
Posts: 43
Joined: Fri Feb 18, 2022 6:45 pm
Contact:

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

Post by dantaipan »

Thanks for the perspective on audio Ian.

I’ve had a chance to play around with the GTIADigitizer in an Atari 5200 and it seems to be working really well. Not a huge surprise as it is essentially an Atari 800 but still good to know. Not sure why this forum shows photos at 45 degrees.
Attachments
IMG_4441.jpeg
User avatar
maniacminer
Posts: 1331
Joined: Thu Sep 21, 2017 2:59 am
Location: Cambridge / Singapore
Contact:

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

Post by maniacminer »

dantaipan wrote: Wed Oct 18, 2023 2:40 am Not sure why this forum shows photos at 45 degrees.
I believe the forum software resamples the image and removes all the EXIF metadata including the instruction from your camera that you had taken the photo in a different orientation.
Big Model B Econet,Master 512,Electron,A3000,A540,Atom,Unilab 3-Chip Plus,6502,Z80,65C816,80186,32016,Matchbox,ARM7TDMI,Master 10/100,PiCoPro,Teletext,Music500,PiSCSI,Challenger3,Gotek,VideoNuLA,GoSDC,GoMMC,Integra-B,RGB2HDMIv4,Epson LQ-850 (for the win!)
User avatar
maniacminer
Posts: 1331
Joined: Thu Sep 21, 2017 2:59 am
Location: Cambridge / Singapore
Contact:

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

Post by maniacminer »

Just wondered why you'd use a USB sound card and all the aggro that is, vs. say an i2s ADC? A reasonably priced, very competent (perhaps massively overkill) is the Texas Instruments PCM1802DBR - they were around £2 a pop, but now more like £3 and it will do 24 bit 96kHz and could be shoehorned onto the existing hat design. Then you'd take the output from the i2s bus and plop it into the HDMI stream (no idea how to do that though!)
Big Model B Econet,Master 512,Electron,A3000,A540,Atom,Unilab 3-Chip Plus,6502,Z80,65C816,80186,32016,Matchbox,ARM7TDMI,Master 10/100,PiCoPro,Teletext,Music500,PiSCSI,Challenger3,Gotek,VideoNuLA,GoSDC,GoMMC,Integra-B,RGB2HDMIv4,Epson LQ-850 (for the win!)
mikeh_nz
Posts: 78
Joined: Wed Nov 30, 2022 3:24 am
Location: Seattle
Contact:

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

Post by mikeh_nz »

dantaipan wrote: Wed Oct 18, 2023 2:40 amNot sure why this forum shows photos at 45 degrees.
I like to imagine that you live on the equator. Hence you’re sideways relative to me. Thank you for making this a global community…
User avatar
IanB
Posts: 1055
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 »

maniacminer wrote: Sat Oct 21, 2023 1:06 am Just wondered why you'd use a USB sound card and all the aggro that is, vs. say an i2s ADC? A reasonably priced, very competent (perhaps massively overkill) is the Texas Instruments PCM1802DBR - they were around £2 a pop, but now more like £3 and it will do 24 bit 96kHz and could be shoehorned onto the existing hat design. Then you'd take the output from the i2s bus and plop it into the HDMI stream (no idea how to do that though!)
The zero does have an i2s peripheral but those GPIO pins are already in use for video capture and there aren't any spare GPIO pins so it would be quite difficult to do that.
One possible option would be to use a larger CPLD to receive the audio data and interleave with the video data so that can also be passed in on the same GPIO pins as the video but the GPIOs are relatively slow so the audio data would have to be interleaved during blanking. This would involve a radical redesign of the board probably making it a lot bigger and losing the compact footprint of the zero and all that makes the USB option look attractive as it would be a simple plug in option to existing hardware.

I have found a bare metal open source USB stack for the zero so I will have a go at porting that. It does have some standard drivers for devices like storage and keyboards/mice etc but not audio so an audio capture driver would still have to be added.
User avatar
Mince
Posts: 525
Joined: Thu Sep 05, 2019 11:25 pm
Location: Cambridge, UK
Contact:

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

Post by Mince »

I'm getting somewhere with my TI Presenter and the RGBtoHDMI — I'm not quite sure how I got where I am, but somehow I seem to have stumbled across almost the correct settings. It's set in NTSC mode and I started with the ZX81 Composite and adjusted the voltages for sync and Y level and have an image. After a bit of tweaking with H Offset (and I think the new Create Custom Profile option might have helped!) I've got an image that is nice and stable but only when the RGBtoHDMI menu is up.

If the V Sync Type is set to anything other than Interlace, I get an image that flickers as I move the menu selector up and down. If I set the V Sync Type to Interlace, I get a perfect picture in the menu but it flickers when I exit out. I've tried playing with both of these settings but I can't seem to get rid of the flickering. The second image looks looks oddly very broken: it's like one half of the interlaced image is corrupted.

I've uploaded a video to YouTube showing this: https://www.youtube.com/watch?v=KqmdDEVhx4U

[Edit: just for completeness — here are a couple of stills showing the two frames it flickers between]
Screenshot 2023-11-06 at 09.42.52.png
Screenshot 2023-11-06 at 09.43.03.png
I'm not sure it's necessary any more but you asked in the past for a photo of the crystals from the board. Here they are, for completeness:
IMG_7989.jpeg
Is there something obvious I need to be changing? It's almost like I need to select just one field of the interlaced pair.
Last edited by Mince on Mon Nov 06, 2023 9:44 am, edited 1 time in total.
BBC Master— PiTube 3A+ PiVDU, PicoTube, Pi1MHz, MMFS, ANFS, MultiOS
BBC B — Integra ß, PiTube Zero 2W, Pi1MHz, MMFS, DFS, ADFS, ANFS
Electron — Plus 1 w/ AP6 2V2, AP5, PiTube 3A+, Pi1MHz, PRES AP3+4, Elkeconet or ATI/ABR, ElkSD 64/Plus 1
User avatar
IanB
Posts: 1055
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 »

Mince wrote: Mon Nov 06, 2023 12:30 am If the V Sync Type is set to anything other than Interlace, I get an image that flickers as I move the menu selector up and down. If I set the V Sync Type to Interlace, I get a perfect picture in the menu but it flickers when I exit out. I've tried playing with both of these settings but I can't seem to get rid of the flickering. The second image looks looks oddly very broken: it's like one half of the interlaced image is corrupted.

Is there something obvious I need to be changing? It's almost like I need to select just one field of the interlaced pair.
What happens when you set the video type to interlaced as well as the sync type?

Also can you post a screencap of the source summary page.
User avatar
Mince
Posts: 525
Joined: Thu Sep 05, 2019 11:25 pm
Location: Cambridge, UK
Contact:

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

Post by Mince »

IanB wrote: Mon Nov 06, 2023 9:24 am What happens when you set the video type to interlaced as well as the sync type?

Also can you post a screencap of the source summary page.
When I set both to Interlaced, I don't get an image that flickers violently between two images but I don't get a good image, either: https://www.youtube.com/watch?v=sw3I1KRsiOc

Here's the Source Summary (sorry, grabbed it from a capture card rather than on the RGBtoHDMI as that avoids having to move cards about!):
Screenshot 2023-11-06 at 09.49.19.png
BBC Master— PiTube 3A+ PiVDU, PicoTube, Pi1MHz, MMFS, ANFS, MultiOS
BBC B — Integra ß, PiTube Zero 2W, Pi1MHz, MMFS, DFS, ADFS, ANFS
Electron — Plus 1 w/ AP6 2V2, AP5, PiTube 3A+, Pi1MHz, PRES AP3+4, Elkeconet or ATI/ABR, ElkSD 64/Plus 1
User avatar
IanB
Posts: 1055
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 »

Mince wrote: Mon Nov 06, 2023 9:51 am
When I set both to Interlaced, I don't get an image that flickers violently between two images but I don't get a good image, either: https://www.youtube.com/watch?v=sw3I1KRsiOc
Setting both Sync and Video type to interlaced is the right setting but the image looks undersampled.
The clock not likely to be 5.7Mhz and you are getting an aliased image.
The clock is likely to be either 14318181 Hz or 7159090 Hz (Either the NTSC crystal frequency on the board or half of it)

To test 7159090: In the create profile menu set the pixel width to 1.25 times the current value then set the clock
To test 14318181, set the pixel width to 2.5 times the current value then set the clock
If both work and look the same then 7159090 is the correct one.

You may find it quicker to adjust the line length until the frequency is auto adjusted to approx the above values
Old_Acorn
Posts: 2
Joined: Thu Aug 17, 2023 8:12 am
Contact:

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

Post by Old_Acorn »

Dear IanB,
I am an old owner of a beautiful Atom Acorn that I bought a few "days ago" in 1982.... In the meantime, helped also by the little ATOM, I became an electronic engineer. I am very intrigued by your 12-bit video interface that transfers the ATOM's video signal to an HDMI screen. Can you confirm me that with this interface it is possible ? Where can I find it already assembled ? or where can I find a DIY kit ? if I can make a contribution, I will be very happy to give it to the whole Acorn community !
=D>
Best
Gino
User avatar
KenLowe
Posts: 4703
Joined: Mon Oct 18, 2004 5:35 pm
Location: UK
Contact:

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

Post by KenLowe »

Old_Acorn wrote: Mon Nov 06, 2023 11:30 am Dear IanB,
I am an old owner of a beautiful Atom Acorn that I bought a few "days ago" in 1982.... In the meantime, helped also by the little ATOM, I became an electronic engineer. I am very intrigued by your 12-bit video interface that transfers the ATOM's video signal to an HDMI screen. Can you confirm me that with this interface it is possible ? Where can I find it already assembled ? or where can I find a DIY kit ? if I can make a contribution, I will be very happy to give it to the whole Acorn community !
=D>
Best
Gino
The original Atom to HDMI interface is detailed here:

viewtopic.php?t=16907

I'm not sure if hoglet is still selling those boards.

If those are no longer available then, as an alternative, you could consider using one of my combined Atom VGA / Tube boards:

viewtopic.php?p=380848#p380848

As the design of the board develops, you'll see that a 2x6 pin header is added, which allows the board to be attached to a standard RGBtoHDMI adaptor:

viewtopic.php?p=385053#p385053.

I've still got a couple of these combined Atom VGA / Tube boards available if you're interested. You'd obviously still need to get hold of a RGBtoHDMI adaptor if you want to go HDMI (instead of VGA), but those are probably easier to get hold of than the Atom to HDMI adaptor.
Jinxter
Posts: 47
Joined: Mon Aug 02, 2021 6:56 am
Location: South Wales
Contact:

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

Post by Jinxter »

Old_Acorn wrote: Mon Nov 06, 2023 11:30 am Dear IanB,
I am an old owner of a beautiful Atom Acorn that I bought a few "days ago" in 1982.... In the meantime, helped also by the little ATOM, I became an electronic engineer. I am very intrigued by your 12-bit video interface that transfers the ATOM's video signal to an HDMI screen. Can you confirm me that with this interface it is possible ? Where can I find it already assembled ? or where can I find a DIY kit ? if I can make a contribution, I will be very happy to give it to the whole Acorn community !
=D>
Best
Gino
Hi,

Boards are available here -
https://www.sellmyretro.com/offer/details/61598

Install instruction via this page -
https://github.com/hoglet67/RGBtoHDMI/wiki/Cables

Welcome aboard.
Jinxter
User avatar
IanB
Posts: 1055
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 »

Old_Acorn wrote: Mon Nov 06, 2023 11:30 am I am an old owner of a beautiful Atom Acorn that I bought a few "days ago" in 1982.... In the meantime, helped also by the little ATOM, I became an electronic engineer. I am very intrigued by your 12-bit video interface that transfers the ATOM's video signal to an HDMI screen. Can you confirm me that with this interface it is possible ? Where can I find it already assembled ? or where can I find a DIY kit ? if I can make a contribution, I will be very happy to give it to the whole Acorn community !
The standard analog RGBtoHDMI will work with the Atom (i.e. the CPLD board plus the analog board as described in the project wiki) although you will need a custom cable to connect the Atom as described in the cables section of the wiki.

Those boards are available ready built on sell my retro as mentioned by Jinxter above. (It's described for BBC/Spectrum/Amstrad as it is supplied with those ready made cables.) If you message the seller (Jinxter) on sell my retro he might be able to make you an Atom cable.

As also mentioned above, Hoglet designed a dedicated RGBtoHDMI Atom board which effectively has the same functionality as the above combination but would not be usable with other systems. That board was not available ready built but I don't know if he still has any blank PCBs available for it.
User avatar
Mince
Posts: 525
Joined: Thu Sep 05, 2019 11:25 pm
Location: Cambridge, UK
Contact:

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

Post by Mince »

IanB wrote: Mon Nov 06, 2023 10:31 am Setting both Sync and Video type to interlaced is the right setting but the image looks undersampled.
The clock not likely to be 5.7Mhz and you are getting an aliased image.
The clock is likely to be either 14318181 Hz or 7159090 Hz (Either the NTSC crystal frequency on the board or half of it)

To test 7159090: In the create profile menu set the pixel width to 1.25 times the current value then set the clock
To test 14318181, set the pixel width to 2.5 times the current value then set the clock
If both work and look the same then 7159090 is the correct one.

You may find it quicker to adjust the line length until the frequency is auto adjusted to approx the above values
I've set the clock to 7159090 and then tried adjusting the line length (I assume this is what you mean by pixel length?) to 455 as it was 364, but I can't get an image that doesn't flicker. 364's the only stable value I can find (although with the same problem as before). I notice that, whilst I'm adjusting the line length, the top line is saying 5727286Hz, so does that mean the clock is being overridden/adjusted to that value and nothing has really changed? I've tried 14318181 and have a similar problem.

Am I right in thinking the h/v offsets and min/max width/height have little to do with this as they really just select the 'interesting' part of the image to display?

The image I'm trying it with at the moment is from a TI-92 so the screen from that is 240x128.
BBC Master— PiTube 3A+ PiVDU, PicoTube, Pi1MHz, MMFS, ANFS, MultiOS
BBC B — Integra ß, PiTube Zero 2W, Pi1MHz, MMFS, DFS, ADFS, ANFS
Electron — Plus 1 w/ AP6 2V2, AP5, PiTube 3A+, Pi1MHz, PRES AP3+4, Elkeconet or ATI/ABR, ElkSD 64/Plus 1
User avatar
Mince
Posts: 525
Joined: Thu Sep 05, 2019 11:25 pm
Location: Cambridge, UK
Contact:

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

Post by Mince »

Looking at the signal on a scope, here's a line from the video where the calculator display has a solid black line running from the left to right edges — the black line measures around 41.6µS:
DS1Z_QuickPrint10.png
Measuring the time between the same point in consecutive frames, I get around 63.8µS:
DS1Z_QuickPrint9.png
... I know the source image is 240 pixels wide from the calculator and 240 / 41.6 * 63.8 = 368, so does that mean the length would be around 368 (which 364 is), or at least it's the correct ratio (as Ian suggested)?

Back in the RGBtoHDMI, setting Min/Max H Width to 240, then adjusting the H Offset, those chop off either a few pixels on the left or the right:
capture2.png
capture3.png
... so I think that roughly corresponds to the pixels in the source image — does that mean the clock and pixel length is correct?
BBC Master— PiTube 3A+ PiVDU, PicoTube, Pi1MHz, MMFS, ANFS, MultiOS
BBC B — Integra ß, PiTube Zero 2W, Pi1MHz, MMFS, DFS, ADFS, ANFS
Electron — Plus 1 w/ AP6 2V2, AP5, PiTube 3A+, Pi1MHz, PRES AP3+4, Elkeconet or ATI/ABR, ElkSD 64/Plus 1
User avatar
IanB
Posts: 1055
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 »

Mince wrote: Tue Nov 07, 2023 9:40 am Looking at the signal on a scope, here's a line from the video where the calculator display has a solid black line running from the left to right edges — the black line measures around 41.6µS:
Looking at those scope traces, there is a colour burst present so is the video output in colour?
A colour subcarrier superimposed on the video will mess up RGBtoHDMI's video capture causing dot crawl.
Can you post a closeup photo or video of some characters when displayed via the monitor's normal composite input

The other possibility is that it is using half pixel character rounding like the BBC's mode 7 which would require sampling at double horizontal resolution with double clock frequency and double line length.

EDIT:
Have you tried adjusting the DAC-A level in the sampling menu. If there is residual subcarrier you might be able to move the level slicing out of its way.
Last edited by IanB on Wed Nov 08, 2023 12:43 am, edited 1 time in total.
User avatar
Mince
Posts: 525
Joined: Thu Sep 05, 2019 11:25 pm
Location: Cambridge, UK
Contact:

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

Post by Mince »

IanB wrote: Tue Nov 07, 2023 5:58 pm Looking at those scope traces, there is a colour burst present so is the video output in colour?
A colour subcarrier superimposed on the video will mess up RGBtoHDMI's video capture causing dot crawl.
Yes and no — the Presenter has a standby screen which has a rather nasty purple background and some white text. It almost seems like they chose those colours to look awful with composite colour fringing!

When connected to a calculator, however, it seems to only output an image in black and white (and all the calculators it works with only have a black and white display). So, aside from the colour burst itself, I don't think there is any colour in the image (whether there's still something there that would upset the RGBtoHDMI is another aspect) but the whites and blacks look fairly clean (at least in the first field — see below), albeit noisy and it looks like some sort of smoothing might be going on:
DS1Z_QuickPrint11.png
When I set the Y Hi level on the RGBtoHDMI correctly, it's easily able to reliably distinguish things cleanly on the first field.
IanB wrote: Tue Nov 07, 2023 5:58 pm Can you post a closeup photo or video of some characters when displayed via the monitor's normal composite input

The other possibility is that it is using half pixel character rounding like the BBC's mode 7 which would require sampling at double horizontal resolution with double clock frequency and double line length.
I was wondering if there was some sort of effect going on but I assume it would have to happen in the Presenter: the 240x128 image is what's on the calculator screen and the sharp version of the images I sent before; if the other field is some sort of rounding, I think it would have to be inferred by the Presenter, using some of smoothing effect based on the image, rather than knowledge of what's actually being displayed, in terms of fonts. I have tried doubling everything, as you suggest, but that doesn't seem to give me anything better.

The image looks fairly clear using the composite input on my Dell LCD monitor and doesn't display any of the effects in the 'dodgy' field you can see in the RGBtoHDMI sampled output. The same goes for my old green screen CRT (which my phone seems to think is cyan).
IMG_8001.jpeg
IMG_7995.jpeg
Another thing that suggests to me the Presenter is doing something odd is the scope trace from near the bottom of the screen: on the source image, there is a single pixel high black line from the left to the right edges of the display, a blank white line and a few exclamation marks. This is clear in the first field of the signal (and there's a blank white line in the signal before this):
DS1Z_QuickPrint12.png
The same line in the second field in the frame looks weird, though:
DS1Z_QuickPrint13.png
... the black line is two scanlines high and the voltage for it seems to be halfway between the white and black levels in the first field, there's also no blank white line between the black line and the start of the exclamation marks, and the exclamation marks voltage level differs on each line.

It looks like the first field is a perfect image from the calculator, then there's some sort of anti-aliasing going on in the second field to smooth things out: zooming in on the LCD photo, it seems like this might be happening, as there looks to be a grey line either side of the black line, and possibly some grey above the 6 and 3, rather than a clean white line, but it might be the monitor doing something aliasing to the LCD pixels, although the monitor does have a 1:1 mode (photo below) that just displays a small image in the middle of the screen and I think I can clearly see the grey bits here (assuming it's not filtering things itself):
IMG_8003.jpeg
If this is the case, is there any way to grab just the first field of the image and discard the second? Or do you think there's something else wrong?
BBC Master— PiTube 3A+ PiVDU, PicoTube, Pi1MHz, MMFS, ANFS, MultiOS
BBC B — Integra ß, PiTube Zero 2W, Pi1MHz, MMFS, DFS, ADFS, ANFS
Electron — Plus 1 w/ AP6 2V2, AP5, PiTube 3A+, Pi1MHz, PRES AP3+4, Elkeconet or ATI/ABR, ElkSD 64/Plus 1
User avatar
IanB
Posts: 1055
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 »

Mince wrote: Tue Nov 07, 2023 11:44 pm It looks like the first field is a perfect image from the calculator, then there's some sort of anti-aliasing going on in the second field to smooth things out: zooming in on the LCD photo, it seems like this might be happening, as there looks to be a grey line either side of the black line, and possibly some grey above the 6 and 3, rather than a clean white line, but it might be the monitor doing something aliasing to the LCD pixels, although the monitor does have a 1:1 mode (photo below) that just displays a small image in the middle of the screen and I think I can clearly see the grey bits here (assuming it's not filtering things itself):
Yes it looks like the second field is a filtered version of the first field and at multiple grey levels probably to reduce flicker and judging by the steps there are 8 levels of grey. It is just about possible to get 8 levels of grey working but it is a little messy.

You could try using just 3 levels to get the half intensity working to see if it makes any difference as follows:
Change the palette to Mono (3 level) or Mono (3 level bright)
set the DAC-A: Yhi to the voltage indicated by the upper red arrow (see below)
set the DAC-B: Ylo to the voltage indicated by the lower red arrow

DS1Z_QuickPrint13.png
Mince wrote: Tue Nov 07, 2023 11:44 pm If this is the case, is there any way to grab just the first field of the image and discard the second? Or do you think there's something else wrong?
I'll have a think about adding a "film" mode that halves the frame rate.
User avatar
Mince
Posts: 525
Joined: Thu Sep 05, 2019 11:25 pm
Location: Cambridge, UK
Contact:

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

Post by Mince »

IanB wrote: Wed Nov 08, 2023 1:08 am Yes it looks like the second field is a filtered version of the first field and at multiple grey levels probably to reduce flicker and judging by the steps there are 8 levels of grey. It is just about possible to get 8 levels of grey working but it is a little messy.

You could try using just 3 levels to get the half intensity working to see if it makes any difference as follows:
Change the palette to Mono (3 level) or Mono (3 level bright)
set the DAC-A: Yhi to the voltage indicated by the upper red arrow (see below)
set the DAC-B: Ylo to the voltage indicated by the lower red arrow
Thanks — this certainly gives me an image that is mostly stable (some of the pixels flicker, I guess as part of the filtering process), but I think the output of the filtering looks much better on a CRT!
capture6.png
On a user interface note, when I was adjusting the palette mode, it was a bit awkward as the background of the screen was white and the text showing the current selection was also white. When using this (or other options on that menu), is there a way the current mode be printed with a dark background to make the text stand out?
BBC Master— PiTube 3A+ PiVDU, PicoTube, Pi1MHz, MMFS, ANFS, MultiOS
BBC B — Integra ß, PiTube Zero 2W, Pi1MHz, MMFS, DFS, ADFS, ANFS
Electron — Plus 1 w/ AP6 2V2, AP5, PiTube 3A+, Pi1MHz, PRES AP3+4, Elkeconet or ATI/ABR, ElkSD 64/Plus 1
User avatar
IanB
Posts: 1055
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 »

Mince wrote: Wed Nov 08, 2023 9:42 am I think the output of the filtering looks much better on a CRT!
That's because it's not being captured properly. I think to capture it fully would require sampling at 14.318 Mhz and multi level capture. It looks like there might be more than 8 level so it would be difficult to perfectly capture that.
Mince wrote: Wed Nov 08, 2023 9:42 am On a user interface note, when I was adjusting the palette mode, it was a bit awkward as the background of the screen was white and the text showing the current selection was also white. When using this (or other options on that menu), is there a way the current mode be printed with a dark background to make the text stand out?
When you start adjusting any setting in the palette menu, the background video un-dims so that when adjusting things like brightness / contrast saturation etc you can see exactly what effect your change is having on the output. If the background is white then this will make the menus difficult to read. This probably doesn't need to happen for all settings, only ones that have a direct effect on the image like brightness so I will look at restricting the un-dimming just to those.

You could try increasing the capture resolution and number of levels as follows:

To Increase resolution:
In the "Create Custom Profile" menu:
Change Pixel Width to 600
Change Line length to 910

To increase levels:
Change the palette to Mono (4 level)
In the Sampling menu:
Change "Sample Mode" to 6 Bits (4 level)
Change Y Hi to slightly higher than now
Change Y Lo to Slightly lower than now
Change Y Mid to half way between. Note the Y Lo setting gets renamed to Y Mid when you change to 6 Bits (4 level).

You will probably need to tweak the above levels for minimum noise in combination with the sampling phase.
Note that Y Hi > Y Mid > Y Lo
e.g If you set Y Lo > Y Mid etc you will get unpredictable effects

However I think the best option for a 100% clean image is going to be the frame drop.
User avatar
IanB
Posts: 1055
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 »

Mince wrote: Mon Nov 06, 2023 12:30 am It's almost like I need to select just one field of the interlaced pair.
I have added a "quick and dirty" Film Mode preference setting which leverages an existing mechanism for coping with 4K @25/30Hz displays.

There is currently no way of selecting between odd or even fields for display when the source is interlaced but I think it should choose the same as the OSD which is what you want anyway and nearly all sources are progressive so it doesn't matter for them.

It will be in the next Alpha release
User avatar
Mince
Posts: 525
Joined: Thu Sep 05, 2019 11:25 pm
Location: Cambridge, UK
Contact:

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

Post by Mince »

Thanks for that — in the meantime, I've doubled the line length and changed the pixel aspect ratio, as well as done some more fiddling with the DAC values and changed the palette to "3 level bright" and have an image which is almost free from flickering (I don't seem to be able to eliminate it completely). But I have ended up with something that looks very similar to the CRT image and, I think, shows that the filtering on the Presenter is doing a fairly good job, after all and probably whether you use this or a "pure" version is a matter of taste:
capture1.png
capture2.png
I've made a profile for this which I'll send over but, before I do, there are several different calculators that work with this which I have some of. Each of these has a different screen size so will probably need different profiles. Do you think they should be manually-selected subprofiles or separate profiles? I haven't tried them yet but I assume that, if the basic framerate is the same, the subprofiles won'y be selected automatically (they are designed to work with PAL and NTSC TVs, after all) — I think they'll all just vary in terms of the active area to crop.

Anyway, I'll see how I get on! Thanks for your help!
BBC Master— PiTube 3A+ PiVDU, PicoTube, Pi1MHz, MMFS, ANFS, MultiOS
BBC B — Integra ß, PiTube Zero 2W, Pi1MHz, MMFS, DFS, ADFS, ANFS
Electron — Plus 1 w/ AP6 2V2, AP5, PiTube 3A+, Pi1MHz, PRES AP3+4, Elkeconet or ATI/ABR, ElkSD 64/Plus 1
InsertDiskTwo
Posts: 1
Joined: Fri Nov 10, 2023 2:50 pm
Contact:

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

Post by InsertDiskTwo »

Hi there,

I just got my RGB2HDMI for my C64 and everything is working perfectly, except scanlines. Whatever I do I do not get the effect. I tried enabling it from the menu, long holding SW1 etc. In the menu it shows they are enabled, but nothing, just very sharp pixels :)

Is there something obvious I am missing?

Thanks :D
User avatar
IanB
Posts: 1055
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 »

I've released beta 61 of RGBtoHDMI here:

https://github.com/IanSB/RGBtoHDMI/releases

Major new features:

A "Create Custom Profile" menu
This makes it much easier to create profiles for unsupported systems
There is built in help in the info menu and also in the menu itself
(This will eventually be expanded upon in the wiki)

Auto detect if the monitor supports HDMI protocols or DVI protocols and switch automatically.
This was previously a manual only setting in the main menu which defaulted to DVI for all monitors
This usually worked but would produce wrong colours on some capture devices and 4K monitors which didn't support the old DVI protocol.
Also if a HDMI audio embedder was used, that would normally only work in HDMI mode.
The auto detection can be disabled and a manual selection made in the settings menu
Please report any issues such as blank screens if your monitor worked with previous versions.

Add 4K @ 50/60Hz support for Pi 4 only.
This will be auto detected if a Pi 4 is plugged into a 4K monitor
Other Pi models only support 4K @25/30Hz so they will default to 1080p @50/60Hz when plugged into a 4K monitor but you can still manually select the 4K @25/30Hz resolution.

Other changes:
Fix scalines not working on c64.
Add support for PAL artifacts on c0pperdragon c64 YUV adapter.
Add variable level scanline support to Atari 800 lumacode.
Fix flashing screen issues with Atari 2600.
Add frame drop mode for 25/30Hz motion.
Add Ti presenter profiles (NTSC only).
Support Atari 800 hybrid configurations (swapped PAL/NTSC Antics etc)
Fix dragon profile
Various minor bug fixes and cosmetic improvements.

InsertDiskTwo wrote: Fri Nov 10, 2023 2:56 pm I just got my RGB2HDMI for my C64 and everything is working perfectly, except scanlines.
That is fixed in the new beta above
Post Reply

Return to “8-bit acorn hardware”