CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > Mach Software (ArtSoft software) > Screen Layouts, Post Processors & Misc



This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 05-14-2009, 05:46 PM
 
Join Date: Dec 2003
Location: UK
Posts: 218
UKRobotics is on a distinguished road
VB Scripting 101

Hopefully an easy one for more of the seasoned engineers here.

If I create a new button and led in a screen design program such as screen4, how can I associate the button with the LED so when the button is pressed the led lights accordingly?

Also how can I choose to make a button latch so I can toggle between an on an off state ?

I would be greatful for generic code examples rather than how a specific screen design program could be made to do this.


Thanks in advance,

Dom
__________________
Dom
http://www.ukrobotics.com/projects
Tweet this Post!Share on Facebook
Reply With Quote

  #2  
Old 05-14-2009, 07:14 PM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 19,570
ger21 is on a distinguished road
Buy me a Beer?

It depends what the LED is doing. Is it a standard Mach3 LED, or a custom LED for a special purpose?

For most standard mach3 LED's, there are button "calls" to turn them on. For a "User" LED, you just use code in the button to turn it on or off.

Also, you can't "latch" a button, but you can have it turn something on so that it stays on.

Basically, when you create a button, you assign a function to it. You have a few options.

1. Built in Mach function. There's a drop down list in Screen4 to choose them, and there are quite a few.
2. Call an OEM code. You just put the code in that does what you want it to do. There are codes for all the built in functions, so both 1 and 2 do the same thing, but 1 is just quicker if the function call is listed.
3. Run G-code. Just enter the g-code you want the button to do. I think it's limited to a single line of code, but you can also call M codes, so you can run a macro by calling it's code, such as M777.
4. Run VB script. This is probably the route you want to take, from what I gather from your post.


All the OEM codes can be found here. Look under #9.
http://www.machsupport.com/MachCusto...itle=Main_Page

One thing to understand in Mach3, is that turning on an LED actually activates that function. For example, the OEM LED code for Flood coolant is 13. So, if you want to turn on flood coolant with a button, you can use 2 of the methods I gave above.
1. Choose Flood from the built in function list.
4. Use the script SetOEMLED(13,1). SetOEMLED(13,0) would turn it off.

Method 2 requires an OEM button code, so you wouldn't use 13 there. The button code to toggle flood is 113. NOte that some button codes toggle on and off, while others are strictly on or off.

If you give me more specifics on what you want to do, I can give you a better answer.
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Tweet this Post!Share on Facebook
Reply With Quote

  #3   Ban this user!
Old 05-15-2009, 02:52 AM
 
Join Date: Dec 2003
Location: UK
Posts: 218
UKRobotics is on a distinguished road

Thanks Gerry,

I really appreciate the time you take to answer my questions. I have read a lot of instruction manuals and watched a lot of tutorial videos but its having that extra knowlege to fill in the gaps which these things don't tell you that makes all the difference.

I will use my power drawbar as an example.

I want to create a new button which when pressed sends a signal to the soild state relay which drives the solonoid for the drawbar. So lets assume for arguments sake that the relay is congfigured as output #1. Also while a signal is going out to that relay i'd like a LED to indicate this on screen.

I was thinking for a latching version of this switch I could use code like:

(on btn click)

If output1 = 0
x = 0
ElseIf output1 = 1
x = 1

If x>0
ouput1 = 0
LED1 = 0

else

output1=1
led1 = 1



And for a non latching version...

While btn1 = 1
output 1 = 1
else
output 1 = 0

or something like that


Please excuse my very poor pseudocode above, - it's been a while since i've done any programming!

If this would work would you mind rewriting what i've written in the correct syntax?


Cheers.
__________________
Dom
http://www.ukrobotics.com/projects

Last edited by UKRobotics; 05-15-2009 at 03:30 AM.
Tweet this Post!Share on Facebook
Reply With Quote

  #4   Ban this user!
Old 05-15-2009, 06:32 AM
H.O H.O is offline
 
Join Date: Jul 2007
Location: Sweden
Posts: 886
H.O is on a distinguished road

Hi,
The only on-screen-buttons that "acts" as long as they are being pressed are the jog-buttons. All other buttons, AFAIK, are "edge-triggered", they run the attached code once, every time they are being clicked. There's no way to "see" if it is being "held down".

For your latching LED example, if the LED is OEMLED1000 then you can do something like this:
Code:
If IsOutPutActive(Output1) Then   'Check the state of the output...
  DeActivateSignal(Output1)       '...if it's "on", turn it off...
  SetUserLED(1000,0)              '...and turn off LED
Else
  ActivateSignal(Output1)          'Otherwise turn the output "on"...
  SetUserLED(1000,1)               '...and turn on the LED
End If
For the non latching version perhaps a time delay might be worth a shot, something like:
Code:
ActivateSignal(Output2)       'Set output
SetUserLED(1000,1)            'Turn on LED
Sleep(1000)                        'Wait one second
DeActivateSignal(Output2)     'Reset output
SetUserLED(1000,0)              'Turn off LED
HTH
Tweet this Post!Share on Facebook
Reply With Quote

  #5   Ban this user!
Old 05-15-2009, 07:23 AM
 
Join Date: Dec 2003
Location: UK
Posts: 218
UKRobotics is on a distinguished road

I'm not sure it would work useing sleep in that way because it is only going to be called once regardless of how long you hold the button down.
__________________
Dom
http://www.ukrobotics.com/projects
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 05-15-2009, 10:21 AM
PoppaBear10's Avatar  
Join Date: Feb 2005
Location: usa
Posts: 481
PoppaBear10 is on a distinguished road

Gerry:

SetOEMLED(13,1) is not something you can do in Mach3, there is no SetOEMLED call. BUT!!!! There is a "GetOEMLED(xxx)" to look at is status.
The OEM Leds are "Read Only", you cant set them (unfortunatly). They only report the status of the function they represent. DoOEMButton(113) will for instance toggle the state of Flood Coolant, or Code("M8") will turn it on, Code("M9") off.

Dom:

If you want in a Button you could also do this You would need to put your button, and a user LED on the screen that you want to represent the status of OUTPUT1, lets call it 1500. I am assuming OUTPUT1 when active captures/grabs the draw bar. Tick the Use VB radio button and put the below code in the box. in Screen3, in Screen4 you have to goto operator->edit button script, and your button will blink. click it, and a VB window will appear.
put the code below in it, hit ONLY the Save button it will title "Hidden Script".
hit the ok to close the window. Then YOU MUST goto View->Save Current Layout (click the save current layout). Then Go Back and look at Operator->Edit button script to MAKE SURE it DID save it, sometimes it does NOT!!! if you see your script there your good, if not redo the steps again, and recheck.

if GetUserLED(1500) then 'if it is on (Output1 is active)
if GetOEMLED(11) then ' if the spindle is running dont release (safety)
Message("Spindle Must Be OFF to release Tool!!")
' Code("M5") 'Optional spindle stop here
else
DeActivateSignal(OUTPUT1) 'Draw bar Release tool output1 off
SetUserLED(1500,0) 'Turn off your indicator LED
end if
else
ActivateSignal(OUTPUT1) 'Draw bar capture tool output1 on
SetUserLED(1500,1) 'Led is on to indicate capture
end if

'NOTE: if you need the reverse of the above logic just flip everything around.

'Enjoy scott
__________________
Commercial Mach3: Screens, Wizards, Plugins, Brains,PLCs, Macros, ATC's, machine design/build, retrofit, EMC2, Prototyping. http://sites.google.com/site/volunteerfablab/
Tweet this Post!Share on Facebook
Reply With Quote

  #7  
Old 05-15-2009, 11:14 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 19,570
ger21 is on a distinguished road
Buy me a Beer?

Originally Posted by PoppaBear10 View Post
Gerry:

SetOEMLED(13,1) is not something you can do in Mach3, there is no SetOEMLED call.
Someone needs to fix the Wiki. It says there is.
http://www.machsupport.com/MachCusto...title=OEM_LEDs

That makes sense, though. So, you can only turn on User LED's?
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Tweet this Post!Share on Facebook
Reply With Quote

  #8  
Old 05-15-2009, 11:16 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 19,570
ger21 is on a distinguished road
Buy me a Beer?

Also, instead of a User LED for Output one, can't you just use OEMLED 852?
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Tweet this Post!Share on Facebook
Reply With Quote

  #9   Ban this user!
Old 05-15-2009, 12:25 PM
PoppaBear10's Avatar  
Join Date: Feb 2005
Location: usa
Posts: 481
PoppaBear10 is on a distinguished road

Gerry,

Yes the Wiki is Wrong on that count, it was written a very long time ago via John Pentice. But, the good news is, if you want you can "Join" and "Correct" the error!!

Open Mach3, then goto Operator->VB scripter, when the window opens,
put in the code: SetOEMLED(13,1) and then do a step through or just hit the "Run" button, it will give you an error saying: Expected =, or something like that........

You could also use the OEM LED code for Output1 as you wanted in place of ULED 1500.........

The really cool thing about mach is the POWER it give to users to customize the Crap out of it!!! There are many ways to do many things. You could even use "Brians" if you wanted to do it as well.

I suspect that the reason that the Wiki hasnt been corrected (btw there are Many other issues there as well), is that editing the Wiki is a pain in the butt, and time consuming.

NOTE: In the Forum section of the "www.machsupport.com", under the subject area called: "Member Docs". I published two documents for the "Undocumented" VB. One is VB Parameters, the other is an extension to the "Mach Specific Subroutines". These where dirived directly from the C++ header file that Art himself sent to me a few months ago, to FINALLY try and get ALL the VB documentation up to date...........

scott
__________________
Commercial Mach3: Screens, Wizards, Plugins, Brains,PLCs, Macros, ATC's, machine design/build, retrofit, EMC2, Prototyping. http://sites.google.com/site/volunteerfablab/
Tweet this Post!Share on Facebook
Reply With Quote

  #10   Ban this user!
Old 05-15-2009, 12:26 PM
H.O H.O is offline
 
Join Date: Jul 2007
Location: Sweden
Posts: 886
H.O is on a distinguished road

I'm not sure it would work useing sleep in that way because it is only going to be called once regardless of how long you hold the button down.
Exactly, that's what I was trying to say in my first post. The only buttons that has a "while-pressed" kind of function are the on screen Jog-buttons and they are a special case. The Sleep was an atempt to find a possible workaround for you...

Gerry,
Yep, the Wiki seems to be wrong on this. If you don't want to do it I can double check with Brian and then edit the Wiki.
There is a SetUserLED call that you can use to set or reset "your" LEDs.
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 05-15-2009, 08:09 PM
PoppaBear10's Avatar  
Join Date: Feb 2005
Location: usa
Posts: 481
PoppaBear10 is on a distinguished road

H.O.

If memory serves, anyone can join and edit the wiki. I have added stuff to it, and others have as well. I think once you ask to join to edit. I think it may be John that approves it or not. I cant remember if he has to approve you or not, since it has been many years since I last logged on to add stuff.

scott
__________________
Commercial Mach3: Screens, Wizards, Plugins, Brains,PLCs, Macros, ATC's, machine design/build, retrofit, EMC2, Prototyping. http://sites.google.com/site/volunteerfablab/
Tweet this Post!Share on Facebook
Reply With Quote

  #12   Ban this user!
Old 05-16-2009, 03:45 AM
H.O H.O is offline
 
Join Date: Jul 2007
Location: Sweden
Posts: 886
H.O is on a distinguished road

Hi Scott,
I think I had to ask Brian to add me to the "aproved list" before I could edit stuff there. Anyway, I now have login so I can edit the SetOEMLED/SetUserLED stuff but I wanted to doublecheck with Brian first so that whatever I put in there is correct.
Tweet this Post!Share on Facebook
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting reference... kiwichris NCPlot G-Code editor / backplotter 5 11-15-2007 04:36 PM
Scripting Question eng8248 BobCad-Cam 6 03-24-2007 03:53 PM
Scripting a constant offset curve over a contoured surface? Splint Rhino 3D 11 03-11-2007 05:35 AM
Bobcad scripting 69owb BobCad-Cam 1 05-14-2006 04:20 PM
Scripting Klox BobCad-Cam 29 10-02-2003 11:11 PM




All times are GMT -5. The time now is 06:20 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353