Hello Guest it is April 19, 2024, 06:07:52 PM

Author Topic: Msgbox function...  (Read 11228 times)

0 Members and 1 Guest are viewing this topic.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Msgbox function...
« on: January 28, 2016, 01:07:34 PM »
Can the msgbox function be invoked from g-code or something like a button script only?

I am tarting up my new probing system with a little g-code block that will likely get called from a screen button.

I have no idea how the msgbox works but i need to prompt myself with something a little more prominent than the M00 (please do whatever) message :)

Could someone point me to a snippet that would go in a screen button, prompt a response then run a block of code presumably from a macro?

I need to tell myself to remove the torch, then run the code block, then tell myself to replace the torch and then run another code block.

Thanks

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #1 on: January 28, 2016, 01:48:44 PM »
HIYA Dave, to use teh MsgBox you would run it from a Mcode(macro) it is a CB function.

Could you not just use teh Message Bar and send a message to yourself ?

Gcode example

G0 X0 Y0
(Put what ever message you want here)
G04P0     <---- you need this empty G04 here
M00


Macro example

MsgBox(" Put what ever message you want here")

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Msgbox function...
« Reply #2 on: January 28, 2016, 01:56:30 PM »
Hi TP,

Nah message bar is naff ;) I want the full Yes / No features on this one :)

Couldn't refresh my memory how i correctly call a macro from a button script could you :)

Researching now....

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #3 on: January 28, 2016, 03:10:57 PM »
You can use  Code"M*********x"   To call teh macro BUT I would not use it as you are calling a macro from a macro, NOT always a good idea.

I would use RunScript()  To call teh macro

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Msgbox function...
« Reply #4 on: January 28, 2016, 03:31:38 PM »
No need, gotta love Mach and VB :)

Here is my button script, no need for a macro as all the macro script can be run direct thus...

Dim Msg, Style, Title, Response

If GetOEMLed(804)<>0 Then Exit Sub'make sure code is not running

Msg = "Please Remove The Torch And Move Z To A Safe Height" 'Define message.
Style = 1 + 64 + 256 'Define buttons.'Style = vbokcancel + vbinformation + vbDefaultButton2 buttons.
Title = "Torch Consumable Change" 'Define title.
Response = MsgBox(Msg, Style, Title) 'Display message.

If Response = 1 Then
  Code "G91" 'switch To incremental mode
  Code "G00 X22.00" 'position probe switch
  Code "G90" 'switch To absolute mode

  ActivateSignal(OutPut3) 'triggers the probe cylinder

  Code "G28.1 Z10.000" 'probe the surface
  Code "G92 Z#15045" 'apply the probe switch offset from settings screen DRO

  DeActivateSignal(OutPut3) 'raise the probe
  Sleep(200)

  Code "G91" 'switch To incremental mode
  Code "G00 X-22.00" 'put the axes back To where we came from
  Code "G90" 'switch To absolute mode
  Code "G00 Z0.00"

  Msg = "Replace Torch After Changing Consumables" 'Define message.
  Style = 0 + 64 + 0 'Define buttons.'Style = vbokonly + vbinformation + vbDefaultButton1 button
  Title = "Torch Consumable Change" 'Define title.   
  Response = MsgBox(Msg, Style, Title) 'Display message.

  Code "G00 Z1.00"'raise torch to 1mm

  Msg = "Verify Calibration With 1mm Feeler Gauge" 'Define message.
  Response = MsgBox(Msg, Style, Title) 'Display message.

  Code "G00 Z20.00"'raise torch to safe height ready for work
End If
 
The need for this is due to my "after-market" IHS probe method, as the probe is not done by the actual torch now, any change in torch position - new consumables, switching to the 30A unshielded from 45A shielded parts etc, upsets the reference between torch nozzle and probe switch - the "switch offset".

My little script here prompts me to remove the torch, runs a IHS sequence against a heavy reference plate (a 3" disc of steel I have), parks the Z axis at Z0.00 then prompts me to replace the torch after fitting new parts etc, the torch is clamped up with the nozzle touching the reference plate. It then moves to Z1.00 so I can verify the setting with a feeler gauge if wanted then it moves to my safe-Z height.

Sounds complex, takes seconds and i get super accurate IHS and another useful button on my screen :)

I do a lot of VB6 programming at work and this version of VB is very close so it's fun to mess with.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Msgbox function...
« Reply #5 on: January 28, 2016, 04:01:37 PM »
Slight edit, new If...Then section

If Response = 1 Then
  Code "G91" 'switch To incremental mode
  Code "G00 X22.00" 'position probe switch
  Code "G90" 'switch To absolute mode
  ActivateSignal(OutPut3) 'triggers the probe cylinder
  Code "G28.1 Z10.000" 'probe the surface
  Code "G92 Z#15045" 'apply the probe switch offset from settings screen DRO
  DeActivateSignal(OutPut3) 'raise the probe
  Sleep(200)
  Code "G91" 'switch To incremental mode
  Code "G00 X-22.00" 'put the axes back To where we came from
  Code "G90" 'switch To absolute mode
  Code "G00 Z0.00"

  Msg = "Change Consumables And Replace Torch" 'Define message.
  Style = 0 + 64 + 0 'Define buttons.'Style = vbokonly + vbinformation + vbDefaultButton1 button
  Response = MsgBox(Msg, Style, Title) 'Display message.

  Code "G00 Z25.00"
  Code "G91" 'switch To incremental mode
  Code "G00 X22.00" 'position probe switch
  Code "G90" 'switch To absolute mode
  ActivateSignal(OutPut3) 'triggers the probe cylinder
  Code "G28.1 Z10.000" 'probe the surface
  Code "G92 Z#15045" 'apply the probe switch offset from settings screen DRO
  DeActivateSignal(OutPut3) 'raise the probe
  Sleep(200)
  Code "G91" 'switch To incremental mode
  Code "G00 X-22.00" 'put the axes back To where we came from
  Code "G90" 'switch To absolute mode
  Code "G00 Z1.00"

  Msg = "Verify Calibration With 1mm Feeler Gauge" 'Define message.
  Response = MsgBox(Msg, Style, Title) 'Display message.

  Code "G00 Z20.00"'raise torch to safe height ready for work
End If

It now does a fresh IHS after replacing the parts and goes to 1mm for verification.

Questions...

In the above code,

Do I need any "While IsMoving" commands??
Can I dump any of the Abs / Inc switches???

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #6 on: January 28, 2016, 04:13:20 PM »
OH Boy another gameboy button maker (;-)  You do know there is a limit on the number of buttons you can have on a screen it is about 3,452,126 you may be close by now.

Sorry I thought you wanted to run it from Gcode My Bad.

(;-) TP

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #7 on: January 28, 2016, 04:16:56 PM »
LOng ago when I was jockeying torch setups I used teh Tool Table to store teh different offsets. There are 5 values you can access for each tool and call when needed. In the Gcode I simply called teh ToolChange (M6T2) and in teh M6 start I retreived the different values for that tool and applied them to teh TOM offsets similar to what you want. 

Just a thought, (;-) TP

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Msgbox function...
« Reply #8 on: January 28, 2016, 04:27:17 PM »
Gameboy button maker - love it :)

Functions are king - if something needs doing, why not fit a button to do it ;)

I did browse the tool table thing BUT as there is no fixed stop for the torch (it does not like being slammed up against the clamp as air comes out round the top of the nozzle-tube-mount thingy, presumably to cool the handle?) I couldn't see a way of making it work that way.

I think this will do it, will test it this weekend.

Should i add any while-ismoving lines or change any of the inc/abs switches????

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Msgbox function...
« Reply #9 on: January 28, 2016, 05:22:23 PM »
Try it like this. It should be fine. You need teh Inc/abs switches.


If Response = 1 Then
  Code "G91" 'switch To incremental mode
  Code "G00 X22.00" 'position probe switch
  Code "G90" 'switch To absolute mode
  ActivateSignal(OutPut3) 'triggers the probe cylinder
  Code "G28.1 Z10.000" 'probe the surface
  Code "G92 Z#15045" 'apply the probe switch offset from settings screen DRO
While Ismoving()
Wend
  DeActivateSignal(OutPut3) 'raise the probe
  Sleep(200)
  Code "G91" 'switch To incremental mode
  Code "G00 X-22.00" 'put the axes back To where we came from
  Code "G90" 'switch To absolute mode
  Code "G00 Z0.00"
While Ismoving()
Wend
  Msg = "Change Consumables And Replace Torch" 'Define message.
  Style = 0 + 64 + 0 'Define buttons.'Style = vbokonly + vbinformation + vbDefaultButton1 button
  Response = MsgBox(Msg, Style, Title) 'Display message.

  Code "G00 Z25.00"
  Code "G91" 'switch To incremental mode
  Code "G00 X22.00" 'position probe switch
  Code "G90" 'switch To absolute mode
While Ismoving()
Wend
  ActivateSignal(OutPut3) 'triggers the probe cylinder
  Code "G28.1 Z10.000" 'probe the surface
  Code "G92 Z#15045" 'apply the probe switch offset from settings screen DRO
While Ismoving()
Wend
  DeActivateSignal(OutPut3) 'raise the probe
  Sleep(200)
  Code "G91" 'switch To incremental mode
  Code "G00 X-22.00" 'put the axes back To where we came from
  Code "G90" 'switch To absolute mode
  Code "G00 Z1.00"
While Ismoving()
Wend
  Msg = "Verify Calibration With 1mm Feeler Gauge" 'Define message.
  Response = MsgBox(Msg, Style, Title) 'Display message.

  Code "G00 Z20.00"'raise torch to safe height ready for work
End If

END


GOTA LOVE IT  ""  Functions are king - if something needs doing, why not fit a button to do it Wink ""

BUT I take it another step further " IF it is worth doing make it fully automatic"  forget the button. That is what the tool routine did make it automatic.

(;-) TP