Add a button to your screenset. (See documentation for details.) Use a button picture like yellowempty_down.png and yellowempty_up.png to show chuck state. Set buttonnumber to 20105.
Add this macro to your macro folder as M20105.txt:
- Code: Select all
// ================================================================================================
// Chuck open/close
// ================================================================================================
if (AS3.Getbuttonstate(ChuckButton))
{ // Chuck is open -> close it
if (OpenChuckOn1)
exec.Clroutpin(ChuckPort, ChuckPin);
else
exec.Setoutpin(ChuckPort, ChuckPin);
AS3.Switchbutton(false, ChuckButton);
}
else
{ // Chuck is closed -> open it
if (OpenChuckOn1)
exec.Setoutpin(ChuckPort, ChuckPin);
else
exec.Clroutpin(ChuckPort, ChuckPin);
AS3.Switchbutton(true, ChuckButton);
}
// ================================================================================================
#Events
// ================================================================================================
const int ChuckButton = 20105; // Must be the same as macro and button number
const int ChuckPort = 1; // UC100 is always port 1
const int ChuckPin = 1; // Set this to the output pin for chuck
const bool OpenChuckOn1 = true; // True if chuck opens on pin high level else set to false
If your chuck opens on low level output, change in the last line true to false. Set ChuckPin to your output. If you changed OpenChuckOn1 to false, only then add the following line to M99998.txt (it will set the output high on stratup):
- Code: Select all
exec.Setoutpin(1,1); // Port and pin, where port is always 1, pin is your output