LED for Analog Output?

If you created a new screenset and want to share it with others then please post it here. You can talk about screens here.

LED for Analog Output?

Postby krsykes23 » Thu May 26, 2022 10:43 am

Is there a way to set an LED on the screenset to show the state of the Analog Output (VAR#1)?

I have my ATC with an Air Blow to clean the tool-holder taper. This is controlled by a relay and VAR #1, which is included in the M6 tool-change macro, plus a button on the screenset to turn on manually if required.

The button code is shown below...

// Air Blow On-Off

bool buttonstate = AS3.Getbuttonstate(20009);
if (!buttonstate)
{
AS3.Switchbutton(true,20009);
exec.Code("#1=32768"); // 5v ON
}
else
{
AS3.Switchbutton(false,20009);
exec.Code("#1=0"); // 0v OFF
}

I just need to add an LED to the status panel on the screenset, LED On when #1=32768 and LED Off when #1=0.
krsykes23
 
Posts: 39
Joined: Wed Apr 27, 2022 9:29 am

Re: LED for Analog Output?

Postby ger21 » Thu May 26, 2022 10:55 am

Add LED number 500 to the screen, and add this code to your macro in the proper spots.

AS3.SetLED(true, 500); // LED On
AS3.SetLED(false, 500)' // LED Off
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Re: LED for Analog Output?

Postby krsykes23 » Thu May 26, 2022 11:47 am

Thanks Gerry,

Still learning macro codes, getting there slowly......but I'm doing something wrong!

Added the LED but I've obviously inserted the code in the wrong place.....

// Air Blow On-Off

bool buttonstate = AS3.Getbuttonstate(20009);
if (!buttonstate)
{
AS3.Switchbutton(true,20009);
exec.Code("#1=32768"); // 5v ON
AS3.SetLED(true, 500); // LED On
}
else
{
AS3.Switchbutton(false,20009);
exec.Code("#1=0"); // 0v OFF
AS3.SetLED(false, 500)' // LED Off
}
krsykes23
 
Posts: 39
Joined: Wed Apr 27, 2022 9:29 am

Re: LED for Analog Output?

Postby ger21 » Thu May 26, 2022 12:32 pm

Typo on my part. Make sure you add LED #500 on the screen.

Code: Select all
// Air Blow On-Off

bool buttonstate = AS3.Getbuttonstate(20009);
if (!buttonstate)
{
AS3.Switchbutton(true,20009);
exec.Code("#1=32768"); // 5v ON
AS3.SetLED(true, 500); // LED On
}
else
{
AS3.Switchbutton(false,20009);
exec.Code("#1=0"); // 0v OFF
AS3.SetLED(false, 500); // LED Off
}
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Re: LED for Analog Output?

Postby krsykes23 » Thu May 26, 2022 1:44 pm

Thanks Gerry,

Works a treat with both the button and the M6 macro. At first I couldn't see what the typo was but I found it eventually.

Thanks for your help.
krsykes23
 
Posts: 39
Joined: Wed Apr 27, 2022 9:29 am


Return to Custom Screensets

Who is online

Users browsing this forum: No registered users and 10 guests