Speed Fan M106 ..... S ???????

why does the M106 S50 command send me the maximum fan speed instead with the old firmware corresponding to 20%?
what is the max value and 50%?

Comments

  • S value can vary between 0 = 0% and 255 = 100%. As far as I know all firmwares use this scale.
  • because from 100 to 255 it does not change speed
    measured with an optical speed reader ..
    is not that the new firmware 1.0.2 has something wrong?
    I use Ramps 1.4 and  arduino mega
  • That code hasn't changed for some years. All pwm use the same function including heaters and they go all 0-255 for intensity. Will recheck code if I see a  limit to 100.
  • I'm sorry to say it but at me over 100 does not change the speed.
    it always remains max from 100 to 255
    if you check the software and if you can tell me what I have to change to have an excursion from 0 to 255
  • Ok in commands.cpp you have

        case 106: // M106 Fan On

            if(com->hasI()) {

                if(com->I != 0)

                    Printer::flag2 |= PRINTER_FLAG2_IGNORE_M106_COMMAND;

                else

                    Printer::flag2 &= ~PRINTER_FLAG2_IGNORE_M106_COMMAND;

            }

            if(!(Printer::flag2 & PRINTER_FLAG2_IGNORE_M106_COMMAND)) {

                if(com->hasP() && com->P == 1)

                    setFan2Speed(com->hasS() ? com->S : 255);

                else

                    setFanSpeed(com->hasS() ? com->S : 255);

            }

            break;


    So no limit. This calls setFanSpeed

    void Commands::setFanSpeed(int speed, bool immediately) {

    #if FAN_PIN >- 1 && FEATURE_FAN_CONTROL

        if(Printer::fanSpeed == speed)

            return;

        speed = constrain(speed, 0, 255);

        Printer::setMenuMode(MENU_MODE_FAN_RUNNING, speed != 0);

        Printer::fanSpeed = speed;

        if(PrintLine::linesCount == 0 || immediately) {

            if(Printer::mode == PRINTER_MODE_FFF) {

                for(fast8_t i = 0; i < PRINTLINE_CACHE_SIZE; i++)

                    PrintLine::lines[i].secondSpeed = speed;         // fill all printline buffers with new fan speed value

            }

            Printer::setFanSpeedDirectly(speed);

        }

        Com::printFLN(Com::tFanspeed, speed); // send only new values to break update loops!

    #endif

    }


    At the beginning you see constrain to 0-255.


    This calls setFanSpeedDirectly:

    void Printer::setFanSpeedDirectly(uint8_t speed) {

    uint8_t trimmedSpeed = TRIM_FAN_PWM(speed);

    #if FAN_PIN > -1 && FEATURE_FAN_CONTROL

        if(pwm_pos[PWM_FAN1] == trimmedSpeed)

            return;

    #if FAN_KICKSTART_TIME

        if(fanKickstart == 0 && speed > pwm_pos[PWM_FAN1] && speed < 85) {

            if(pwm_pos[PWM_FAN1]) fanKickstart = FAN_KICKSTART_TIME / 100;

            else                  fanKickstart = FAN_KICKSTART_TIME / 25;

        }

    #endif

        pwm_pos[PWM_FAN1] = trimmedSpeed;

    #endif

    }

    Here TRIM_FAN_PWM could be the problem

    #if !defined(MAX_FAN_PWM) || MAX_FAN_PWM == 255

    #define TRIM_FAN_PWM(x) x

    #undef MAX_FAN_PWM

    #define MAX_FAN_PWM 255

    #else

    #define TRIM_FAN_PWM(x) static_cast<uint8_t>(static_cast<unsigned int>(x) * MAX_FAN_PWM / 255)

    #endif


    As you see if you defined MAX_FAN_PWM 100 then 100 then what you describe would happen, but you would need to set this explicitly. But maybe you did.



Sign In or Register to comment.