A Centroid CNC App I made using the Centroid API

Make your own CNC Control Apps

Moderator: cnckeith

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

A Centroid CNC App I made using the Centroid API

Post by Centroid_Jacob »

Hello Centroid Forums,

I wanted to share my experience creating a project for an Acorn customer with a custom machine. This customer has a Acorn that moves a Saw with its X Axis, instead of using keyboard and mouse to jog or use MDI mode he wanted a simple User Interface that he could use with his touch screen. The customer sent me an example of WinHinge from WinCNC
Here is the old UI the customer wanted to recreate in CNC12
WinHinge_small.png


and here is my new App running with CNC12.
I was able to recreate the desired elements using a Visual Basic .net WinForms Project in Visual Studio.
Power Feed App.png
The new App can take touch screen input for 0-9, a decimal point, clear, cycle start, and cycle cancel.


This machine has a fixed saw as well as a movable saw attached to the X Axis. The fixed saw is on the left, at machine home. The moveable saw moves to the right the amount that was entered using the form. Once the machine moves the amount desired, the operator then runs the saws to cut the panel the desired length. So we only need to automate an absolute positioning move using G1 X[Length], which is very simple to accomplish using the Centroid API.

Getting Started with the Development Environment
Requirements:
Visual Studio Community/Pro/Enterprise Edition installed: https://visualstudio.microsoft.com/#vs-section
CNC12 Standard or Offline Intercon versions: https://centroidcnc.com/centroid_diy/ce ... loads.html



Getting Started with the Programming
First, we need to add a reference to the CentroidAPI (See your CentroidAPI Documentation in your cncm/cnct/cncr directory for instructions).

Then, we need to create a variable to hold the CNC Pipe used for communicating with CNC12.

Code: Select all

   ' create pipe
    Dim m_pipe As CentroidAPI.CNCPipe
We are going to use "Sub New" to initialize the CNC Pipe.

Code: Select all

   
    ''' <summary>
    ''' This sub is called when this form is created, we use it to initialize the cnc pipe
    ''' </summary>
    Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        ' initialize pipe so we can communicate with CNC12
        m_pipe = New CentroidAPI.CNCPipe
    End Sub
Now we are ready to send commands to CNC12.

Sending a single line of G Code is quite simple, we are going to create a variable that is a reference to the Job class then use this variable to call the RunCommand Function, passing it our command, the working directory, and whether to require the operator to press cycle start before running the command. It is important to pass the correct working directory based on the version of CNC12 you have installed.

Code: Select all


    ''' <summary>
    ''' Sends a G1 command using xDistance as X axis distance and FeedRate as desired FeedRate
    ''' </summary>
    ''' <param name="xDistance">Distance to move X Axis</param>
    ''' <param name="FeedRate">Speed at which to move X Axis</param>
    ''' <returns></returns>
    Function SendXMoveCommand(ByVal xDistance As Double, Optional ByVal FeedRate As Double = 50)
        ' check that pipe is initialized
        If m_pipe IsNot Nothing Then
            ' then check that it is constructed
            If m_pipe.IsConstructed Then
                ' reference to Job class
                Dim cmd As New CentroidAPI.CNCPipe.Job(m_pipe)
                ' return the result of the command after building the command and sending it to cnc12
                Return cmd.RunCommand("G1 X" & xDistance & " F" & FeedRate, "C:/cncm", False)
            End If
        End If
        ' if we failed, send back an unknown error
        Return CentroidAPI.CNCPipe.ReturnCode.ERROR_UNKNOWN
    End Function



I'm out of time for today, I will be back next week to answer questions and dive a little deeper into working with CNC Pipes and the Centroid API so feel free to ask any questions or poke holes in my programming logic!

Soon we will be updating the Centroid API Documentation and publishing downloadable example projects for Visual Studio (In both Visual Basic .net and C#!

The entire source code for this application is available on GitHub, here: https://github.com/CentroidCNC/Centroid ... _PowerFeed
The C# Version of source code is available here: https://github.com/CentroidCNC/Centroid ... _PowerFeed


Here's a quick video showing the app in action:


A full 'code with me' video is also available:
When requesting support please read this post first.

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


cnckeith
Site Admin
Posts: 8803
Joined: Wed Mar 03, 2010 4:23 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: none
DC3IOB: Yes
CNC11: Yes
CPU10 or CPU7: Yes
Contact:

Re: A Centroid CNC App I made using the Centroid API

Post by cnckeith »

nice work Jacob, looking forward to more and a video showing how you did it!
Need support? READ THIS POST first. http://centroidcncforum.com/viewtopic.php?f=60&t=1043
All Acorn Documentation is located here: viewtopic.php?f=60&t=3397
Answers to common questions: viewforum.php?f=63
and here viewforum.php?f=61
Gear we use but don't sell. https://www.centroidcnc.com/centroid_di ... _gear.html


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: A Centroid CNC App I made using the Centroid API

Post by Ryan Patterson »

I tried building an app a couple of weeks ago and I get and was getting a build error. I have nothing in the code other than the declaration for the pipe and setting the variable to a new pipe.

You mentioned the source code in your post but do not see a link for it.

Code: Select all

Public Class Form1
    Dim m_pipe As CentroidAPI.CNCPipe

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        m_pipe = New CentroidAPI.CNCPipe
    End Sub
End Class



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: A Centroid CNC App I made using the Centroid API

Post by Centroid_Jacob »

Hi Ryan,

Did you add a reference to the Centroid API to your project?

I'll add instructions for that soon, it is covered by the existing Centroid API documentation so I didn't cover it here but it is helpful information.

What does your Error List show when you try to compile, I'm guessing it doesn't see the Centroid API but send a screenshot of the errors and I'll try to help.

I didn't attach a project to this post yet, I will add one in the coming days. However I put the entire source code into the bottom code block on my post.

Edit: A GitHub repo is now linked at the bottom of my first post.
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: A Centroid CNC App I made using the Centroid API

Post by Ryan Patterson »

Yes I did add reference. And the strange thing is the error list shows no errors. I will record a video of the project later today.


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: A Centroid CNC App I made using the Centroid API

Post by Centroid_Jacob »

Ryan,

Make a new post in the Centroid CNC12 APi Discussion forum when you do get around to recording that video, if you don't mind. Just to keep this thread on topic.

Everyone else,

I've updated my opening post with a short video of my app in action, plus a 50 minute video following me as I remake the original version of the Power Feed App. It's my first 'code with me' style video, so I apologize if I go to fast.

I'm currently working on the C# Example project as well but I have other responsibilities at this time.
When requesting support please read this post first.

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


suntravel
Community Expert
Posts: 3406
Joined: Thu Sep 23, 2021 3:49 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 6433DB0446C1-08115074
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Germany

Re: A Centroid CNC App I made using the Centroid API

Post by suntravel »

Great Video, Jacob.

You explain very well and it is easy to follow.

Uwe


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: A Centroid CNC App I made using the Centroid API

Post by Centroid_Jacob »

Thanks, Uwe!

I've updated my opening post with a few more details and uploaded my code to the Official CentroidCNC GitHub and placed a new link in the post.
When requesting support please read this post first.

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


cnckeith
Site Admin
Posts: 8803
Joined: Wed Mar 03, 2010 4:23 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: none
DC3IOB: Yes
CNC11: Yes
CPU10 or CPU7: Yes
Contact:

Re: A Centroid CNC App I made using the Centroid API

Post by cnckeith »

suntravel wrote: Tue Nov 05, 2024 5:10 pm Great Video, Jacob.

You explain very well and it is easy to follow.

Uwe
i second that! looking forward to more videos.
Need support? READ THIS POST first. http://centroidcncforum.com/viewtopic.php?f=60&t=1043
All Acorn Documentation is located here: viewtopic.php?f=60&t=3397
Answers to common questions: viewforum.php?f=63
and here viewforum.php?f=61
Gear we use but don't sell. https://www.centroidcnc.com/centroid_di ... _gear.html


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: A Centroid CNC App I made using the Centroid API

Post by Centroid_Jacob »

The C# Version of the Power Feed Example App is now available on GitHub: https://github.com/CentroidCNC/Centroid ... _PowerFeed
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