Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: scrambled on May 24, 2010, 11:25:11 AM

Title: Using a Variable
Post by: scrambled on May 24, 2010, 11:25:11 AM
Hi everyone-

Now that I have the M code problems figured out (for now), time for a new twist.

I talked to LES at sheetcam, and he said what I am wanting to do is possible on the sheetcam end, now to figure out if Mach can do it.


Since I am using an Oxy/ propane torch, when  have multiple cuts on a sheet, or the cuts are close together, then I am needing a way to change the pre heat time.

Les Said that he can have sheetcam insert a varable into the G-code, so how could I change this on the fly?


If you need more information, let me know




Steve
Title: Re: Using a Variable
Post by: BR549 on May 25, 2010, 12:05:33 PM
There are several ways.

1. Simply type in the VAR and value at the MDI line    #1000=25  would set the #1000 var to 25

2. Set up a DRO on the main screen then ADD code to your macropump to update the VAR based on the DRO value
    
     SetVar(1000,GetOemDro(500))     That would set the GcodeVar #1000 to equal the OemDro#500

In either case you would HAVE to set the NEW VAR before the code ran that would use it otherwise nothing would change in the actual program

Hope that helps


**********NOTE:
I just saw you post on Scam. POST vars and Gcode Vars are two different critter and not interchangable.

SO you need to let me know WHICH approach you intend to use.
Title: Re: Using a Variable
Post by: scrambled on May 25, 2010, 01:34:31 PM
BR549-

I would think that the second option would be the best.

When I talked to Less at Sheetcam, he said that the sheetcam portion would be easy.  He just could not remember how to make the changes in Mach.

For me this is the sequence that would work the best for me.

1.  run sheetcam the same as always.  Sheetcam loads the tool preheat settings into a variable
2.  If the DRO is not changed, then Mach loads the default variable into the g-code and the cut sequence runs the same as always
3.  If I choose to adjust the DRO (increase or decrease timer) then MACH loads this new variable into the next cut sequence
4  If the DRO is not changed, then the variable is loaded into the next cut sequence
5  this repeats thoughout the program


IS that clear as mud???


What do you think?


Steve
Title: Re: Using a Variable
Post by: manmeran on May 25, 2010, 01:49:41 PM
what version of MACH are you running?
Title: Re: Using a Variable
Post by: BR549 on May 25, 2010, 06:11:40 PM
Perfectly clear(;-)  That should work well.

Title: Re: Using a Variable
Post by: manmeran on May 26, 2010, 02:56:22 AM
hi Steve
is it possible you more explain about this issue?
How should defined these steps in sheetcam ?

amir
Title: Re: Using a Variable
Post by: scrambled on May 26, 2010, 08:38:45 AM
Amir-

I am working with Les at sheetcam.  Right now, I dont have a clue.  But as soon as I figure it out, I will let everyone knw.


Steve
Title: Re: Using a Variable
Post by: BR549 on May 26, 2010, 01:00:04 PM
Basically what he is doing is allowing the Scam post to add a Variable to the Dwell so that he can change the dwell time on the fly as needed.

Gcode Dwell

G4 P1         would indicate a pause of 1 sec based on the P parameter of 1 (IF you set up config to do secs not Msecs)

The Scam post would input a VAR in place of the number

G4 P#100       Now the pause will be controled by the value of the VAR. All that is needed is a DRO on the program screen to set what dwell you    need for the NEXT section of code. You will also need a piece of code in the Macropump to update the VAR.

SetVar(100,Getoemdro(???))            With that in place with every loop of the macropump the var will be updated to the onscreen DRO value .

A VERY GOOD IDEA that I will add to my setup as well.

You might want to think about a Pierce count DRO as well . It makes it easier to keep track of the number of pierces you have completed.
Title: Re: Using a Variable
Post by: scrambled on May 26, 2010, 01:15:58 PM
Br549-

 I am starting to understanding of what I am trying to do.

I have a few questions:

1.  What is a Scam post?
2  What is a Macropump?

Is there are range of variables that I should use, or a range of variables I need to stay away from?

that is a good idea about pierce count.


thanks for all the help


Steve
Title: Re: Using a Variable
Post by: manmeran on May 26, 2010, 01:20:14 PM
is it possible that you talk about a practical example.
i never did not use the variable in sheetcam.
Title: Re: Using a Variable
Post by: manmeran on May 26, 2010, 01:27:38 PM
Br549-

 I am starting to understanding of what I am trying to do.

I have a few questions:

1.  What is a Scam post?
2  What is a Macropump?

Is there are range of variables that I should use, or a range of variables I need to stay away from?

that is a good idea about pierce count.


thanks for all the help


Steve

about Scam post : in folder post in sheetcam ,there are many file that constructive Gcode with our custom settings.
about macropump: When we want something check constantly we can use this function.
Title: Re: Using a Variable
Post by: BR549 on May 26, 2010, 04:12:07 PM
The Scam(SheetCam) post is the part of Scam that actually writes the Gcode based on the drawing and other parameters. Less will handle the modifications of that part for you.

A Macropump is a piece of code that mach runs continuesly. I t can be used for uses such as this.

You can use any Gcode Var # and you will only use 1 AND you have to let LES know which one you choose.  I would use one in the range of 500-600 as those Vars are stored in MachsXML file when it shuts down and will always be there at startup. The other #Vars are not retained when Mach shuts down.

Also you can set the dro to be stored as well so you have double safe values on startup(;-)

Hope that helps, if not we will try again(;-)
Title: Re: Using a Variable
Post by: scrambled on May 27, 2010, 12:08:04 AM
BR549-

Thanks for the information.  It does not look like it should be that hard to accomplish what I am trying to do.  Now to find some extra time.  I don't think I am going to make it to the shop until this weekend.  Work has picked up, I guess that is a good thing.


Steve
Title: Re: Using a Variable
Post by: manmeran on May 27, 2010, 04:41:12 PM
i think this Thread is forgotten.
please describe a practical example.

Amir
Title: Re: Using a Variable
Post by: scrambled on June 28, 2010, 12:37:51 PM
OK-

I finally have time to work on this project again!!

Everything is kinda working, and I am trying to track down where the problem is.

The sheetcam POST has been modified so that it uses variable #500 to determine preheat time for the Oxy fuel torch.

The problem is that the only way I can change the variable is to edit the g-code. 

There is a line towards the top that sets the variable to what the tool setpoint is in sheetcam.

the line is

N********* P#500=20

so if i edit this line then I can change the preheat time through the g-code.

I tried to change the #500 variable using the MDI and it did not change anything.

I entered this in the MDI      VAR #500=10

the problem is that I am not sure if the variable changed.


So here is what I think I need for now

a small window that has the actual value of variable 500
and a up and a down arrow, that when clicked on will either add or subtract 1 sec to the variable #500
then display the new value of the Variable #500 in the window.


How would I go about this????


thanks for the help



Steve
Title: Re: Using a Variable
Post by: BR549 on June 28, 2010, 07:32:36 PM
from the MDI line type            #500=20       then press enter


To make it seemless you need to install a OEMDRO on the screen, then add an update button beside it.

Add code to the button to update the var based on the OemDro

SetVar(500,Getoemdro(*********))      where ********* is the OEMDRO# you used. This way whenever you want to update the preheat number just input the new value then press update.
Title: Re: Using a Variable
Post by: BR549 on June 28, 2010, 08:12:58 PM
OOPS message timed out,eating supper(;-)



Add an OemDro to the screen. Then add a Raise and Lower button to the side.


To the Macropump add the following code, This will update the OemDro with the Var500 value UNLESS it is a negative number then it sets Zero

If GetOemDro(***) < 0 Then SetOemDro(500,0)       ' Where *** is the OemDro Number
Else
SetOemdro(***,GetVar(500))
End If


Next add some button code to the up and down buttons

Up

SetVar(500,(GetVar(500)+1))

Down

SetVar(500,(Getvar(500) -1))



That should about do it, If you need more help just holler
Title: Re: Using a Variable
Post by: scrambled on June 29, 2010, 12:08:38 AM
BR549-

I will try that first thing in the morning.  It is too late to go to the shop tonight



Steve
Title: Re: Using a Variable
Post by: BR549 on June 29, 2010, 08:59:36 PM
Steve did you get your Scam post sorted out? I saw where you did not have the OnToolChange() included in the post so the Var value was never included in the output.
Title: Re: Using a Variable
Post by: scrambled on June 29, 2010, 11:59:13 PM
BR549-

My wife made me mow the fields.  :(  but there is always tomorrow :)

I should make it to the shop in the morning.  I should have 4-5 hours before I goto work, so I will let you know how it turns out.


Thanks again


Steve
Title: Re: Using a Variable
Post by: scrambled on July 05, 2010, 09:15:21 PM
Success-

With the help of Les at Sheetcam, and Br549 I can now adjust the preheat time of my flame cutter on the fly!

I am going to get all of my notes together nad post all the information so that others who want to do this can.

Steve