def plot_diode(): def graph_diode(): try: cnt = 0 if (f_bias.get()): cnt += 1 if (r_bias.get()): cnt += 1 q = 1.6 * pow(10, -19) k = 1.38 * pow(10, -23) e = 2.72 a = Area.get() * pow(10, pow_Area.get()) ni = intrinsic.get() * pow(10, pow_intrinsic.get()) nd = Donor_concn.get() * pow(10, pow_Donor_concn.get()) na = acceptor_concn.get() * pow(10, pow_acceptor_concn.get()) dp = diffusion_holes.get() * pow(10, pow_diffusion_holes.get()) dn = diffusion_electron.get() * pow(10, pow_diffusion_electron.get()) tp = holes_life.get() * pow(10, pow_holes_life.get()) tn = electron_life.get() * pow(10, pow_electron_life.get()) t = temp.get() * pow(10, pow_temp.get()) holes = (math.sqrt(dp / tp)) / nd electron = (math.sqrt(dn / tn)) / na I0 = q * a * ni * ni * (holes + electron) #I0=0.001 pow_coe = (q) / (t * k) #print(q,k,e,a,ni,nd,na,dp,dn,tp,tn,t,holes,electron,pow_coe,I0) current = [] v = [] max_vol = scale_factor.get() for i in range(1, max_vol, 1): volt = i / 100 hel = pow_coe * volt sec_num = pow(e, hel) val = I0 * (sec_num - 1) current.append(val) v.append(volt) r_voltage = [] r_current = [] for i in range(1, max_vol, 1): volt = -(i / 100) hel = pow_coe * volt sec_num = pow(e, hel) val = I0 * (sec_num - 1) r_current.append(val) r_voltage.append(volt) #print(v) #print(current) fig.clf() inc = 1 if (f_bias.get()): axis = fig.add_subplot(1, cnt, inc) axis.plot(v, current) axis.set_xlabel('voltage(Volt)') axis.set_ylabel('Currnet(Amp)') axis.set_title('Current Vs Voltage') axis.grid(linestyle='-') inc += 1 if (r_bias.get()): carrier_graph = fig.add_subplot(1, cnt, inc) carrier_graph.plot(r_current, r_voltage) carrier_graph.set_xlabel('voltage(Volt)') carrier_graph.set_ylabel('Currnet(Amp)') carrier_graph.set_title('Current Vs Voltage') carrier_graph.grid(linestyle='-') inc += 1 canvas = FigureCanvasTkAgg(fig, master=diode_window) canvas._tkcanvas.grid(row=12, column=0, columnspan=4, sticky=tk.EW) # Amp_sig=Amp_c.get()*(1+(Amp_sen.get()*Amp_m.get())*(cos())) diode_window.update() save_diode(int(nd), int(na), int(a), int(ni), int(tp), int(tn), float(dp), float(dn), float(t)) except: msg.showerror('Input Entry Error', 'Please Enter Valid Number') diode_window = tk.Tk(className='Diode Simulation') # icon_background(modulation_window,photo) diode_window.configure(background='AntiqueWhite1') fig = Figure(figsize=(10, 4), facecolor='pink', edgecolor='green', linewidth=1) canvas = FigureCanvasTkAgg(fig, master=diode_window) create_menu.create_menu_bar1(diode_window, canvas) diode_window.resizable(False, False) Donor_concn = tk.DoubleVar(diode_window) pow_Donor_concn = tk.IntVar(diode_window) pow_Donor_concn.set(20) Donor_concn.set(1) acceptor_concn = tk.DoubleVar(diode_window) pow_acceptor_concn = tk.IntVar(diode_window) pow_acceptor_concn.set(20) acceptor_concn.set(1) Area = tk.DoubleVar(diode_window) pow_Area = tk.IntVar(diode_window) pow_Area.set(4) Area.set(1.25) intrinsic = tk.DoubleVar(diode_window) pow_intrinsic = tk.IntVar(diode_window) pow_intrinsic.set(17) intrinsic.set(1) holes_life = tk.DoubleVar(diode_window) pow_holes_life = tk.IntVar(diode_window) pow_holes_life.set(-6) holes_life.set(1) electron_life = tk.DoubleVar(diode_window) pow_electron_life = tk.IntVar(diode_window) pow_electron_life.set(-6) electron_life.set(1) voltage = tk.DoubleVar(diode_window) pow_voltage = tk.IntVar(diode_window) pow_voltage.set(0) voltage.set(10) diffusion_holes = tk.DoubleVar(diode_window) pow_diffusion_holes = tk.IntVar(diode_window) pow_diffusion_holes.set(-4) diffusion_holes.set(4.5) diffusion_electron = tk.DoubleVar(diode_window) pow_diffusion_electron = tk.IntVar(diode_window) pow_diffusion_electron.set(-4) diffusion_electron.set(22.5) temp = tk.DoubleVar(diode_window) pow_temp = tk.IntVar(diode_window) pow_temp.set(0) temp.set(300) ttk.Label(diode_window, text='Donor Concenteration At N-Side ').grid(row=0, column=0, sticky=tk.W) Entry(diode_window, textvariable=Donor_concn).grid(row=0, column=1, sticky=tk.W) Entry(diode_window, textvariable=pow_Donor_concn).grid(row=0, column=2, sticky=tk.W) ttk.Label(diode_window, text='Acceptor Concenteration At P-Side ').grid(row=1, column=0, sticky=tk.W) Entry(diode_window, textvariable=acceptor_concn).grid(row=1, column=1, sticky=tk.W) Entry(diode_window, textvariable=pow_acceptor_concn).grid(row=1, column=2, sticky=tk.W) ttk.Label(diode_window, text='Cross Section Area ').grid(row=2, column=0, sticky=tk.W) Entry(diode_window, textvariable=Area).grid(row=2, column=1, sticky=tk.W) Entry(diode_window, textvariable=pow_Area).grid(row=2, column=2, sticky=tk.W) ttk.Label(diode_window, text='Intrinsic Carrier Concenteration ').grid(row=3, column=0, sticky=tk.W) Entry(diode_window, textvariable=intrinsic).grid(row=3, column=1, sticky=tk.W) Entry(diode_window, textvariable=pow_intrinsic).grid(row=3, column=2, sticky=tk.W) ttk.Label(diode_window, text='Lifetime Of Holes ').grid(row=4, column=0, sticky=tk.W) Entry(diode_window, textvariable=holes_life).grid(row=4, column=1, sticky=tk.W) Entry(diode_window, textvariable=pow_holes_life).grid(row=4, column=2, sticky=tk.W) ttk.Label(diode_window, text='Lifetime Of Electron ').grid(row=5, column=0, sticky=tk.W) Entry(diode_window, textvariable=electron_life).grid(row=5, column=1, sticky=tk.W) Entry(diode_window, textvariable=pow_electron_life).grid(row=5, column=2, sticky=tk.W) ttk.Label(diode_window, text='Diffusion Constant Of Holes').grid(row=6, column=0, sticky=tk.W) Entry(diode_window, textvariable=diffusion_holes).grid(row=6, column=1, sticky=tk.W) Entry(diode_window, textvariable=pow_diffusion_holes).grid(row=6, column=2, sticky=tk.W) ttk.Label(diode_window, text='Diffusion Constant Of Electron').grid(row=7, column=0, sticky=tk.W) Entry(diode_window, textvariable=diffusion_electron).grid(row=7, column=1, sticky=tk.W) Entry(diode_window, textvariable=pow_diffusion_electron).grid(row=7, column=2, sticky=tk.W) #tk.Label(diode_window, text='Applied Voltage ').grid(row=8, column=0, sticky=tk.W) #Entry(diode_window, textvariable=voltage).grid(row=8, column=1, sticky=tk.W) #Entry(diode_window, textvariable=pow_voltage).grid(row=8, column=2, sticky=tk.W) tk.Label(diode_window, text='Temperature ').grid(row=9, column=0, sticky=tk.W) Entry(diode_window, textvariable=temp).grid(row=9, column=1, sticky=tk.W) Entry(diode_window, textvariable=pow_temp).grid(row=9, column=2, sticky=tk.W) scale_factor = tk.IntVar(diode_window) scale_factor.set(75) ttk.Label(diode_window, text='scale_factor :').grid(row=10, column=0, sticky=tk.E) scaleing = Scale(diode_window, from_=0, to=1000, variable=scale_factor, orient=HORIZONTAL).grid(row=10, column=1, sticky=tk.EW) action = ttk.Button(diode_window, command=graph_diode, text='Plot Graph').grid(row=11, column=0, sticky=tk.E) tk.Label(diode_window, text='Select to plot Graph').grid(row=0, column=3, sticky=tk.W) f_bias = tk.IntVar(diode_window) check1 = tk.Checkbutton(diode_window, text="Forward Bias", variable=f_bias) f_bias.set(1) check1.grid(row=1, column=3, sticky=tk.W) r_bias = tk.IntVar(diode_window) check2 = tk.Checkbutton(diode_window, text="Reverse Bias", variable=r_bias) check2.deselect() check2.grid(row=2, column=3, sticky=tk.W)
def Plot_Amplitude_Modulation(): def plot_AM(): save_mod(Amp_c.get(), fre_c.get(), Amp_m.get(), fre_m.get(), Amp_sen.get(), 'AM') try: check_ = 0 if (mod_sig.get()): check_ += 1 if (car_sig.get()): check_ += 1 if (mes_sig.get()): check_ += 1 inc_ = 1 Amplitde = [] Amplitude_carrier = [] Amplitude_send = [] time_ = [] m_f = fre_m.get() time_period = ((1 / m_f) * (scale_factor.get() / 10)) / 100000 for i in range(1, 100000, 1): time_.append(time_period * i) Amplitde.append(Amp_m.get() * (np.cos(2 * math.pi * m_f * (time_period * i)))) Amplitude_carrier.append(Amp_c.get() * (np.cos( (2 * math.pi * fre_c.get() * (time_period * i))))) Amplitude_send.append(Amplitude_carrier[i - 1] * Amp_sen.get() * Amplitde[i - 1] + Amplitude_carrier[i - 1]) #Amplitude_send.append(Amp_c.get()*(1+(Amp_sen.get()*Amp_m.get()*(np.cos(2*3.14*m_f*(time_period*i)))))*(np.cos(2*3.14*fre_c.get()*(time_period*i)))) max_y_lev = max(Amplitude_send) #fig = Figure(figsize=(15, 6), facecolor='pink', edgecolor='green', linewidth=1) fig.clf() if (mod_sig.get()): axis = fig.add_subplot(1, check_, inc_) axis.plot(time_, Amplitde) axis.set_xlabel('time(Sec)') axis.set_ylabel('Amplitude(Volt)') axis.set_title('Amplitude Vs Time of modulating signal') axis.grid(linestyle='-') inc_ += 1 if (car_sig.get()): carrier_graph = fig.add_subplot(1, check_, inc_) carrier_graph.plot(time_, Amplitude_carrier) carrier_graph.set_xlabel('time(Sec)') carrier_graph.set_ylabel('Amplitude(Volt)') carrier_graph.set_title('Amplitude Vs Time of carrier signal') carrier_graph.grid(linestyle='-') inc_ += 1 if (mes_sig.get()): sender_graph = fig.add_subplot(1, check_, inc_) sender_graph.plot(time_, Amplitude_send) sender_graph.set_xlabel('time(Sec)') sender_graph.set_ylabel('Amplitude(Volt)') sender_graph.set_title('Amplitude Vs Time of message signal') sender_graph.grid(linestyle='-') inc_ += 1 #axis.set_ylim(-max_y_lev-10, max_y_lev+10) #carrier_graph.set_ylim(-max_y_lev-10, max_y_lev+10) #sender_graph.set_ylim(-max_y_lev-10, max_y_lev+10) #axis.set_xlim(-10, max_range + 10) canvas = FigureCanvasTkAgg(fig, master=modulation_window) canvas._tkcanvas.grid(row=7, column=0, columnspan=3, sticky=tk.EW) #Amp_sig=Amp_c.get()*(1+(Amp_sen.get()*Amp_m.get())*(cos())) modulation_window.update() except: msg.showerror('Input Entry Error', 'Please Enter Valid Number') modulation_window = tk.Tk(className='Amplitude Modulation') #icon_background(modulation_window,photo) modulation_window.configure(background='MintCream') fig = Figure(figsize=(13, 4), facecolor='HoneyDew', edgecolor='green', linewidth=1) canvas = FigureCanvasTkAgg(fig, master=modulation_window) create_menu.create_menu_bar1(modulation_window, canvas) modulation_window.resizable(False, False) Amp_c = tk.DoubleVar(modulation_window) fre_c = tk.DoubleVar(modulation_window) Amp_m = tk.DoubleVar(modulation_window) fre_m = tk.DoubleVar(modulation_window) Amp_sen = tk.DoubleVar(modulation_window) ttk.Label(modulation_window, text='Carrier Signal Amplitude :').grid(row=0, column=0, sticky=tk.E) Entry(modulation_window, textvariable=Amp_c).grid(row=0, column=1, sticky=tk.W) ttk.Label(modulation_window, text='Carrier Signal Frequency :').grid(row=1, column=0, sticky=tk.E) Entry(modulation_window, textvariable=fre_c).grid(row=1, column=1, sticky=tk.W) ttk.Label(modulation_window, text='Modulating Signal Amplitude :').grid(row=2, column=0, sticky=tk.E) Entry(modulation_window, textvariable=Amp_m).grid(row=2, column=1, sticky=tk.W) ttk.Label(modulation_window, text='Modulating Signal Frequency :').grid(row=3, column=0, sticky=tk.E) Entry(modulation_window, textvariable=fre_m).grid(row=3, column=1, sticky=tk.W) ttk.Label(modulation_window, text='Amplitude Sensitivity :').grid(row=4, column=0, sticky=tk.E) Entry(modulation_window, textvariable=Amp_sen).grid(row=4, column=1, sticky=tk.W) scale_factor = tk.DoubleVar(modulation_window) ttk.Label(modulation_window, text='scale_factor :').grid(row=5, column=0, sticky=tk.E) scaleing = Scale(modulation_window, from_=0, to=100, variable=scale_factor, orient=HORIZONTAL).grid(row=5, column=1, sticky=tk.EW) # check box making tk.Label(modulation_window, text='Select to plot Graph').grid(row=0, column=2, sticky=tk.W) mod_sig = tk.IntVar(modulation_window) check1 = tk.Checkbutton(modulation_window, text="Modulating Signal", variable=mod_sig) # ,state='disabled') check1.deselect() check1.grid(row=1, column=2, sticky=tk.W) car_sig = tk.IntVar(modulation_window) check2 = tk.Checkbutton(modulation_window, text="Carrier Signal", variable=car_sig) check2.deselect() check2.grid(row=2, column=2, sticky=tk.W) mes_sig = tk.IntVar(modulation_window) check3 = tk.Checkbutton(modulation_window, text='Message Signal', variable=mes_sig) check3.select() check3.grid(row=3, column=2, sticky=tk.W) action = ttk.Button(modulation_window, command=plot_AM, text='Plot Graph').grid(row=6, column=0, sticky=tk.E)