From 38afe46c0bf866547f1751f25912c28b4eb9a2e5 Mon Sep 17 00:00:00 2001 From: johnnyr Date: Wed, 10 Nov 2010 11:23:12 -0800 Subject: Added Fan control --- Tonokip_Firmware/Tonokip_Firmware.pde | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'Tonokip_Firmware/Tonokip_Firmware.pde') diff --git a/Tonokip_Firmware/Tonokip_Firmware.pde b/Tonokip_Firmware/Tonokip_Firmware.pde index 71d495b..0b12188 100644 --- a/Tonokip_Firmware/Tonokip_Firmware.pde +++ b/Tonokip_Firmware/Tonokip_Firmware.pde @@ -20,6 +20,8 @@ //RepRap M Codes // M104 - Set target temp // M105 - Read current temp +// M106 - Fan on +// M107 - Fan off // M109 - Wait for current temp to reach target temp. //Custom M Codes @@ -301,6 +303,12 @@ inline void process_commands() manage_heater(); } break; + case 106: //M106 Fan On + digitalWrite(FAN_PIN, HIGH); + break; + case 107: //M107 Fan Off + digitalWrite(FAN_PIN, LOW); + break; case 80: // M81 - ATX Power On if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,OUTPUT); //GND break; @@ -511,8 +519,16 @@ inline void manage_heater() current_raw = analogRead(TEMP_0_PIN); // If using thermistor, when the heater is colder than targer temp, we get a higher analog reading than target, if(USE_THERMISTOR) current_raw = 1023 - current_raw; // this switches it up so that the reading appears lower than target for the control logic. - if(current_raw >= target_raw) digitalWrite(HEATER_0_PIN,LOW); - else digitalWrite(HEATER_0_PIN,HIGH); + if(current_raw >= target_raw) + { + digitalWrite(HEATER_0_PIN,LOW); + digitalWrite(LED_PIN,LOW); + } + else + { + digitalWrite(HEATER_0_PIN,HIGH); + digitalWrite(LED_PIN,HIGH); + } } // Takes temperature value as input and returns corresponding analog value from RepRap thermistor temp table. @@ -599,4 +615,4 @@ inline void kill(byte debug) } } -inline void manage_inactivity(byte debug) { if( (millis()-previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) kill(debug); } +inline void manage_inactivity(byte debug) { if( (millis()-previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) kill(debug); } \ No newline at end of file -- cgit v1.2.1