Adding ON/OFF control & temp display to PID SCRIPT


hey playing of pid scripts , arduino.

i've got hooked 2 things, heater heat set temp , thermocouple take readings , adjust accordingly.

my questions script...

i've  got following  script uploaded board:

/********************************************************
* pid simple example
* reading analog input 0 control analog pwm output 3
********************************************************/

#include <pid_beta6.h>

//define variables we'll connecting to
double setpoint, input, output;

//specify links , initial tuning parameters
pid mypid(&input, &output, &setpoint, 2,5,1);

void setup()
{
 //initialize variables we're linked to
 input = analogread(0);
 setpoint = 150;
 
 //turn pid on
 mypid.setmode(auto);
 mypid.setsampletime(250);
 mypid.settunings(2,3,1);
 
}

void loop()
{
 input = analogread(0);
 mypid.compute();
 analogwrite(3,output);
}

now, when board turned on, starts heating setpoint , magnificent job of keeping there.

what trying achieve adding on/off button trigger board start heating element when signal button received also, add 2 buttons adjust temperature or down, , lcd readout of setpoint, , actual temperature via single serial wire.

can point me direction might find example of this?  or throw code down in post?  i imagine first 2 things trying achieve relatively simple in terms of coding. simple on/off thing , temp up/down in response buttons.

thanks in advance responses!

okay... i've got 3 spst pushbutton switches (normally open) hooked +5v  and outputs of each going digital  pins 4--- (trigger or operation button)  5---(increase temp 1 degree) , 6----(decrease temp)

as far on/off operation goes.. kind of on right track??... i'd keep code simple possible.


void setup()
{
 //initialize variables we're linked to
 input = analogread(0);
 input = digitalread(4);
 input = digitalread(5);
 input = digitalread(6);
 setpoint = 150;
 
 //turn pid on
 mypid.setmode(auto);
 mypid.setsampletime(250);
 mypid.settunings(2,3,1);
 mypid.setoutputlimits(0, 178.5);
 
}

void loop()
{
 input = analogread(0);
 mypid.compute();
 
 if(digitalread(4),high);
  analogwrite(3,output);
  }else{
     i dont know put here??
}


how's going?

did okay introducing new inputs? should digital or analog?


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Adding ON/OFF control & temp display to PID SCRIPT


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums