Go Down

Topic: does not name a type.[ solved] (Read 2118 times) previous topic - next topic

Boardburner2

Apr 03, 2013, 12:48 am Last Edit: Apr 03, 2013, 08:43 pm by Boardburner2 Reason: 1
I have recently purchaced a reflow oven controller shield.
I have the very basic experience of programming arduino uno/3, flashing led etc.

after downloading the (proven working software ) for the shield I get the error message
PID does not name a type
at the following line

PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);

The libraries are present and the include statement does not generate an error.

The include also has the updated Arduino filename.
The file extensions also appear to be correct.
I am guessing that it may be something to do with libraries as I have not used them yet.
AFAICS there is no syntax error.
Many other errors but hoping once I understand this one I can fix the rest

tia

codlink

Post your code and a link to the library.  Also, please tell us where you installed the library.

How to use this forum
//LiNK

Boardburner2

Main sketch.

https://github.com/rocketscream/Reflow-Oven-Controller/blob/master/reflowOvenController.ino

Library files.

https://github.com/br3ttb/Arduino-PID-Library/tree/master/PID_v1

https://github.com/rocketscream/MAX31855/blob/master/MAX31855.cpp

These are placed in the arduino/libraries directory.

PaulS

Quote
These are placed in the arduino/libraries directory.

Did you start the IDE again after doing that?

Post a screenshot showing where the files really are.

Boardburner2

#4
Apr 03, 2013, 01:29 pm Last Edit: Apr 03, 2013, 01:40 pm by Boardburner2 Reason: 1

Quote
These are placed in the arduino/libraries directory.

Did you start the IDE again after doing that?


No , that problem is now solved.

I now get the same error with
      MAX31855 thermocouple(thermocoupleSOPin, thermocoupleCSPin,thermocoupleCLKPin);

I only have a.cpp file though, no .h file for this.
Is there a faq on library conventions somewhere ?

I am guessing that .h is a compiled .cpp ?
I have tried to compile the .cpp as a sketch but it does not work.

Screen shot > working on that.

PaulS

Quote
I am guessing that .h is a compiled .cpp ?

No. A .h file defines a class or set of functions. A .cpp file implements that class or set of functions.

Quote
I now get the same error with

Then the MAX31855 wasn't downloaded/installed correctly.

Quote
I only have a.cpp file though, no .h file for this

Post it.

Boardburner2


Quote
Then the MAX31855 wasn't downloaded/installed correctly.


Yes the zip file was incomplete.
.h is here

Code: [Select]
/***************************************************
  This is a library for the Adafruit Thermocouple Sensor w/MAX31855K

  Designed specifically to work with the Adafruit Thermocouple Sensor
  ----> https://www.adafruit.com/products/269

  These displays use SPI to communicate, 3 pins are required to 
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
****************************************************/


#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class Adafruit_MAX31855 {
public:
  Adafruit_MAX31855(int8_t SCLK, int8_t CS, int8_t MISO);

  double readInternal(void);
  double readCelsius(void);
  double readFarenheit(void);
  uint8_t readError();

private:
  int8_t sclk, miso, cs;
  uint32_t spiread32(void);
};


.cpp is here
Code: [Select]
/***************************************************
  This is a library for the Adafruit Thermocouple Sensor w/MAX31855K

  Designed specifically to work with the Adafruit Thermocouple Sensor
  ----> https://www.adafruit.com/products/269

  These displays use SPI to communicate, 3 pins are required to 
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
****************************************************/

#include "Adafruit_MAX31855.h"
#include <avr/pgmspace.h>
#include <util/delay.h>
#include <stdlib.h>


Adafruit_MAX31855::Adafruit_MAX31855(int8_t SCLK, int8_t CS, int8_t MISO) {
  sclk = SCLK;
  cs = CS;
  miso = MISO;

  //define pin modes
  pinMode(cs, OUTPUT);
  pinMode(sclk, OUTPUT);
  pinMode(miso, INPUT);

  digitalWrite(cs, HIGH);
}


double Adafruit_MAX31855::readInternal(void) {
  uint32_t v;

  v = spiread32();

  // ignore bottom 4 bits - they're just thermocouple data
  v >>= 4;

  // pull the bottom 11 bits off
  float internal = v & 0x7FF;
  internal *= 0.0625; // LSB = 0.0625 degrees
  // check sign bit!
  if (v & 0x800)
    internal *= -1;
  //Serial.print("\tInternal Temp: "); Serial.println(internal);
  return internal;
}

double Adafruit_MAX31855::readCelsius(void) {

  int32_t v;

  v = spiread32();

  //Serial.print("0x"); Serial.println(v, HEX);

  /*
  float internal = (v >> 4) & 0x7FF;
  internal *= 0.0625;
  if ((v >> 4) & 0x800)
    internal *= -1;
  Serial.print("\tInternal Temp: "); Serial.println(internal);
  */

  if (v & 0x7) {
    // uh oh, a serious problem!
    return NAN;
  }

  // get rid of internal temp data, and any fault bits
  v >>= 18;
  //Serial.println(v, HEX);

  // pull the bottom 13 bits off
  int16_t temp = v & 0x3FFF;

  // check sign bit
  if (v & 0x2000)
    temp |= 0xC000;
  //Serial.println(temp);
 
  double centigrade = v;

  // LSB = 0.25 degrees C
  centigrade *= 0.25;
  return centigrade;
}

uint8_t Adafruit_MAX31855::readError() {
  return spiread32() & 0x7;
}

double Adafruit_MAX31855::readFarenheit(void) {
  float f = readCelsius();
  f *= 9.0;
  f /= 5.0;
  f += 32;
  return f;
}

uint32_t Adafruit_MAX31855::spiread32(void) {
  int i;
  uint32_t d = 0;

  digitalWrite(sclk, LOW);
  _delay_ms(1);
  digitalWrite(cs, LOW);
  _delay_ms(1);

  for (i=31; i>=0; i--)
  {
    digitalWrite(sclk, LOW);
    _delay_ms(1);
    d <<= 1;
    if (digitalRead(miso)) {
      d |= 1;
    }

    digitalWrite(sclk, HIGH);
    _delay_ms(1);
  }

  digitalWrite(cs, HIGH);
  //Serial.println(d, HEX);
  return d;
}




UKHeliBob

Does it compile now that you have the .h file ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Boardburner2

No , I have the same error msg.
I have compared it to the pid library which now works but can see no difference in file types/locations.

UKHeliBob

What exactly are the names of the MAX31855 .h and .cpp files and what is the name of the folder that they are in ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Boardburner2

#10
Apr 03, 2013, 06:10 pm Last Edit: Apr 03, 2013, 06:25 pm by Boardburner2 Reason: 1
in libraries/max31855

max31855.h
max31855.cpp

and in libraries/adafruit_max31855

adafruit_31855.h
adafruit_31855.cpp

The most recent ino file from rocketscream at github only seems to reference the max31855 library though.

max31855.h

Code: [Select]
/***************************************************
 This is a library for the Adafruit Thermocouple Sensor w/MAX31855K

 Designed specifically to work with the Adafruit Thermocouple Sensor
 ----> https://www.adafruit.com/products/269

 These displays use SPI to communicate, 3 pins are required to  
 interface
 Adafruit invests time and resources providing this open source code,
 please support Adafruit and open-source hardware by purchasing
 products from Adafruit!

 Written by Limor Fried/Ladyada for Adafruit Industries.  
 BSD license, all text above must be included in any redistribution
****************************************************/


#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

class Adafruit_MAX31855 {
public:
 Adafruit_MAX31855(int8_t SCLK, int8_t CS, int8_t MISO);

 double readInternal(void);
 double readCelsius(void);
 double readFarenheit(void);
 uint8_t readError();

private:
 int8_t sclk, miso, cs;
 uint32_t spiread32(void);
};


max31855.cpp

Code: [Select]
/***************************************************
 This is a library for the Adafruit Thermocouple Sensor w/MAX31855K

 Designed specifically to work with the Adafruit Thermocouple Sensor
 ----> https://www.adafruit.com/products/269

 These displays use SPI to communicate, 3 pins are required to  
 interface
 Adafruit invests time and resources providing this open source code,
 please support Adafruit and open-source hardware by purchasing
 products from Adafruit!

 Written by Limor Fried/Ladyada for Adafruit Industries.  
 BSD license, all text above must be included in any redistribution
****************************************************/

#include "Adafruit_MAX31855.h"
#include <avr/pgmspace.h>
#include <util/delay.h>
#include <stdlib.h>


Adafruit_MAX31855::Adafruit_MAX31855(int8_t SCLK, int8_t CS, int8_t MISO) {
 sclk = SCLK;
 cs = CS;
 miso = MISO;

 //define pin modes
 pinMode(cs, OUTPUT);
 pinMode(sclk, OUTPUT);
 pinMode(miso, INPUT);

 digitalWrite(cs, HIGH);
}


double Adafruit_MAX31855::readInternal(void) {
 uint32_t v;

 v = spiread32();

 // ignore bottom 4 bits - they're just thermocouple data
 v >>= 4;

 // pull the bottom 11 bits off
 float internal = v & 0x7FF;
 internal *= 0.0625; // LSB = 0.0625 degrees
 // check sign bit!
 if (v & 0x800)
   internal *= -1;
 //Serial.print("\tInternal Temp: "); Serial.println(internal);
 return internal;
}

double Adafruit_MAX31855::readCelsius(void) {

 int32_t v;

 v = spiread32();

 //Serial.print("0x"); Serial.println(v, HEX);

 /*
 float internal = (v >> 4) & 0x7FF;
 internal *= 0.0625;
 if ((v >> 4) & 0x800)
   internal *= -1;
 Serial.print("\tInternal Temp: "); Serial.println(internal);
 */

 if (v & 0x7) {
   // uh oh, a serious problem!
   return NAN;
 }

 // get rid of internal temp data, and any fault bits
 v >>= 18;
 //Serial.println(v, HEX);

 // pull the bottom 13 bits off
 int16_t temp = v & 0x3FFF;

 // check sign bit
 if (v & 0x2000)
   temp |= 0xC000;
 //Serial.println(temp);
 
 double centigrade = v;

 // LSB = 0.25 degrees C
 centigrade *= 0.25;
 return centigrade;
}

uint8_t Adafruit_MAX31855::readError() {
 return spiread32() & 0x7;
}

double Adafruit_MAX31855::readFarenheit(void) {
 float f = readCelsius();
 f *= 9.0;
 f /= 5.0;
 f += 32;
 return f;
}

uint32_t Adafruit_MAX31855::spiread32(void) {
 int i;
 uint32_t d = 0;

 digitalWrite(sclk, LOW);
 _delay_ms(1);
 digitalWrite(cs, LOW);
 _delay_ms(1);

 for (i=31; i>=0; i--)
 {
   digitalWrite(sclk, LOW);
   _delay_ms(1);
   d <<= 1;
   if (digitalRead(miso)) {
     d |= 1;
   }

   digitalWrite(sclk, HIGH);
   _delay_ms(1);
 }

 digitalWrite(cs, HIGH);
 //Serial.println(d, HEX);
 return d;
}


I have tried going through the ino file and changing MAX31855.h to adafruit_MAX31855.h but to no avail.
all the above came in the same zip file and are said to work together.

Boardburner2

ok

Now I read my last post and understand.
The ino uses the max31855 library but the one I have appears to be a renamed copy of the addafruitmax31855 library.
I would have spotted this much earlier but the ide will not open cpp or h files and my text editor would not display the properly,cr/lf missing causes the file to be displayed as one line.

I was using notepad, any suggestions ?

codlink

notepad++

http://notepad-plus-plus.org/download/v6.3.2.html

Awesome program and free!
//LiNK

UKHeliBob

Another vote for Notepad++
It can be set to understand C++ source files so that functions and for/while loops etc are recognised and highlighted and can be collapsed to make better use of screen space.

Very nice to use
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Boardburner2

Many thanks.
That looks to be an excellent editor.

Found the libraries now and compiles, however I now get

avrdude: stk500_getsync(): not in sync: resp=0x00

Thos is a uno and not a mega, I have previously run small sketches though.
Should I be starting a new topic for this ?

Go Up