KStep Spindle Control Example - UserData[1] array is empty


Results 1 to 5 of 5

Thread: KStep Spindle Control Example - UserData[1] array is empty

  1. #1
    Registered
    Join Date
    Jan 2007
    Location
    us
    Posts
    5
    Downloads
    0
    Uploads
    0

    Default KStep Spindle Control Example - UserData[1] array is empty

    Afternoon all,

    I use the example code below and nothing happens. I printed the persist.UserData[1] array to console and its empty. When I hard code 'speed = 12000' everything hardware wise works as it should and my VFD drive goes to the appropriate HZ (in this case 200hz).

    What am I missing? When and where is persist.UserData[1] updated with the current Gcode S value? Is this something I have to add somewhere else? I don't see any sign of it in any of the default config files either.

    main()
    {
    float speed = *(float *)&persist.UserData[1]; // value stored is actually a float
    printf("speed=%f UserData1=%f\n",speed,persist.UserData[1]);

    FPGA(KAN_TRIG_REG)=4; // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP
    SetBitDirection(44,1); // define bit as an output
    FPGA(IO_PWMS_PRESCALE) = 46; // divide clock by 46 (1.4 KHz)
    FPGA(IO_PWMS+1) = 1; // Enable

    FPGA(IO_PWMS) = CorrectAnalog(speed/RPM_FACTOR); // Set PWM
    }





    If i do this everything works hardware wise. So all my connections are good.


    main()
    {
    float speed = *(float *)&persist.UserData[1]; // value stored is actually a float
    printf("speed=%f UserData1=%f\n",speed,persist.UserData[1]);
    speed = 12000;
    printf("speed=%f\n,speed);

    FPGA(KAN_TRIG_REG)=4; // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP
    SetBitDirection(44,1); // define bit as an output
    FPGA(IO_PWMS_PRESCALE) = 46; // divide clock by 46 (1.4 KHz)
    FPGA(IO_PWMS+1) = 1; // Enable

    FPGA(IO_PWMS) = CorrectAnalog(speed/RPM_FACTOR); // Set PWM
    }

    Similar Threads:


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

    Default Re: KStep Spindle Control Example - UserData[1] array is empty

    Hi kdoske,

    Looks like you are double posting questions.

    Did you read my response on the Yahoo Group?

    Regards

    Regards
    TK http://dynomotion.com


  3. #3
    Registered
    Join Date
    Jan 2007
    Location
    us
    Posts
    5
    Downloads
    0
    Uploads
    0

    Default Re: KStep Spindle Control Example - UserData[1] array is empty

    Sorry, when I realized that there was support on here I removed my yahoo post since its not something I will ever use. I added your post to here below.

    Oh, so that's what the VAR field is for? Its to late to try now, but I assume that when execute program is selected a value is passed to the VAR/Array index number indicated?

    Do all of the commands on the M0-M30 pass a value of some kind? Is there anywhere this is all broken down more clearly?

    Tool Setup Screen M3-M9
    This location talked about Execute Prog but only mentions that the VAR is a 'persistent variable' set at runtime. It doesn't mention whats stored in it and what variable/array it even passes its value in is called so it can be accessed at a later time. Of course now I see based on the example and you mentioning it here, but shouldn't all this be stated in the same area instead of it being spread across 2 or 3 different areas like it probably is?

    Am I crazy? The board seems fantastic but the docs for this thing are spaghetti. Thanks for your time.






    Quote Originally Posted by TomKerekes View Post
    Hi,

    Are you configuring KMotionCNC | Tool Setup | M0-M30 | S for this program and to use Var=1?

    Are you executing a GCode line with an S1200 in it?

    Regards
    TK




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

    Default Re: KStep Spindle Control Example - UserData[1] array is empty

    Ouch. If you knew how much effort we put into hundreds and hundreds of pages of documents, on-line help, examples, articles, wiki, Forum Posts, etc and how we attempt to hyper-link parameter descriptions like this 1 mouse click away you might understand how it hurts to have it dismissed as "spaghetti". That is certainly our biggest complaint and thanks for the feedback. If you couldn't all find the info you needed quickly then we failed.

    Your link does describe what is stored in the Var for the S Word with:

    S - Spindle Speed Setting. If C Program is specified Speed in RPM is passed to the specified KFLOP Var as a 32-bit floating point number

    Many of the "Actions" don't have any associated data to pass to a C Program. For example M3 is to turn on the Spindle and no Var information is really needed. In those cases where data isn't specified the M Code Number is placed in the Variable. This can allow multiple Actions to be serviced by a single C Program if that works out easier.

    HTH
    Regards

    Regards
    TK http://dynomotion.com


  5. #5
    Registered
    Join Date
    Jan 2007
    Location
    us
    Posts
    5
    Downloads
    0
    Uploads
    0

    Default Re: KStep Spindle Control Example - UserData[1] array is empty

    Tom,

    Thanks alot for the additional info Tom.

    Sorry I was so blunt but I do feel that way. I took way more time then I should and I created what I believe to be a much cleaner and comprehensive way to break down the M-0 to M30 Tab. Its attached here in a word doc. I'm not saying use this exactly but it would definitely in my opinion alleviate a lot of questions. If the whole manual was done this way I bet it would cut customer support down as well. Anyway, not trying to step on toes. Just thought I would help. Thanks again.

    https://drive.google.com/file/d/0B7h...ew?usp=sharing

    Last edited by kdoske; 12-30-2015 at 09:09 PM.


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

KStep Spindle Control Example - UserData[1] array is empty

KStep Spindle Control Example - UserData[1] array is empty