#include "KMotionDef.h"
//Plugin Notifications and defines..
enum { EX_DDA , EX_VMS, EX_COMMAND, EX_SPINON, EX_SPINOFF, EX_SPINSPEED, EX_MOTORTUNED
, EX_SETUP, EX_FEEDHOLD, EX_RUN, EX_ESTOP , EX_CONFIG };
main()
{
int message = persist.UserData[0]; // Mach3 message ID
int Direction = persist.UserData[1]; // Mach3 Spindle Direction
float speed = *(float *)&persist.UserData[2]; // value stored is actually a float
float SpindleSpeed;
SpindleSpeed=speed*4300; /My Constant
switch (message)
{
case EX_SPINSPEED:
if (SpindleSpeed>500)
{
ch3->InputGain0=1;
printf("+Spindle Speed Set to %f High Range\n",SpindleSpeed);
}
else
{
ch3->InputGain0=1/8.3;
printf("-Spindle Speed Set to %f LOW Range\n",SpindleSpeed);
}
break;
case EX_SPINON:
if (Direction==0)
{
printf("Spindle CW ON\n");
}
else if (Direction==1)
{
printf("Spindle CCW ON\n");
}
break;
case EX_SPINOFF:
{
printf("Spindle Stop\n");
}
break;
}
}