Home
Downloads
Mach3
Plugins
CAM Post Processors
Screensets
Purchase
Support
Forum
Tutorial Videos
Documentation
Yahoo Group
Mach Wiki
Resources
Contact Us
Links
CNCZone
German Forum
Italian Forum
Korean Forum
Portugese (Brazil) Forum
Russian Forum (RSK CNCROUTER)
Thai Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 23, 2012, 10:54:03 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Select from and to languages
Chinese-simp to English
Chinese-trad to English
English to Chinese-simp
English to Chinese-trad
English to Dutch
English to French
English to German
English to Greek
English to Italian
English to Japanese
English to Korean
English to Portuguese
English to Russian
English to Spanish
Dutch to English
Dutch to French
French to English
French to German
French to Greek
French to Italian
French to Portuguese
French to Dutch
French to Spanish
German to English
German to French
Greek to English
Greek to French
Italian to English
Italian to French
Japanese to English
Korean to English
Portuguese to English
Portuguese to French
Russian to English
Spanish to English
Spanish to French
Machsupport Forum
Mach Discussion
VB and the development of wizards
My first Macro-- quick Q's on reading external inputs.
Pages:
1
Go Down
« previous
next »
Author
Topic: My first Macro-- quick Q's on reading external inputs. (Read 1143 times)
0 Members and 2 Guests are viewing this topic.
nicad
Active Member
Offline
Posts: 30
My first Macro-- quick Q's on reading external inputs.
«
on:
March 28, 2009, 12:17:43 AM »
I am needing to make a macro to:
A) Read a 3-position switch
B) Set a value to a variable in my G-code based on which position the switch is in.
What I have so far:
I am using a G100 for I/O. I have my switch wired to 3 of the digital inputs. This works so far.
I assume I need to assign each of the 3 inputs to an "OEM Trigger" under Ports/Pins.??
What do I then need to do in my macro to read the condition of each of these 3 inputs?
And the, how do I set a variable to a value accordingly so that my G-code can then use the set value? (it will be for a G1 Y xx call, where "xx" is the value)
Thanks-
Logged
nicad
Active Member
Offline
Posts: 30
Re: My first Macro-- quick Q's on reading external inputs.
«
Reply #1 on:
March 28, 2009, 01:05:46 AM »
OK so after doing some more digging I have found that I can check the state of an OEMTRIG with "IsActive(OEMTRIGx)" where x is the #.
I think this pretty much answers my first part.
I can figure out the logic part in the macro.
But I am still not clear on how to get a value into a variable in my code.
Should I place my Macro at the beginning of the Gcode, and in the Macro, have it do something like:
If IsActive(OEMTRIG3) Then
Code "#501=2.65"
...
Then later in my Gcode, use the variable #501?
Also, when you use the "Code" command in a Macro, does the line(s) that the Macro was called from in the Gcode get replaced with whatever is written with the "Code" command?
Logged
vmax549
Guest
Re: My first Macro-- quick Q's on reading external inputs.
«
Reply #2 on:
March 28, 2009, 03:04:57 PM »
Yes that is one way to get the value into the VAR.
ANother way would be
If IsActive(OEMTRIG3) then setvar(501,2.65)
When a CODE"" is run in a macro it runs as a separte entity outside of the gcode then returns to the Gcode. SO the line does NOT actually replace the line in the program but it still will run.
Hope that helps, ((;-) TP
«
Last Edit: March 28, 2009, 03:08:08 PM by vmax549
»
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
Offline
Posts: 1,707
Briceville, TN, USA
Re: My first Macro-- quick Q's on reading external inputs.
«
Reply #3 on:
March 28, 2009, 03:08:16 PM »
here is an option:
In your G code set the three possible values in your param/vars like this:
#1=xx.xx
#2=yy.yy
#3=zz.zz
OR you could drop 3 User DROs on your Screen, and put a button next to each one. you would then put the value that you want in the DRO and that would store the value you want into the param/var Lets say you used UserDRO 2000, 2001, and 2002 and had a button next to each one, and when you pushed the button next to the 1st DRO it would load that value into Param/var #1 for, the others would do #2, and #3 respectively.
The code you would put for instance in Button 1 would be:
Paramone = GetUserDRO(2000)
SetVar(1, Paramone)
Then in my macropump I would put this: (I would use Param/Var 4 to be my on the fly varible var from external buttons.)
if IsActive(OEMTRIGGER1) then
Param = GetVar(1)
end if
if IsActive(OEMTRIGGER2) then
Param = GetVar(2)
end if
if IsActive(OEMTRIGGER3) then
Param = GetVar(3)
end if
SetVar(4,Param)
'///////////////////////
Then in your G-Code, I would call param #4 that would contain the value that one of the three external buttons would cause to be loaded.
With Hard coding the Params then you would have to edit your g code to change values 1-3, but with the User Dros, and Buttons, you could change thier value just by puttin in a new value and hitting the "update" button next to it.
scott
Logged
Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
nicad
Active Member
Offline
Posts: 30
Re: My first Macro-- quick Q's on reading external inputs.
«
Reply #4 on:
April 03, 2009, 11:23:56 AM »
I used the "setvar(1,x)" route and it worked great.
I even got brave and used some variables to control subroutine loop counters.
Thanks for the help yall!
Logged
Pages:
1
Go Up
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Mach Discussion
-----------------------------
=> General Mach Discussion
=> Mach3 under Vista
=> Quantum
=> Mach SDK plugin questions and answers.
===> Finished Plugins for Download
=> VB and the development of wizards
=> Brains Development
=> Video P*r*o*b*i*n*g
=> Mach Screens
===> Screen designer tips and tutorials
===> Works in progress
===> Finished Screens
===> Flash Screens
===> JetCam screen designer
===> Machscreen Screen Designer
===> CVI MachStdMill (MSM)
=> Feature Requests
=> Non English Forums
===> Italian
===> French
===> Spanish
===> Chinese
===> German
===> Russian
===> Romanian
===> Japanese
===> Vietnamese
=> FAQs
-----------------------------
*****VIDEOS*****
-----------------------------
=> *****VIDEOS*****
-----------------------------
General CNC Chat
-----------------------------
=> Share Your GCode
=> Show"N"Tell ( What you have made with your CNC machine.)
=> Building or Buying a Wood routing table.. Beginnners guide..
=> Show"N"Tell ( Your Machines)
-----------------------------
G-Code, CAD, and CAM
-----------------------------
=> G-Code, CAD, and CAM discussions
=> LazyCam (Beta)
-----------------------------
Third party software and hardware support forums.
-----------------------------
=> LazyTurn
=> GearoticMotion Preliminary testing
=> Tempest Trajectory Planner
=> Contec
=> dspMC/IP Motion Controller
=> HiCON Motion Controller
=> Third party software and hardware support forums.
=> Galil
=> Newfangled Solutions Wizards
=> Mach3 and G-Rex
=> Mesa
=> Modbus
=> NC Pod
=> PoKeys
=> SmoothStepper USB
=> Sieg Machines
=> Promote and discuss your product
-----------------------------
Tangent Corner
-----------------------------
=> Tangent Corner
=> Competitions
=> Polls
=> Bargain Basement
-----------------------------
Support
-----------------------------
=> Downloads
===> XML files
===> Post Processors
===> Macros
===> Tutorials
===> Others
===> Beta Brains
===> Screen Sets
===> Documents
===> MACH TOOL BOX
=> One on one phone support.
=> Forum suggestions and report forum problems.
-----------------------------
Mach4
-----------------------------
=> Mach4 pre-Alpha Testing
Loading...