Libraries angepasst, Limits eingefügt, Testsoftware für Messungen angelegt.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//#include <prg_342.h>
|
||||
#include <Libraries/PRG_342/prg_342.h>
|
||||
#include <Libraries/datalogger/Datalogger.h>
|
||||
#include <Libraries/pid/pid.h>
|
||||
#include <prg_342.h>
|
||||
#include <Datalogger.h>
|
||||
#include <pid.h>
|
||||
#include <string>
|
||||
#include <math.h>
|
||||
|
||||
@@ -58,6 +58,8 @@ int angle;
|
||||
int lastAnglePID;
|
||||
int lastAngle;
|
||||
int actTorque;
|
||||
int upperLimit = 0;
|
||||
int lowerLimit = -0;
|
||||
//int actTorqueArray[100];
|
||||
float filteredTorque = 0; // gefilterter Wert
|
||||
float filteredSetpoint = 0;
|
||||
@@ -194,7 +196,7 @@ void loop() {
|
||||
}*/
|
||||
myPID.setTunings(Kp, Ki, Kd);
|
||||
|
||||
if (lastAnglePID != angle && Pon && !manOut && ((abs(actTorque) >= 1000 || abs(RotSpeed) >= 400) || abs(actTorque) > setpoint)) {
|
||||
if (lastAnglePID != angle && Pon && !manOut && !checkLimits(setpoint, abs(actTorque), upperLimit, lowerLimit) &&((abs(actTorque) >= 1000 || abs(RotSpeed) >= 400) || abs(actTorque) > setpoint)) {
|
||||
unsigned int output = myPID.compute(setpoint, actTorque);
|
||||
prg.setOutput(output);
|
||||
prg.ActOut = output;
|
||||
@@ -212,6 +214,15 @@ void loop() {
|
||||
prg.isRunning == false;
|
||||
}
|
||||
|
||||
bool checkLimits(float setpoint, int actVal, int upperLimit, int lowerLimit) {
|
||||
int error = setpoint - actVal;
|
||||
if (error <= upperLimit && error >= lowerLimit) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void interpolateWinkelArray() {
|
||||
int lastSetIndex = -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user