![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
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 |
|
#2
| ||||
| ||||
| 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) |
|
#3
| |||
| |||
| 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. |
|
#4
| |||
| |||
| 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 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 |
|
#6
| ||||
| ||||
| 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/ |
|
#7
| ||||
| ||||
| 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) |
|
#8
| ||||
| ||||
| 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) |
|
#9
| ||||
| ||||
| 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/ |
|
#10
| |||
| |||
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. |
| Sponsored Links |
|
#11
| ||||
| ||||
| 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/ |
|
#12
| |||
| |||
| 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. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
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 |