Welcome to Our Community

Some features disabled for guests. Register Today.

xpro V3 sphinx 55 - how to get current position?

Discussion in 'Controller Boards' started by orbitronics, Feb 26, 2019.

  1. orbitronics

    Builder

    Joined:
    Oct 12, 2018
    Messages:
    8
    Likes Received:
    5
    Hi,

    I'm using the sphinx 55 with the xpro V3, and i'm trying to figure out how to retrieve the current xyz coordinates.

    I've tried M114, $? and ? to no avail.

    What am I missing ?
     
  2. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    15,193
    Likes Received:
    4,346
    '?' will print the current postition. In a terminal at least. Which host software are you using, if you use OpenBuilds CONTROL (software.openbuilds.com) you dont even have to send anything, we display it right there in the DRO (Digital Readouts) (top left corner above 3d viewer)

    1.png
     
  3. orbitronics

    Builder

    Joined:
    Oct 12, 2018
    Messages:
    8
    Likes Received:
    5
    Thank you for your response.

    in CONTROL '?' wasn't doing anything which confused me, but i noticed that in a normal terminal it was indeed printing out:

    <Alarm|MPos:0.000,0.000,0.000|FS:0,0|WCO:-290.000,-42.998,-321.999>

    Do you have any tips on how to filter out just the positional data?

    Also, I noticed everytime i reconnect to the serial port that the positional values jump back to 0, is there a way to change that?
     
    Peter Van Der Walt likes this.
  4. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    15,193
    Likes Received:
    4,346
    Disable AutoReset on your controller (Hardware) - When USB connects, it resets the board.

    We parse it in JS, you'll have to elaborate on what you want to do, but basic programming skills will suffice, position finding, a little Regex, etc:
    See OpenBuilds/SW-Machine-Drivers

    Its intercepted by the parser above to show it to users in a nice pretty GUI with flashing alarm icons, modal error messages and all the other eye candy that counts
     
  5. orbitronics

    Builder

    Joined:
    Oct 12, 2018
    Messages:
    8
    Likes Received:
    5
    Thank you for your help I managed to get this working nicely in C#.

    I can't find AutoReset, is it a jumper or in software?

    Back to the parsing of the '?' result; my solution for that one guy that'll read this in two years:

    Code:
    enum Mode {Run, Idle, Alarm };
    Mode currentMode;
    Decimal[] curPos = new Decimal[3];
    
    private void getState(String input)
    {
        char[] delimiterChars = { '<', '>', ':', ',', '|' };
        String[] words = input.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
        Enum.TryParse(words[0], out currentMode);
        for (uint i = 0; i < 3; i++)               
        {
            curPos[i] = Decimal.Parse(words[2 + i]);
        }
    
        System.Console.WriteLine(input); // DEBUG
        System.Console.WriteLine("Mode: " + currentMode.ToString());  //DEBUG
        for (uint i = 0; i < 3; i++)                //DEBUG
        {
            System.Console.WriteLine(curPos[i]);
        }
    }
    Calling this with the result of '?' e.g.:

    Code:
    getState("<Run|MPo:300,2.8,2.9|:5,|O-3.0,3699-2.9>");
    outputs:
    Code:
    Mode: Run
    300
    2.8
    2.9
    This makes it easy for me to find the state and positional data. I don't really know what the rest of '?'s result is or where to go to read further.

    More specifically, is there a list of 'modes' the cnc can be in? so far i've figured 'Run, Alarm, Idle'.
     
  6. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    15,193
    Likes Received:
    4,346
    Its intercepted by the parser above to show it to user

    Thats all perfectly documented under gnea/grbl

    All the states, data, overrides etc.

    Autoreset: depends on the board: some has a jumper (OpenBuilds BlackBox) , some has a switch, on some you stick a 10uF cap between gnd and reset (Arduino Uno)

    What board do you have?
     
  7. orbitronics

    Builder

    Joined:
    Oct 12, 2018
    Messages:
    8
    Likes Received:
    5
    Answering my own question

    Code:
        runStatus: "Pending", // 0 = init, 1 = idle, 2 = alarm, 3 = stop, 4 = run, etc?
    
    I assume this is it EDIT: i am wrong. I want to hold on some code until homing is done, i'm not sure if the status during homing is 'init' or 'run', but i would think holding until status is 'idle' is the right way forward.
     
    #7 orbitronics, Feb 27, 2019
    Last edited: Feb 27, 2019
  8. orbitronics

    Builder

    Joined:
    Oct 12, 2018
    Messages:
    8
    Likes Received:
    5
    Thanks, i found through your link the states: Valid states types: Idle, Run, Hold, Jog, Alarm, Door, Check, Home, Sleep

    Sorry for the noob questions, I am completely new to the world of CNCs, and am only figuring out what Grbl / architecture of my hardware and software is.

    As for my board, i'm using what was recommended when i got the sphinx 55, the xPro v3.
     
  9. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    15,193
    Likes Received:
    4,346
    No those are internal states

    Used for decision making inside our application


    o
     
  10. Peter Van Der Walt

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

    Joined:
    Mar 1, 2017
    Messages:
    15,193
    Likes Received:
    4,346
    If i may ask, why own software? As a new user wouldnt existing software makes it easier to learn? Software.openbuilds.com for example
     
  11. orbitronics

    Builder

    Joined:
    Oct 12, 2018
    Messages:
    8
    Likes Received:
    5
    You may ask.

    We are using 'control' to jog the cnc and am very happy with it (it's a very neat piece of software, I assume you had something to do with it, thanks!).

    Other than that, I'm writing software to automate a task that plots several thousand pre-calculated points and rests for some time while a probe takes some readings.

    I have learnt basic G codes that has allowed me to finish this (i'm currently testing/debugging/optimising). But the structure of Grbl, where you guys come in, why some M codes don't work in certain controllers etc is still something I'm figuring out.

    My understanding is, Gcodes is some semi standardised language to control CNC machines. Grbl is some open source cnc/g code controller? You guys have made some decent hardware that interfaces with Grbl. Is this right?
     
    MaryD and Peter Van Der Walt like this.
  12. orbitronics

    Builder

    Joined:
    Oct 12, 2018
    Messages:
    8
    Likes Received:
    5
    I know i can inject gcode files into 'control', but the end users will be some physicists in my lab and they really only want to see relevant options that make sense for the task / measurements.
     
    Giarc and Peter Van Der Walt like this.

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