Page 1 of 1

LED for Analog Output?

PostPosted: Thu May 26, 2022 10:43 am
by krsykes23
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.

Re: LED for Analog Output?

PostPosted: Thu May 26, 2022 10:55 am
by ger21
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

Re: LED for Analog Output?

PostPosted: Thu May 26, 2022 11:47 am
by krsykes23
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
}

Re: LED for Analog Output?

PostPosted: Thu May 26, 2022 12:32 pm
by ger21
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
}

Re: LED for Analog Output?

PostPosted: Thu May 26, 2022 1:44 pm
by krsykes23
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.