Spindle PWM, issues changing PWM prescale, X-axis "rings"!


Results 1 to 2 of 2

Thread: Spindle PWM, issues changing PWM prescale, X-axis "rings"!

  1. #1
    Registered
    Join Date
    Oct 2016
    Posts
    1
    Downloads
    0
    Uploads
    0

    Default Spindle PWM, issues changing PWM prescale, X-axis "rings"!

    I have a somewhat hacked K2CNC (3-axis, 2x3ft, 2.2kWspindle) system, could not figure out how to get the 0-10V analog spindle control signal out of their breakout board, so I worked around it with a standalone PWM-to-Analog board, attempting to use pin33(PWM7) to generate a 1-3kHz 3.3V PWM signal, converting it to 0-10V analog for the spindle VFD. That works great, spindlepwm.c does what it needs to do and I can control spindle RPM from Gcode.

    So... This all worked fine with no axis plugged in. With the axes plugged in, my X-axis "rings" as soon as I send an SXXXXX command, its a nice sharp and loud tone. The axis will move, but makes a pretty ugly noise in the process.

    With the standalone PWM->analog board completely removed from the system, I get the same result, its not a wiring issue, or is my logic here incorrect?

    If I comment out the scaler change line from spindlepwm.c, I dont get the ringing, but my PWM frequency is too high (I think?) and the board cannot detect the signal. So, in changing the prescale to get pin 33 to where I want it, something else is happening... not really sure where to go next.

    Questions:
    1. What could be causing X-axis to freak out? or what do I do next to troubleshoot?
    2. Any tips on learning more about FPGA() commands in use? Im a C novice and have not had luck in finding anything online that explains what this is doing to me, I dont know enough to really understand what the comments are trying to communicate, most of the FPGA() lines beyond "prescale" look like black boxes to me.
    3. Any workarounds? stepaspwm.c doesnt seem like it would work for me, and I would want to use it through one of the open IO pins not through an axis channel if possible...


    Thanks in advance!

    Here is my spindlepwm.c:

    #include "KMotionDef.h"


    #define MAX_RPM 18000.0f
    #define PWM_NUMBER 7 //0-7 pins 27-33
    #define pdSpindleRPM 35


    #define INVERT


    main()
    {
    int pwm;
    float speed = *(float *)&persist.UserData[pdSpindleRPM]; // value stored is actually a float

    pwm = speed/MAX_RPM * 255.0f;

    if (pwm > 255) pwm=255; // limit to max pwm value
    if (pwm < 85) pwm=0; // limit to min pwm value


    #ifndef INVERT
    pwm = 255 - pwm; // set the PWM


    #endif


    //pwm = 128;//165-175

    printf("Spindle Set to %f pwm %d\n",speed, pwm); // print the desired speed
    SetBitDirection(26+PWM_NUMBER,1); // Set bit PWM pin as an output
    FPGA(IO_PWMS_PRESCALE) = 33; // PWM approx 1 KHz
    FPGA(IO_PWMS+2*PWM_NUMBER+1) = 1; // enable the PWM
    FPGA(IO_PWMS+2*PWM_NUMBER) = pwm; // set the PWM
    }

    Similar Threads:


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

    Default Re: Spindle PWM, issues changing PWM prescale, X-axis "rings"!

    Hi durbs,

    I think K2CNC is probably using PWMs to drive their bridge drivers for your servo motors. KFLOP only has one Prescaler to set the frequency for all 8 PWM channels. The bridge drivers probably need a high frequency such as 20KHz to work properly (and above our hearing range). When you change the frequency to 1KHz they have problems.

    You might want to get a different module that can accept Step/Dir signals and use a spare Step/Dir output.

    Or figure out how to get the K2CNC converter you have to work.

    HTH
    Regards

    Regards
    TK http://dynomotion.com


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

Spindle PWM, issues changing PWM prescale, X-axis &quot;rings&quot;!

Spindle PWM, issues changing PWM prescale, X-axis &quot;rings&quot;!