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