RGB to HDMI using a Pi Zero and a small CPLD

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
User avatar
hoglet
Posts: 7241
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 Jun 13, 2018 4:50 pm

tricky wrote:
Wed Jun 13, 2018 4:31 pm
Having the option is good and we might be able to sneak a feature or two in when Hoglet isn't looking.
One "feature" I was thinking about was a poor-mans Video NuLA, because the Pi's palette allows each of the eight colours to be redefined.

I've also got a simple OSD-Menu system working, so that does make it easier to access this kind of feature.

Now, if we can only get the GPU working as well!

Dave

User avatar
Elminster
Posts: 2403
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 Jun 13, 2018 5:11 pm

john_A3000 wrote:
Wed Jun 13, 2018 4:00 pm
HDMI will never look as good as a CRT. These machines were not designed with HD in mind, so will look awful when stretched on a big HDTV.
Not used a CRT for 15 years myself. Don’t have luxury of space that others have. I think I meantioned above my beebs are generally not even connected to a monitor but go through series of converters, beamed across tcp/ip and appear on a Mac. So connected directly to a pi will be an improvement for me.

Budgie
Posts: 78
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 » Wed Jun 13, 2018 5:45 pm

I think its great just to have the option. Without this your into expensive bulky alternatives !

john_A3000
Posts: 10
Joined: Tue Jun 12, 2018 4:24 pm

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

Post by john_A3000 » Wed Jun 13, 2018 6:12 pm

Expensive ? Hardly.
Most of my CRT TVs and monitors were less than £20 each.
Acorn BBC Model B, 32k, Turbo MMC, 9-Pin Joystick adapter.
Acorn BBC Master 128k, IDE + 2Gb CF Card, Multi-OS selector.
Acorn Archimedes A3000, 25Mhz Arm3 upgrade, 4Mb, IDE + 2Gb SDCard, PS/2 Mouse.
Acorn AKF30 RGB Monitor.

User avatar
Elminster
Posts: 2403
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 Jun 15, 2018 10:02 am

john_A3000 wrote:
Wed Jun 13, 2018 4:00 pm
HDMI will never look as good as a CRT. These machines were not designed with HD in mind, so will look awful when stretched on a big HDTV.
To late to add optional scanline generator features I wonder. e.g.

https://www.arananet.net/pedidos/produc ... generator/

User avatar
BigEd
Posts: 1891
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 » Fri Jun 15, 2018 10:34 am

Never too late with a software-based solution! Which is not to say that anything is possible, because there are timing constraints with updating the Pi's framebuffer.

User avatar
hoglet
Posts: 7241
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 Jun 15, 2018 3:27 pm

Elminster wrote:
Fri Jun 15, 2018 10:02 am
To late to add optional scanline generator features I wonder. e.g.
Not all all....

All you need to do is comment out this line:
https://github.com/hoglet67/RGBtoHDMI/b ... _fb.S#L273

I'm sure we could make it a UI configurable option.

I'll add this to the TODO list, which is looking like:
- continue to tweak auto calibration code
- add "feature" OSD menu
- add palette changing to "feature" menu
- add scan line enabling to "feature" menu
- also make all the features (and the default samping points) configurable through the cmdline.txt file on the SD card

Also, I just had this email from Seeed:
seeed1.PNG
My first professional PCB!

Dave

User avatar
Elminster
Posts: 2403
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 Jun 15, 2018 4:25 pm

Great. Now about the feature to direct beam the video feed into my brain ......

User avatar
Elminster
Posts: 2403
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 » Tue Jun 19, 2018 10:22 am

Added to hardware list, that means you have no choice but to make it work now. No pressure.

User avatar
hoglet
Posts: 7241
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 Jun 21, 2018 1:06 pm

I've been doing a bit more work on the firmware this morning and now have the following implemented:
- add "feature" menu to the OSD
- add palette changing to feature menu (together with a selection of palettes, including a 3-bit monochrome scale)
- add scan line enabling to feature menu (mode 0..6 only)
- add mux control to feature menu (mainly used for older Elks)
- add debug control to feature menu
- make all the features (and the default sampling points) configurable through the cmdline.txt file on the SD card

I do hope the boards work when they come back...

Dave

User avatar
hoglet
Posts: 7241
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 » Tue Jun 26, 2018 7:15 pm

The boards are now on their way. I'm expecting they will take ~8 days to get here.
Last edited by hoglet on Fri Jul 06, 2018 3:26 pm, edited 1 time in total.

User avatar
hoglet
Posts: 7241
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 Jul 06, 2018 3:27 pm

Well, a bit more than 8 days, but the boards have arrived in the UK now.

It should take Royal Mail 2 working days to deliver them, so hopefully early next week.

User avatar
hoglet
Posts: 7241
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 07, 2018 11:12 am

hoglet wrote:
Fri Jul 06, 2018 3:27 pm
It should take Royal Mail 2 working days to deliver them, so hopefully early next week.
Or even today!
IMG_1383.JPG
Lets get building......

:D :D :D :D :D

User avatar
hoglet
Posts: 7241
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 07, 2018 12:06 pm

Getting there, just a cable to make up now....
IMG_1386.JPG
IMG_1387.JPG
IMG_1388.JPG
IMG_1389.JPG
[-o< [-o< [-o< [-o< [-o<

User avatar
hoglet
Posts: 7241
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 07, 2018 1:13 pm

Cable made:
IMG_1391.JPG
IMG_1392.JPG
And lo and behold....
P1030968.JPG
(this was on an Issue 4 Elk)

Dave

User avatar
tricky
Posts: 2554
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 Jul 07, 2018 1:46 pm

That's great news. =D>
Has anyone volunteered to build them?
They don't look too difficult, but I recon I would get about 50/50 working :oops:

User avatar
hoglet
Posts: 7241
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 07, 2018 1:55 pm

tricky wrote:
Sat Jul 07, 2018 1:46 pm
Has anyone volunteered to build them?
Not yet... The first board took me about 90 minutes (I'm slow at SMT stuff).

There's still a bit more work to do, on both the software and possibly the hardware:
- On the Elk the output is error free in all modes
- On the Master the output is error free in all modes
- On the certain Beebs I'm still seeing some sampling issues that the calibration doesn't eliminate, resulting in a small number of twittering pixels

This is the same level of fidelity that I saw with the prototype. I was hoping the shorter connections and better grounding would have sorted this, but it hasn't, which is a shame.

Anyway, it's a good opportunity to play with the new super-fast scope!

Dave

User avatar
Elminster
Posts: 2403
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 07, 2018 2:34 pm

Happy to build one for myself, but doing SMDs for more than a couple of boards would take me forever.

User avatar
danielj
Posts: 6284
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

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

Post by danielj » Sat Jul 07, 2018 2:51 pm

=D> Great work Dave - I'm happy to build a couple. Anything but beebscsis :D

d.

User avatar
BigEd
Posts: 1891
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 Jul 07, 2018 3:44 pm

Very neat indeed!

User avatar
hoglet
Posts: 7241
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 07, 2018 5:17 pm

Thanks to the new scope I'm getting to the bottom of why on certain model Bs there is a problem with twittering pixels that can't be eliminated with the calibration.

One of the problem letters is the upper-case K:

Code: Select all

##......##
##.....###
##....###.
##...###..
##..###...
##.###....    <<<<<<<
#####.....
#####.....
##.###....    <<<<<<<
##..###...
##...###..
##....###.
##.....###
##......##
There are two problem lines, marked above, where on some Beebs there is a twittering pixel.

And this scope shot shows why:
IMG_1397.JPG
It seems there is insufficient time for the "off" pixel right in the corner of the K to properly reach the logic zero threshold. It's only going down as low as 1.2V. Both of my Model B's exhibit this problem to some extent. On the worst one, the pixel is actually always filled in. On the other one it twitters.

The root cause of this is the 6MHz clock being very asymmetric. The only answer I think here is to be able to shift the sampling threshold up to something like 2V. Which would mean lots more hardware (specifically a DAC and three very fast comparators). And even then there's precious little time to catch the pixel in it's off state.

Dave
Last edited by hoglet on Sat Jul 07, 2018 5:18 pm, edited 1 time in total.

dp11
Posts: 802
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

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

Post by dp11 » Sat Jul 07, 2018 5:24 pm

You could move the sampling threshold voltage with two resistors. For a dac you can a pwm and and rc filter.

User avatar
hoglet
Posts: 7241
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 07, 2018 5:57 pm

dp11 wrote:
Sat Jul 07, 2018 5:24 pm
You could move the sampling threshold voltage with two resistors.
Interesting... How exactly?

dp11
Posts: 802
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

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

Post by dp11 » Sat Jul 07, 2018 6:26 pm

Simply take the video input and feed it through a potential divider. E. G. Video input via R1 to Cpld input. At the junction of of R1 and the cpld connect R2. The other end of R2 could just go to ground but could goto a dac.

User avatar
tricky
Posts: 2554
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 Jul 07, 2018 6:41 pm

I don't want to send you off down a rabbit hole, but, do you think this a design problem or maybe some tired beeb components?
If it is a simple short answer, why can't you just use some pull-up/downs - maybe some optional pots?

User avatar
myelin
Posts: 420
Joined: Tue Apr 26, 2016 9:17 pm
Location: San Francisco, CA, USA
Contact:

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

Post by myelin » Sun Jul 08, 2018 6:56 am

hoglet wrote:
Sat Jul 07, 2018 1:13 pm
And lo and behold....
P1030968.JPG
(this was on an Issue 4 Elk)
Nice work! Looking forward to building up a few of these so I can have more than one machine with a display at once :)
SW/EE from New Zealand, now in San Francisco, making BBC/Electron hardware projects for fun.
Most popular: fast serial port, FX2+PiTubeDirect Tube/Cartridge adapter, USB cart interface.

User avatar
hoglet
Posts: 7241
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 08, 2018 11:39 am

I think I now have a fix for the Mode 7 video problems with the Model B.

For reference, here's the 6MHz clock circuit:
6M_clock_beeb.png
The filter formed by R119/C48 has quite a detrimental effect on the 6MHz clock, because rising edges experience far more delay through the filter than falling edges. So this changes the mark space ratio.

The fix is simply to remove C48 (e.g. by desoldering one side, or just snipping the lead).

According to the service manual, the purpose of R119/C48 is:
Glitches on this output are removed by R119 and C48 to produce the 6 MHz clock signal at Pin 8 of IC37.
I don't see any evidence of glitches after making this change.

Here's the before scope trace:
IMG_1404.JPG
The top trace is the blue output in a Mode 7 screen showing a vertical column of "/" characters. The bottom trace is the 6MHz clock into the SAA5050.

Notice how the mark-space ratio of the 6MHz clock is very uneven, with the high pulses being shorter than the low pulses. As both edge of the clock are used, this results in very uneven pixel spacing.

Now with C48 removed.
IMG_1405.JPG
You can see how the falling edge of the clock has been moved out, giving a much more even mark-space ratio.

If you look at the debug log from RGB to HDMI during calibration, you can see this makes a massive difference to the error counts:

Before:

Code: Select all

INFO: Calibrating mode 7
INFO: offset = 0: metric = 25294
INFO: offset = 1: metric =   516
INFO: offset = 2: metric =  7059
INFO: offset = 3: metric =  3355
INFO: offset = 4: metric =  2187
INFO: offset = 5: metric = 51872
INFO: offset = 6: metric = 30841
INFO: offset = 7: metric = 22715
After:

Code: Select all

INFO: Calibrating mode 7
INFO: offset = 0: metric =  2257
INFO: offset = 1: metric = 41182
INFO: offset = 2: metric = 30612
INFO: offset = 3: metric = 16186
INFO: offset = 4: metric = 24122
INFO: offset = 5: metric =     0
INFO: offset = 6: metric =     0
INFO: offset = 7: metric =     0
There are now three sample points that are error free, which is the same as I typically see on the Master.

The resulting image appears perfect.

Edit: I'm also finding (maybe not surprisingly) that removing C48 make a bit improvement to the image when using the SCART input of my LG LCD TV.

Dave
Last edited by hoglet on Sun Jul 08, 2018 11:46 am, edited 4 times in total.

dp11
Posts: 802
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

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

Post by dp11 » Sun Jul 08, 2018 11:46 am

If glitches do occur then a diode across R119 will speed up the rising edge. If the ls86 is socketed then replacing it with a 74hc86 could also work.

User avatar
tricky
Posts: 2554
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 08, 2018 12:03 pm

Great news Hoglet, this was the sort of answer I was expecting/hoping from you :)
Off to see what difference it makes in my CRT.

User avatar
hoglet
Posts: 7241
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 08, 2018 12:14 pm

dp11 wrote:
Sun Jul 08, 2018 11:46 am
If glitches do occur then a diode across R119 will speed up the rising edge. If the ls86 is socketed then replacing it with a 74hc86 could also work.
IC38 (the LS86) is not typically socketted.

The first thing I did this morning was desolder it and fit a socket so I could try an HC version. The machine booted, but just gave a black screen in Mode 7. The 6MHz clock looked OK, but I guess there was just too much overall delay (the HC part being slower I think).

Interestingly, now I've removed C48, you no longer get a black screen with the HC variant.

Dave

Post Reply