copia12092018

Dependencies:   mbed

Revision:
1:59c30e854dfb
Parent:
0:b0a79a3a9da8
Child:
2:5111c6c0639e
--- a/main.cpp	Wed Jun 13 08:41:23 2018 +0000
+++ b/main.cpp	Fri Jun 15 16:11:17 2018 +0000
@@ -39,6 +39,7 @@
 //***************************************************
 void ReadWheelInterrupt(){  //interrupt that read the wheel sensor
   TempRead=uSWheel.read_us();
+      pc.printf("\nruota");
   ReadWheelArray.push(TempRead);
   uSWheel.reset();
 }
@@ -127,15 +128,15 @@
       motorPID.setSetPoint(WantedMotorSpeed);
       motorPID.setProcessValue(ReadMotorSpeed);
       MotorSpeedCorrected=motorPID.compute();
-//      pc.printf("\n\nMotorSpeedCorrectedF %f ",MotorSpeedCorrected);
-//      pc.printf("\nWantedMotorSpeed %d ",WantedMotorSpeed);
-//      pc.printf("\nReadMotorSpeed %d ",ReadMotorSpeed);
-//      pc.printf("\nElapsed %d ",Elapsed);
-//      pc.printf("\nElapsedM4 %d ",Elapsed*4);
-//      pc.printf("\nTrigsPerWheelRevolution %d ",TrigsPerWheelRevolution);
-//      pc.printf("\nWheelToMotorRatio %f ",WheelToMotorRatio);
-//      pc.printf("\nPercent %f ",Percent);
-//      pc.printf("\nMotorSpeedPwm %f ",MotorSpeedPwm);
+      pc.printf("\n\nMotorSpeedCorrectedF %f ",MotorSpeedCorrected);
+      pc.printf("\nWantedMotorSpeed %d ",WantedMotorSpeed);
+      pc.printf("\nReadMotorSpeed %d ",ReadMotorSpeed);
+      pc.printf("\nElapsed %d ",Elapsed);
+      pc.printf("\nElapsedM4 %d ",Elapsed*4);
+      pc.printf("\nTrigsPerWheelRevolution %d ",TrigsPerWheelRevolution);
+      pc.printf("\nWheelToMotorRatio %f ",WheelToMotorRatio);
+      pc.printf("\nPercent %f ",Percent);
+      pc.printf("\nMotorSpeedPwm %f ",MotorSpeedPwm);
       //MotorCorrection=WantedMotorSpeed/ReadMotorSpeed;
       MotorSensorSecurityCheck=0;
     }
@@ -144,6 +145,14 @@
 
 //***************************************************
 void CheckTimeElapsedFromLastTrig(){  //check time Elapsed from last wheel trig
+//      pc.printf("\nuSWheel.read_us %d ",uSWheel.read_us());
+//      pc.printf("\nReadWheelArray.last %d ",ReadWheelArray.last());
+      wait(0.5);
+      pc.printf("\nWheelSensorPin.read %d  ", WheelSensorPin.read());
+      pc.printf("\nMotorSensorPin.read %d  ", MotorSensorPin.read());
+      pc.printf("\nOnOffPin.read %d        ", OnOffPin.read());
+      pc.printf("\nPlusPercentPin.read %d  ", PlusPercentPin.read());
+      pc.printf("\nMinusPercentPin.read %d ", MinusPercentPin.read());
   if((uSWheel.read_us()>(ReadWheelArray.last()*DecelerationControlRatio)) || (ReadWheelArray.last()==1) ){  //if the lag between the last read and now is more than *DecelerationControlRatio* times of the last trig or more of a max limit, or equal 1 -so, no reads- (this is an error control), it assumes the speed is too slow to act and resets
     OffTheMotor();
   }else{
@@ -241,8 +250,8 @@
     ReadWheelArray.push((int)1);
     ReadMotorArray.push((int)1);  //                          | this fills the wheel sensor array with "1"
   }
-//    pc.printf("Hello World");
-//    pc.printf("%d",millis());
+    pc.printf("Hello World");
+    pc.printf("%d",millis());
 
   WheelSensorPin.rise(&ReadWheelInterrupt);  //interrupt for wheel sensor, trigs when changes from 0 to 1
   MotorSensorPin.rise(&ReadMotorInterrupt);  //interrupt for motor sensor, trigs when changes from 0 to 1