本文整理汇总了C++中PID::result方法的典型用法代码示例。如果您正苦于以下问题:C++ PID::result方法的具体用法?C++ PID::result怎么用?C++ PID::result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PID
的用法示例。
在下文中一共展示了PID::result方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
// Setup
setup_config(argc,argv);
setup_state();
setup_sigs();
// Objects
logger.setup();
server.setup();
sensor.setup();
heater.setup();
// Thread
if(pthread_create( &serverThread, NULL, serverPoll, NULL) != 0)
logger.fail("Server thread creation failure");
float chosenSetPoint;
int sensorResult = 0;
clock_t nextLoop;
conf.update = 1000/conf.update;
timeTick();
nextLoop = state.time + conf.update;
logger.info("Starting up Coffeed");
while(state.run)
{
// Time update
timeTick();
if(state.time >= nextLoop)
{
// Get sensor data
sensorResult = sensor.update();
// If active choose set point
if(state.active)
{
if(state.brewmode == TRUE)
chosenSetPoint = conf.brewPoint;
else
chosenSetPoint = conf.steamPoint;
// Sensor fault
if(!sensorResult)
{
logger.fail("Sensor read failure");
state.active = FALSE;
heater.off();
}
// Tuning mode
else if(state.tuning != FALSE)
{
// Begin
if(state.tuning == 2)
{
state.tuning = TRUE;
heater.setPower(50);
aTune.cancel();
//aTune.setNoiseBand(1);
//aTune.setOutputStep(50);
//aTune.setLookbackSec(20);
//aTune.setControlType(1);
logger.info("Autotuning BEGIN %f %f %f",conf.pgain,conf.igain,conf.dgain);
}
// While (1) we want to tune + (2) update is not done
else if(state.tuning == TRUE && aTune.update() == FALSE)
{
logger.info("tuning");
}
// Tuning complete because state.tuning = TRUE but aTune == TRUE
else
{
logger.info("tuning successful am I right?");
// Done
conf.pgain = aTune.getKp();
conf.igain = aTune.getKi();
conf.dgain = aTune.getKd();
logger.info("Autotuning FINISH %f %f %f",conf.pgain,conf.igain,conf.dgain);
state.tuning = FALSE;
}
}
// Regular control
else
{
// PID result
state.pidResult = pid.result(chosenSetPoint, state.tempPoint);
// Set Heater Duty
heater.setPower( state.pidResult );
// Log
logger.debug("PID Result %d temperature %f setP %f brewP %f steamP %f", state.pidResult, state.tempPoint, chosenSetPoint, conf.brewPoint, conf.steamPoint);
//.........这里部分代码省略.........