Francesco Pistone
/
Viaro_SpandiConcime_V3_inizio
copia12092018
variables.h@3:1cd8d048cd4a, 2018-06-19 (annotated)
- Committer:
- viaromassimo
- Date:
- Tue Jun 19 16:47:15 2018 +0000
- Revision:
- 3:1cd8d048cd4a
- Parent:
- 0:b0a79a3a9da8
- Child:
- 4:1643fea75703
- added control for minimal speed (below wich it stops); - added ramp for motor startup
Who changed what in which revision?
User | Revision | Line number | New 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 |
nerit | 0:b0a79a3a9da8 | 11 | char MotorSensorError(1); //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 | 3:1cd8d048cd4a | 20 | int MinMotorSpeed(1300); //min motor speed |
nerit | 0:b0a79a3a9da8 | 21 | int MaxMotorSpeed(100000); //max motor speed |
nerit | 0:b0a79a3a9da8 | 22 | float WheelToMotorRatio; //set the ideal ratio between wheel speed and motor speed |
nerit | 0:b0a79a3a9da8 | 23 | //float ReductionRatio(24); |
nerit | 0:b0a79a3a9da8 | 24 | float MotorCorrection(1.0); //set the initial motor correction factor |
nerit | 0:b0a79a3a9da8 | 25 | int MotorSensorSecurityCheck(0); //set the initial motor correction factor |
nerit | 0:b0a79a3a9da8 | 26 | float DecelerationControlRatio(1.5); //ratio to control wheel decelaration accepted limit |
viaromassimo | 3:1cd8d048cd4a | 27 | const int ConstArrayIns(4); //the number set the array values |
nerit | 0:b0a79a3a9da8 | 28 | CB1<int,ConstArrayIns> ReadWheelArray; //Circular array (for LIFO purposes) for wheel sensor readings |
nerit | 0:b0a79a3a9da8 | 29 | CB1<int,ConstArrayIns> ReadMotorArray; //Circular array (for LIFO purposes) for wheel sensor readings |
nerit | 0:b0a79a3a9da8 | 30 | int i; //general purpose integer for loops |
nerit | 0:b0a79a3a9da8 | 31 | int a; //general purpose integer for loops |
nerit | 0:b0a79a3a9da8 | 32 | unsigned long TempRead; //temporal read of wheel sensor millis for analysis |
nerit | 0:b0a79a3a9da8 | 33 | unsigned long TempReadM; //temporal read of motor sensor millis for analysis |
nerit | 0:b0a79a3a9da8 | 34 | unsigned long Elapsed(0); //used to take note of Elapsed time |
nerit | 0:b0a79a3a9da8 | 35 | unsigned long ElapsedM(0); //used to take note of Elapsed time |
nerit | 0:b0a79a3a9da8 | 36 | unsigned long CheckIfReadMChanges(0); //feedback of motor sensor |
nerit | 0:b0a79a3a9da8 | 37 | //from PID library: 0.0 - 1.0 |
viaromassimo | 3:1cd8d048cd4a | 38 | PID motorPID(1.0, 0.4, 0.3, 0.3); //Kc, Ti, Td, interval (0.1ms) |
nerit | 0:b0a79a3a9da8 | 39 | |
nerit | 0:b0a79a3a9da8 | 40 | //the below declarations are meant to prevent problems on switches due to tractor vibrations |
nerit | 0:b0a79a3a9da8 | 41 | int VibrationTimer(500); //timer for avoid vibrations in millis |
nerit | 0:b0a79a3a9da8 | 42 | char ChangeStatusOfOnOffPinToHigh(1); |
nerit | 0:b0a79a3a9da8 | 43 | char ChangeStatusOfOnOffPinToLow(1); |
nerit | 0:b0a79a3a9da8 | 44 | unsigned long OnOffPinTimerToHigh(0); //this is to avoid false positive on ON/OFF switch due to vibrations |
nerit | 0:b0a79a3a9da8 | 45 | unsigned long OnOffPinTimerToLow(0); //this is to avoid false positive on ON/OFF switch due to vibrations |
nerit | 0:b0a79a3a9da8 | 46 | char ChangeStatusOfPlusPercentPinToHigh(1); |
nerit | 0:b0a79a3a9da8 | 47 | char ChangeStatusOfPlusPercentPinToLow(1); |
nerit | 0:b0a79a3a9da8 | 48 | unsigned long PlusPercentPinTimerToHigh(0); //this is to avoid false positive on Plus switch due to vibrations |
nerit | 0:b0a79a3a9da8 | 49 | unsigned long PlusPercentPinTimerToLow(0); //this is to avoid false positive on Plus switch due to vibrations |
nerit | 0:b0a79a3a9da8 | 50 | char PercentPlus(0); |
nerit | 0:b0a79a3a9da8 | 51 | char ChangeStatusOfMinusPercentPinToHigh(1); |
nerit | 0:b0a79a3a9da8 | 52 | char ChangeStatusOfMinusPercentPinToLow(1); |
nerit | 0:b0a79a3a9da8 | 53 | unsigned long MinusPercentPinTimerToHigh(0); //this is to avoid false positive on Minus switch due to vibrations |
nerit | 0:b0a79a3a9da8 | 54 | unsigned long MinusPercentPinTimerToLow(0); //this is to avoid false positive on Minus switch due to vibrations |
nerit | 0:b0a79a3a9da8 | 55 | char PercentMinus(0); |