Reading Current Position in C program?


Results 1 to 6 of 6

Thread: Reading Current Position in C program?

  1. #1
    Registered
    Join Date
    Nov 2012
    Location
    US
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default Reading Current Position in C program?

    This is my first effort to post in the forum. I do not know if this is the right thread, so please feel free to move me to another thread if you see fit...

    I am very close to having my CNC mill/router/plasma cutter running on KFLOP/Kanalog platform and I have worked through all issues eventually, but I am stuck on what I think should be an easy problem...

    I have written a routine which positions each axis using an analog joystick, read via ADC channels. While doing that I decided to put in a "Capture Position" function which is triggered by a pushbutton to send up to twenty location readings to persistent.UserData to use elsewhere. The problem is that I can find no obvious function to read the current position. The Pos script command on the console is what I need, but is there a way to invoke that same function from the C program? I see many script commands have an equivalent available in C, but cannot find the equivalent of Pos.

    Any suggestions? It looks like it should be possible to capture the entire state and then find the parameters which contain current location, but that seems like a lot of research and time to go down that path if there is an easier way.

    Thank You,
    Larry Smith

    Similar Threads:


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

    Default

    Hi Larry,

    From a KFLOP C Program the Current Measured Position of axis 0 can be obtained by accessing the Axis Channel Member Variable "Position" as:

    ch0->Position

    This will only be meaninful if the axis has a feedback device such as an encoder. If it is an open loop device then what you may want is the last commanded position which would be:

    ch0->Dest

    both are 64-bit double precision floating point variables. These and other channel member variables are listed in the CHAN data structure which is defined in the KMotionDef.h header file.

    HTH
    Regards

    Regards
    TK http://dynomotion.com


  3. #3
    Registered
    Join Date
    Nov 2012
    Location
    US
    Posts
    4
    Downloads
    0
    Uploads
    0

    Smile Capture current position

    Tom,

    That was exactly what I needed. It works like a charm! Plus, I started really studying the KMotionDef.h header file and the whole system is starting to make more sense. This is my first venture into C programming and this system is a challenging but rewarding example to begin with.

    Thank you for your great help and such a prompt response,
    Larry



  4. #4
    Registered
    Join Date
    Nov 2012
    Location
    US
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default Passing Tool number and tool parameters to C Program?

    Tom,
    I am down to the last custom function I need to get my project operating...

    1) When using the T# (tool number) Gcode command, is that value passed to a thread similar to the S# (spindle speed) value, or P, Q, and R parameters?

    2) When executing code in response to an M6 mcode, where can I find the T value?

    3) Do you have an example program which accesses the tool parameters in the tool table? Or, at least a declaration for the Tool table structure? (I want to display the required parameters to the operator in a MsgBox to have him perform a manual tool change.)

    Thank you for any insight you can share on this.

    Regards,
    Larry



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

    Default

    Hi Larry,

    #1/2 the Tool number is passed as an integer into the specified User Variable. See the ToolChange.c example.

    #3 No there isn't currently a method to do that. You could only display the tool number. (otherwise you would need to modify KMotionCNC to download the tool table info to KFLOP).

    Actually I don't really understand why you want a KFLOP C program for a tool change if you don't have an automatic tool changer. You can display a message from G Code to tell the operator to put in a tool.

    (MSG,Put in Tool XXXXXX)

    Regards
    TK

    Regards
    TK http://dynomotion.com


  6. #6
    Registered
    Join Date
    Nov 2012
    Location
    US
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default Access to Tool Table?

    Tom,

    Thank you for the info on passing the Tool number with M6. That sounds like what I need. I will try it tomorrow.

    The idea of looking up the tool parameters for the operator is just an enhancement that I was thinking of to not require that the operator keep a listing of his tools, but instead remind him in a message box what length, style, diameter, etc. to load manually. It is not a critical feature so I will not explore it further if the Tool Table is not readily accessible...

    I am finding KFLOPS a great adventure and am really impressed with all the capability. By this weekend I plan to run my first part from a GCODE file...

    Thanks again,
    Larry



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

Reading Current Position in C program?

Reading Current Position in C program?