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
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.
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
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
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: