Hi PeterTheWolf,
I was thinking that would be accomplished with the "OFF" position of the axis selection knob since this MPG pendant does not have the a safety switch to be held-In while using it.
Yes of course you can do this. What confused me was on the schematic the 4 positions were labeled X Y Z A. Let's treat the A selection as "OFF". BTW its actually not necessary to have the OFF position wired in as we could assume if no X Y Z is selected, then assume OFF. But since it is wired in let's use it.
Let's change these definitions:
Code:
#define ENABLE_MPG 29 // Switch/Button used to enable MPG Motion
#define FACTOR1 31 //Petes JP6 pin #12 to MPG pin #18 Wire
#define FACTOR10 32 //Petes JP6 pin #13 to MPG pin #6 Wire
#define FACTOR100 33 //Petes JP6 pin #14 to MPG pin #19 Wire
#define FACTOR200 23 //Not Used -- Petes MPG does not have a X200 setting
#define SELECTX 28 //Petes JP6 pin #7 to MPG pin #16 Wire
#define SELECTY 29 //Petes JP6 pin #10 to MPG pin #4 Wire
#define SELECTZ 30 //Petes JP6 pin #11 to MPG pin #17 Wire
#define SELECTA 27 //Petes JP6 pin #6 to MPG pin #5 Wire
to
Code:
#define FACTOR1 31 //Petes JP6 pin #12 to MPG pin #18 Wire
#define FACTOR10 32 //Petes JP6 pin #13 to MPG pin #6 Wire
#define FACTOR100 33 //Petes JP6 pin #14 to MPG pin #19 Wire
#define SELECTX 28 //Petes JP6 pin #7 to MPG pin #16 Wire
#define SELECTY 29 //Petes JP6 pin #10 to MPG pin #4 Wire
#define SELECTZ 30 //Petes JP6 pin #11 to MPG pin #17 Wire
#define SELECTOFF 27 //Petes JP6 pin #6 to MPG pin #5 Wire
Now change
Code:
if (!ReadBit(ENABLE_MPG) || JOB_ACTIVE) // if not button pressed or Job Active ignore the encoder.
Change1 = 0;
To (notice the '!' NOT operator is removed as when the OFF bit is active we want to prevent motion, rather than when an ENABLE bit is not active). Also change to the more appropriate symbol name.
Code:
if (ReadBit(SELECTOFF) || JOB_ACTIVE) // if OFF or Job Active ignore the encoder.
Change1 = 0;
change
Code:
if (ReadBit(FACTOR1)) // is X1 selected?
Factor = 4;
else if (ReadBit(FACTOR10)) // is X10 selected?
Factor = 20;
else if (ReadBit(FACTOR100)) // is X100 selected?
Factor = 40;
else if (ReadBit(FACTOR200)) // is X200 selected?
Factor = 400;
else
Factor = 0.0;
if (ReadBit(SELECTX)) // is x selected?
Axis = 0;
else if (ReadBit(SELECTY)) // is y selected?
Axis = 1;
else if (ReadBit(SELECTZ)) // is z selected?
Axis = 2;
else if (ReadBit(SELECTA)) // is A selected?
Axis = 3;
to this because we don't have a FACTOR200 or an A axis
Code:
if (ReadBit(FACTOR1)) // is X1 selected?
Factor = 4;
else if (ReadBit(FACTOR10)) // is X10 selected?
Factor = 20;
else if (ReadBit(FACTOR100)) // is X100 selected?
Factor = 40;
else
Factor = 0.0;
if (ReadBit(SELECTX)) // is x selected?
Axis = 0;
else if (ReadBit(SELECTY)) // is y selected?
Axis = 1;
else if (ReadBit(SELECTZ)) // is z selected?
Axis = 2;
Make sense?
Regards