
first commit
Diff: driving.h
- Revision:
- 17:d2c98ebda90b
- Parent:
- 16:8cd4dd323941
- Child:
- 18:831c1e03d83e
--- a/driving.h Tue Oct 26 17:06:39 2021 +0000 +++ b/driving.h Tue Oct 26 19:10:13 2021 +0000 @@ -71,6 +71,9 @@ are_brakes_activated = true; brakeLeft = 1; brakeRight = 1; + errorAreaRight = 0.0; + errorAreaLeft = 0.0; + }; @@ -82,9 +85,13 @@ volatile bool motor_enabled = false; void PI(void) { //motor PI interrupt + +speedLeftVolt = (speedSensorLeft.read() * 3.3f); +speedRightVolt = (speedSensorRight.read() * 3.3f); + if(motor_enabled == true) { - setpointLeft = 0.2; - setpointRight = 0.2; + //setpointLeft = 0.2; + //setpointRight = 0.2; //--- Calculate Error --- errorLeft = setpointLeft - (speedLeftVolt / 3.3f); //error and setpoint is defined as a percentage, from 0 to 1 errorRight = setpointRight - (speedRightVolt / 3.3f); @@ -153,26 +160,10 @@ clampRight = false; } - //--- fucked up manual braking stuff --- - if (brakeLeftBool == true) - { - errorAreaLeft = 0.0; - brakeLeft = 1; - } else { - brakeLeft = 0; - } - - if (brakeRightBool == true) - { - errorAreaRight = 0.0; - brakeRight = 1; - } else { - brakeRight = 0; - } - + //--- set motors to calculated output --- - motorLeft.write(0.2); // 0.2 For debugging - motorRight.write(0.2); + motorLeft.write(dutyCycleLeft); // 0.2 For debugging + motorRight.write(dutyCycleRight); //--- motor braking --- /*