diff --git a/config/board.3drag.h b/config/board.3drag.h index a8528cd..0a28439 100644 --- a/config/board.3drag.h +++ b/config/board.3drag.h @@ -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. diff --git a/config/board.cnc-shield-v3.h b/config/board.cnc-shield-v3.h index 1c30c21..2d5300c 100644 --- a/config/board.cnc-shield-v3.h +++ b/config/board.cnc-shield-v3.h @@ -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. diff --git a/config/board.gen3.h b/config/board.gen3.h index 7e8f165..35a23a6 100644 --- a/config/board.gen3.h +++ b/config/board.gen3.h @@ -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. diff --git a/config/board.gen6.h b/config/board.gen6.h index 9c5630e..40d445b 100644 --- a/config/board.gen6.h +++ b/config/board.gen6.h @@ -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. diff --git a/config/board.gen7-arm.h b/config/board.gen7-arm.h index 003f066..c1e504d 100644 --- a/config/board.gen7-arm.h +++ b/config/board.gen7-arm.h @@ -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. diff --git a/config/board.gen7-v1.1-v1.3.h b/config/board.gen7-v1.1-v1.3.h index db3387e..e2006a7 100644 --- a/config/board.gen7-v1.1-v1.3.h +++ b/config/board.gen7-v1.1-v1.3.h @@ -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. diff --git a/config/board.gen7-v1.4.h b/config/board.gen7-v1.4.h index 93df06e..d134e65 100644 --- a/config/board.gen7-v1.4.h +++ b/config/board.gen7-v1.4.h @@ -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. diff --git a/config/board.melzi.h b/config/board.melzi.h index f33a8e3..d050ba5 100644 --- a/config/board.melzi.h +++ b/config/board.melzi.h @@ -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. diff --git a/config/board.nanoheart-v1.0.h b/config/board.nanoheart-v1.0.h index 07f2bb7..70c37ef 100644 --- a/config/board.nanoheart-v1.0.h +++ b/config/board.nanoheart-v1.0.h @@ -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. diff --git a/config/board.ramps-v1.2.h b/config/board.ramps-v1.2.h index 2d2eac4..5468707 100644 --- a/config/board.ramps-v1.2.h +++ b/config/board.ramps-v1.2.h @@ -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. diff --git a/config/board.ramps-v1.3.h b/config/board.ramps-v1.3.h index 5191ccc..e1722d0 100644 --- a/config/board.ramps-v1.3.h +++ b/config/board.ramps-v1.3.h @@ -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. diff --git a/config/board.rumba.h b/config/board.rumba.h index 766b134..50d4ac4 100644 --- a/config/board.rumba.h +++ b/config/board.rumba.h @@ -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. diff --git a/config/board.sanguinololu-v1.1.h b/config/board.sanguinololu-v1.1.h index 31d66a2..903c63a 100644 --- a/config/board.sanguinololu-v1.1.h +++ b/config/board.sanguinololu-v1.1.h @@ -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. diff --git a/config/board.sanguinololu-v1.2.h b/config/board.sanguinololu-v1.2.h index ebca784..163bff8 100644 --- a/config/board.sanguinololu-v1.2.h +++ b/config/board.sanguinololu-v1.2.h @@ -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. diff --git a/config/board.sanguish.h b/config/board.sanguish.h index 0514d3a..5b52dc1 100644 --- a/config/board.sanguish.h +++ b/config/board.sanguish.h @@ -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. diff --git a/config/board.sinaptec-at328-02.h b/config/board.sinaptec-at328-02.h index 99c73d6..e5e6d33 100644 --- a/config/board.sinaptec-at328-02.h +++ b/config/board.sinaptec-at328-02.h @@ -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. diff --git a/config/board.teensy++-v2.0.h b/config/board.teensy++-v2.0.h index 906454b..0c88d3b 100644 --- a/config/board.teensy++-v2.0.h +++ b/config/board.teensy++-v2.0.h @@ -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. diff --git a/config/board.teensy-v2.0.h b/config/board.teensy-v2.0.h index 2f27d50..089d2b4 100644 --- a/config/board.teensy-v2.0.h +++ b/config/board.teensy-v2.0.h @@ -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. diff --git a/config_wrapper.h b/config_wrapper.h index 249f51b..d6ea720 100644 --- a/config_wrapper.h +++ b/config_wrapper.h @@ -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 diff --git a/configtool/addsensordlg.py b/configtool/addsensordlg.py index 187bb85..60e5e8b 100644 --- a/configtool/addsensordlg.py +++ b/configtool/addsensordlg.py @@ -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 diff --git a/configtool/board.generic.h b/configtool/board.generic.h index aa5004a..acc0498 100644 --- a/configtool/board.generic.h +++ b/configtool/board.generic.h @@ -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. diff --git a/configtool/data.py b/configtool/data.py index eb5742a..67294cf 100644 --- a/configtool/data.py +++ b/configtool/data.py @@ -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) diff --git a/configtool/sensorpage.py b/configtool/sensorpage.py index 68bf203..a7b195f 100644 --- a/configtool/sensorpage.py +++ b/configtool/sensorpage.py @@ -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 diff --git a/spi.h b/spi.h index c5258f4..73d3c77 100644 --- a/spi.h +++ b/spi.h @@ -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 diff --git a/temp.c b/temp.c index 912506d..e0162cf 100644 --- a/temp.c +++ b/temp.c @@ -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); diff --git a/temp.h b/temp.h index f6ab663..de96bd3 100644 --- a/temp.h +++ b/temp.h @@ -27,6 +27,7 @@ typedef enum { TT_AD595, TT_PT100, TT_INTERCOM, + TT_MCP3008, TT_DUMMY, } temp_type_t; diff --git a/testcases/config.h.Profiling b/testcases/config.h.Profiling index 23348b9..64876f4 100644 --- a/testcases/config.h.Profiling +++ b/testcases/config.h.Profiling @@ -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.