Welcome to Our Community

Some features disabled for guests. Register Today.

Prompt Grbl for position

Discussion in 'Other Software' started by benet116, Oct 25, 2019.

Tags:
  1. benet116

    benet116 New
    Builder

    Joined:
    Oct 25, 2019
    Messages:
    1
    Likes Received:
    0
    Hey everyone,

    I was wondering if anyone knew how to use python to prompt Grbl for its current position (x,y,z)? The goal is to send all my g-code via python (can already do that with existing codes), and I want to periodically prompt GRBL for its current position, then write these to a file such that in the .txt file you would have an large matrix of all your [ x | y | z ].
     
  2. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Project Maker Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    6,155
    Likes Received:
    2,107
    Just send "?"

    See gnea/grbl - the grbl interface is described in great detail for developers on the Wiki
     
    David the swarfer and sharmstr like this.
  3. base1379

    base1379 New
    Builder

    Joined:
    Jan 9, 2017
    Messages:
    23
    Likes Received:
    4
    Real-time status reports...
    I've been trying to get this to work for days (and reading) with no success.
    When I send "?" at the command prompt of Openbuilds Control, I get no response (see questionmark.gif).

    I've tried all 3 options in setting $10.

    I've read the entire gnea/grbl which mentions:
    When a ? character is sent to Grbl (no additional line feed or carriage return character required), it will immediately respond with something like <Idle|MPos:0.000,0.000,0.000|FS:0.0,0> to report its state and current position.
    but like I said this doesn't work for me. Also mentioned is scenarios where grbl will not respond to the ? request, none of which apply to me I think.

    I've tried resetting and rebooting blackbox.

    Does "?" not work when sent from the Openbuilds Control prompt?

    Here's the result of sending "$$":
    [18:41:49] [ $$ ] $0=10 ;Step pulse time, microseconds
    [18:41:49] [ $$ ] $1=255 ;Step idle delay, milliseconds
    [18:41:49] [ $$ ] $2=0 ;Step pulse invert, mask
    [18:41:49] [ $$ ] $3=5 ;Step direction invert, mask
    [18:41:49] [ $$ ] $4=1 ;Invert step enable pin, boolean
    [18:41:49] [ $$ ] $5=0 ;Invert limit pins, boolean
    [18:41:49] [ $$ ] $6=0 ;Invert probe pin, boolean
    [18:41:49] [ $$ ] $10=2 ;Status report options, mask
    [18:41:49] [ $$ ] $11=0.020 ;Junction deviation, millimeters
    [18:41:49] [ $$ ] $12=0.002 ;Arc tolerance, millimeters
    [18:41:49] [ $$ ] $13=0 ;Report in inches, boolean
    [18:41:49] [ $$ ] $20=0 ;Soft limits enable, boolean
    [18:41:49] [ $$ ] $21=1 ;Hard limits enable, boolean
    [18:41:49] [ $$ ] $22=1 ;Homing cycle enable, boolean
    [18:41:49] [ $$ ] $23=3 ;Homing direction invert, mask
    [18:41:49] [ $$ ] $24=50.000 ;Homing locate feed rate, mm/min
    [18:41:49] [ $$ ] $25=7000.000 ;Homing search seek rate, mm/min
    [18:41:49] [ $$ ] $26=15 ;Homing switch debounce delay, milliseconds
    [18:41:49] [ $$ ] $27=1.000 ;Homing switch pull-off distance, millimeters
    [18:41:49] [ $$ ] $30=255 ;Maximum spindle speed, RPM
    [18:41:49] [ $$ ] $31=0 ;Minimum spindle speed, RPM
    [18:41:49] [ $$ ] $32=0 ;Laser-mode enable, boolean
    [18:41:49] [ $$ ] $100=26.667 ;X-axis steps per millimeter
    [18:41:49] [ $$ ] $101=26.667 ;Y-axis steps per millimeter
    [18:41:49] [ $$ ] $102=199.100 ;Z-axis steps per millimeter
    [18:41:49] [ $$ ] $110=30000.000 ;X-axis maximum rate, mm/min
    [18:41:49] [ $$ ] $111=30000.000 ;Y-axis maximum rate, mm/min
    [18:41:49] [ $$ ] $112=2500.000 ;Z-axis maximum rate, mm/min
    [18:41:49] [ $$ ] $120=450.000 ;X-axis acceleration, mm/sec^2
    [18:41:49] [ $$ ] $121=450.000 ;Y-axis acceleration, mm/sec^2
    [18:41:49] [ $$ ] $122=150.000 ;Z-axis acceleration, mm/sec^2
    [18:41:49] [ $$ ] $130=2000.000 ;X-axis maximum travel, millimeters
    [18:41:49] [ $$ ] $131=1000.000 ;Y-axis maximum travel, millimeters
    [18:41:49] [ $$ ] $132=100.000 ;Z-axis maximum travel, millimeters
    [18:41:49] [ $$ ] ok
     

    Attached Files:

  4. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Project Maker Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    6,155
    Likes Received:
    2,107
    CONTROL already sends "?" every 200ms, receives it, parses the data, and updates the UI for you. It uses that data internally (no log, imagine how that log would look with a line every 200ms, you'd miss the actual items you want to log)

    Only if you write your own software would you be sending it, receiving the reply, and then doing with that data what you want :)

    CONTROL is already a full host
     
    #4 Peter Van Der Walt, Dec 9, 2020
    Last edited: Dec 9, 2020
  5. base1379

    base1379 New
    Builder

    Joined:
    Jan 9, 2017
    Messages:
    23
    Likes Received:
    4
    Yes I know. I'm trying to figure out how to write the current position to file when a button is pushed.
    I've been looking into using the javascript option of macro to do this but don't know what I'm doing.
    Thanks again Peter.
     
  6. Peter Van Der Walt

    Peter Van Der Walt OpenBuilds Team
    Staff Member Moderator Project Maker Builder Resident Builder

    Joined:
    Mar 1, 2017
    Messages:
    6,155
    Likes Received:
    2,107
    Js doesnt have file access. You'd have to do this outside control so you are in the loop and can control the sequence of events.
     
  7. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    1,815
    Likes Received:
    1,003
    why are you writing code when bCNC can already do this?
    vlachoudis/bCNC
    I bound some F keys to the 'record rapid' and 'record motion' functions so the recorded Gcode is easy to create and read.
    then I jog around with the camera and record points, I have digitized several model airplane plans this way. I run the Gcode through a program that converts it to dxf, then load that into Sketchup for further processing.
     
  8. base1379

    base1379 New
    Builder

    Joined:
    Jan 9, 2017
    Messages:
    23
    Likes Received:
    4
    Thanks David the swarfer!
    I've downloaded bCNC and played around with it some.
    I'm not looking to generate gcode, instead I'd like to use the machine for measurement purposes (specifically to digitize 2D patterns/templates).
    I think the closest thing I've been able to do with bCNC is using Probe>Probe>Record>POINT.
    Then I'm able to File>Save and save as a text file.
    Is there any way to just record the X and Y positions? If not I could just strip out all the G codes with another step.
    Thanks!
    wolfgang
     
  9. David the swarfer

    David the swarfer OpenBuilds Team
    Staff Member Moderator Builder Resident Builder

    Joined:
    Aug 6, 2013
    Messages:
    1,815
    Likes Received:
    1,003
    ok, I did not see the text file output, it has many options (-:
    you will have to process the file after saving since I think it will always save the axis words and so on
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice