Dynomotion

Group: DynoMotion Message: 85 From: s.astrom Date: 12/21/2009
Subject: More C help wanted
I want to modify my machine so i can program M3 and M4, now i have to start and stop the motors manualy.
I need a C code that when M3 it checks that the pin for M4 is off then sets the pin for M3, and if M4 it checks, and if nessesary sets pin for M3 to of then turns M4 on.
It should not be possible to start M3 if M4 is on and Not to start M4 if M3 is on

Hope this makes sense.
Group: DynoMotion Message: 86 From: Tom Kerekes Date: 12/21/2009
Subject: Re: More C help wanted
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