Need Help! KFlop to Super PID PWM contorl


Results 1 to 7 of 7

Thread: KFlop to Super PID PWM contorl

  1. #1
    Member
    Join Date
    Dec 2010
    Location
    United States
    Posts
    34
    Downloads
    0
    Uploads
    0

    Question KFlop to Super PID PWM contorl

    I have a DIY CNC 4 axis router controlled by Mach3 & parallel. My spindle is a Bosh 1617 controlled with a SuperPID. Mach3 outputs a PWM signal to the SuperPID and works great. I decided to dump the parallel port control and install Dynomotion's Kflop and Konnect boards. I am driving my stepper amps directly from the Kflop and the limit switches with the Kconnect board. The Kflop board has been just a bit tricky to figure out but I am getting there. My question is, has anyone used a Kflop board to drive a SuperPID using PWM rather then 0 to 10 volts outputted with a DAC? ANy help would be appreciated

    Similar Threads:


  2. #2
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: KFlop to Super PID PWM contorl

    Hi JoeKumanchik,

    KFLOP has 8 PWM Generators on JP6. See the PWM1KHZ.c example:

    Code:
    #include "KMotionDef.h"
    
    main()
    {
    	SetBitDirection(26,1);  // define bit as an output
    	FPGA(IO_PWMS_PRESCALE) = 65;  	// divide clock by 65 (1 KHz)
    	FPGA(IO_PWMS) = 128;  			// square wave
    	FPGA(IO_PWMS+1) = 1;  			// Enable
    }

    to test whether you can control desired speeds. The value of 128 sets the duty cycle to 50%


    HTH
    Regards

    Regards
    TK http://dynomotion.com


  3. #3
    Member
    Join Date
    Dec 2010
    Location
    United States
    Posts
    34
    Downloads
    0
    Uploads
    0

    Default Re: KFlop to Super PID PWM contorl

    Thanks for the response Tom. I think I am getting this figured out. I keep reading the documentation and looking at the examples and it is slowly starting to make sense. I am assuming that the PWM signal will pass through the Konnect board since it is connected to JP6 and I can output the signal through an output pin on the Konnect board. I am also thinking that I will select bits for the Spindle CW On, Spindle CCW ON, and Spindle Stop commands that are within the Konnect board output address. Below is the sample code I am using


    #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

    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);

    SetBitDirection(26,1); // define bit as an output
    FPGA(IO_PWMS_PRESCALE) = 65; // divide clock by 65 (1 KHz)
    FPGA(IO_PWMS) = (unsigned char)(255.0f*speed); // set period
    FPGA(IO_PWMS+1) = 1; // Enable

    break;

    case EX_SPINON:
    if (Direction==0)
    {
    printf("Spindle CW ON\n");
    SetBit(144);
    ClearBit(145);
    }
    else if (Direction==1)
    {
    printf("Spindle CCW ON\n");
    ClearBit(144);
    SetBit(145);
    }
    break;

    case EX_SPINOFF:
    {
    printf("Spindle Stop\n");
    ClearBit(144);
    ClearBit(145);
    }
    break;
    }
    }



  4. #4
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: KFlop to Super PID PWM contorl

    Hi JoeKumanchik,

    That is mostly correct except that JP6 PWM signals can not be passed through to Konnect. Konnect requires a dedicated Aux Port for it to operate. Konnect can be connected to either Aux0 (JP4) or Aux1 (JP6). So in your case you should move Konnect to to JP4. Then use the AddKonnect_Aux0() function to activate it instead of the AddKonnect() function.

    HTH
    Regards

    Regards
    TK http://dynomotion.com


  5. #5
    Member
    Join Date
    Dec 2010
    Location
    United States
    Posts
    34
    Downloads
    0
    Uploads
    0

    Default Re: KFlop to Super PID PWM contorl

    Hi Tom,

    First I wanted to let you know I was able to get the SuperPID speed controller working. 1khz PWM base frequency works fine.

    I do have another question about programming in general.Can you give me a brief overview on how the Mach3 info is passed into Kflop C programs? As an example, in the reference all axis for mach the first line is "int flags = persist.UserData[5];". I understand that "flags" is being defined as an integer value of "persist.UserData[5]" but what I do not understand is where did the "persist.UserData[5]" come from. According to what I have read, the "Ref All" for Homing is OEM button is 105 in the screen set. How does this value influence the "persist.UserData[5]"

    I would be grateful if you can point me in the right direction to read up on this or possibly explain how this works



  6. #6
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: KFlop to Super PID PWM contorl

    Hi JoeKumanchik,

    For Mach3 Homing when Mach3 wants to home (ref) some axes it calls the Plugin and passes the "flags" value to specify which axes it would like to home.

    When our Plugin receives this it places the "flags" value into a KFLOP persist.UserData variable that has been specified as the "Var" setting in the Dynomotion Plugin Configuration that you configure. The default is 5. It then compiles/downloads/executes the C Program that you have configured for Homing.

    HTH
    Regards

    Regards
    TK http://dynomotion.com


  7. #7
    Member
    Join Date
    Dec 2010
    Location
    United States
    Posts
    34
    Downloads
    0
    Uploads
    0

    Default Re: KFlop to Super PID PWM contorl

    So the Mach3 plug in allows you to define a storage location "Var x" and you receive the data in the C program by making sure the persist.UserData[x} number matches. Got it.

    Thanks so much for the explanation. It's making sense now



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
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

KFlop to Super PID PWM contorl

KFlop to Super PID PWM contorl