RGB to HDMI using a Pi Zero and a small CPLD

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
Budgie
Posts: 91
Joined: Mon Nov 02, 2015 9:14 pm
Location: Manchester, UK
Contact:

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

Post by Budgie » Sat Jul 21, 2018 8:46 pm

Okay so here's mine. Works flawlessly so far.

The first 4 images are from the BBC micro. The last 2 are from an issue 6 Electron. The TV resolution is 1920 x 1080 50Hz

Just realised I didn't set Elk=1 in cmdline but it seems to be fine ?
Attachments
1.png
2.png
3.png
4.png
5.png
6.png
Last edited by Budgie on Sat Jul 21, 2018 8:55 pm, edited 1 time in total.

User avatar
Elminster
Posts: 3978
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Sat Jul 21, 2018 8:52 pm

davidb wrote:
Sat Jul 21, 2018 8:29 pm
Elminster wrote:
Sat Jul 21, 2018 8:00 pm
Edit3: Playing in colour is a novelty though. Played Boxer, the last game on the game challenge, seems pretty good. Anyone remember if they is anything taxing I might have choosen on the MGC, other wise I ma going to need to load up DC or GoSDC with stuff.
Depends what you have on the MGC. Firetrack, perhaps?
Okay not played Firetrack before but the graphics are stunning.

As Iused to use an Electron on a 10inch manual tune black and white TV. And I have been using it modern day on composite (i.e. black and white) I cant ever recall having a better picture on an Electron I own.

So for Electron Issue 4 on an unbranded 12inch ebay HDMI monitor, it does the business.
Attachments
IMG_4080.jpg
Last edited by Elminster on Sat Jul 21, 2018 8:55 pm, edited 1 time in total.

User avatar
trixster
Posts: 952
Joined: Wed May 06, 2015 11:45 am
Location: York
Contact:

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

Post by trixster » Sat Jul 21, 2018 9:24 pm

Having 50hz is brilliant. Coming from my gbs8200 which only outputs 60hz, the smooth 50hz scrolling on my dell 2001fp is fantastic :)
A3020 | A3000 | A420/1 | BBC B | Master Turbo | ZX48K | NeoGeo
Atom | Amiga A4000 | A3000 | A1200 | A500 | PC Engine | Enterprise
Falcon | Saturn | PS1 | SNES | CPC6128 | C64 | 3DO | MD | Jaguar | X68000 | CD32

User avatar
hoglet
Posts: 8680
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 Jul 21, 2018 9:54 pm

Budgie wrote:
Sat Jul 21, 2018 8:46 pm
The first 4 images are from the BBC micro. The last 2 are from an issue 6 Electron. The TV resolution is 1920 x 1080 50Hz
The third image, M0TEST, looks like the monitor is also doing some scaling, as the vertical lines are uneven.

What's the TV/Monitor model?

Might be worth seeing if there are settings like:
a) Overscan: off, or
b) Aspect ratio: "1:1" or "Original" or "Just Scan"

Dave

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

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

Post by tricky » Sun Jul 22, 2018 7:28 am

Here is a link to the video of what the fuel bar corruption looks like on the NuLA beeb with mux off.
https://www.dropbox.com/s/66v26f14tinrg ... n.avi?dl=0
With the mode 0 test screen, in the left hand edge line, the corruption can be seen moving down the screen several times a second.
It looks to me like two clocks slightly out of sync, but as I say, there are no issues with mux on, other than might be fixed by a cap swap.

As I say though, I'm not planning on using it/them on a NuLA'd beeb, so I will swap to another beeb today.

PS Just tried another beeb, works fine, mux seems to make no difference and today the Panasonic isn't stretching the picture!
It has a TWO MEG card in it which seems to conflict with the user port, so I might need to set up the GOTEK too.
Last edited by tricky on Sun Jul 22, 2018 8:10 am, edited 1 time in total.

User avatar
hoglet
Posts: 8680
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 Jul 22, 2018 8:32 am

tricky wrote:
Sun Jul 22, 2018 7:28 am
Here is a link to the video of what the fuel bar corruption looks like on the NuLA beeb with mux off.
https://www.dropbox.com/s/66v26f14tinrg ... n.avi?dl=0
With the mode 0 test screen, in the left hand edge line, the corruption can be seen moving down the screen several times a second.
It looks to me like two clocks slightly out of sync, but as I say, there are no issues with mux on, other than might be fixed by a cap swap.
That does just look like the video level being a bit low. The Mux=On setting does is to take the RGB signals after they have been fed through the 74LS08, which has a slightly lower switching threshold than the CPLD. It's also useful to do this on older Elks.

Dave

User avatar
BigEd
Posts: 2691
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 Jul 22, 2018 8:30 pm

hoglet wrote:
Fri Jul 20, 2018 10:02 am
To implement a programmable palette we really just need to add the communications stuff
I had some thoughts about in-band signalling:
- put data in the last line of the frame
- add a checksum at the end (perhaps very simple XOR)
- the Pi should do nothing special if the last line has a bad checksum
- the Pi should rewrite a line with a good checksum as all-black for display purposes
- just possibly the CPLD could compute and validate the checksum, if there's room for one more bit from the CPLD to the Pi?
- and finally, of course, if the checksum is good the Pi should decode the line as a command

User avatar
hoglet
Posts: 8680
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 Jul 22, 2018 9:07 pm

Lots of good ideas there Ed - I do particularly like the idea of in-band signalling in the video data.
BigEd wrote:
Sun Jul 22, 2018 8:30 pm
- just possibly the CPLD could compute and validate the checksum, if there's room for one more bit from the CPLD to the Pi?
I don't think this will be possible, as it would require several additional registers.

A couple of minor complexities:

1. Depending on the screen mode, Beeb pixels will map to 1, 2, or 4 pixels. So probably we should design the encoding around Mode 2/5 pixels, which gives us 160 bits.

2. We can't guarantee the Beeb pixels ends up at an exact offset in the 672 pixel frame buffer - it varies depending on screen mode, and also on the sampling offset. So we probably need some kind of start bit, or sync byte.

All quite doable though.

If we restrict the colour palette to 4096 colours, then the full palette is 8 x 12 = 96 bits, so that fits nicely.

Dave

User avatar
hoglet
Posts: 8680
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 Jul 22, 2018 9:09 pm

In other news, I've finally managed to adjust the frequency of the PLLH (which us user for the HDMI clock) by writing to the clock manager registers:
https://github.com/hoglet67/RGBtoHDMI/b ... dmi.c#L319

I can also put a marker on the screen at the point that the HDMI VSync is detected, which allows you to observe the phase of the HDMI VSync wrt the Beeb's VSync. After calculating for the clock error and updaing PLLH, this marker is very stable.

It's interesting to deliberately introduce a known clock error, so the VSync phase shifts continuously. This has demonstrated the the double buffering scheme I have currently implemented is not sufficient to avoid tearing. So I need to upgrade this to triple buffering. Done correctly, it seems that triple buffering not only eliminates tearing, it actually reduces lag (compared to double buffering). At least, according to this article.

So I'm going to have a stab at that tomorrow.

Dave
Last edited by hoglet on Sun Jul 22, 2018 9:13 pm, edited 1 time in total.

User avatar
hoglet
Posts: 8680
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 » Mon Jul 23, 2018 5:29 pm

I've been working on the dev branch today and have added three new items to the feature menu:

1. An "HDMI Clock" setting to compensate for the clock offset between the Beeb and the Pi, and also compensate for games that run with interlace off (i.e. 50.08Hz rather than 50Hz).

2. A "VSync" setting that is a debugging aid to let you see the position of the Pi's HDMI VSync compared to the Beeb's VSync. Useful to check the previous setting is correct. Currently this is only visible in Modes 0..6.

3. A "Num Buffers" setting that changes the buffering strategy used in Modes 0..6:
- single buffering (minimal latency, but lots of potential for tearing and currently messes up the OSD)
- double buffering (typically an extra 20ms latency, but greatly reduces tearing)
- triple buffering (eliminates all tearing)
- quadruple buffering (overkill, never really needed)

More buffers doesn't necessarily mean more latency, it just means those buffers are available if needed. In all cases the Pi should flip to the most recently written buffer on HDMI VSync. So in practice there is little difference in latency between 2, 3 and 4 buffers.

This is quite a big change, so I need to do more testing tomorrow before I merge back to master.

But if anyone is dead keen to try this, there is a test build available here:
https://github.com/hoglet67/RGBtoHDMI/r ... 23_156dec8

I've been using Tricky's scramble as a test program, and then deliberately setting "HDMI Clock" to 623 or 625 to induce VSync slip. The correct behaviour is to drop or replicate a frame as needed, rather than tear. When "HDMI Clock" is set to 624 the sync rates match very closely indeed.

Dave
Last edited by hoglet on Mon Jul 23, 2018 5:34 pm, edited 3 times in total.

User avatar
Elminster
Posts: 3978
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Mon Jul 23, 2018 6:12 pm

i am away from my machine at the moment, but my conclusion was the Electron was perfect. Will see what it does on the Nula’s Master next, then swap to a Nula’s free Beeb b issue 7 or a b+

Edit: is the videonula the only addon expected to break things? I might have asked this already.
Last edited by Elminster on Mon Jul 23, 2018 6:12 pm, edited 1 time in total.

User avatar
hoglet
Posts: 8680
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 » Mon Jul 23, 2018 6:19 pm

Elminster wrote:
Mon Jul 23, 2018 6:12 pm
Edit: is the videonula the only addon expected to break things? I might have asked this already.
Yup, definitely not designed to deal with the "non-digital" RGB values you get using the palette.

It should work if you don't use the palette, and set Mux=On in the OSD (or mux=1 in cmdline.txt)

Dave

User avatar
myelin
Posts: 751
Joined: Tue Apr 26, 2016 9:17 pm
Location: Mountain View, CA, USA
Contact:

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

Post by myelin » Thu Aug 02, 2018 3:55 am

Finally set mine up, and it works very nicely with my Master 128. Thanks Dave! Now I can run three computers at VCF West rather than two :)
SW/EE from New Zealand, now in Mountain View, CA, making BBC/Electron hardware projects for fun.
Most interesting: Arcflash, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

sjo03
Posts: 5
Joined: Thu Nov 17, 2011 5:05 pm
Contact:

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

Post by sjo03 » Fri Aug 03, 2018 6:54 pm

I was late to see this topic. If another batch would be made - would definitely be interested in getting one or two.

User avatar
marcusjambler
Posts: 693
Joined: Mon May 22, 2017 11:20 am
Location: Bradford
Contact:

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

Post by marcusjambler » Thu Aug 09, 2018 9:06 am

Also registering interest in one built up board

Marcus

User avatar
hoglet
Posts: 8680
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 » Thu Aug 09, 2018 9:43 am

Hi Guys,

Thanks for the interest, but I just want to make it clear that I'm not planning to produce any more built-up boards, at least not in the near future. It took me the best part of a week, working 8-10 hours a day, to produce the previous 10, when you include all the time for component ordering, building, cleaning, programming, testing, packaging, shipping, etc. The final accounts say I made a profit of £13.61.

All the design files are on github (including the gerber files for the PCB) and the design is open source so you (or anyone else) are welcome to order the parts and make these up yourself. If you are reasonable at through-hole soldering, but have yet to do any surface mount assembly, this is a good board to start on.

regards

Dave

User avatar
daveejhitchins
Posts: 5194
Joined: Wed Jun 13, 2012 5:23 pm
Location: Newton Aycliffe, County Durham
Contact:

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

Post by daveejhitchins » Fri Aug 10, 2018 7:18 am

hoglet wrote:
Thu Aug 09, 2018 9:43 am
The final accounts say I made a profit of £13.61
Wow! . . . That's £1.36/unit - I've just got to get a viewing of your business plan, Dave - it seems to be far better than mine =D>

Dave H :D
Last edited by daveejhitchins on Fri Aug 10, 2018 7:19 am, edited 1 time in total.
Parts: UM6502CE, GAL22V10D, GAL16V8D, AS6C62256A, TC514400AZ, WD1772, R6522, TMS27C512, AT28C256
Products: ARA II, ARA III, ABR, ATI, AP6, MGC, AP5 . . .
For a price list, contact me at: Retro Hardware AT dave ej hitchins DOT plus DOT com

User avatar
trixster
Posts: 952
Joined: Wed May 06, 2015 11:45 am
Location: York
Contact:

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

Post by trixster » Fri Aug 10, 2018 7:27 am

Swapped the pi zero W out for a normal v1.3 pi zero, still works great!
A3020 | A3000 | A420/1 | BBC B | Master Turbo | ZX48K | NeoGeo
Atom | Amiga A4000 | A3000 | A1200 | A500 | PC Engine | Enterprise
Falcon | Saturn | PS1 | SNES | CPC6128 | C64 | 3DO | MD | Jaguar | X68000 | CD32

User avatar
Elminster
Posts: 3978
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Mon Aug 27, 2018 10:39 am

Random people thought, could he debug output from hdmi board give any useful information for debugging video issues? Not specifically my issue but in general,or perhaps I should say what sort of video issues could you debut with this?

User avatar
hoglet
Posts: 8680
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 » Mon Aug 27, 2018 11:25 am

Elminster wrote:
Mon Aug 27, 2018 10:39 am
Random people thought, could he debug output from hdmi board give any useful information for debugging video issues? Not specifically my issue but in general,or perhaps I should say what sort of video issues could you debut with this?
About all it could tell you is exactly what the VSync period is, and whether the video is interlaced or not.

I think you can tell that easily with a scope as well.

Dave

User avatar
Elminster
Posts: 3978
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Mon Aug 27, 2018 11:43 am

hoglet wrote:
Mon Aug 27, 2018 11:25 am
Elminster wrote:
Mon Aug 27, 2018 10:39 am
Random people thought, could he debug output from hdmi board give any useful information for debugging video issues? Not specifically my issue but in general,or perhaps I should say what sort of video issues could you debut with this?
About all it could tell you is exactly what the VSync period is, and whether the video is interlaced or not.

I think you can tell that easily with a scope as well.

Dave
Ah okay just a thought. Although could be useful for someone without a scope I guess.

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

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

Post by tricky » Mon Aug 27, 2018 4:48 pm

If you have a scope capable of capturing and syncing to the signal!
I couldn't capture my vsync issue on my cheap USB scope if you remember.
Sometimes, it would be helpful to get a log of scan line counts between vsyncs, especially if it isn't 312/313.

User avatar
Elminster
Posts: 3978
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Wed Aug 29, 2018 4:14 pm

As part of my testing the fixed video on my Beeb issu4 I have tested the following.

- Kix
- Frenzy
- Tricky Space Invaders
- Tricky Frogger
- Tricky AstroBlast
- Bad Apple (Mode 7)

Only thing I have noticed is on space invaders the backgroud shakes a little. I guess everything is shifting 1 pixel back and forth. Not qite sure how to describe it. Not sure a video would pick it up.
Last edited by Elminster on Wed Aug 29, 2018 4:18 pm, edited 1 time in total.

User avatar
hoglet
Posts: 8680
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 » Wed Aug 29, 2018 4:17 pm

Elminster wrote:
Wed Aug 29, 2018 4:14 pm
Only thing I have noticed is on space invaders the backgroud shakes a little. I guess everything is shifting 1 pixel back and forth. Not qite sure how to describe it. Not sure a video would pick it up.
Do you have a link to the .ssd file? I'll give it a try as well.

User avatar
Elminster
Posts: 3978
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Wed Aug 29, 2018 4:18 pm

hoglet wrote:
Wed Aug 29, 2018 4:17 pm
Elminster wrote:
Wed Aug 29, 2018 4:14 pm
Only thing I have noticed is on space invaders the backgroud shakes a little. I guess everything is shifting 1 pixel back and forth. Not qite sure how to describe it. Not sure a video would pick it up.
Do you have a link to the .ssd file? I'll give it a try as well.
viewtopic.php?f=57&t=12474&p=167377&hil ... rs#p167377

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

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

Post by tricky » Wed Aug 29, 2018 8:24 pm

hoglet wrote:
Wed Aug 29, 2018 4:17 pm
Elminster wrote:
Wed Aug 29, 2018 4:14 pm
Only thing I have noticed is on space invaders the backgroud shakes a little. I guess everything is shifting 1 pixel back and forth. Not qite sure how to describe it. Not sure a video would pick it up.
Do you have a link to the .ssd file? I'll give it a try as well.
Most of my stuff is on bbcmicro.co.uk, search for broadhurst.

User avatar
Elminster
Posts: 3978
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Wed Aug 29, 2018 8:41 pm

i like frogger, it was really clean and crisp on HDMI, could not spot any artifacts. And plays well to boot.

alienkidmj12
Posts: 50
Joined: Sat Aug 26, 2017 8:30 am
Contact:

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

Post by alienkidmj12 » Fri Sep 14, 2018 10:16 pm

are you able to give me some advice to those less fortunate to have a complete one and a bit unsure how to proceed with putting these together ?

what do we do with the files for this, what do i we load gerber files into ?

what programmers do we need if any ?

thanks

dave
hoglet wrote:
Wed Aug 29, 2018 4:17 pm
Elminster wrote:
Wed Aug 29, 2018 4:14 pm
Only thing I have noticed is on space invaders the backgroud shakes a little. I guess everything is shifting 1 pixel back and forth. Not qite sure how to describe it. Not sure a video would pick it up.
Do you have a link to the .ssd file? I'll give it a try as well.

bprosman
Posts: 364
Joined: Sun Mar 29, 2015 10:27 pm
Contact:

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

Post by bprosman » Fri Sep 14, 2018 10:43 pm

Maybe a weird/dumb question but can this also be used to create an Atom "color board" ?

Kind regards, Bram
Last edited by bprosman on Fri Sep 14, 2018 10:43 pm, edited 1 time in total.

User avatar
Elminster
Posts: 3978
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Fri Sep 14, 2018 10:53 pm

bprosman wrote:
Fri Sep 14, 2018 10:43 pm
Maybe a weird/dumb question but can this also be used to create an Atom "color board" ?

Kind regards, Bram
Similar question asked/answer here, does that answer your question?

viewtopic.php?f=3&t=14430&p=209125&hilit=Atom#p209125

Post Reply