## Copyright (C) D. Kuehling ## This program comes with ABSOLUTELY NO WARRANTY. ## License: GPLv3 0; ## Modell des YPbPr DAC via Knotenpotentialverfahren. Am Eingang nur ## Stromquellen. Versteckte Knoten haben Eingangsstrom 0. Spannungsquelle mit ## X Ohm Innenwiderstand ist gleich Stromquelle mit X Ohm Innenwiderstand! ## ## G * PHI = I ## AVR R/G/B SYNC Ausgänge (LSB first): global RED = [1,2,3]; global GREEN = [4,5,6]; global BLUE = [7,8]; global SYNC = 9; ## Pb Inverter Ausgänge R/G: global NRED = [10,11,12]; global NGREEN = [13,14,15]; ## Pr Inverter Ausgänge G/B: global NGREEN2 = [16,17,18]; global NBLUE = [19,20]; ## Y/Pb/Pr Ausgänge global Y = 21; global Pb = 22; global Pr = 23; ## Der Masseknoten hat bereits ein bekanntes Potential (0) und ist nicht Teil ## der Matrix. Wir benutzen vorübergehend Index GND für den Masseknoten, der ## wird nachher wieder aus der Matrix entfernt. global GND = 24; global G; G = zeros(GND); function R(knoten1,knoten2,widerstand) global G; G(knoten1,knoten1) += 1/widerstand; G(knoten2,knoten2) += 1/widerstand; G(knoten1,knoten2) += -1/widerstand; G(knoten2,knoten1) += -1/widerstand; endfunction ## Y R(Y, GND, 120); R(RED(3), Y, 2e3); R(RED(2), Y, 4.3e3); R(RED(1), Y, 8.2e3); R(GREEN(3), Y, 604); R(GREEN(2), Y, 1.2e3); R(GREEN(1), Y, 2.4e3); R(BLUE(2), Y, 6.2e3); R(BLUE(1), Y, 13e3); R(SYNC, Y, 604); ## use 604, too? ## Pb R(Pb, GND, 100); R(BLUE(2), Pb, 910); R(BLUE(1), Pb, 1.8e3); R(NRED(3), Pb, 3.9e3); R(NRED(2), Pb, 8.2e3); R(NRED(1), Pb, 16.2e3); R(NGREEN(3), Pb, 1.2e3); R(NGREEN(2), Pb, 2.4e3); R(NGREEN(1), Pb, 4.7e3); ## Pr R(Pr, GND, 100); R(RED(3), Pr, 910); R(RED(2), Pr, 1.8e3); R(RED(1), Pr, 3.6e3); R(NGREEN2(3), Pr, 1e3); R(NGREEN2(2), Pr, 2e3); R(NGREEN2(1), Pr, 4.3e3); R(NBLUE(2), Pr, 10e3); R(NBLUE(1), Pr, 20e3); ## 75 Ohm Load of TV connected to component outputs R(Y, GND, 75); R(Pb, GND, 75); R(Pr, GND, 75); ## Internal resistance of all drivers global R_avr = 40; global R_74hc = 50; R(SYNC,GND,R_avr); for j = 1:3 R(RED(j), GND, R_avr); R(GREEN(j), GND, R_avr); R(NRED(j), GND, R_74hc); R(NGREEN(j), GND, R_74hc); R(NGREEN2(j), GND, R_74hc); endfor for j = 1:2 R(BLUE(j), GND, R_avr); R(NBLUE(j), GND, R_74hc); endfor function component_out = dacaction(pc, syncval) global G; global R_avr; global R_74hc; global RED; global GREEN; global BLUE; global NRED; global NGREEN; global NGREEN2; global NBLUE; global SYNC; global Y; global Pb; global Pr; global GND; U_dout=5; J=zeros(rows(G)-1, 1); if (syncval) J(SYNC) = U_dout / R_avr; endif for idx = 1:3 if (bitand(pc,bitshift(1,idx-1))) J(RED(idx)) = U_dout / R_avr; else J(NRED(idx)) = U_dout / R_74hc; endif; if (bitand(pc,bitshift(8,idx-1))) J(GREEN(idx)) = U_dout / R_avr; else J(NGREEN(idx)) = U_dout / R_74hc; J(NGREEN2(idx)) = U_dout / R_74hc; endif; endfor; for idx = 1:2 if (bitand(pc,bitshift(1,idx-1))) J(RED(idx)) = U_dout / R_avr; else J(NRED(idx)) = U_dout / R_74hc; endif; if (bitand(pc,bitshift(64,idx-1))) J(BLUE(idx)) = U_dout / R_avr; else J(NBLUE(idx)) = U_dout / R_74hc; endif; endfor; G_ = G(1:GND-1, 1:GND-1); phi = G_ \ J; component_out = [phi(Y), phi(Pb), phi(Pr)]; endfunction function pc = rgb(r,g,b) pc = bitor(r, bitor(bitshift(g,3), bitshift(b, 6))); endfunction white = dacaction(0xFF,1) black = dacaction(0x0,1) sync = dacaction(0x0,0) darkgrey = dacaction(rgb(2,2,1),1) grey = dacaction(rgb(4,4,2),1) lightgrey = dacaction(rgb(6,6,3),1) red = dacaction(rgb(7,0,0),1) green = dacaction(rgb(0,7,0),1) blue = dacaction(rgb(0,0,3),1) yellow = dacaction(rgb(7,7,0),1) magenta = dacaction(rgb(6,0,3),1) cyan = dacaction(rgb(0,6,3),1)