Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FastPWM mbed QEI biquadFilter HIDScope MODSERIAL
Diff: main.cpp
- Revision:
- 36:077fe5b3189b
- Parent:
- 35:ba556f2d0fcc
- Child:
- 38:681100ce5fb8
--- a/main.cpp Wed Oct 31 10:22:04 2018 +0000 +++ b/main.cpp Wed Oct 31 10:24:01 2018 +0000 @@ -130,11 +130,6 @@ return angle; } - float DesiredAngler() // Sets the desired angle for the controller dependent on the scaled angle of potmeter 1 - { float angle = (pot2*2.0f*pi)-pi; - return angle; - } - float* turnl() // main function for movement of motor 1, all above functions with an extra tab are called { //float refvalue = pi/4.0f; @@ -157,28 +152,6 @@ return outcome; } -float* turnr() // main function for movement of motor 1, all above functions with an extra tab are called -{ - //float refvalue = pi/4.0f; - float refvalue = DesiredAngler(); // different minus sign per motor - int counts = Countsrinput(); // different encoder pins per motor - float currentangle = CurrentAngle(counts); // different minus sign per motor - float PIDcontrol = PIDcontroller(refvalue,currentangle); // same for every motor - float error = ErrorCalc(refvalue,currentangle); // same for every motor - - pin6 = fabs(PIDcontrol); // different pins for every motor - pin7 = PIDcontrol > 0.0f; // different pins for every motor - //pin6 = 0.4+0.6*fabs(PIDcontr); //geschaald - //pin6 = fabs(PIDcontr)/pi; - //pc.printf(" error: %f ref: %f angle: %f \r\n",error,refvalue,currentangle); - float* outcome; - float turninfo[3] = {error, refvalue, currentangle}; - //float ( &fillarr( float (&outcome)[3] ) )[3] { // no decay; argument must be size 3 - outcome = turninfo; - - return outcome; -} - float ActualPosition(int counts, int offsetcounts) // After calibration, this function is used to return the counts (and thus the angle of the system) to 0 { float MotorPosition = - (counts - offsetcounts) / fCountsRad; // minus sign to correct for direction convention @@ -203,13 +176,7 @@ float motorl2 = motoroutcomel[1]; float motorl3 = motoroutcomel[2]; - //float* motoroutcomer = turnr(); - //float motorr1 = motoroutcomer[0]; - //float motorr2 = motoroutcomer[1]; - //float motorr3 = motoroutcomer[2]; - pc.printf(" error1: %f ref1: %f angle1: %f \r\n",motorl1,motorl2,motorl3); - //pc.printf(" error1: %f ref1: %f angle1: %f \r\n",motorr1,motorr2,motorr3); wait(dt); //wait(dt*10); //wait(printingfreq); --> still needs to be defined