copia12092018

Dependencies:   mbed

Committer:
root@developer-sjc-indigo-compiler.local.mbed.org
Date:
Fri Nov 16 10:55:45 2018 +0000
Revision:
13:4d6114864f2d
Parent:
11:dde73cf20353
Added tag fine for changeset dde73cf20353

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nerit 0:b0a79a3a9da8 1 int SD_faultA=0;
nerit 0:b0a79a3a9da8 2 int SD_faultB=0;
nerit 0:b0a79a3a9da8 3 int DC_brake=1;
nerit 0:b0a79a3a9da8 4 int DC_forward=1;
nerit 0:b0a79a3a9da8 5
francescopistone 9:6fb26643eecd 6 float PID_Rate(0.1);
francescopistone 9:6fb26643eecd 7
nerit 0:b0a79a3a9da8 8 string MachineType("electric"); //two options: "electric" or "idraulic"
nerit 0:b0a79a3a9da8 9
nerit 0:b0a79a3a9da8 10 float Percent(1.0); //variable to add/take out a Percent of product with PlusPercentPin/MinusPercentPin
nerit 0:b0a79a3a9da8 11 char ChangeFromOffToOn(1); //used to reset Previous millis() when the operator switch off and back on
nerit 0:b0a79a3a9da8 12 char StopTheMotorWeGoTooSlow(1); //stop the motor, we go too slow
viaromassimo 4:1643fea75703 13 char MotorSensorError(0); //stop the motor, we go too slow
nerit 0:b0a79a3a9da8 14 int TrigsPerWheelRevolution(10); //number of triggers per weheel complete revolution
nerit 0:b0a79a3a9da8 15 int WheelDiameter(400); //wheel diameter in millimeters
nerit 0:b0a79a3a9da8 16 unsigned long WantedMotorSpeed(0); //motor speed (initial is 0)
nerit 0:b0a79a3a9da8 17 unsigned long ReadMotorSpeed(0); //motor speed (initial is 0)
nerit 0:b0a79a3a9da8 18 float MotorSpeedCorrected(0); //motor speed (initial is 0)
nerit 0:b0a79a3a9da8 19 float MotorSpeedPwmTemp(0); //motor speed pwm (initial is 0)
nerit 0:b0a79a3a9da8 20 float MotorSpeedPwm(0); //motor speed pwm (initial is 0)
nerit 0:b0a79a3a9da8 21 int MinMotorPwm(1); //min pwm for the motor to start
viaromassimo 4:1643fea75703 22 int MinMotorSpeed(1000); //min motor speed
viaromassimo 4:1643fea75703 23 int MaxMotorSpeed(10000); //max motor speed
francescopistone 9:6fb26643eecd 24 //int WheelToMotorRatio(100); //set the ideal ratio between wheel speed and motor speed //RUOTA FONICA > MOTORE
francescopistone 9:6fb26643eecd 25 //francesco 17/09/2018 -> test
francescopistone 9:6fb26643eecd 26 int WheelToMotorRatio(100); // 4 (=pv) * 60(=3000/50) * 12 (differenza circonferenza di rotazione)
nerit 0:b0a79a3a9da8 27 float MotorCorrection(1.0); //set the initial motor correction factor
nerit 0:b0a79a3a9da8 28 int MotorSensorSecurityCheck(0); //set the initial motor correction factor
nerit 0:b0a79a3a9da8 29 float DecelerationControlRatio(1.5); //ratio to control wheel decelaration accepted limit
viaromassimo 4:1643fea75703 30 const int ConstArrayIns(3); //the number set the array values
nerit 0:b0a79a3a9da8 31 CB1<int,ConstArrayIns> ReadWheelArray; //Circular array (for LIFO purposes) for wheel sensor readings
nerit 0:b0a79a3a9da8 32 CB1<int,ConstArrayIns> ReadMotorArray; //Circular array (for LIFO purposes) for wheel sensor readings
nerit 0:b0a79a3a9da8 33 int i; //general purpose integer for loops
nerit 0:b0a79a3a9da8 34 int a; //general purpose integer for loops
viaromassimo 4:1643fea75703 35 unsigned long TempReadW; //temporal read of wheel sensor millis for analysis
nerit 0:b0a79a3a9da8 36 unsigned long TempReadM; //temporal read of motor sensor millis for analysis
viaromassimo 4:1643fea75703 37 unsigned long ElapsedW(0); //used to take note of Elapsed time
nerit 0:b0a79a3a9da8 38 unsigned long ElapsedM(0); //used to take note of Elapsed time
nerit 0:b0a79a3a9da8 39 unsigned long CheckIfReadMChanges(0); //feedback of motor sensor
nerit 0:b0a79a3a9da8 40 //from PID library: 0.0 - 1.0
francescopistone 7:dc3cb1a5764b 41 //PID motorPID(0.5, 0.3, 0.1, 0.1); //Kc, Ti, Td, interval (0.1ms)
francescopistone 7:dc3cb1a5764b 42 //francesco 13/09/2018 --> test togliendo la parte derivativa del PID
francescopistone 9:6fb26643eecd 43 //PID motorPID(0.5, 0.3, 0.0, 0.1); //Kc, Ti, Td, interval (0.1ms)
francescopistone 11:dde73cf20353 44 PID motorPID(1.0, 1.0, 0.0, 0.1); //Kc, Ti, Td, interval (0.01ms)
francescopistone 9:6fb26643eecd 45
nerit 0:b0a79a3a9da8 46
nerit 0:b0a79a3a9da8 47 //the below declarations are meant to prevent problems on switches due to tractor vibrations
nerit 0:b0a79a3a9da8 48 int VibrationTimer(500); //timer for avoid vibrations in millis
viaromassimo 4:1643fea75703 49 bool ChangeStatusOfOnOffPinToHigh(1);
viaromassimo 4:1643fea75703 50 bool ChangeStatusOfOnOffPinToLow(1);
viaromassimo 4:1643fea75703 51 bool ChangeStatusOfPlusPercentPinToHigh(1);
viaromassimo 4:1643fea75703 52 bool ChangeStatusOfPlusPercentPinToLow(1);
viaromassimo 4:1643fea75703 53 bool PercentPlus(0);
viaromassimo 4:1643fea75703 54 bool ChangeStatusOfMinusPercentPinToHigh(1);
viaromassimo 4:1643fea75703 55 bool ChangeStatusOfMinusPercentPinToLow(1);
viaromassimo 4:1643fea75703 56 bool PercentMinus(0);
viaromassimo 4:1643fea75703 57 bool WheelData(0); //need to tell main() there's some data to handle
viaromassimo 4:1643fea75703 58 bool MotorData(0); //need to tell main() there's some data to handle
viaromassimo 4:1643fea75703 59 bool Compute(0);
viaromassimo 4:1643fea75703 60 bool SecurityStop(0);