--- Marlin/Configuration.h 2013-12-07 04:31:28.000000000 -0500 +++ Marlin/Configuration.h 2014-01-05 13:49:42.120582949 -0500 @@ -19,7 +19,7 @@ #define STRING_CONFIG_H_AUTHOR "Adrian/Lawsy/Rincewind/Tealvince" // Who made the changes. // change to 3 for SD3 //{SD Patch} -#define SOLIDOODLE_VERSION 3 //{SD Patch} +#define SOLIDOODLE_VERSION 2 //{SD Patch} // Enable support for either of the Z-Wobble Solutions //#define ZWOBBLE_PATCH //{SD Patch} (+5528 Bytes) @@ -78,9 +78,19 @@ // Original Solidoodle w/ Sanguinololu shipped pre June 2013 - Choose 62 // Solidoodle w/ Printrboard shipped post June 2013 - Choose 81 #ifndef MOTHERBOARD -#define MOTHERBOARD 62 +#define MOTHERBOARD 81 #endif +// This is a hacky definition that is designed to get my force sensitive resistor +// as bed level detctor working. It will cause TEMP_PIN_2 to monitor the analog +// value of the force sensitive resistor rather than a thermistor. Define it to +// be the analog pin number where the FSR is connected (or -1 for no FSR). +#define TEMP_2_PIN_IS_BEDLEVEL_FSR 3 + +// If a bedleve FSR is installed, this is the number of samples to accumulate +// to provide a smoothed out running average +#define BEDLEVEL_FSR_SAMPLE_COUNT 5 + // Define this to set a custom name for your generic Mendel, // #define CUSTOM_MENDEL_NAME "This Mendel" --- Marlin/Marlin_main.cpp 2013-12-07 04:31:28.000000000 -0500 +++ Marlin/Marlin_main.cpp 2014-01-05 18:45:23.577528455 -0500 @@ -160,6 +160,7 @@ // M400 - Finish all moves // M401 - Lower z-probe if present // M402 - Raise z-probe if present +// M402 - report bedlevel FSR smoothed average value // M500 - stores paramters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. @@ -973,6 +974,28 @@ #endif // #ifdef ENABLE_AUTO_BED_LEVELING +#if TEMP_2_PIN_IS_BEDLEVEL_FSR != -1 + +static void report_bedlevel_fsr() { + float avg = 0.0; + for (int i = 0; i < BEDLEVEL_FSR_SAMPLE_COUNT; ++i) { + avg += (float)bedlevel_fsr_samples[i]; + } + avg /= (float)BEDLEVEL_FSR_SAMPLE_COUNT; + SERIAL_PROTOCOLPGM("FSR:"); + SERIAL_PROTOCOL(avg); + SERIAL_PROTOCOL(" COUNT: "); + SERIAL_PROTOCOL(bedlevel_count); + SERIAL_PROTOCOL(" SAMPLES:"); + for (int i = 0; i < BEDLEVEL_FSR_SAMPLE_COUNT; ++i) { + SERIAL_PROTOCOL(" "); + SERIAL_PROTOCOL(bedlevel_fsr_samples[i]); + } + SERIAL_PROTOCOLLN(""); +} + +#endif + static void homeaxis(int axis) { #define HOMEAXIS_DO(LETTER) \ ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1)) @@ -2579,6 +2602,13 @@ } break; #endif +#if TEMP_2_PIN_IS_BEDLEVEL_FSR != -1 + case 403: + { + report_bedlevel_fsr(); // Report the bedlevel FSR running average + } + break; +#endif case 500: // M500 Store settings in EEPROM { Config_StoreSettings(); --- Marlin/pins.h 2013-12-07 04:31:28.000000000 -0500 +++ Marlin/pins.h 2014-01-05 10:07:46.258029404 -0500 @@ -1464,7 +1464,7 @@ #endif #define TEMP_1_PIN -1 -#define TEMP_2_PIN -1 +#define TEMP_2_PIN TEMP_2_PIN_IS_BEDLEVEL_FSR #define SDPOWER -1 #define SDSS 14 --- Marlin/temperature.h 2013-12-07 04:31:28.000000000 -0500 +++ Marlin/temperature.h 2014-01-05 15:11:17.872809832 -0500 @@ -44,6 +44,10 @@ #ifdef TEMP_SENSOR_1_AS_REDUNDANT extern float redundant_temperature; #endif +#if TEMP_2_PIN_IS_BEDLEVEL_FSR != -1 + extern int bedlevel_fsr_samples[BEDLEVEL_FSR_SAMPLE_COUNT]; + extern int bedlevel_count; +#endif #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 extern unsigned char soft_pwm_bed; --- Marlin/temperature.cpp 2013-12-07 04:31:28.000000000 -0500 +++ Marlin/temperature.cpp 2014-01-05 20:05:31.036547555 -0500 @@ -47,6 +47,12 @@ int redundant_temperature_raw = 0; float redundant_temperature = 0.0; #endif +#if TEMP_2_PIN_IS_BEDLEVEL_FSR != -1 + int bedlevel_fsr_raw = 0; + int bedlevel_fsr_samples[BEDLEVEL_FSR_SAMPLE_COUNT] = { 0 }; + int bedlevel_fsr_next_sample = 0; + int bedlevel_count = 0; +#endif #ifdef PIDTEMP float Kp=DEFAULT_Kp; float Ki=(DEFAULT_Ki*PID_dT); @@ -684,6 +690,12 @@ #ifdef TEMP_SENSOR_1_AS_REDUNDANT redundant_temperature = analog2temp(redundant_temperature_raw, 1); #endif + #if TEMP_2_PIN_IS_BEDLEVEL_FSR != -1 + bedlevel_fsr_samples[bedlevel_fsr_next_sample++] = bedlevel_fsr_raw; + if (bedlevel_fsr_next_sample == BEDLEVEL_FSR_SAMPLE_COUNT) { + bedlevel_fsr_next_sample = 0; + } + #endif //Reset the watchdog after we know we have a temperature measurement. watchdog_reset(); @@ -916,13 +928,15 @@ #endif #endif - #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 - target_temperature[2]=0; - soft_pwm[2]=0; - #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 - WRITE(HEATER_2_PIN,LOW); - #endif - #endif + #if TEMP_2_PIN_IS_BEDLEVEL_FSR == -1 + #if defined(TEMP_2_PIN) && TEMP_2_PIN > -1 + target_temperature[2]=0; + soft_pwm[2]=0; + #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 + WRITE(HEATER_2_PIN,LOW); + #endif + #endif + #endif #if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1 target_temperature_bed=0; @@ -1170,6 +1184,7 @@ #endif ADMUX = ((1 << REFS0) | (TEMP_2_PIN & 0x07)); ADCSRA |= 1< -1) raw_temp_2_value += ADC; + bedlevel_count++; #endif temp_state = 0; temp_count++; @@ -1198,6 +1214,9 @@ #ifdef TEMP_SENSOR_1_AS_REDUNDANT redundant_temperature_raw = raw_temp_1_value; #endif +#if TEMP_2_PIN_IS_BEDLEVEL_FSR != -1 + bedlevel_fsr_raw = raw_temp_2_value; +#endif #if EXTRUDERS > 2 current_temperature_raw[2] = raw_temp_2_value; #endif