Hello Guest it is March 28, 2024, 08:30:59 PM

Author Topic: formulas in brains  (Read 10969 times)

0 Members and 1 Guest are viewing this topic.

formulas in brains
« on: May 03, 2010, 03:30:49 PM »
Attempting to write a "brain formula" that uses variables.
By swinging a rotary b & c axis head.

Something like the following:
v0=userdro(1198) 'C axis Swing Radius user inputted
v1=userdro(1199) 'B axis Swing radius tool holder face position
v2=ToolLengthOffset
v3=v0-((cos(c/180*3.1416)*v0) 'calculate the cosine of the C axis angle
v4=(sin(c/180*3.1416)*-v0 'calculate the sine of C
v5=Y Position 'get the current position
v6=X Position
v7=Z Position
v8=v3+v5 'compute for new position
v9=v4+v6
Y Position = v8 'update the dro to the new position
X position = v9
??? 'Now drive to location

I can calculate the positions and pass them the the X and Y positions. The
screen shows the computed value after I move C axis. Seems like I could do this
in all one swing move.
Could someone pass along a reference document how these variables & formulas
work.
I can create a calculated value but cant seem to add or pass them back.
And what correlation is there to Mach3 variables?
DRO(801)=v? or y?
a b c etc... not sure if they are axis's or variables.
Seems like both.
As fast as the brains run they should be able to update positions in real time.
I looked at formulas under Functions Config but they dont seem to do anymore
than let me test the calculations. I am running 3.42.40

My lack of gray matter as I get older. :'(
Thanks for any guidance.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: formulas in brains
« Reply #1 on: May 06, 2010, 04:27:40 AM »
Brains formula
in your case above, given that you need to drive to a new calculated machine position.
Brians in this case doesnt have functions to set and do, goto some axis position function.
you would need the ability to run Motion code, so, you would need to make your above
code run in 1 of three options:
1).  Macropump/(or custom macros depending on what your tyring to do)
 with VB script, (you would need to decide if you want to have it run
all the time and activate it by setting an control LED), or if the above code
can be condensed into a custom Macro that you call when you need it.
2). you could use G code "Parameters/functions", mabey a subroutine.
3). do or get a plugin done.
scott
fun times
Re: formulas in brains
« Reply #2 on: May 06, 2010, 04:05:24 PM »
Thanks for the reply
I'm working on a plugin now, I have C axis working, now to get B. I love a good matrix's   :-X

Could you still explain the variables, I'm at a loss for some examples of how to use more than one of them. Are they written to the 500 range?  Kind of was looking for some documentation. But pretty limited from what I found on the NET on variable usage. They speak about using A B C also as variables but can only get A to work.

Thanks again
Craig

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: formulas in brains
« Reply #3 on: May 07, 2010, 04:36:45 AM »
Craig,

   For "Parametric" G code variables, look in the MachMill users guide for the range.
You can access the parameters under I think MachView or mabey it was the _setup in plugins cant remember which one it was. But, from your code above, it looks like your pulling all User DROs and intrinsic mach info, nothing out of the running G code file.

scott
fun times
Re: formulas in brains
« Reply #4 on: May 07, 2010, 06:41:22 AM »
 Sorry, ??? I thought we we referring to Brains, were did I led you to think I was needing GCode Parametric variables? I guess maybe because I was just trying to see if there was some universal crock pot of variables that could be seen and utilized. That's why I mentioned the 500 range. I'm new to mach so be gentle. Trying to understand just what all I can do with brains, mine and mach's. ;D Is there a Holy Grail (documentation) on the Brain? I did find your fine article, among others, thank you. But still looking for something on brain variables. Sorry, I'm a resource glutton, love a good Library.
Thanks

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: formulas in brains
« Reply #5 on: May 07, 2010, 11:55:15 PM »
the "Vars" in Brians are local only for that Brian.
Brians can't do MDI style motion control, directly, you can do some indirectly, but I dont think you want to fool with that.

for motion control, it would be better to go with VB script (easier), or a C++ plugin (ALOT harder).

scott
fun times
Re: formulas in brains
« Reply #6 on: May 08, 2010, 12:59:58 AM »
Just finished getting my C++ plugin working in both B and C axis. Now I can swing the head and it moves the XYZ axis's around the ball tip of the cutter or the center. Now to add functions to drive along vectors. Like to beable to Mill pockets and Drill at compound angles. Cuts down on setups. Guess I'll just figure out how brains work in time.
Thanks  ;)

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: formulas in brains
« Reply #7 on: May 08, 2010, 04:23:49 AM »
Brians do work, for IO, and several Mach functions, they just dont do motion control type stuff....

But for processing, Modbus IO, buttons, LEDs, DROs and other HMI functions of Mach and doing logic with that stuff, they are pretty good.

scott
fun times
Re: formulas in brains
« Reply #8 on: May 08, 2010, 07:21:55 AM »
I did write a brain to move an axis, so I do know that it is possible. I just didn't like the lack of axis control. That is why I was looking for more information on brain variables. Which led me to move on to other alternatives to complete the task.
Ya-Nvr-No

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: formulas in brains
« Reply #9 on: May 08, 2010, 11:53:32 PM »
yes you can move an axis with Brians, that is true, but fine and intelligent control it cant do.

scott
fun times