reballing


this second post topic posted in project guidence part pritty there im work on code project im sorry double post im having trouble got code read thermal couple max6675 issue not turnng on ssr here code advice great
code: [select]
/********************************************************
 * pid relayoutput example
 * same basic example, except time, output
 * going digital pin (we presume) controlling
 * relay.  pid designed output analog value,
 * relay can on/off.
 *
 *   to connect them use "time proportioning
 * control"  it's slow version of pwm.
 * first decide on window size (5000ms say.)
 * set pid adjust output between 0 , window
 * size.  lastly, add logic translates pid
 * output "relay on time" remainder of
 * window being "relay off time"
 ********************************************************/

#include <pid_v1.h>
#include "max6675.h"
#define relaypin 7

//max6675 stuff

int thermodo = 4;
int thermocs = 5;
int thermoclk = 6;
max6675 thermocouple(thermoclk, thermocs, thermodo);
int vccpin = 3;
int gndpin = 2;
//end max
//define variables we'll connecting to
double setpoint, input, output;

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

int windowsize = 1000; //default 5000
unsigned long windowstarttime;
void setup()
{
  windowstarttime = millis();
 
  //initialize variables we're linked to
  setpoint = 100;  // think temp in celcius aiming - default 100

  //tell pid range between 0 , full window size
  mypid.setoutputlimits(0, windowsize);

  //turn pid on
  mypid.setmode(automatic);
  //more max6675
   serial.begin(9600);
  pinmode(vccpin, output); digitalwrite(vccpin, high);
  pinmode(gndpin, output); digitalwrite(gndpin, low);
  //end max
}

void loop()
{
  delay(500);
  input = thermocouple.readcelsius();
  mypid.compute();
   serial.print(" input: ");
   serial.print(input);
   serial.print(" output: ");
   serial.print(output);
   serial.print(" setpoint: ");
   serial.println(setpoint);
  /************************************************
   * turn output pin on/off based on pid output
   ************************************************/
  if(millis() - windowstarttime > windowsize)
  { //time shift relay window
    windowstarttime += windowsize;
  }
  if(output > millis() - windowstarttime)
  {serial.print("relaypin high - ");  //digitalwrite(relaypin,high);
  }
  else {serial.print("relaypin low - ");//digitalwrite(relaypin,low);
   }
 
}

solved issue had set pin output thought done if wanted use 2 pins relaypin put in #define relaypin 7-8 automatically once set relay pin output both work ???????


Arduino Forum > Using Arduino > Programming Questions > reballing


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code