Service Pack 1 PID, FLOAT and TENS types compatib.

This commit is contained in:
2021-03-14 15:44:50 +03:00
parent a444ef9b31
commit 0d231345c2
33 changed files with 30262 additions and 29782 deletions

View File

@@ -280,6 +280,7 @@ int out_AC::Ctrl(itemCmd cmd, char* subItem , bool toExecute)
switch(suffixCode)
{
case S_SET:
case S_ESET:
set_tmp = cmd.getInt();
if (set_tmp >= 10 && set_tmp <= 30)
{

View File

@@ -30,13 +30,6 @@ int out_dmx::Status()
return driverStatus;
}
int out_dmx::isActive()
{
itemArgStore st;
st.aslong = item->getVal(); //Restore old params
debugSerial<< F(" val:")<<st.v<<endl;
return st.v;
}
int out_dmx::Poll(short cause)
{

View File

@@ -15,7 +15,7 @@ public:
int Poll(short cause) override;
int Stop() override;
int Status() override;
int isActive() override;
int getChanType() override;
// int Ctrl(itemCmd cmd, char* subItem=NULL) override;
// int PixelCtrl(itemCmd cmd) override;

View File

@@ -427,6 +427,7 @@ case S_NOTFOUND:
toExecute = true;
debugSerial<<F("Forced execution");
case S_SET:
case S_ESET:
if (!cmd.isValue()) return 0;
//TODO

View File

@@ -161,8 +161,8 @@ if (digitalPinHasPWM(pinUp))
if (inverted) velocity = map(-dif, 0, 10, 255, 0);
else velocity = map(-dif, 0, 10, 0, 255);
if (velocity>255) velocity=255;
if (velocity<0) velocity=0;
velocity = constrain (velocity, MIN_PWM, 255);
analogWrite(pinUp,velocity);
}
@@ -176,8 +176,7 @@ else if (digitalPinHasPWM(pinDown))
velocity = map(-dif, 0, 10, 0, 255);
else velocity = map(-dif, 0, 10, 255, 0);
if (velocity>255) velocity=255;
if (velocity<0) velocity=0;
velocity = constrain (velocity, MIN_PWM, 255);
analogWrite(pinDown,velocity);
}
else
@@ -200,11 +199,11 @@ if (digitalPinHasPWM(pinDown))
{
//Serial.println("pinDown PWM");
int velocity;
if (inverted) velocity = map(dif, 0, 10, 255, 0);
else velocity = map(dif, 0, 10, 0, 255);
if (inverted) velocity = map(dif, 0, 20, 255, 0);
else velocity = map(dif, 0, 20, 0, 255);
velocity = constrain (velocity, MIN_PWM, 255);
if (velocity>255) velocity=255;
if (velocity<0) velocity=0;
analogWrite(pinDown,velocity);
}
else
@@ -268,6 +267,7 @@ case S_NOTFOUND:
toExecute = true;
debugSerial<<F("Forced execution");
case S_SET:
case S_ESET:
if (!cmd.isValue()) return 0;
// item->setVal(cmd.getPercents());
if (item->getExt()) item->setExt(millisNZ()); //Extend motor time

View File

@@ -5,9 +5,10 @@
#include <item.h>
#ifndef POS_ERR
#define POS_ERR 2
#define POS_ERR 5
#endif
#define MIN_PWM 70
// The number of simultaniusly working motors
#ifndef MOTOR_QUOTE
#define MOTOR_QUOTE 1

View File

@@ -77,7 +77,8 @@ bool out_pid::getConfig()
{store->pid= new PID (&store->input, &store->output, &store->setpoint, kP, kI, kD, direction);
if (!store->pid) return false;
store->pid->SetMode(AUTOMATIC);
store->pid->SetOutputLimits(outMin,outMax);
//store->pid->SetOutputLimits(outMin,outMax);
store->pid->SetSampleTime(5000);
return true;}
else errorSerial<<F("PID already initialized")<<endl;
@@ -136,11 +137,11 @@ int out_pid::Poll(short cause)
if (store && store->pid && (Status() == CST_INITIALIZED) && item && (item->getCmd()!=CMD_OFF))
{
double prevOut=store->output;
store->pid->Compute();
if (abs(store->output-prevOut)>OUTPUT_TRESHOLD)
if(store->pid->Compute())
//if (abs(store->output-store-prevOut)>OUTPUT_TRESHOLD)
{
aJsonObject * oCmd = aJson.getArrayItem(item->itemArg, 1);
itemCmd value((float) store->output);
itemCmd value((float) (store->output * (100./255.)));
executeCommand(oCmd,-1,value);
}
@@ -182,6 +183,7 @@ return 1;
case S_NOTFOUND:
case S_SET:
case S_ESET:
// Setpoint for PID
if (!cmd.isValue()) return 0;
store->setpoint=cmd.getFloat();

View File

@@ -13,6 +13,7 @@ public:
double output;
double input;
double setpoint;
float prevOut;
int driverStatus;
};

View File

@@ -83,13 +83,7 @@ int out_pwm::Status()
return driverStatus;
}
int out_pwm::isActive()
{
itemArgStore st;
st.aslong = item->getVal(); //Restore old params
debugSerial<< F(" val:")<<st.v<<endl;
return st.v;
}
int out_pwm::Poll(short cause)
{

View File

@@ -15,7 +15,7 @@ public:
int Poll(short cause) override;
int Stop() override;
int Status() override;
int isActive() override;
int getChanType() override;
//int Ctrl(itemCmd cmd, char* subItem=NULL) override;
int PixelCtrl(itemCmd cmd, char* subItem=NULL, bool show=true ) override;

View File

@@ -87,13 +87,7 @@ int out_SPILed::Status()
return driverStatus;
}
int out_SPILed::isActive()
{
itemArgStore st;
st.aslong = item->getVal(); //Restore old params
debugSerial<< F(" val:")<<st.v<<endl;
return st.v;
}
int out_SPILed::Poll(short cause)
{

View File

@@ -20,7 +20,6 @@ public:
int Poll(short cause) override;
int Stop() override;
int Status() override;
int isActive() override;
int getChanType() override;
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
//int Ctrl(itemCmd cmd, char* subItem=NULL) override;