copia12092018

Dependencies:   mbed

Committer:
francescopistone
Date:
Fri Sep 14 09:31:34 2018 +0000
Revision:
7:dc3cb1a5764b
Parent:
4:1643fea75703
Child:
9:6fb26643eecd
modifiche varie

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