Get Dro Machine cordinates

Make your own CNC Control Apps

Moderator: cnckeith

Post Reply
Ryan Patterson
Posts: 59
Joined: Wed Oct 16, 2024 3:30 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Get Dro Machine cordinates

Post by Ryan Patterson »

I am making progress in understanding the API. Below is the code that will retrieve the machine coordinates. DroStrings will return an array of the machine cordinates.

Code: Select all

        Dim cnc12Pipe As New CNCPipe()
        Dim droObject As New CentroidAPI.CNCPipe.Dro(cnc12Pipe)

        Dim droType As CentroidAPI.CNCPipe.Dro.DroCoordinates = droObject.DroCoordinates.DRO_MACHINE
        Dim droStrings As Tuple(Of String, String, String)() = Nothing
        Dim result = droObject.GetDro(droType, droStrings)


Centroid_Jacob
Web Developer
Posts: 93
Joined: Wed Oct 19, 2022 4:49 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: none
DC3IOB: No
CNC12: No
CNC11: Yes
CPU10 or CPU7: No

Re: Get Dro Machine cordinates

Post by Centroid_Jacob »

Visual Studio gave me a warning about this line:

Code: Select all

Dim droType As CentroidAPI.CNCPipe.Dro.DroCoordinates = droObject.DroCoordinates.DRO_MACHINE
Because of the droObject reference but it ran fine for me. To avoid this warning, Import CentroidAPI.CNCPipe.Dro and then change the reference in your typing to:

Code: Select all

Dim droType As CentroidAPI.CNCPipe.Dro.DroCoordinates = DroCoordinates.DRO_MACHINE
Then you would call:

Code: Select all

droStrings(0).Item1 ' to get the first Axis Label
droStrings(0).Item2 ' to get the first Axis Machine Position
droStrings(0).Item3 ' to get the first Axis Load Meter readout. 
I would put it all together as a function, like so:

Code: Select all

Imports CentroidAPI.CNCPipe.Dro

......

Function GetDroReadout(ByVal axis As Integer) as String
    ' reuse existing pipe to prevent using up all of CNC12's API Pipes
    Dim droObject As New CentroidAPI.CNCPipe.Dro(m_pipe)

    Dim droType As CentroidAPI.CNCPipe.Dro.DroCoordinates = DroCoordinates.DRO_MACHINE
    Dim droStrings As Tuple(Of String, String, String)() = Nothing
    Dim result As ReturnCode = droObject.GetDro(droType, droStrings)

    Return droStrings(axis).Item2
End Function
Where axis is 0-7, Default Mill/Router config would be 0 = X, 1 = Y, 2 = Z but may vary depending on machine purpose and setup.
When requesting support please read this post first.

A fresh report makes it easier to assist you. To make a report check this post


Ryan Patterson
Posts: 59
Joined: Wed Oct 16, 2024 3:30 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Get Dro Machine cordinates

Post by Ryan Patterson »

I suppose to protect against the Axis not being in a set location in the array a For each loop could be used. But of course the labels of each axis would need to cover all the possible (U,V,W,X,Y and Z)

Code: Select all

        For Each dro As Tuple(Of String, String, String) In droStrings
            ' Access each component of the tuple
            Dim axis As String = dro.Item1
            Dim position As String = dro.Item2
            Dim additionalInfo As String = dro.Item3
            Select Case axis
                Case "X"
                    Console.WriteLine("X=" & position)
                Case "Y"
                    Console.WriteLine("Y=" & position)
                Case "Z"
                    Console.WriteLine("Z=" & position)
                Case "C"
                    Console.WriteLine("C=" & position)
            End Select
        Next


Centroid_Jacob
Web Developer
Posts: 93
Joined: Wed Oct 19, 2022 4:49 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: none
DC3IOB: No
CNC12: No
CNC11: Yes
CPU10 or CPU7: No

Re: Get Dro Machine cordinates

Post by Centroid_Jacob »

Depending on exactly how you want it to function, I would drop the 'select case' and use 'axis' to print the label (or use it as a lookup if you have a control or dictionary/collection/array of axes).

The 'for each' loop is the way to go in my opinion, or do a 'for i as integer = droStrings.Length - 1' and use i as your index to get/set the label in whatever dictionary/collection/array you are using to manage your DRO coordinates.

Many solutions for the same 'problem'.
When requesting support please read this post first.

A fresh report makes it easier to assist you. To make a report check this post


Post Reply