Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Auf_Entladen_Kondesator
- {
- public partial class Form1 : Form
- {
- /*
- Aufladen: Uc = U * (1-e ^ -(t/(R*C))) nach t: t = ln(1 - (Uc/U) * (-tau) ln -> math.log10
- Entladen: Uc = U * e ^ -(t/(R*C))
- */
- public Form1()
- {
- InitializeComponent();
- BackColor = Color.LightBlue;
- listBox1.Items.Add("t in μs \t U in V\n");
- }
- private void Ende_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void Rechnen_Click(object sender, EventArgs e)
- {
- double Tau;
- double Uc;
- int Zeit = 0;
- double U;//=Convert.ToDouble(EingabeVolt.Text);
- bool KonvertU = double.TryParse(EingabeVolt.Text, out U);
- double R;//= Convert.ToDouble(EingabeWiderstand.Text);
- bool KonvertR = double.TryParse(EingabeWiderstand.Text, out R);
- double C;// = Convert.ToDouble(EingabeUFahr.Text);
- bool KonvertC = double.TryParse(EingabeUFahr.Text, out C);
- double AnzahlWerte5=5,AnzahlWerte10=10,AnzahlWerte50=50;
- Tau = Convert.ToDouble(EingabeWiderstand.Text) * Convert.ToDouble(EingabeUFahr.Text);
- AusgabeTau.Text = Convert.ToString(Tau);
- if (KonvertU==true && Anzahl5.Checked == true && Aufladung.Checked == true)
- {
- for (int i = 0; i < AnzahlWerte5; i++)
- {
- Uc = U * (1 - (Math.Pow(Math.E, -(Zeit / (R * C)))));
- //Uc = Math.Round(Uc, 2);
- listBox1.Items.Add(Convert.ToString(Zeit) + "\t" + Convert.ToString(Uc));
- }
- }
- else if (this.EingabeVolt.Text != "" && Anzahl10.Checked == true && Aufladung.Checked == true) //!string.IsNullOrEmpty(this.EingabeVolt.Text)
- {
- for (int i = 0; i < AnzahlWerte10; i++)
- {
- //t = t + 1;
- Zeit = Zeit + 5000;
- Uc = U * (1- (Math.Pow(Math.E, -(Zeit / (R * C)))));
- //Uc = Math.Round(Uc, 2);
- listBox1.Items.Add(Convert.ToString(Zeit) + "\t" + Convert.ToString(Uc)); //$"{Zeit.ToString()} \t {Uc}"
- }
- }
- else if (this.EingabeVolt.Text != "" && Anzahl50.Checked == true && Aufladung.Checked == true)
- {
- for (int i = 0; i < AnzahlWerte50; i++)
- {
- //t = t + 1;
- Zeit = Zeit + 5000;
- Uc = U * (1 - (Math.Pow(Math.E, -(Zeit / (R * C)))));
- //Uc = Math.Round(Uc, 2);
- listBox1.Items.Add(Convert.ToString(Zeit) + "\t" + Convert.ToString(Uc));
- }
- }
- else if (this.EingabeVolt.Text!=""&& Anzahl5.Checked==true&& Entladung.Checked==true)
- {
- for (int i = 0; i < AnzahlWerte5; i++)
- {
- Zeit = Zeit + 5000;
- Uc = U * (Math.Pow(Math.E, -(Zeit / (R * C))));
- //Uc = Math.Round(Uc, 2);
- listBox1.Items.Add(Convert.ToString(Zeit)+"\t"+Convert.ToString(Uc));
- }
- }
- else if(this.EingabeVolt.Text != "" && Anzahl10.Checked == true && Entladung.Checked == true)
- {
- for (int i = 0; i < AnzahlWerte10; i++)
- {
- Uc = U * (Math.Pow(Math.E, -(Zeit / (R * C))));
- //Uc = Math.Round(Uc, 2);
- listBox1.Items.Add(Convert.ToString(Zeit) + "\t" + Convert.ToString(Uc));
- }
- }
- else if (this.EingabeVolt.Text != "" && Anzahl50.Checked == true && Entladung.Checked == true)
- {
- for (int i = 0; i < AnzahlWerte50; i++)
- {
- Uc = U * (Math.Pow(Math.E, -(Zeit / (R * C))));
- //Uc = Math.Round(Uc, 2);
- listBox1.Items.Add(Convert.ToString(Zeit) + "\t" + Convert.ToString(Uc));
- }
- }
- else
- {
- listBox1.Items.Add("Fehler");
- }
- }
- private void ClearList_Click(object sender, EventArgs e)
- {
- listBox1.Items.Clear();
- listBox1.Items.Add("t in μs \t U in V\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement