587,086 active members*
2,831 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Dynomotion/Kflop/Kanalog > KFlop how to configure spindle as Step and Dir No output for DIR
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2006
    Posts
    37

    KFlop how to configure spindle as Step and Dir No output for DIR

    I'm working on converting my Mach 3 controlled 4 axis mill (XYZA). It has a Break out board which takes Step/Dir signals for the spindle and outputs 10V and on/off signal to control the VFD.

    Working: I can get Step and Dir for XYZA to output.

    Problem: I cannot get the Dir signal to output for spindle. Step works great in the Console using Jog4=2000, as well as in KmotionCNC using "on CW" and "on CCW"

    Settings:

    I'm using these programs for spindle:
    M3 SpindleOnCWJogV2.c
    M4 SpindleOnCWWJogV2.c
    M5 SpindleOffJogV2.c
    S SpindleMillJogV2.c

    Spindle .c file headers:
    Code:
    #include "KMotionDef.h"
    
    #define SPINDLEAXIS 4
    #define FACTOR (1000/60.0) //1000 counts/sec / 1000 counts/rev = 1 RPS = 60 RPM
    #define SPINDLECW_BIT 38
    #define SPINDLECCW_BIT 39
    #define SPEEDVAR 99
    #define STATEVAR 98
    #define KMVAR 1
    Init.c contains:
    Code:
    	SetBitDirection(38,1); // Set Bit 38 as an Output
    	SetBitDirection(39,1); // Set Bit 39 as an Output
    I don't see any change when I turn on the spindle while probing J5 pins 3 and 43 (bits 38 and 39)

    Right now I am using a simple USB logic analyzer to monitor the outputs of the KFLOP.
    I don't think I need pull-ups on J5 since they are LVTTL, correct?

    DefineCoordSystem(01234)

    I feel like i'm so close to getting it. I don't really know much about coding in C, but can follow most of it.

    Anyway any help would be great.

    Thanks,

    Steven

  2. #2
    Join Date
    May 2006
    Posts
    4047

    Re: KFlop how to configure spindle as Step and Dir No output for DIR

    Hi Steven,

    There must be a C program created and configured in the Dynomotion plugin configuration to handle the messages to the plugin to turn the spindle on/off and set the speed.

    Try the one below derived from the examples. I added the code to switch your bits 38 and 39.

    The hardware, wiring, and axis configurations should all be correct because the Jogs and KMotionCNC is working properly.


    Code:
    #include "KMotionDef.h"
    
    // Handles Mach3 Messages to command an Axis to Jog 
    // Assumes two bits used to enable CW or CCW Spindle directions
    
    //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 };
    
    
    #define SPINDLE_AXIS 4  // axis set up as Spindle, possibly Step/Dir or Servo
    #define FACTOR 2000000.0            // Converts fractional pulley speed to counts/sec (may be negative)
    #define SPINDLECW_BIT 38
    #define SPINDLECCW_BIT 39
    
    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
    	int *On = &persist.UserData[3];  // Place to remember whether we are on or off
    	int DirFactor = -1;
    
    	if (Direction==0) DirFactor=1; // change Direcion 0 or 1 to DirFactor -1 or +1
    
    	printf("Mach3 Notify Message=%d, Direction=%2d, Spindle Set to %f\n",message,Direction,speed);
    
    	switch (message)
    	{
    	case EX_SPINSPEED:
    		printf("Spindle Speed Set to %f\n",speed);
    		if (*On)
    		{
    			printf("Spindle Is Running\n");
    			Jog(SPINDLE_AXIS,speed*FACTOR*DirFactor);
    		}
    		break;
    
    	case EX_SPINON:
    		*On = TRUE;
    		if (Direction==0)
    		{
    			SetBit(SPINDLECW_BIT);
    			ClearBit(SPINDLECCW_BIT);
    			Jog(SPINDLE_AXIS,speed*FACTOR);
    			printf("Spindle CW ON\n");
    		}
    		else if (Direction==1)
    		{
    			ClearBit(SPINDLECW_BIT);
    			SetBit(SPINDLECCW_BIT);
    			Jog(SPINDLE_AXIS,speed*FACTOR*-1);
    			printf("Spindle CCW ON\n");
    		}
    		break;
    
    	case EX_SPINOFF:
    		*On = FALSE;
    		printf("Spindle Stop\n");
    		ClearBit(SPINDLECW_BIT);
    		ClearBit(SPINDLECCW_BIT);
    		Jog(SPINDLE_AXIS,0.0);
    		break;
    	}
    }
    HTH
    Regards
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Mar 2006
    Posts
    37

    Re: KFlop how to configure spindle as Step and Dir No output for DIR

    Hi Tom,

    Thanks for your response.

    I should have been more clear. I'm not interested in using Mach3 anymore. I'm interested in using Kmotioncnc. I like that it has one screen with everything I need on it.

    With regard to the "on CW" and "on CCW" can you see anything wrong with my code/settings? Like I said, the step pulses when I issue the command Jog4=2000 in the console works, but the signals for the relays don't seem to be working in either Kmotion or kmotionCNC.

    Thanks.

    Steven

  4. #4
    Join Date
    May 2006
    Posts
    4047

    Re: KFlop how to configure spindle as Step and Dir No output for DIR

    Hi Steven,

    Oh, sorry. No I don't see anything particularly wrong.

    If you toggle Bits 38 or 39 on the KMotion.exe Digital I/O Screen does the Spindle relays turn on?

    Please post the modified 4 Spindle C Programs and your full Initialization C Program so we can see those.

    Also a screen shot of the KMotionCNC | Tool Setup | M0-M30 configuration page.

    Regards
    TK
    http://dynomotion.com

  5. #5
    Join Date
    Mar 2006
    Posts
    37

    Re: KFlop how to configure spindle as Step and Dir No output for DIR

    I think I understand what was happening. I'm almost done with the bench testing and just about ready to install it on the machine.

    Two things I need help with still:


    I have changed my CW and CCW bits to 6 and 7 in my init.c program:

    SetBitDirection(6,1); // Set Bit 06 as an Output
    SetBitDirection(7,1); // Set Bit 07 as an Output

    The CW and CCW outputs don't work until I go into the Digital I/O menu and tick the bits as output. Shouldn't this be taken care of by the init.c program?


    Also, how do I add a delay to allow for spindle spin up?
    Can I just add "Delay_sec(3.0);" to the end of the CW and CCW programs?
    If I eventually put an encoder on the spindle, would Kmotion CNC take care of this in the feedback process?

    Thanks for your help.

    -Steven

  6. #6
    Join Date
    Mar 2006
    Posts
    37

    Re: KFlop how to configure spindle as Step and Dir No output for DIR

    OK,

    I figured out the CW and CCW outputs not being setup as outputs during init. I had them at the bottom of my init.c program.

    But I still need help with the spindle spin up delay.

    Thanks again.

    -Steven

  7. #7
    Join Date
    May 2006
    Posts
    4047

    Re: KFlop how to configure spindle as Step and Dir No output for DIR

    Hi Steven,

    Yes you should be able to add the delays before exiting into the CW CCW programs. You will need to configure M3 and M4 as Exec/wait/Sync so that the Interpreter waits for the programs complete.

    HTH
    Regards
    TK
    http://dynomotion.com

Similar Threads

  1. Step by step guide settings Kflop (Russian language)
    By ukr_sasha in forum Dynomotion/Kflop/Kanalog
    Replies: 2
    Last Post: 04-29-2015, 05:23 PM
  2. Does Kflop have a built in Step Multiplier?
    By slimneill in forum Dynomotion/Kflop/Kanalog
    Replies: 3
    Last Post: 03-04-2014, 02:41 AM
  3. kflop step&dir in velocity mode?
    By mmontev in forum Dynomotion/Kflop/Kanalog
    Replies: 4
    Last Post: 06-24-2013, 02:38 AM
  4. Kflop Dir / Step setup time
    By BobKinsman in forum Dynomotion/Kflop/Kanalog
    Replies: 3
    Last Post: 11-16-2012, 12:10 AM
  5. Not getting +5 VDC output with KFlop
    By nova24 in forum Dynomotion/Kflop/Kanalog
    Replies: 0
    Last Post: 01-30-2012, 03:31 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •