Welcome! Log In Create A New Profile

Advanced

Controlling digital pins via gcode?

Posted by tm america 
Controlling digital pins via gcode?
October 19, 2015 11:02PM
I am working on adding some relays to my arduino mega 2560-ramps 1.4 with marlin firmware i basically did a copy and paste ot the case 106 and case 107 section changed things to thc instead of fan and added the THC_PIN in the pins h here is what i have and i an getting errors for thc speed not declared in this scope ..Where do i declare the thc speed like i would the fan speed?I know i will need to add something in another part but where?Any idea where i would declare the speed for the thc or is there an easier way to control a pin via gcode?Just has to go from low=off to high=on?

These are the errors i got when i compiled?
Arduino: 1.6.5 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Marlin_main.cpp: In function 'void process_commands()':
Marlin_main.cpp:2718: error: 'ThcSpeed' was not declared in this scope
ThcSpeed=constrain(code_value(),0,255);
^
Marlin_main.cpp:2721: error: 'ThcSpeed' was not declared in this scope
ThcSpeed=255;
^
Marlin_main.cpp:2725: error: 'ThcSpeed' was not declared in this scope
ThcSpeed = 0;
^
'ThcSpeed' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.


I added this to the pins h .....

#define THC_PIN 57



Here is what i have so far in the marlin main ccp........

#if defined(THC_PIN) && THC_PIN > -1
case 95: //M95 Thc On
if (code_seen('S')){
ThcSpeed=constrain(code_value(),0,255);
}
else {
ThcSpeed=255;
}
break;
case 96: //M107 Thc Off
ThcSpeed = 0;
break;
#endif //THC_PIN
Re: Controlling digital pins via gcode?
October 19, 2015 11:03PM
Thanks in advance..Any suggestions are greatly appreciated
Re: Controlling digital pins via gcode?
October 20, 2015 02:11AM
Ok decided to go a different way with that kept the part i added in the pins h but put this in the marlin main ccp.......


#if THC_PIN > -1
case 95: //M95 thc On
analogWrite(57, 0);
break;
case 96: //M96 thc Off
if (code_seen('S')){
analogWrite(57, constrain(code_value(),0,255));} //D57 is thc_pin as in pins.h
else {
analogWrite(57, 255);}
break;
#endif //THC_PIN

This works for controlling the relay with the M95 and M96..The problem i am having now is i wa running this with a reprap discount full graphic controller and it works fine however when i switch the settings ,upload and try to use it with with a reprap discount smart controller the lcd screen is not working ?I even tried uploading a sketch i know worked without any of the changes and it does the same thing?I know the smart controller it good if i put it on one of my megatronics v2.0 boards that is set up for it the lcd works just fine..So to sum it up the full graphic controller will work with the ramps 1.4 but the smart controller will not.. But the smart controller works with the megatronics board.. so i know it is not a hardware problem.It will not work even with sketches that i know worked in the past with a smart controller.The only thing i can think is somehow having the u8glib libruary installing in the arduino ide is making it not work when uploading the sketch for the smart controller??Is there a way to remove the u8glib without completely removing and reinstalling the arduino ide?
Re: Controlling digital pins via gcode?
October 20, 2015 07:05PM
The compiler error indicates that the vsriable ThcSpeed is not defined. Put
char ThcSpeed;
Somewhere at the start of the function.

The second problem I suspect that pin 57 may used by the lcd. Did you check if it's used anywhere else? The graphics display uses i2C which only uses 2 pins, the smart lcd controller, iirc, uses nibble mode plus two control lines, which is about 6 or 7 pins. You can probably borrow the max endstop switches pins as they are not used in many printer designs.
Sorry, only registered users may post in this forum.

Click here to login