[SOLVED] DAC resistor value calculation

amine2: the thing is , i dont think the transistor is needed . . . . .

Why not just use a ladder as here? That way the sync pulses will be the correct proportion of the overall video waveform amplitude (assuming the digital video is at 'black' during sync pulses).

during sync pulses the needed voltage is 0v .
when all the bits are high the voltage is needed to be 1v
when the sync is high and all the bits are high the needed voltage is 0.3v

the ladder you presented is good :slight_smile: but not for this particular case

Grumpy_Mike: Yes. Yes but when only the sync was high and all the other bits going into the D/A were low, then the output voltage would be zero not the 0.3V that you want to build the analogue signal on.

oh sorry, i forgot to mention that the sync pin is also individually connected to the D/A . ima maintain the logic chips and add your transistor at one , just to make sure . thank you Mike :)

i did do that circuit but it does not work for some reason

but it does not work

Not a lot of information in those words. You need to expand on this.

What does it do? What waveform can you see on the output? What are you connecting it to? How are you connecting it? What circuit did you finally use, can you post a schematic of this? What software are you running?

i was using a bad quality , badly calculated , resistor ladder . it generates bad and not so many shades of gray for 8bit . but it was working so the code does work . now this is my circuit :


Mike , i think it would be better to just calculate an other ladder ? what do you think ? since my circuit now does not even generate any form of analog-video . i couldn't check it with an oscilosocope since i no longer have one .

A good 8 bit ladder is impossible to make with just fixed resistors because they simply are not accurate enough. The best you can do is an R 2R design with the 2R being two resistors in series and measuring and presorting the 24 resistors so they are as close as possible to being the same value.

However that does not matter at the moment the problem I think you are saying is that you have no video displayed at all.

Without a scope it is difficult to track down. What I would do however is to write some software that gives you some static situation and measure the voltage with your meter on the transistor’s collector. So say you set the most significant bit of your video signal high what is this voltage when the sync is high and low. It should be about 2.5V / <0.7V.

yes indeed mike . i did some math and these are the values i calculated (might be incorrect) had to do a couple of simple equations . where the 8bit ladder resistances are in powers of 2 like what you said i don't think i can get such accurate resistance values though (like you said)

R - 908R R - 1816R R - 3632R R - 7264R R - 14528R R - 29056R R - 58112R R - 116224R

SYNC - 876

the output of the circuit is either near 5v or 0v , i think the DAC is not working with the R2R circuit

though the matter seems kinda complicated since you have a voltage being outputted from the DAC that is between 0 and 5v --> it must become between 0.3 and 1v . that is not directly proportional since "Vout = Vin*(0.7/5) + 0.3" -> + i dont think that the input is exactly 5v , when i measure it with a multi-meter it's around 4.25v and 4.8v so should i use 4.5v in calculation instead of 5v ? . and did you consider the 75ohm resistance in the TV ? cauz i cant understand your calculation with that 330ohm resistance .

did you consider the 75ohm resistance in the TV

Yes, it is the other side of a capacitor so from the DC point of view it is not there.

Don't get hung up on the D/A for the moment. Test it with DC values like I said. But a scope is the best way because you can see the waveform and see what it is doing. You could try a 75R or so resistor across the collector / emitter of the transistor, value not too critical at this point.

i checked the circuit dude , the voltage i get when the PORT is at 255 and sync is disabled is 2.3v and the voltage i get when the PORT is at 255 and the sync is enabled is exactly the same at around 2.3v the voltage i get when the port is at 0 is near 1.95v

its like the circuit does not work

Looks like that transistor is not turning on. Check the voltage on the base with and without the sync pulse. Either it is wired wrong, or you don't have the right components or the transistor is faulty.

hey Mike , your circuit worked . but the picture is too dark . i managed to get text on the screen but it's too dark .

i changed the 330Ohm resistor to 10K and the picture got lighter . but i had some flicker (a little bit of it)

and the darkest places in the screen are gray . i think the dark level is getting alot more than 0.3v and the white level is getting much less than 1v .

OK if you replace those two fixed resistors with pots you should be able to control your brightness and contrast.

and the darkest places in the screen are gray

That could be down to the fact that you have no front or back porch on your video. The monitor often uses these to clamp the video to get a proper reference level.

the front and back porch signals are good i think , because they are integrated in the code . i kept changing the two resistors and it should keep getting better . thank you for the circuit Mike , it's very good . now one more thing, can i use a TLC7528 instead of the R2R ladder ? i think you can set a voltage reference for that chip , like you can set the top voltage to 1v by supplying 1v to the reference pin i think .

can i use a TLC7528 instead of the R2R ladder

Basically yes, but:-

The data sheet says the settling time is 100ns, given a 64uS line period this gives you a maximum resolution of 640 pixels in the X direction. Rough calculations it will be a bit less than that in practice.

ok here is the full deal Mike , i am using an external 128KB I/O volatile RAM chip with the device .
the setting time is 74ns . for now i managed to get the video to run at 480/224pixels (for some odd reason , while working with a fake progressive PAL mode . i set a delay of 16ms bettween frames while setting the sync is low but the whole thing seems to work . that is really odd . at first i started with a fully interlaced PAL frame mod , but that leaves no time for other processes that i need in parallel)
working with an external ram is really good , since all you need to do is fill it with the video data then just increment the address and set the lines . anyway since the RAM setting time is around 74ns and the hors resolution is 480px i dont think that would matter , right ?

and for the voltage i think i need about 5.1v i think . the thing is the voltage being outputted by the supposedly 5v regulator is 4.7v

the thing is the voltage being outputted by the supposedly 5v regulator is 4.7v

What is your circuit? That is a bit low but not too low.

working with an external ram is really good ..........

So the does the scanning address and the write address use the same pins?

You can save a very lot of processing time by having counters give you a scanning address and the processor the write address. Then you can switch between the two with data selectors or tri state buffers. One trick is to only access the memory during frame blanking periods.

i set a delay of 16ms bettween frames while setting the sync is low but the whole thing seems to work . that is really odd

That is more of a function of your monitor than anything else.