Good question. Below (and attached) are 3 C programs that I think do what you require. If an M4 is called after an M3, then the M3 bit will be turned off, then delay, then M4 will turn on. Similar for M3 after M4. Save and modify each for your specific output bit numbers and output polarity. The default bits are 46 and 47 which are the KFlop LEDs. Assign each of the M3, M4, and M5 codes to run the respective programs in the KMotionCNC Tool Setup Screen. Select the Exec/Wait mode and an unused thread and var (1,1 should work).
#include "KMotionDef.h"
#define M3BIT 46 // set to bit to enable CW spindle
#define M4BIT 47 // set to bit to enable CCW spindle
#define ON 1 // set to 1 for positive true output else 0
main()
{
printf("M3\n");
if (ReadBit(M4BIT)==ON)
{
// M4 was active
SetStateBit(M4BIT,1-ON);
Delay_sec(3.0);
}
SetStateBit(M3BIT,ON);
}
#include "KMotionDef.h"
#define M3BIT 46 // set to bit to enable CW spindle
#define M4BIT 47 // set to bit to enable CCW spindle
#define ON 1 // set to 1 for positive true output else 0
main()
{
printf("M4\n");
if (ReadBit(M3BIT)==ON)
{
// M4 was active
SetStateBit(M3BIT,1-ON);
Delay_sec(3.0);
}
SetStateBit(M4BIT,ON);
}
#include "KMotionDef.h"
#define M3BIT 46 // set to bit to enable CW spindle
#define M4BIT 47 // set to bit to enable CCW spindle
#define ON 1 // set to 1 for positive true output else 0
main()
{
printf("M5\n");
if (ReadBit(M3BIT)==ON || ReadBit(M4BIT)==ON)
{
// M3 or M4 was active, turn both off, delay
SetStateBit(M3BIT,1-ON);
SetStateBit(M4BIT,1-ON);
Delay_sec(3.0);
}
}
| Group: DynoMotion |
Message: 87 |
From: s.astrom |
Date: 12/25/2009 |
| Subject: Re: More C help wanted |
|
This was just what i wanted. Works great. Thanx
|
|