6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 3:26 am

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: 12-bit VGA DAC feedback
PostPosted: Mon Jul 17, 2023 12:25 pm 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
Hi,

I've been working on a VGA DAC for my upcoming CPLD graphics project. I wanted it to be more accurate than the usual quick-and-dirty resistor ladder arrangement, mostly as a fun challenge, as I have never worked with analog circuitry before.

In my research for a suitable opamp buffer, I came across the LT1260 triple amplifier which seems purpose made for driving RGB signals and is available in DIP, though a bit expensive at 7€ (https://nl.mouser.com/datasheet/2/609/1 ... 123073.pdf). So, I designed the following circuit around this IC. It uses pre-made 4-bit R2R ladders, with a multiturn potentiometer on each channel allowing me to calibrate the outputs to 0.7Vp-p as required by the VGA signal.

Even though I was only able to find 4-bit R2R ladders, the intent is to use this circuit with a RRRGGGBB palette, I'm only including the additional bits because they're free.

The color signals have proper 75ohm output impedance, and I added 75ohms (because it simplifies the BOM) source termination on HSYNC and VSYNC, though I'm not sure if that's useful. The gain and feedback resistors are 1.1k as recommended by the datasheet.

The negative power supply is generated by a MAX1044 (https://www.analog.com/media/en/technic ... AX1044.pdf) which is a charge pump, so probably not accurate enough for this? I'm struggling with how to generate this negative power nicely.

As mentioned, I'm not really an analog guy, and would love to hear any feedback you may have.

Attachment:
Screenshot 2023-07-17 at 14.29.32.png
Screenshot 2023-07-17 at 14.29.32.png [ 533.39 KiB | Viewed 1996 times ]


I also created a simulation on circuitjs

Attachment:
circuit-20230717-1427.png
circuit-20230717-1427.png [ 157 KiB | Viewed 1996 times ]

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 17, 2023 6:25 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
I would put the trimmer at R1 or R2 instead of where you show it.  This will adjust the gain of the op amp circuit, and keep the R-2R ladder nicely balanced.

The charge pump will be fine for the negative power-supply voltage.  Ideally the op amp's output voltage will depend only on the signal inputs and the feedback network, as long as the power supply voltage is great enough to reach the desired peak output voltages.  The only problem might be that at the higher frequencies like your charge pump would work at, the PSRR (power supply rejection ratio) might be poor; but particularly if the op amp is taking very little current relative to what the charge pump is capable of, the ripple shouldn't be a problem.  If you notice any artifacts in your video, they'll probably be cleared up by increasing the capacitor values in the charge pump.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 17, 2023 8:02 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
I wonder if you're over-thinking it...

So just as another data point, there exists a VGA adapter for the Raspberry Pi that's driven purely from the GPIO connector (by the GPU) that's nothing more than an R/2R network and it works remarkably well without any buffer amplifier, trim pots, etc. It's only 6 bits per channel but for the most part you'd never know it wasn't the full 24-bit RGB and despite passive components it run right past full HD resolutions too.

Search for Gert VGA666 for more details. (inc. schematic, etc.)

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 18, 2023 9:04 am 
Offline
User avatar

Joined: Mon Aug 30, 2021 11:52 am
Posts: 287
Location: South Africa
I'm not sure you need that negative voltage. As far as I know the VGA RGB signals are 0V to 0.7V. It's possible that the LT1260 can be run off +5V positive and 0V negative but I only think that from a quick scan of the datasheet - don't trust me until you've tested it.

You might not need the LT1260 at all. If you haven't seen them then James Sharman's videos are a pretty good reference: DAC Test - VGA from Scratch - Part 10.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 19, 2023 11:11 am 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
GARTHWILSON wrote:
I would put the trimmer at R1 or R2 instead of where you show it.  This will adjust the gain of the op amp circuit, and keep the R-2R ladder nicely balanced.

The charge pump will be fine for the negative power-supply voltage.  Ideally the op amp's output voltage will depend only on the signal inputs and the feedback network, as long as the power supply voltage is great enough to reach the desired peak output voltages.  The only problem might be that at the higher frequencies like your charge pump would work at, the PSRR (power supply rejection ratio) might be poor; but particularly if the op amp is taking very little current relative to what the charge pump is capable of, the ripple shouldn't be a problem.  If you notice any artifacts in your video, they'll probably be cleared up by increasing the capacitor values in the charge pump.


Thanks! I came across this useful app note from Analog Devices showing the best ways to implement gain adjustment: https://www.analog.com/en/technical-art ... cuits.html. Based on that and your advice, I've now moved the trimmers.

For the charge pump, I was worried because it shows a significant drop in output voltage, 1V between 0mA and 20mA which is what the three opamps would typically use. However, I since realized I had already purchased a MAX739 a long time ago for a DRAM project, so I updated the power supply to be based on that. It is a regulator and should be more stable in the range I'm using it, although it needs a few more passives.

Now, that makes both ICs used on this board quite expensive, at 7€ each. Plus the trimmers and R2Rs, it is an expensive board. Maybe in the future I'll try to reduce costs, I know going to SMD will likely make this a fraction of the price, but for now I want to experiment.

drogon wrote:
I wonder if you're over-thinking it...

So just as another data point, there exists a VGA adapter for the Raspberry Pi that's driven purely from the GPIO connector (by the GPU) that's nothing more than an R/2R network and it works remarkably well without any buffer amplifier, trim pots, etc. It's only 6 bits per channel but for the most part you'd never know it wasn't the full 24-bit RGB and despite passive components it run right past full HD resolutions too.

Search for Gert VGA666 for more details. (inc. schematic, etc.)

-Gordon


Yes, I'm most definitely over-thinking it. I agree that a couple of resistors is all you need, but where is the fun in that! :mrgreen: If I can get marginally better color reproduction and signal integrity, while learning something in the process, then I'll be happy.

AndrewP wrote:
I'm not sure you need that negative voltage. As far as I know the VGA RGB signals are 0V to 0.7V. It's possible that the LT1260 can be run off +5V positive and 0V negative but I only think that from a quick scan of the datasheet - don't trust me until you've tested it.

You might not need the LT1260 at all. If you haven't seen them then James Sharman's videos are a pretty good reference: DAC Test - VGA from Scratch - Part 10.


Thanks! I watch James' videos religiously, and his approach is sound. What's missing from his presentation is the effect of current on the R2R ladder. If a bit of current flows through the cable, or you have signal integrity problems due to the impedance mismatch and not driving it at 75 ohms, then I would argue that it could generate errors comparable to the 1% tolerance of resistors, especially noticeable in 8 bits of resolution. I have not measured this though, so maybe I'm overstating it. Still, using an opamp buffer is an approach that should fix that and a learning opportunity for me!

On the power supply issue, they do recommend +/- 5V, but also say it could run with a single supply. I'm not sure how to interpret the datasheet to see how much error there would be at 0V in a single supply circuit? And I'm also not familiar at all with DC biasing and filtering to make the opamp work in a better range, maybe that's for a future learning project.


Attachments:
Screenshot 2023-07-19 at 13.13.34.png
Screenshot 2023-07-19 at 13.13.34.png [ 523.91 KiB | Viewed 1840 times ]

_________________
BB816 Computer YouTube series
Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 19, 2023 11:56 am 
Offline
User avatar

Joined: Mon Aug 30, 2021 11:52 am
Posts: 287
Location: South Africa
For a charge pump I use the TC7660 which is pin compatible with the MAX1044. You can see it in the right hand side of this schematic. It comes in at around a US dollar making it a bit cheaper than the MAX1044. I'm also not familiar with DC biasing so I'd probably just use a charge pump for -5V and be done.

If you're willing to try a completely off-the-wall solution you could use a 30bit video DAC like the THS8136 or a 24bit video DAC like the ADV7125. Those will both handle the current for you (with appropriate 75Ω termination resistors). I'm using the '7125 but that comes with a few gotchas. Mostly that it's not produced anymore*. And also that both are capable** of encoding the sync signal in the green channel.

I'm not sure that the above is a solution in the spirit of your project though.

* available for around a US dollar on aliexpress if you're brave.
** but can be disabled.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 19, 2023 12:34 pm 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
Those are very interesting ICs, thanks!

To be honest though, if I end up going for a premade version of the DAC in the future, in a TQFP package, I might as well go digital and use the TFP410, similar to how 1bitsquared is doing with their PMOD DVI https://1bitsquared.com/products/pmod-d ... -interface. Though supply for this one is a bit delayed at the moment.

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 19, 2023 4:54 pm 
Offline

Joined: Fri Sep 18, 2015 5:01 am
Posts: 20
A resistor DAC is not really quick-and-dirty IMO, it is pretty much a case of a simple solution that is also the right solution. I suppose you might consider the binary-ladder DAC quick and dirty, and the R-2R DAC the sophisticated solution.

For VGA (analog video), because the digital voltages are known, and the analog voltage range and impedance are also known, you can calculate the values you need for either resistor DAC type.

For a DAC you have are few parameters you are trying to achieve:

Accuracy - how well the same binary value produces the same analog voltage.
Precision - how closely the binary value can be represented by the analog voltage.
Resolution - how small of a change can be represented.
Linearity - how equal the analog change is between any two sequential binary input values.

The main problem for a binary resistor DAC is finding resistor values that are exact powers of two, i.e. 1K, 2K, 4K, 8K, etc.. Since resistors don't come in exact values like that, and their tolerance varies a lot, these kinds of DACs become difficult to make when the binary input is large, i.e. 6 or more bits per channel. For a small video DAC, like 3 or 4 bits per color, this kind of DAC will work great and is probably well outside of a human eye to tell the difference. Use 1% or 0.5% tolerance quality resistors and you can get nice video. I'll attach a photo of a 9-bit (RRRGGGBBB) binary resistor DAC.

For more bits, the R-2R ladder is well suited because you only need two different values of resistors which are easier to achieve.

Analog electronics are much harder than digital, and noise is harder than analog. If you really want to "up your DAC game", then the single most critical parameter is going to be your power supply voltages, and controlling noise.

A VGA signal is 0V to 0.7V full range, per color channel. For full 24-bit color, there are 8-bits per channel, which is 0.7 / 256, or 0.00273V per gradient change. So, the first thing you need is a power supply for your digital electronics that is accurate to around +/-0.00002V with ripple that is even smaller.

The amplifiers on the output of your DAC are fine if you need the drive, but they do not help with with parameters above. Actually, your amplifier will also need the low-noise power supplies, and its bandwidth and linearity will matter greatly.

Last, all this is moot for digital video, i.e. Display Port, DVI, and HDMI. And if you are driving analog VGA for a hobby project, then a 3-bit or 4-bit resistor DAC will produce a nice result that you will not be able to distinguish from anything else. IMO.


Attachments:
File comment: VGA 9-bit (3-bpp) binary resistor DAC on an LCD.
9bit_dac.png
9bit_dac.png [ 854.59 KiB | Viewed 1809 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 19, 2023 9:32 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
akohlbecker wrote:
For the charge pump, I was worried because it shows a significant drop in output voltage, 1V between 0mA and 20mA which is what the three op amps would typically use. However, I since realized I had already purchased a MAX739 a long time ago for a DRAM project, so I updated the power supply to be based on that. It is a regulator and should be more stable in the range I'm using it, although it needs a few more passives.

An op amp does not require the plus and minus voltages to match, nor to be regulated.  Because of the PSRR mentioned earlier, the ripple noise coming from the charge pump could be a bit of a problem that shows up in the video display; but a regulated charge pump will still have the ripple unless the regulator is a good linear one following the charge pump, IOW, that the regulation is not done by turning the pump switching on and off.

Another closely related thing however is that the digital noise coming from the power supply, and ground bounce, on whatever feeds the R-2R ladder is no less important.  I imagine you'll have to keep your nose really clean on that part.  Myself, I don't have any experience in video to know the extent of the potential problem; so I can only talk about this stuff from a theoretical standpoint.

AndrewP wrote:
I'm not sure you need that negative voltage. As far as I know the VGA RGB signals are 0V to 0.7V. It's possible that the LT1260 can be run off +5V positive and 0V negative but I only think that from a quick scan of the datasheet - don't trust me until you've tested it.

The LT1260 does not have a RtR (rail-to-rail) output.  According to page 6 of the data sheet, the output will not come within 0.5V of the negative rail.  The simplified schematic on the next page shows why.  So yes, you would need the negative power-supply voltage to get the output down to 0V.

Quote:
If a bit of current flows through the cable, or you have signal integrity problems due to the impedance mismatch and not driving it at 75 ohms, then I would argue that it could generate errors comparable to the 1% tolerance of resistors, especially noticeable in 8 bits of resolution. I have not measured this though, so maybe I'm overstating it. Still, using an op amp buffer is an approach that should fix that and a learning opportunity for me!

For eliminating reflections, the cable really only needs to be terminated with its characteristic impedance at the receiving end.  In the case where the signal is only supposed to go one direction, having the receiver at the end of a 75Ω cable to be 75Ω is enough.  If it's not 75Ω though, or if there are discontinuities in the cable that would cause reflections back to the transmitting end, then yes, you might want the transmitting end to look like 75Ω as well so the reflections don't echo back yet again (and again...and again...and...).  Other than that, the impedance of the transmitting end will only affect the level fed into the cable, like a voltage divider.  If I did the math right (if I didn't make a mistake in the chain of Thévenin-Norton conversions), and if your digital inputs will truly be at 0V and 5V, the max output from the R-2R ladder, with no load, is a little under 3.6V, which is way above your 0-.7V target, and then your op amp will further amplify it (and may clip).  Some changes may be needed.  Again, since I don't have experience in video, I should probably stop here.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 20, 2023 10:51 am 
Offline
User avatar

Joined: Sat Jul 24, 2021 1:37 pm
Posts: 282
Thank you both for very good feedback. I won't be able to reply for a few days but I'll be back!

_________________
BB816 Computer YouTube series


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 20, 2023 6:51 pm 
Offline

Joined: Sat Jan 02, 2016 10:22 am
Posts: 197
matthew180 wrote:
The main problem for a binary resistor DAC is finding resistor values that are exact powers of two, i.e. 1K, 2K, 4K, 8K, etc..

For a 3 bit DAC, exact powers of 2 are easy, as long as you have the middle value resisrtor to hand.

2 resistors in parallel will give you half the value.
2 reistors in series will give you double.

3 "perfect" values, at the expense of using 5 resistors per colour, instead of 3.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 25, 2023 3:44 pm 
Offline

Joined: Mon Jan 19, 2004 12:49 pm
Posts: 983
Location: Potsdam, DE
As pointed out above, the video output from a VGA port is 0.0 to 0.7v, as measured into 75 ohms built into the display. So open circuit, you should expect to see 1.4v at peak white (er, peak rgb).

Note that this means the black level is sat on the supply zero which might have implications if your local ground is insufficiently stiff - though with a bi-rail op-amp this shouldn't be a problem. Op-amps which work to 'ground' rarely actually make it without distortion as they approach the rail.

A PAL or NTSC composite video is raised 0.3v to include the sync pulses, so runs from 0.3v to 1.0v. In broadcast applications, exactly 0.3v is considered 'superblack' and is never (deliberately) transmitted; the lowest black is at 2% (0.014v/0.314v depending on component or composite).

Neil


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: