Page 1 of 1

How to show button using if-then condition

Posted: Tue Dec 19, 2023 5:20 pm
by DesertRider
Hello, I have begun customizing my Acorn VCP. I have a KP-3 touch probe and probe detect is on Input 6 of Acorn, whereas probe tripped is on Input 7.

I would like to add a probe display (not press button) with conditional appearance combining inputs 6 and 7. For example, if Input 6 is OFF, there would be one SVG image (say "probe not present") . If input 6 is ON and Input 7 is OFF the button shows one way (e.g. probe present in green; that would be the default, probe connected but not tripped). If tripped, it would show "Tripped" in red.

I was able to create two buttons (probe_detected reading input 6 and probe_tripped reading input 7) with the desired functionality, but would like to combine them. Is there a specific syntax I can use in the xml. Apologies if this is trivial, I have no xml experience. The esthetics of these buttons are irrelevant for now, and I will ultimately combine them into one informational display, but I need to know how to use both inputs with the if-then clause. THANK YOU.

This is what I have so far:

Code: Select all

<vcp_button>
	<plc_input>
		<number>6</number>
		<image_on>probe_detected_yes.svg</image_on>
		<image_off>probe_detected_no.svg</image_off>
	</plc_input>
</vcp_button>

Code: Select all

<vcp_button>
	<plc_input>
		<number>7</number>
		<image_on>probe_trip.svg</image_on>
		<image_off>probe_clear.svg</image_off>
	</plc_input>
</vcp_button>
IMG_3098.jpg
IMG_3099.jpg

Re: How to show button using if-then condition

Posted: Wed Dec 20, 2023 10:33 am
by dpascucci_support
Thinking through it more, I think I thought of a way to get it to work, but it involves adding logic to the PLC.

Edit: It can be done. It involves adding 3 lines of logic to the plc. 3 buttons are mapped to the same vcp coordinate, emulating one button with three states instead of just two.

Re: How to show button using if-then condition

Posted: Thu Dec 21, 2023 1:01 pm
by DesertRider
Thank you for the reply. Any thoughts on how one could do it through the PLC?

Re: How to show button using if-then condition

Posted: Thu Dec 21, 2023 3:51 pm
by dpascucci_support
You'll need three new memory bits for each condition (NoProbe_M, ProbeClear_M, ProbeTripped_M) and in the mainstage add the logic such that the correct memory bit is SET given the current input states. Make sure that only 1 memory bit is SET at any given moment (ie when you SET one, RST the other two). Then compile the program. Refer to the PLC manual for more information on the logic and Setting/Resetting memory bits: https://www.centroidcnc.com/centroid_di ... manual.pdf

For the VCP buttons, create three buttons and map them to the coordinate you want and have them watch the corresponding memory using the <plc_memory> and <number> tags. Set the SVGs of your choosing as with <image_on> and set a blank SVG with <image_off> (you can grab a blank svg from wikipedia here if you need: https://en.wikipedia.org/wiki/File:Blank.svg

When done correctly, you'll have all three buttons mapped to one place, and only one of the buttons will be visible at a time.

Re: How to show button using if-then condition

Posted: Thu Dec 21, 2023 8:42 pm
by cncsnw
Doesn't the developmental v5.08 software have a new VCP feature for showing/hiding buttons and other elements in response to PLC conditions?

That would eliminate the need for "blank" SVG files when a button is not present.

Re: How to show button using if-then condition

Posted: Fri Dec 22, 2023 10:18 am
by dpascucci_support
Point 5 in the v5.08 release notes (https://centroidcncforum.com/viewtopic.php?f=67&t=9517) describes the Switching functionality. This method requires button groups to be defined but it can absolutely be done.

Re: How to show button using if-then condition

Posted: Fri Dec 22, 2023 10:38 pm
by DesertRider
I am currently on 4.6.4. and my system works perfectly. I was somewhat reluctant to update but sounds like that is necessary. Will try to do it over the weekend. I very much appreciate the replies; while programming the PLC seems way out of my skill set will look up the manual and decide if I want to try it.