copia12092018

Dependencies:   mbed

Revision:
4:1643fea75703
Parent:
3:1cd8d048cd4a
Child:
7:dc3cb1a5764b
--- a/variables.h	Tue Jun 19 16:47:15 2018 +0000
+++ b/variables.h	Fri Jun 29 13:07:46 2018 +0000
@@ -8,7 +8,7 @@
 float Percent(1.0);  //variable to add/take out a Percent of product with PlusPercentPin/MinusPercentPin
 char ChangeFromOffToOn(1);  //used to reset Previous millis() when the operator switch off and back on
 char StopTheMotorWeGoTooSlow(1);  //stop the motor, we go too slow
-char MotorSensorError(1);  //stop the motor, we go too slow
+char MotorSensorError(0);  //stop the motor, we go too slow
 int TrigsPerWheelRevolution(10);  //number of triggers per weheel complete revolution
 int WheelDiameter(400);  //wheel diameter in millimeters
 unsigned long WantedMotorSpeed(0);  //motor speed (initial is 0)
@@ -17,39 +17,36 @@
 float MotorSpeedPwmTemp(0);  //motor speed pwm (initial is 0)
 float MotorSpeedPwm(0);  //motor speed pwm (initial is 0)
 int MinMotorPwm(1);  //min pwm for the motor to start
-int MinMotorSpeed(1300);  //min motor speed
-int MaxMotorSpeed(100000);  //max motor speed
-float WheelToMotorRatio;  //set the ideal ratio between wheel speed and motor speed
-//float ReductionRatio(24);
+int MinMotorSpeed(1000);  //min motor speed
+int MaxMotorSpeed(10000);  //max motor speed
+int WheelToMotorRatio(100);  //set the ideal ratio between wheel speed and motor speed  //RUOTA FONICA > MOTORE
 float MotorCorrection(1.0);  //set the initial motor correction factor
 int MotorSensorSecurityCheck(0);  //set the initial motor correction factor
 float DecelerationControlRatio(1.5);  //ratio to control wheel decelaration accepted limit
-const int ConstArrayIns(4);  //the number set the array values
+const int ConstArrayIns(3);  //the number set the array values
 CB1<int,ConstArrayIns> ReadWheelArray;  //Circular array (for LIFO purposes) for wheel sensor readings
 CB1<int,ConstArrayIns> ReadMotorArray;  //Circular array (for LIFO purposes) for wheel sensor readings
 int i;  //general purpose integer for loops
 int a;  //general purpose integer for loops
-unsigned long TempRead;  //temporal read of wheel sensor millis for analysis
+unsigned long TempReadW;  //temporal read of wheel sensor millis for analysis
 unsigned long TempReadM;  //temporal read of motor sensor millis for analysis
-unsigned long Elapsed(0);  //used to take note of Elapsed time
+unsigned long ElapsedW(0);  //used to take note of Elapsed time
 unsigned long ElapsedM(0);  //used to take note of Elapsed time
 unsigned long CheckIfReadMChanges(0);  //feedback of motor sensor
 //from PID library: 0.0 - 1.0
-PID motorPID(1.0, 0.4, 0.3, 0.3);  //Kc, Ti, Td, interval (0.1ms)
+PID motorPID(0.5, 0.3, 0.1, 0.1);  //Kc, Ti, Td, interval (0.1ms)
 
 //the below declarations are meant to prevent problems on switches due to tractor vibrations
 int VibrationTimer(500);  //timer for avoid vibrations in millis
-char ChangeStatusOfOnOffPinToHigh(1);
-char ChangeStatusOfOnOffPinToLow(1);
-unsigned long OnOffPinTimerToHigh(0);  //this is to avoid false positive on ON/OFF switch due to vibrations
-unsigned long OnOffPinTimerToLow(0);  //this is to avoid false positive on ON/OFF switch due to vibrations
-char ChangeStatusOfPlusPercentPinToHigh(1);
-char ChangeStatusOfPlusPercentPinToLow(1);
-unsigned long PlusPercentPinTimerToHigh(0);  //this is to avoid false positive on Plus switch due to vibrations
-unsigned long PlusPercentPinTimerToLow(0);  //this is to avoid false positive on Plus switch due to vibrations
-char PercentPlus(0);
-char ChangeStatusOfMinusPercentPinToHigh(1);
-char ChangeStatusOfMinusPercentPinToLow(1);
-unsigned long MinusPercentPinTimerToHigh(0);  //this is to avoid false positive on Minus switch due to vibrations
-unsigned long MinusPercentPinTimerToLow(0);  //this is to avoid false positive on Minus switch due to vibrations
-char PercentMinus(0);
+bool ChangeStatusOfOnOffPinToHigh(1);
+bool ChangeStatusOfOnOffPinToLow(1);
+bool ChangeStatusOfPlusPercentPinToHigh(1);
+bool ChangeStatusOfPlusPercentPinToLow(1);
+bool PercentPlus(0);
+bool ChangeStatusOfMinusPercentPinToHigh(1);
+bool ChangeStatusOfMinusPercentPinToLow(1);
+bool PercentMinus(0);
+bool WheelData(0);  //need to tell main() there's some data to handle
+bool MotorData(0);  //need to tell main() there's some data to handle
+bool Compute(0);
+bool SecurityStop(0);
\ No newline at end of file