Page 1 of 2

Coding for a VCP button

Posted: Thu Sep 05, 2019 2:04 am
by FlyingHaggis
Are there any good examples of coding a button in the VCP ?

I don't mean calling a macro, i mean code as the button needs to work when a NC program is running.
Hopefully the example shows the steps for the build process and the inclusion of the button graphics etc..

Re: Coding for a VCP button

Posted: Fri Sep 06, 2019 8:56 pm
by cnckeith
the VCP is a 'skin' you can learn more about 'Skinning" in the Skinning folder int he cncm directory.
the VCP is built in Microsoft Visual Studio using C#

the coming updated version of the VCP will have an intermediate file that it "looks" to to build the buttons. this will be an XML file that is user editable. user will be able to edit the XML file to change the buttons colors, Text, and function.

Re: Coding for a VCP button

Posted: Fri Sep 06, 2019 11:36 pm
by cncsnw
What kind of action do you have in mind for the button?

Graphics aside, most of an implementation would be in your PLC program.

For example, whenever the button you have circled is touched, your PLC program should see SV_SKIN_EVENT_24 "SkinAux13_M" on (1). When that button is not pressed, the bit would be off (0).

Re: Coding for a VCP button

Posted: Sat Sep 07, 2019 11:46 am
by FlyingHaggis
I would like to implement this....

Button
toggle #109 between the values 1 and 0
if #109 == 1 then show the active light in the corner of the button

When a NC program is run the value of #109 may be set in the G code, i'd like the active light to reflect the state of #109

A bit like how the flood and spindle buttons work.

Re: Coding for a VCP button

Posted: Sat Sep 07, 2019 2:09 pm
by cncsnw
To do exactly what you describe is not possible. Only the PLC program can respond in real time to button presses, and the PLC program does not have access to CNC variables such as #109.

You can achieve your intent by using a memory bit in the PLC program instead of a CNC variable.

The PLC program can then set and clear the bit in response to button presses, and can light up the LED when the bit is set.

If you need the CNC program to also be able to set and clear the bit, then you can use an M94/M95 request.

The CNC program cannot test the state of M94/M95 flags, but it can test PLC output bits (including the jog panel outputs for Aux LEDs).

For example, the appropriate sections of your PLC program could include:

Code: Select all

SpecialRequest_SV IS SV_M94_M95_123
; ...
Aux13PD IS PD78
; ...
IF SkinAux13_M THEN (Aux13PD)
IF SpecialRequest_SV ^ Aux13PD THEN (SpecialRequest_SV), (Aux13LED)
Your CNC program could check status by looking at the Aux13LED bit (OUT1080, CNC variable #61080). It can change the status using M94 and M95.

For example:

Code: Select all

IF [#61080 == 0] THEN GOTO 200  ; if no request, then skip
   ; do some special action...
   M95/123 ; clear the request until next time
 N200
 ; continue normal operation 

The PLC code above:

Code: Select all

IF SkinAux13_M THEN (Aux13PD)
IF SpecialRequest_SV ^ Aux13PD THEN (SpecialRequest_SV), (Aux13LED)
is a standard method of toggling a bit on and off with a keypress. Using the XOR operator (^), the new value of SpecialRequest_SV is the same as the old value if the key has not been pressed, and is the opposite of the old value if the key has been pressed.

Note that the PLC program is allowed to change the value of an M94/M95 request flag. In between PLC scans, the CNC program might also change the value of that same request flag using M94 or M95.

Re: Coding for a VCP button

Posted: Sun Sep 08, 2019 11:47 am
by FlyingHaggis
Many many thanks for such a detailed answer.

I'll start reading the PLC stuff now.


Thanks.

Re: Coding for a VCP button

Posted: Mon Sep 09, 2019 9:53 am
by cnckeith
PLC programming video series..is here.
https://www.youtube.com/playlist?list=P ... i2WKIedQlQ

Re: Coding for a VCP button

Posted: Wed Nov 20, 2019 1:34 pm
by FlyingHaggis
Hi Keith

You mentioned there would be a version soon that supported changing images of the VCP buttons in an easier manner than present.
Is there an eta for that update ?

Re: Coding for a VCP button

Posted: Mon Nov 25, 2019 1:18 am
by briuz
Is changing the images part of the new Beta release?

Thanks!

FlyingHaggis wrote: Wed Nov 20, 2019 1:34 pm Hi Keith

You mentioned there would be a version soon that supported changing images of the VCP buttons in an easier manner than present.
Is there an eta for that update ?

Re: Coding for a VCP button

Posted: Mon Nov 25, 2019 1:27 am
by Dan M
briuz wrote: Mon Nov 25, 2019 1:18 am Is changing the images part of the new Beta release?

Thanks!

FlyingHaggis wrote: Wed Nov 20, 2019 1:34 pm Hi Keith

You mentioned there would be a version soon that supported changing images of the VCP buttons in an easier manner than present.
Is there an eta for that update ?
No