Tool Change G-CODE
Hello. I have two questions about the tool change script.
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.
I'm newbie in this respect and I hope for your help.
Best regards, Marcel.
I am using the RADDS 1.5 board in conjunction with the Arduino DUE.
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?
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.
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?
Deselect "M42 P11 S0"
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 thiscase 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.analogWrite(pin_number, com->S);
so only the digital version stays. Then pin 11 should also work.