Welcome! Log In Create A New Profile

Advanced

How to enable software control for extruder fan in G code?

Posted by Duckmang 
How to enable software control for extruder fan in G code?
November 19, 2016 06:40PM
Cheers. I've got an FLSUN machine that has a BT7272A board running marlin. I recently switched over to a software controlled fan for the extruder. It works but I have to manually turn it on in the manual settings. I'm pretty sure there is a G code to turn it on and off but I'm too much of a newbie to know what it is or how to search for it. I'm mainly using Slic3r and I see the options for start and end G code. It would be awesome to enable it at a certain temp and disable it at another. Can you guys help me out or point me to a G code resource that can help me figure it out?

Thanks for any help.

Edited 1 time(s). Last edit at 11/19/2016 07:58PM by Duckmang.
Re: How to enable software control for extruder fan in G code?
November 25, 2016 11:43AM
M106 and M145 give you a lot of control over these things. The code is shown below.


#if FAN_COUNT > 0

  /**
   * M106: Set Fan Speed
   *
   *  S   Speed between 0-255
   *  P Fan index, if more than one fan
   */
  inline void gcode_M106() {
    uint16_t s = code_seen('S') ? code_value_ushort() : 255,
             p = code_seen('P') ? code_value_ushort() : 0;
    NOMORE(s, 255);
    if (p < FAN_COUNT) fanSpeeds[p] = s;
  }

  /**
   * M107: Fan Off
   */
  inline void gcode_M107() {
    uint16_t p = code_seen('P') ? code_value_ushort() : 0;
    if (p < FAN_COUNT) fanSpeeds[p] = 0;
  }

#endif // FAN_COUNT > 0



  /**
   * M145: Set the heatup state for a material in the LCD menu
   *   S (0=PLA, 1=ABS)
   *   H
   *   B
   *   F
   */
  inline void gcode_M145() {
    int8_t material = code_seen('S') ? (int8_t)code_value_int() : 0;
    if (material < 0 || material > 1) {
      SERIAL_ERROR_START;
      SERIAL_ERRORLNPGM(MSG_ERR_MATERIAL_INDEX);
    }
    else {
      int v;
      switch (material) {
        case 0:
          if (code_seen('H')) {
            v = code_value_int();
            plaPreheatHotendTemp = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
          }
          if (code_seen('F')) {
            v = code_value_int();
            plaPreheatFanSpeed = constrain(v, 0, 255);
          }
          #if TEMP_SENSOR_BED != 0
            if (code_seen('B')) {
              v = code_value_int();
              plaPreheatHPBTemp = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
            }
          #endif
          break;
        case 1:
          if (code_seen('H')) {
            v = code_value_int();
            absPreheatHotendTemp = constrain(v, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - 15);
          }
          if (code_seen('F')) {
            v = code_value_int();
            absPreheatFanSpeed = constrain(v, 0, 255);
          }
          #if TEMP_SENSOR_BED != 0
            if (code_seen('B')) {
              v = code_value_int();
              absPreheatHPBTemp = constrain(v, BED_MINTEMP, BED_MAXTEMP - 15);
            }
          #endif
          break;
      }
    }
  }
Sorry, only registered users may post in this forum.

Click here to login