Forums - C# Corner

Forum guidelines
Nick Goodson

Nick Goodson

  • 1.5k
  • 3
  • 340

How does timer know when to start

May 22 2016 10:42 AM
The timer used here doesn't have a t=0 set time. How does it know when to start? Sorry if this is a silly question.

public partial class Form1 : Form

{
double t;
double dt = 0.1;
StreamWriter myfile = new StreamWriter("myresults.csv");
double previous_error = 0;
double integral = 0;
double error;
double setpoint = 0;
double measured_value;
double derivative;
double output;
double SpeedAccuracy = 0;
double Kp = 0.05, Ki = 0, Kd = 0;
double k1 = -2, k2 = 2;
private void timer1_Tick(object sender, EventArgs e)
{
if (car.speedX == 0) return; 
*CODE BODY*
t = t + dt 

 

Thanks in advance.

Nick 
 


Answers (2)