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: Encoder HIDScope MODSERIAL TouchButton mbed-dsp mbed
Revision 9:ba7f541cef3a, committed 2014-10-30
- Comitter:
- Tanja2211
- Date:
- Thu Oct 30 16:24:22 2014 +0000
- Parent:
- 8:7bf274156e1f
- Child:
- 10:d1260f8e5300
- Commit message:
- false werkt niet
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 30 15:18:06 2014 +0000
+++ b/main.cpp Thu Oct 30 16:24:22 2014 +0000
@@ -395,18 +395,18 @@
}//end int main
-float pid(float setspeed, float measurement, bool reset)
+float pid(float setspeed, float measurement, bool reset )
{
float error;
static float prev_error = 0;
float out_p = 0;
static float out_i = 0;
float out_d = 0;
- if(reset)
- {
- out_i = 0;
- prev_error = 0;
- }
+ //if(reset==true)
+ //{
+ // out_i = 0;
+ // prev_error = 0;
+ //}
error = setspeed-measurement;
out_p = error*K_P;
out_i += error*K_I;
@@ -619,7 +619,7 @@
if (motor1.getPosition()>= ANGLEMIN && toestand != SLAAN) {
toestand = WACHTEN;
//out_i=0;
- pid(0,0,true);
+ //pid(0,0,true);
pc.printf("if1\n");
}
if (snelheidsstand != 0 && toestand == WACHTEN && stop == 0) { // stop = 0 in het begin let op dat dit na reset nog zo is
@@ -638,13 +638,13 @@
if (toestand == SLAAN && motor1.getPosition() <= ANGLEMAX) {
pc.printf("toestand = terugkeren\n\r");
//out_i=0;
- pid(0,0,true);
+ //pid(0,0,true);
toestand = TERUGKEREN;
stop = 1; //zorgt dat hij niet weer gaat slaan tot er gereset is...
}
if (toestand == TERUGKEREN) {
pc.printf("motor gaat terugkeren\n\r");
- new_pwm=pid(setspeed, motor1.getSpeed());
+ new_pwm=pid(setspeed, motor1.getSpeed(),false);
pwm_motor1.write(new_pwm);
pc.printf("new pwm %f\r\n",new_pwm);
@@ -655,7 +655,7 @@
pc.printf("ifwachten\n");
}
if (toestand == SLAAN) {
- pid(setspeed, motor1.getSpeed());
+ pid(setspeed, motor1.getSpeed(),false);
motordir1 = 1;
pwm_motor1.write(new_pwm);
pc.printf("SLAAN\n");