585,759 active members*
4,118 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Dynomotion/Kflop/Kanalog > KmotionCNC - Sending information to user program?
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2012
    Posts
    44

    KmotionCNC - Sending information to user program?

    Hi,
    Servo's are tuned up, a little feed-forward gain, I gain around .011, and the response looks great!

    Now,

    to control my spindle, I have an enabling relay driven by the relay driver outputs... and a DAC that sends an analog signal to the spindle drive to tell it what speed to run at. I can't just wire this relay "on", as it is what prevents my spindle draw-bar from opening if the spindle is turning.

    To run CW @ 3500 (100% speed) I need to send a -10V signal to the drive.
    To run CCW @ 3500, the signal would need to be +10V.

    I can't seem to see how to set this up in the Kmotion screen. I also can't figure out how to pass the speed and direction to a user program. If I could pass the direction and speed to a user program, I'd have no problem getting this working. Is there a way to do this? I'm a bit confused about how to use the "Persist.UserData" to make this work.

    Any ideas?

    Thanks again!
    -Nick

  2. #2
    Join Date
    May 2006
    Posts
    4045
    Hi Nick,

    Yes that becomes a bit tricky because the various commands S, M3, M4, M5 depend on each other and can come in various orders. So for example the S command can't immediately set the DAC even though it knows the speed because it doesn't know the direction yet (if the spindle was).

    Please take a look at the \C Programs\SpindleUsingJogs example. That example is quite similar to your situation except it issues Jog commands to an axis to set the speed vs writing o a DAC. It maintains the previous state of things in 3 persist variables as described in the comments

    // desired speed is passed in variable 1
    // save in user variable 99 the last speed setting
    // save in user variable 98 whether it was off, CW, or CCW (0,1,-1)
    // save in user variable 97 the last desired speed

    You will need to modify all 4 C programs for M3,M4,M5, and S.

    Please try to modify those and if necessary post the changed files and we can help.

    Regards
    TK
    http://dynomotion.com

  3. #3
    Join Date
    Oct 2012
    Posts
    44
    I think I've massaged the example programs to work. I just need to wait 'till this weekend to test it out!

    By the way, floating point math isn't as intuitive as I'd thought... (IE, dividing 2047 by 3500 to get the DAC factor is NOT the same as multplying 2047.0/3500.0... one gives you zero, one gives you .584!

    And, tom... please add some kind of indicator in the C programming screen in Kmotion that tells you what line you're on. As of now, if I have a programming error, I have to copy-paste the program in notepad to find the line the error is on... Or am I missing something?

  4. #4
    Join Date
    May 2006
    Posts
    4045
    Hi Nick,

    Heh heh. C can be tricky. With integers it does integer division

    2047/3500 - zero + Remainder 2047

    2047.0/3500.0 - 64-bit floating point numbers with ~17 digits of precision

    2047.0f/3500.0f - 32-bit floating point which is about 2X faster but only ~7 digits precision.

    But actually the compiler should reduce the value to a constant at compile time so no division is actually performed at run time.

    When you have an error there should be a RED marker on the line of the error. Doesn't it show on your screen?
    Attached Thumbnails Attached Thumbnails Error.png  
    TK
    http://dynomotion.com

  5. #5
    Join Date
    Oct 2012
    Posts
    44
    Quote Originally Posted by TomKerekes View Post
    Hi Nick,

    Heh heh. C can be tricky. With integers it does integer division

    2047/3500 - zero + Remainder 2047

    2047.0/3500.0 - 64-bit floating point numbers with ~17 digits of precision

    2047.0f/3500.0f - 32-bit floating point which is about 2X faster but only ~7 digits precision.

    But actually the compiler should reduce the value to a constant at compile time so no division is actually performed at run time.

    When you have an error there should be a RED marker on the line of the error. Doesn't it show on your screen?
    Typically I run the programs by hitting "init" on the KmotionCNC screen. (or by typing the relevant M code, etc) When I see an error there, I have nothing to cross-reference the line to, and I don't see that line in the C program editor. When I run it from the C program screen, I do get the red dot.

  6. #6
    Join Date
    May 2006
    Posts
    4045
    Hi Nick,

    If you have the program open in the C Programs Screen but don't want to Compile/Run it from there for some reason, then another option is to just push the "Compile" button and it should pop up the same compile error message and take you to the offending line.

    Regards
    TK
    http://dynomotion.com

Similar Threads

  1. Replies: 3
    Last Post: 10-25-2012, 05:46 PM
  2. FANUC 6M PROGRAM SENDING...
    By QUALMACH1 in forum Fanuc
    Replies: 7
    Last Post: 01-22-2011, 07:27 PM
  3. sending large program to Funuc 21I-mb
    By bigtown in forum Fanuc
    Replies: 7
    Last Post: 09-22-2009, 10:49 PM
  4. Sending Program Files
    By Astrocncdept in forum HURCO
    Replies: 3
    Last Post: 05-09-2009, 01:21 PM
  5. Sending Program ...
    By politecnica in forum Fanuc
    Replies: 0
    Last Post: 03-05-2008, 01:28 PM

Posting Permissions

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