Added support for MCP3008 and MCP3004 ADC for temperature read

This commit is contained in:
Witold Sowa 2016-04-07 22:46:00 +02:00 committed by Markus Hitter
parent 52e5d784fd
commit fdf6dbe849
27 changed files with 556 additions and 165 deletions

View File

@ -112,6 +112,17 @@
*/
#define SD_CARD_SELECT_PIN DIO25
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -124,6 +135,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -133,6 +146,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -151,12 +165,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -115,6 +115,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -127,6 +138,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -136,6 +149,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -155,12 +169,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -112,6 +112,17 @@
*/
#define SD_CARD_SELECT_PIN DIO4
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -124,6 +135,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -133,6 +146,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -150,12 +164,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -112,6 +112,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -124,6 +135,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -133,6 +146,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -150,12 +164,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -112,6 +112,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -124,6 +135,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -133,6 +146,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -151,12 +165,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -116,6 +116,17 @@
*/
#define SD_CARD_SELECT_PIN DIO10
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -128,6 +139,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -137,6 +150,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -155,12 +169,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -116,6 +116,17 @@
*/
#define SD_CARD_SELECT_PIN DIO10
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -128,6 +139,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -137,6 +150,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -156,12 +170,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -115,6 +115,17 @@
*/
#define SD_CARD_SELECT_PIN DIO31
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -127,6 +138,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -136,6 +149,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -154,12 +168,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -115,6 +115,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -127,6 +138,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -136,6 +149,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -154,12 +168,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -113,6 +113,17 @@
*/
#define SD_CARD_SELECT_PIN DIO53
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -125,6 +136,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -134,6 +147,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -152,12 +166,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -113,6 +113,17 @@
*/
#define SD_CARD_SELECT_PIN DIO53
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -125,6 +136,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -134,6 +147,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -153,12 +167,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -112,6 +112,17 @@
*/
#define SD_CARD_SELECT_PIN DIO53
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -124,6 +135,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -133,6 +146,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -154,12 +168,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -115,6 +115,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -127,6 +138,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -136,6 +149,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -154,12 +168,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -115,6 +115,17 @@
*/
#define SD_CARD_SELECT_PIN DIO33
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -127,6 +138,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -136,6 +149,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -154,12 +168,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -115,6 +115,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -127,6 +138,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -136,6 +149,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -154,12 +168,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -115,6 +115,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -127,6 +138,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -136,6 +149,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -154,12 +168,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -112,6 +112,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -124,6 +135,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -133,6 +146,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -151,12 +165,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -112,6 +112,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -124,6 +135,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -133,6 +146,7 @@
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -151,12 +165,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -37,7 +37,8 @@
/**
Check wether we need SPI.
*/
#if (defined SD_CARD_SELECT_PIN || defined TEMP_MAX6675) && ! defined SIMULATOR
#if (defined SD_CARD_SELECT_PIN || defined TEMP_MAX6675 || \
defined TEMP_MC3008) && ! defined SIMULATOR
#define SPI
#endif

View File

@ -509,7 +509,7 @@ class AddSensorDlg(wx.Dialog):
self.chPresets.SetSelection(0)
def selectSensorType(self, lbl):
if lbl == "Thermistor":
if lbl == "Thermistor" or lbl == "MCP3008":
self.currentMode = MODE_THERMISTOR
else:
self.currentMode = MODE_NONTHERM

View File

@ -113,6 +113,17 @@
*/
#define SD_CARD_SELECT_PIN DIO53
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
* *
@ -125,6 +136,8 @@
#endif
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
@ -134,6 +147,7 @@
#define TEMP_AD595
#define TEMP_PT100
#define TEMP_INTERCOM
#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.
@ -153,12 +167,12 @@
"noheater".
Types are same as TEMP_ list above - TT_MAX6675, TT_THERMISTOR, TT_AD595,
TT_PT100, TT_INTERCOM. See list in temp.c.
TT_PT100, TT_INTERCOM, TT_MCP3008. See list in temp.c.
The "additional" field is used for TT_THERMISTOR only. It defines the
name of the table(s) in thermistortable.h to use. This name is arbitrary,
often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED. Also,
several sensors can share the same table, which saves binary size.
The "additional" field is used for TT_THERMISTOR and TT_MCP3008 only. It
defines the name of the table(s) in thermistortable.h to use. This name is
arbitrary, often used names include THERMISTOR_EXTRUDER and THERMISTOR_BED.
Also, several sensors can share the same table, which saves binary size.
For a GEN3 set temp_type to TT_INTERCOM and temp_pin to AIO0. The pin
won't be used in this case.

View File

@ -12,7 +12,7 @@ pinNamesWithBlank = ["-"] + pinNames
sensorTypes = {'MAX6675': "TT_MAX6675", 'Thermistor': "TT_THERMISTOR",
'AD595': "TT_AD595", 'PT100': "TT_PT100",
'Intercom': "TT_INTERCOM"}
'Intercom': "TT_INTERCOM", 'MCP3008': "TT_MCP3008"}
BSIZE = (100, 60)
BSIZESMALL = (90, 30)

View File

@ -18,12 +18,16 @@ class SensorsPage(wx.Panel, Page):
self.sensorTypeKeys = {'TT_MAX6675': 'TEMP_MAX6675',
'TT_THERMISTOR': 'TEMP_THERMISTOR',
'TT_AD595': 'TEMP_AD595', 'TT_PT100': 'TEMP_PT100',
'TT_INTERCOM': 'TEMP_INTERCOM'}
'TT_INTERCOM': 'TEMP_INTERCOM',
'TT_MCP3008': 'TEMP_MCP3008'}
self.labels = {'TEMP_MAX6675': "MAX6675", 'TEMP_THERMISTOR': "Thermistor",
'TEMP_AD595': "AD595", 'TEMP_PT100': "PT100",
'TEMP_INTERCOM': "Intercom"}
'TEMP_INTERCOM': "Intercom",
'TEMP_MCP3008': 'MCP3008',
'MCP3008_SELECT_PIN': "MCP3008 CS Pin:"}
self.validPins = pinNames
labelWidth = 120
sz = wx.GridBagSizer()
sz.AddSpacer((10, 10), pos = (0, 0))
@ -65,6 +69,10 @@ class SensorsPage(wx.Panel, Page):
sz.Add(bsz, pos = (1, 3))
k = "MCP3008_SELECT_PIN"
tc = self.addPinChoice(k, "", pinNames, True, labelWidth)
sz.Add(tc, pos = (2, 1))
self.SetSizer(sz)
self.enableAll(False)
@ -143,6 +151,13 @@ class SensorsPage(wx.Panel, Page):
def insertValues(self, cfgValues):
Page.insertValues(self, cfgValues)
for k in self.choices.keys():
if k in cfgValues.keys():
self.choicesOriginal[k] = cfgValues[k]
self.setChoice(k, cfgValues, "-")
else:
print "Key " + k + " not found in config data."
self.bAdd.Enable(True)
def setSensors(self, sensors):
@ -186,4 +201,11 @@ class SensorsPage(wx.Panel, Page):
for v in values.keys():
result[v] = values[v]
for k in self.choices.keys():
if result[k][0] == "-":
if k in self.choicesOriginal.keys():
result[k] = self.choicesOriginal[k][0], False
else:
result[k] = "", False
return result

14
spi.h
View File

@ -11,7 +11,7 @@
Test configuration.
*/
#ifdef __ARMEL__
#error SPI (SD_CARD_SELECT_PIN, TEMP_MAX6675) not yet supported on ARM.
#error SPI (SD_CARD_SELECT_PIN, TEMP_MAX6675, TEMP_MCP3008) not yet supported on ARM.
#endif
// Uncomment this to double SPI frequency from (F_CPU / 4) to (F_CPU / 2).
@ -55,6 +55,18 @@ inline void spi_deselect_max6675(void) {
}
#endif /* TEMP_MAX6675 */
#ifdef TEMP_MCP3008
static void spi_select_mcp3008(void) __attribute__ ((always_inline));
inline void spi_select_mcp3008(void) {
WRITE(MCP3008_SELECT_PIN, 0);
}
static void spi_deselect_mcp3008(void) __attribute__ ((always_inline));
inline void spi_deselect_mcp3008(void) {
WRITE(MCP3008_SELECT_PIN, 1);
}
#endif /* TEMP_MCP3008 */
/** Set SPI clock speed to something between 100 and 400 kHz.
This is needed for initialising SD cards. We set the whole SPCR register

187
temp.c
View File

@ -34,6 +34,14 @@
#include "spi.h"
#endif
#ifdef TEMP_MCP3008
#ifdef __ARMEL__
#error MCP3008 sensors (TEMP_MCP3008) not yet supported on ARM.
#endif
#include "spi.h"
#include "thermistortable.h"
#endif
#ifdef TEMP_THERMISTOR
#include "analog.h"
#include "thermistortable.h"
@ -94,6 +102,13 @@ void temp_init() {
// Intentionally no break, we might have more than one sensor type.
#endif
#ifdef TEMP_MCP3008
case TT_MCP3008:
SET_OUTPUT(MCP3008_SELECT_PIN);
spi_deselect_mcp3008();
// Intentionally no break, we might have more than one sensor type.
#endif
#ifdef TEMP_THERMISTOR
// handled by analog_init()
/* case TT_THERMISTOR:
@ -125,6 +140,104 @@ void temp_init() {
}
}
/**
Read a measurement from the MCP3008 analog-digital-converter (ADC).
\param channel The ADC channel to read.
\return The raw ADC reading.
Documentation for this ADC see
https://www.adafruit.com/datasheets/MCP3008.pdf.
*/
#ifdef TEMP_MCP3008
static uint16_t mcp3008_read(uint8_t channel) {
uint8_t temp_h, temp_l;
spi_select_mcp3008();
// Start bit.
spi_rw(0x01);
// Send read address and get MSB, then LSB byte.
temp_h = spi_rw((0b1000 | channel) << 4) & 0b11;
temp_l = spi_rw(0);
spi_deselect_mcp3008();
return temp_h << 8 | temp_l;
}
#endif /* TEMP_MCP3008 */
/**
Look up a degree Celsius value from a raw ADC reading.
\param temp The raw ADC reading to look up.
\param sensor The sensor to look up. Each sensor can have its own table.
\return Degree Celsius reading in 14.2 fixed decimal format.
The table(s) looked up here are in thermistortable.h and are created on the
fly by Configtool when saving config.h. They contain value pairs mapping
raw ADC readings to 14.2 values already, so all we have to do here is to
inter-/extrapolate.
*/
#if defined TEMP_THERMISTOR || defined TEMP_MCP3008
static uint16_t temp_table_lookup(uint16_t temp, uint8_t sensor) {
uint8_t j;
uint8_t table_num = temp_sensors[sensor].additional;
for (j = 1; j < NUMTEMPS; j++) {
if (pgm_read_word(&(temptable[table_num][j][0])) > temp) {
if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR("pin:%d Raw ADC:%d table entry: %d"),
temp_sensors[sensor].temp_pin, temp, j);
// Wikipedia's example linear interpolation formula.
// y = ((x - x₀)y₁ + (x₁-x)y₀) / (x₁ - x₀)
// y = temp
// x = ADC reading
// x₀= temptable[j-1][0]
// x₁= temptable[j][0]
// y₀= temptable[j-1][1]
// y₁= temptable[j][1]
temp = (
// ((x - x₀)y₁
((uint32_t)temp - pgm_read_word(&(temptable[table_num][j-1][0]))) *
pgm_read_word(&(temptable[table_num][j][1]))
// +
+
// (x₁-x)y₀)
(pgm_read_word(&(temptable[table_num][j][0])) - (uint32_t)temp) *
pgm_read_word(&(temptable[table_num][j - 1][1])))
// /
/
// (x₁ - x₀)
(pgm_read_word(&(temptable[table_num][j][0])) -
pgm_read_word(&(temptable[table_num][j - 1][0])));
if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR(" temp:%d.%d"), temp / 4, (temp % 4) * 25);
// Value found, no need to read the table further.
break;
}
}
if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR(" Sensor:%d\n"), sensor);
// Clamp for overflows.
if (j == NUMTEMPS)
temp = temptable[table_num][NUMTEMPS - 1][1];
return temp;
}
#endif /* TEMP_THERMISTOR || TEMP_MCP3008 */
/// called every 10ms from clock.c - check all temp sensors that are ready for checking
void temp_sensor_tick() {
temp_sensor_t i = 0;
@ -172,67 +285,25 @@ void temp_sensor_tick() {
#endif /* TEMP_MAX6675 */
#ifdef TEMP_THERMISTOR
case TT_THERMISTOR:
do {
uint8_t j, table_num;
//Read current temperature
temp = analog_read(i);
// for thermistors the thermistor table number is in the additional field
table_num = temp_sensors[i].additional;
case TT_THERMISTOR:
// Read current temperature.
temp = temp_table_lookup(analog_read(i), i);
//Calculate real temperature based on lookup table
for (j = 1; j < NUMTEMPS; j++) {
if (pgm_read_word(&(temptable[table_num][j][0])) > temp) {
// Thermistor table is already in 14.2 fixed point
#ifndef EXTRUDER
if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR("pin:%d Raw ADC:%d table entry: %d"),temp_sensors[i].temp_pin,temp,j);
#endif
// Linear interpolating temperature value
// y = ((x - x₀)y₁ + (x₁-x)y₀ ) / (x₁ - x₀)
// y = temp
// x = ADC reading
// x₀= temptable[j-1][0]
// x₁= temptable[j][0]
// y₀= temptable[j-1][1]
// y₁= temptable[j][1]
// y =
// Wikipedia's example linear interpolation formula.
temp = (
// ((x - x₀)y₁
((uint32_t)temp - pgm_read_word(&(temptable[table_num][j-1][0]))) * pgm_read_word(&(temptable[table_num][j][1]))
// +
+
// (x₁-x)
(pgm_read_word(&(temptable[table_num][j][0])) - (uint32_t)temp)
// y₀ )
* pgm_read_word(&(temptable[table_num][j-1][1])))
// /
/
// (x₁ - x₀)
(pgm_read_word(&(temptable[table_num][j][0])) - pgm_read_word(&(temptable[table_num][j-1][0])));
#ifndef EXTRUDER
if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR(" temp:%d.%d"),temp/4,(temp%4)*25);
#endif
break;
}
}
#ifndef EXTRUDER
if (DEBUG_PID && (debug_flags & DEBUG_PID))
sersendf_P(PSTR(" Sensor:%d\n"),i);
#endif
//Clamp for overflows
if (j == NUMTEMPS)
temp = temptable[table_num][NUMTEMPS-1][1];
temp_sensors_runtime[i].next_read_time = 0;
} while (0);
break;
temp_sensors_runtime[i].next_read_time = 0;
break;
#endif /* TEMP_THERMISTOR */
#ifdef TEMP_MCP3008
case TT_MCP3008:
// Read current temperature.
temp = temp_table_lookup(mcp3008_read(temp_sensors[i].temp_pin), i);
// This is an SPI read so it is not as fast as on-chip ADC. A read
// every 100ms should be sufficient.
temp_sensors_runtime[i].next_read_time = 10;
break;
#endif /* TEMP_MCP3008 */
#ifdef TEMP_AD595
case TT_AD595:
temp = analog_read(i);

1
temp.h
View File

@ -27,6 +27,7 @@ typedef enum {
TT_AD595,
TT_PT100,
TT_INTERCOM,
TT_MCP3008,
TT_DUMMY,
} temp_type_t;

View File

@ -367,6 +367,17 @@
*/
//#define SD_CARD_SELECT_PIN xxxx
/** \def MCP3008_SELECT_PIN
Chip Select pin of the MCP3008 ADC.
MCP3008/4 analog-digital converter works over SPI and has a Chip Select pin.
Choose this pin according to where the MCP3008 is connected. Setting this
pin is required only if at least one temperature sensor of type MCP3008 is
configured. Else it's ignored.
*/
//#define MCP3008_SELECT_PIN xxxx
/***************************************************************************\
@ -405,12 +416,19 @@
*/
#define TEMP_EWMA 1.0
/// which temperature sensors are you using? List every type of sensor you use here once, to enable the appropriate code. Intercom is the gen3-style separate extruder board.
// #define TEMP_MAX6675
#define TEMP_THERMISTOR
// #define TEMP_AD595
// #define TEMP_PT100
// #define TEMP_INTERCOM
/** \def TEMP_MAX6675 TEMP_THERMISTOR TEMP_AD595 TEMP_PT100 TEMP_INTERCOM
\def TEMP_MCP3008
Which temperature sensor types are you using? Leave all used ones
uncommented, comment out all others to save binary size and enhance
performance.
*/
//#define TEMP_MAX6675
#define TEMP_THERMISTOR
//#define TEMP_AD595
//#define TEMP_PT100
//#define TEMP_INTERCOM
//#define TEMP_MCP3008
/** \def TEMP_SENSOR_PIN
Temperature sensor pins a user should be able to choose from in configtool.