batata004
Posts: 17
Joined: Fri Apr 21, 2017 9:30 am

Using variables inside S3D

Hi,

Sometimes I need to do this in my INITIAL GCODE SCRIPT:

M140 S[bed0_temperature - 10]

But it does not work :( Isnt there a way I can subtract the configured temperature in the profile inside S3D and use it in GCODE? I know I can change this temperature manually everytime but it's not good, is it possible to use any arithmetic operation?
horst.w
Posts: 861
Joined: Fri Oct 17, 2014 5:00 pm

Re: Using variables inside S3D

M 140 is not waiting to reach the temperature, is that your problem?


RepRap GCode Cheat Sheet
M140 Degrees[S] Set heated bed temperature to S (not waiting) M140 S55

Regards
horst.w, GER
batata004
Posts: 17
Joined: Fri Apr 21, 2017 9:30 am

Re: Using variables inside S3D

horst.w wrote:M 140 is not waiting to reach the temperature, is that your problem?


RepRap GCode Cheat Sheet
M140 Degrees[S] Set heated bed temperature to S (not waiting) M140 S55

Regards
horst.w, GER


No Sir, dont consider the GCODE that I am using, that was just a simple silly example. I just wanna know if it's possible to use the BED and HEAT variable temperatre (that S3D already provides) and make some minus/add math with it?
wirlybird
Posts: 1374
Joined: Sun Jul 17, 2016 1:32 pm

Re: Using variables inside S3D

As far as I have seen the answer is no.

What are you trying to achieve?
batata004
Posts: 17
Joined: Fri Apr 21, 2017 9:30 am

Re: Using variables inside S3D

wirlybird wrote:As far as I have seen the answer is no.

What are you trying to achieve?
I want to run some GCODES when my bed temperature is 5C degrees BEFORE the final bed tempeerature. For example, if I want to get my bed to 90C I want to run some codes at 85C. If I could use arithmetic it would be great.

Of course, 90 is just an example, I change a lot the temperature so I would like it to be automatic.
mdavis1863
Posts: 17
Joined: Tue Jul 03, 2018 11:25 am

Re: Using variables inside S3D

Did you ever get any answer to this? I have similar request, for similar reason. For example it would be nice during a tool change script to set the inactive toolhead temperature to its print temperature minus 10 degrees. Then if I modify the profile to a different print temperature, the tool change script would not need to be modified because it is in the form of a mathematical expression based off the print temperature.

The closest thing I can think of is defining extra temperature controllers, for example you can have "print temperature" and "inactive temperature" as two different temperature controllers on the Temperature page. You still have to remember to set these two controllers to be 10 degrees apart in the Temperature page, but at least you don't have to go editing Gcode. It is a slight improvement, but only slight.

I saw this thread on another forum. Interesting, there appears to be a "MATH" command, but nobody knows how it works.

https://www.reddit.com/r/3Dprinting/com ... ipting_in/
greybeard
Posts: 178
Joined: Mon Mar 02, 2015 1:23 pm

Re: Using variables inside S3D

More than anything, this is an FYI...

For printers using Marlin firmware (and similar that can be tweaked), implementing Math and a whole range of other tweaks is easily accomplished.

Copies of the firmware are posted many places on the net (or, you can edit the one on the printer - just save a backup).

For Mariin, it's an Arduino xxx.ino file that I open with the Arduino IDE. Of course, you need some knowledge about this stuff but, it's fairly easy to learn & do. Can have it respond to input from s3d command-line if attached to usb... as normally done if manually entering something such as M140...

I've tweaked mine - now includes Messages/Prompts in LCD and receives Button presses to do what I want.
I won't be doing a tutorial here but, will say that there are several files that are in the .ino but, only 'two' needed tweaking as the others (for what I needed to do) are simply the code relates/ties together variable name, some values, some this and some that.
A minimally-experienced programmer will know how to find/edit what's needed...

Summary - you can make it do almost anything and many printers use Marlin and similar.

Screenshots showing some example code... one shows Github location of file to download...
Attachments
Screen Shot 2019-03-07 at 12.08.17 PM.png
Screen Shot 2019-03-07 at 12.09.54 PM.png
3D Print Parts
https://www.thingiverse.com/Still_Breathing/designs
mdavis1863
Posts: 17
Joined: Tue Jul 03, 2018 11:25 am

Re: Using variables inside S3D

All,
I noticed that merely referencing a variable in a script can alter the slicer behavior (i.e. it behaves differently than it would you entered the same number as a constant rather than as a variable name). So use with caution. Details are posted at:

viewtopic.php?f=9&t=12966#p49691


(Regarding Marlin : Thanks - I have looked at Marlin source for better understanding in some cases, but have never modified it. I guess that is another whole world to explore.....after retirement. )

Return to “General Discussion and Tips”