Tool Change G-CODE

Hello. I have two questions about the tool change script.

I am using  the RADDS 1.5 board in conjunction with the Arduino DUE.

I would like to switch on an LED when changing from extruder 0 (main material) to extruder 1 (support). This I put on the free fan slot of the RADDS boards. The LED is configured to handle the 24V output voltage of the board.
I use the firmware configuration tool version 1.03.
Now to the question:
At the point "Select commands EXT1_SELECT_COMMANDS" you can indeed insert the appropriate G-code. But how would such a code look like?
This is supposed to be done: switch voltage on PIN xy.

But how do you formulate it as G-code?
And how do I assign these pins in the firmware?

I'm newbie in this respect and I hope for your help.
Best regards, Marcel.

Comments

  • M42 P<pin number> S<value 0..255> - Change output of pin P to S. Does not work on most important pins.

    is your friend here. Just use S0 to disable and S255 to enable. Works with any pin that has no special function.

    But do you really want to use a 24V output for a led? You can use any pin - they have 3.3V. Just make sure the current does not exceed what due can handle on a single pin. There should be plenty of examples using google.

    Of course if you do not need the 24V outputs that is also totally fine. Just a tip so you have more outputs for fans.

  • Thank you that works good. The problem now is that when I used this g code in the firmware the steppers stop working.
    When I select/ deselect the extruder via display or repetier host the light turns on an off as it should.
    But no movement of any axis after I have done it.

    When I use that g code in the g code window in "manual control" of repetier host the system works afterwards.


    What could be the error?
  • What exactly did you put into the gcodes for select/deselect?
  • Select "M42 P11 S255"
    Deselect "M42 P11 S0"
  • Looks normal and I see no real reason it should not work inside it. It is implemented in Commands.com near line 1754

    case 42: //M42 -Change pin status via gcode

            if (com->hasP()) {

                int pin_number = com->P;

                for(uint8_t i = 0; i < (uint8_t)sizeof(sensitive_pins); i++) {

                    if (pgm_read_byte(&sensitive_pins[i]) == pin_number) {

                        pin_number = -1;

                        break;

                    }

                }

                if (pin_number > -1) {

                    if(com->hasS()) {

                        if(com->S >= 0 && com->S <= 255) {

                            pinMode(pin_number, OUTPUT);

                            digitalWrite(pin_number, com->S);

                            analogWrite(pin_number, com->S);

                            Com::printF(Com::tSetOutputSpace, pin_number);

                            Com::printFLN(Com::tSpaceToSpace, (int)com->S);

                        } else

                            Com::printErrorFLN(PSTR("Illegal S value for M42"));

                    } else {

                        pinMode(pin_number, INPUT_PULLUP);

                        Com::printF(Com::tSpaceToSpace, pin_number);

                        Com::printFLN(Com::tSpaceIsSpace, digitalRead(pin_number));

                    }

                } else {

                    Com::printErrorFLN(PSTR("Pin can not be set by M42, is in sensitive pins! "));

                }

            }

            break;

    What you can try is remove all Com:: parts which write data to output. Also I do not know why that would be the only thing I can think of that could make a problem. It would look then like this

    case 42: //M42 -Change pin status via gcode

            if (com->hasP()) {

                int pin_number = com->P;

                for(uint8_t i = 0; i < (uint8_t)sizeof(sensitive_pins); i++) {

                    if (pgm_read_byte(&sensitive_pins[i]) == pin_number) {

                        pin_number = -1;

                        break;

                    }

                }

                if (pin_number > -1) {

                    if(com->hasS()) {

                        if(com->S >= 0 && com->S <= 255) {

                            pinMode(pin_number, OUTPUT);

                            digitalWrite(pin_number, com->S);

                            analogWrite(pin_number, com->S);

                        } 

                    } else {

                        pinMode(pin_number, INPUT_PULLUP);

                    }

                }

            }

            break;

    Just a test and if it helps please report so I can investigate why this is an issue.
  • I will try that on monday. Thank you for the help. Wish you a happy weekend.
  • i have trieed it and there was no succses :( i also recognized, that sending the code via repetier host, also makes the machine stop working. I have replaced the led  with a fan to exclude it as a source of error.

  • i have deleted the M42 P11 S255 line from select command and reuploaded the firmware to the printer. i can select the extruders and use the printer afterwards, but when i send the M42 Command via repetier host, the problem is still the same.... no working steppers, no thermistor signals.... the log says "busy processing"
    I also trieed it with V0.92 of the firmware. same problem here.
  • edited January 21
    FYI i use Pin 11 on the radds board, which is a pin for Heater 3.... could there be the problem? maybe its not suited for PMW or the M42 command? because when I send "M42 P12 S255" the extruder starts Heating ( Pin 12 is extruder 2 heater pin) and after that the system stops working, saying "busy processing"

  • finally I found a walkaround... I use P9 instead of P11 for the LED.... Pin 11 is now the Extruder cooling Fan. now M42 works. also it doesn't make sense to me why M42 on Pin 11 dont works...
  • With S255/S0 you should set digital values. I just checked the due version and it differs. It sets hardware PWM breaking firmware. Please remove
    analogWrite(pin_number, com->S);
    so only the digital version stays. Then pin 11 should also work.
  • I will try this tomorrow and tell you if it works. Thank you for the effort and your help.
  • it works! thank you! :)
Sign In or Register to comment.