reball ardiuno

well this is my second quest for help on here a very good member Larry has helped me collect my parts for this but now it time for the programming i need help with i am trying to use the bretts pid library to use heater elements to reach a basic temp of 250c. i'm having trouble interfacing this using my max 6675 chip witch is using d pins 23456 my ssr is on d pin 7 i will integrate my LCD later on just right now i would just like to get this thing to hit the set temp once i load the library i get no signs the ssr turns on or off i'm a very big noob any help would be great

post a photo and schematic and link to the ssr.

not sure how you have it wired, but there are a few ways to connect an LED to the same output as the SSR.

the ssr is connected to the ardiuno positive wire to pin 7 ground to ground pin max6675 connected to pins 23456 all digital pins I've verified the ssr works through the blink code i think its the code im using im just not sure im a noob completely

light0070702: i think its the code im using

No way of knowing without seeing the code. In the "Programming Questions" forum there are several pinned messages that tell you how to properly ask for programming help.

go back to the main forum page, select any forum, read the first post about how to post code.

then post your code. save yourself from the muddled thinkers who would post things like... I think line 27 is your problem. since you did not post your code, we have no clue how to help.

if the relay works when you bring pin 7 high or low, then you have a problem with your code. if the relay does not work when you bring pin 7 high or low, you have a problem in hardware.

i do apologize for not posting my code first so basically im starting off with the pid relay example code

#include <PID_v1.h>
#define RelayPin 7

//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);

int WindowSize = 5000;
unsigned long windowStartTime;
void setup()
{
  windowStartTime = millis();
  
  //initialize the variables we're linked to
  Setpoint = 100;

  //tell the PID to range between 0 and the full window size
  myPID.SetOutputLimits(0, WindowSize);

  //turn the PID on
  myPID.SetMode(AUTOMATIC);
}

void loop()
{
  Input = analogRead(0);
  myPID.Compute();

  /************************************************
   * turn the output pin on/off based on pid output
   ************************************************/
  unsigned long now = millis();
  if(now - windowStartTime>WindowSize)
  { //time to shift the Relay Window
    windowStartTime += WindowSize;
  }
  if(Output > now - windowStartTime) digitalWrite(RelayPin,HIGH);
  else digitalWrite(RelayPin,LOW);

if(Output > now - windowStartTime) digitalWrite(RelayPin,HIGH);
else digitalWrite(RelayPin,LOW);

should be

if(Output > now - windowStartTime){
digitalWrite(RelayPin,HIGH);
}
else
{
digitalWrite(RelayPin,LOW);

}

i started to write in parts i thought would help but i think im way off my mark with what i added here is the new adjusted code :

#include <max6675.h>
#include <PID_v1.h>
#define RelayPin 7

//Define Variables we'll be connecting to
double Setpoint, max6675, Output;

//Specify the links and initial tuning parameters
PID myPID(&max6675, &Output, &Setpoint,2,5,1, DIRECT);

int WindowSize = 5000;
unsigned long windowStartTime;
void setup()
{
  windowStartTime = millis();
  
  //initialize the variables we're linked to
  Setpoint = 100;

  //tell the PID to range between 0 and the full window size
  myPID.SetOutputLimits(0, WindowSize);

  //turn the PID on
  myPID.SetMode(AUTOMATIC);
}

void loop()
{
  Input = read max6675;
  myPID.Compute();

  /************************************************
   * turn the output pin on/off based on pid output
   ************************************************/
  unsigned long now = millis();
  if(now - windowStartTime>WindowSize)
  { //time to shift the Relay Window
    windowStartTime += WindowSize;
  }
  if(Output > now - windowStartTime){
    digitalWrite(RelayPin,HIGH);
    }
  else 
  {
digitalWrite(RelayPin,LOW);

  }

okay can you just look over this and see if im missing anything

#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 be connecting to
double Setpoint, Input, Output;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);

int WindowSize = 1000; //default is 5000
unsigned long windowStartTime;
void setup()
{
  windowStartTime = millis();
  
  //initialize the variables we're linked to
  Setpoint = 100;  // I think this is the temp in Celcius we are aiming for - default is 100

  //tell the PID to range between 0 and the full window size
  myPID.SetOutputLimits(0, WindowSize);

  //turn the 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 the output pin on/off based on pid output
   ************************************************/
  if(millis() - windowStartTime > WindowSize)
  { //time to shift the Relay Window
    windowStartTime += WindowSize;
  }
  if(Output > millis() - windowStartTime) 
  {Serial.print("HIGH - ");  //digitalWrite(RelayPin,HIGH);
  }
  else {Serial.print("LOW - ");//digitalWrite(RelayPin,LOW);
   }
  
}

dave-in-nj: if(Output > now - windowStartTime) digitalWrite(RelayPin,HIGH); else digitalWrite(RelayPin,LOW);

should be

if(Output > now - windowStartTime) { digitalWrite(RelayPin,HIGH); } else { digitalWrite(RelayPin,LOW); }

The brackets are only needed when the IF or ELSE clause contains more than one statement. In this case they don't so the brackets are not needed.

johnwasser: The brackets are only needed when the IF or ELSE clause contains more than one statement. In this case they don't so the brackets are not needed.

Not helpful.

This is a bracket:

(

This is a brace:

{

The brackets most certainly are necessary. The code won't work without them.

The braces are not required by the compiler but any time your if-else is written on multiple lines then they are needed for human readability and future maintainability. By 'future' I mean "when you add a new line of code tomorrow."

 {Serial.print("HIGH - ");  //digitalWrite(RelayPin,HIGH);[color=#222222][/color]
  }[color=#222222][/color]
  else {Serial.print("LOW - ");//digitalWrite(RelayPin,LOW);[color=#222222][/color]
   }[color=#222222][/color]

so. the digitalWrite are just comments and not actions ?

How does this sentence:-

The brackets most certainly are necessary. The code won't work without them.

Square with the one you follow it with:-

The braces are not required by the compiler but any time your if-else is written on multiple lines then they are needed for human readability and future maintainability.

Yes it is better to use braces but as you yourself say it is not necessary. I would disagree with your second point as well, it is a C coding style issue not a functional issue.

so im not telling the uno to actually turn the ssr on? one guy sugested slow down the loop to make sure the loop is not switching on off the relay too fast