• matthew@hierthinking.com
Control Systems
It’s Time To Focas: CNC Router Programming Tutorial – Part 1

It’s Time To Focas: CNC Router Programming Tutorial – Part 1

ATTENTION!!!!!

We have a newer up to date video version of this tutorial here!

We now offer Consulting, Contracting, and Training services for Focas. Check it out here!

If you have a question with something in this series, check out our new forum here!

Ok, ok. I know you are wondering why I misspelled focus. Well, I didn’t. This post is the start of a series of posts that will center around programming for the Fanuc control system. If you are wondering what Fanuc is, all you need to know is that Fanuc makes industrial control systems.

These control systems can be found in CNC routers, mills, and robots. This post won’t contain any code, however, if you wish to test out any code in future posts in this series, you will need to have access to a Fanuc control system that you can connect to. All the code that appears in future posts will be in .Net. I will be using C#, however, if you are familiar with VB.Net you can apply all the concepts to that.

What is Focas?

Focas is essentially just an API from Fanuc that allows you to make calls to the Fanuc system. Using these calls you can read from and write to the Fanuc. This may be reading information such as the mode or status of the controller, or it may be setting parameters or triggering an action.

Fanuc has APIs for C++, however, we will be working with the .Net API. The .Net API is nothing more than the C++ API with a C# wrapper. In fact, the wrapper is just a .cs file with a bunch of dll Imports from the C++ dll.

the cs file will not contain all of the API calls from the dll, however, if you understand how to use the dll import within C#, it is not difficult to use the C++ header file to import the missing methods. It just takes a little more effort. I have actually done this a few times in the past for things that I needed.

Also, I would like to note that I will be writing code in this series that I have used while writing applications for routers. While a lot of this code will be able to be used for any type of machinery that has a Fanuc control, I will not be using parts of the API that are specific to other types of machinery such as lathes or lasers.

Stuff You Should Know

So there are some things that I am going to assume when writing these posts. The first thing I am going to assume is that you have access to some type of Fanuc control that would be able to use to test your code out.

I will also assume that you have some experience in writing code in .Net. This is not a .Net tutorial, this is a series of informative posts on the Fanuc Focas API. We will be covering some .Net specific stuff, however, learning .Net is not the focus of this series. If you are not familiar with basic .Net programming, then you should find a good tutorial to follow before going through this series.

While I do expect some level of basic understanding of .Net, if I happen to venture into any advanced .Net concepts I will do my best to explain what it is that I am doing and why I am doing it. Again, this is not a .Net tutorial, so if there is something you don’t understand, leave a comment and I will get back to you. If it is a basic concept that you don’t understand, I will probably tell you to go find a .Net tutorial.

It should also be noted, that there are different versions of Fanuc controls. Because of this, some of the code that I cover may not work on specific controls. In the resources below, which we will go over here is a bit, there is a website that documents all the API calls. Each call has a list of controls that it will and will not work on. So if there is a question on whether or not the code will work for you, you may need to consult the documentation.

What This Series is Not

One thing that I think is important to mention, is that this is by no means a G Code tutorial. If you are looking for a tutorial on G Code, you will need to look elsewhere. This is a tutorial on programming applications that can communicate with Fanuc systems and in no way will it teach any G Code.

Resources For This Series

Inventcom

https://www.inventcom.net/fanuc-focas-library/general/fwlib32

The first resource we are going to use is a website called Inventcom. This webpage is going to be our Focas Bible. This is where we will go when we have questions on specific API calls. Whether it is compatibility with the version of your control, the supported parameters for the call, or what the call does. Make sure to bookmark this site, because this is where most of your questions will be answered.

FwLib32

https://github.com/openindustryorg/OpenIndustryFrameworkFanuc/blob/master/FwLib/FwLib32.cs

FwLib32.cs is the file that we will be using to access the API calls. You will need to include this file in your project. What this file does, is import the individual API calls from the dll so that we can use them in C#.

Coming Up

Now, that we have all the preliminary stuff out of the way, we can start getting to the good stuff. In the next post, we will discuss the various ways that we can communicate with the Fanuc systems and a couple of different methods for creating those connections. I hope to see you all there!

Go to Part 2 —>

24 thoughts on “It’s Time To Focas: CNC Router Programming Tutorial – Part 1

Leave a Reply