Hi guys In the development of my ADC project i have a new new challenge.
First i need to implement a 10 Bit pipelineADC that will be the basis to later implement any kind of pipeline arquitecture (i mean, with 10 Bit, 16 Bit or any other configuration i want) i wish to... What's a 10 Bit pipiline ADC? This link with a draw will help have a perfect view of what is it: http://t3.gstatic.com/images?q=tbn:ANd9GcQK_Pwz3ssk1yoDDFwGjJ5FWAwcqr1mV9EwdndlHCEvOMdTOa4&t=1&usg=__-TsH7dnNdJm4GZTuWCxjvajZhfk= To have a 10 Bit pipiline ADC we need 9 stages, where 8 of them are a 1.5 bit configuration and the last one have a 2 Bit configuration. How it works? When we inject a input voltage (at the first block), it will be computed in the first 1.5 Bit stage and when finished the compute it will generate a output voltage who served of input voltage for the second 1.5 Bit stage which in his turn generate also a output voltage who served of input voltage in the third stage ... and successively continuing until the ninth stage. The ninth stage it's a 2 Bit stage and it will receive the last output voltage from the eighth stage and in his turn it will compute a final output signal. I already implemented the 1.5 Bit/stage and the 2 Bit/stage functions with good results (i already watch their plot's and they are cool to me) but my Pipeline function try don't seems that good. After the 2 Bit compute i expect a output signal like the drawing on the link below but more stretched. http://t3.gstatic.com/images?q=tbn:ANd9GcQGQYDW0iLCSXfMMurIksWsgklsvtj26IBtQRacFtY7ifu9RQA&t=1&usg=__-yHJFMatnCPcf9jWQv3kaxM0brE= Instead of have a lot of steps one after the another, it will have something like a single step only. Why? That it's because when we have a pipeline with a lot of stage's the final output voltage until the 2 Bit stage it's very "dense" and long and that nearly saturating the last block ( the 2 Bit stage). Next i will leave the code that I have done so far for my Pipeline function: ------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------------------------------------- from flash1b5 import flash1b5 from flash1b5 import * from flash2b import flash2b from flash2b import * import matplotlib.pyplot as plt import numpy as np from pylab import * if __name__ == "__main__": Inc = raw_input("Valor do Incrimento = ") Vref = np.linspace(1,1, Inc) Vi = np.linspace(-1,1, Inc) Cs = np.linspace(3e-12, 3e-12, Inc) Cf = np.linspace(3e-12, 3e-12, Inc) f1 = flash1b5(Vi, Vref, Cs, Cf) Vin1 = f1[0] Vt1 = f1[1] Vd1 = f1[2] f2b = flash2b(Vt1, Vref) Vin2 = f2b[0] Vd2 = f2b[1] hold(True) fig2 = figure(1,figsize=(8,5)) ax2 = fig2.add_subplot(111, autoscale_on=False, xlim=(-1,1), ylim=(-0.5,2.5)) ax2.plot(Vin2, Vd2, lw=2, color='blue') grid (True); xlabel('V_ent');ylabel('Vout_Digital') plt.show() ------------------------------------------------------------------------------------------------------------------------------------------------------------------- The 1.5 Bit function: import numpy as np from pylab import * def flash1b5(Vi, Vref, Cs, Cf): Vin = np.zeros(Vi.shape, dtype=np.float) Vt = np.zeros(Vi.shape, dtype=np.float) Vd = np.zeros(Vi.shape, dtype=np.float) if any(Vi > Vref/4): mask1 = (Vi > Vref/4) np.putmask(Vin, mask1, Vi) Vs= (1+Cs/Cf)*Vin - (Cs/Cf)*Vref np.putmask(Vd, mask1, [2]) np.putmask(Vt, mask1, Vs) ## if any(-Vref/4 <= Vi) and any( Vi<= Vref/4): mask2 = (-Vref/4 <= Vi) & (Vi <= Vref/4) np.putmask(Vin, mask2, Vi) Vs = (1+(Cs/Cf))*Vin np.putmask(Vd, mask2, [1]) np.putmask(Vt, mask2, Vs) ## if any(Vi < -Vref/4): mask3 = (Vi < -Vref/4) np.putmask(Vin, mask3, Vi) Vs= (1+Cs/Cf)*Vin + (Cs/Cf)*Vref np.putmask(Vd, mask3, [0]) np.putmask(Vt, mask3, Vs) ## out = [Vin, Vt, Vd] return out ------------------------------------------------------------------------------------------------------------------------------------------------------------------- The 2 Bit function: import numpy as np from pylab import * def flash2b(Vi, Vref): Vin = np.zeros(Vi.shape, dtype=np.float) Vt = np.zeros(Vi.shape, dtype=np.float) Vd = np.zeros(Vi.shape, dtype=np.float) if any(Vi > Vref/2): mask1 = (Vi > Vref/2) np.putmask(Vin, mask1, Vi) np.putmask(Vd, mask1, [3]) if any(Vi > 0) and any(Vref/2 >= Vi): mask2 = (Vref/2 >= Vi) & (Vi > 0) np.putmask(Vin, mask2, Vi) np.putmask(Vd, mask2, [2]) if any(Vi <= 0) and any(-Vref/2 < Vi): mask3 = (-Vref/2 < Vi) & (Vi <= 0) np.putmask(Vin, mask3, Vi) np.putmask(Vd, mask3, [1]) if any(Vi <= -Vref/2): mask4 = (Vi < -Vref/2) np.putmask(Vin, mask4, Vi) np.putmask(Vd, mask4, [0]) S_Out = [Vin, Vd] return S_Out --------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------- Guys i'm asking if it's possible for a generic function for a pipeline, all the suggestions ideas are welcome. Also if you have a specific solution for my problem I will be grateful for it here. Thanks for reading my post. Cheers -- http://mail.python.org/mailman/listinfo/python-list