This page shows how to use the Fanuc SDK from LabVIEW, to control a Fanuc controller or a ROBOGUIDE virtual robot with Telnet KCL, FTP and SNPX. The library is a set of VIs grouped in `UnderAutomation.Fanuc.lvlib`, compatible with LabVIEW 2010 to 2024. Nothing is installed on the controller.

## Download

The [releases of Fanuc.vi](https://github.com/underautomation/Fanuc.vi/releases) contain:

- the library `UnderAutomation.Fanuc.lvlib`, with its VIs;
- the example project `UnderAutomation.Fanuc.lvproj`, for your LabVIEW version.

The sources are on GitHub: [github.com/underautomation/Fanuc.vi](https://github.com/underautomation/Fanuc.vi). Questions and bug reports go to its issues.

<p align="center">
  <img src="https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/project-items.png" alt="Items of the Fanuc LabVIEW library" />
</p>

## What the library does

- Read and write system variables.
- Read and write numeric, string and position registers.
- Run, pause, hold, continue and abort programs.
- Reset alarms and read the alarm history.
- Set, simulate and unsimulate I/O ports (DOUT, UI, UO, GI, GO...).
- Read the safety status, the current position and the diagnostics.

## Demonstration video

<p align="center">
  <iframe
    width="560"
    height="315"
    style={{ maxWidth: '100%' }}
    src="https://www.youtube.com/embed/r0EadczJwOU"
    title="Connect your Fanuc Robot to LabVIEW"
    frameBorder="0"
    allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
    allowFullScreen="true"
  ></iframe>
</p>

## Example application

The example project shows every VI of the library, with one tab per protocol.

<p align="center">
  <img
    height="250"
    src="https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/main-demo-connect-to-robot.png"
    alt="Connection tab of the LabVIEW example"
  />
  <img
    height="250"
    src="https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/main-demo-telnet.png"
    alt="Telnet tab of the LabVIEW example"
  />
</p>
<p align="center">
  <img
    height="250"
    src="https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/main-demo-ftp.png"
    alt="FTP tab of the LabVIEW example"
  />
  <img
    height="250"
    src="https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/main-demo-snpx.png"
    alt="SNPX tab of the LabVIEW example"
  />
</p>

## Register the license

The SDK runs for 30 days without a key. After that, buy a license ([see pricing](/order)): you receive a license key, to pass to `RegisterLicense.vi`. Call this VI each time the application starts, before `ConnectToRobot.vi`.

![Register License](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/RegisterLicense.png)

See [Licensing](/fanuc/documentation/license).

## Connect to the robot

`ConnectToRobot.vi` connects to the robot with its IP address. Booleans enable or disable `Telnet`, `FTP` and `SNPX`. Telnet needs its password, FTP its user and password. The VI returns an instance of the robot and of each protocol: wire them to the VIs below.

![Connect to robot](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/ConnectToRobot.png)

## Telnet KCL

Telnet KCL sends commands to the controller: reset alarms, write variables, set an I/O... It needs no option on the controller, but it must be enabled: see [Enable Telnet on your robot](/fanuc/documentation/telnet-enable-on-robot).

### Run

To run a program:

- set `$RMT_MASTER = 1` and `$REMOTE_CFG.$REMOTE_TYPE = 1` (with `SetVariableValue.vi`);
- turn the TP switch off;
- reset the alarms.

![Run](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-Run.png)

### Pause

![Pause](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-Pause.png)

### Continue

![Continue](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-Continue.png)

### Hold

![Hold](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-Hold.png)

### Abort

![Abort](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-Abort.png)

### Abort all programs

![Abort all programs](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-AbortAllPrograms.png)

### Clear program

![Clear program](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-ClearProgram.png)

### Get current position

![Get current position](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-GetCurrentPosition.png)

### Get variable value

![Get variable value](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-GetVariableValue.png)

### Set variable value

![Set variable value](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-SetVariableValue.png)

### Clear variables

![Clear variables](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-ClearVariables.png)

### Reset alarms

![Reset alarms](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-ResetAlarms.png)

### Set port

![Set port](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-SetPort.png)

### Simulate

![Simulate](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-Simulate.png)

### Unsimulate

![Unsimulate](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-Unsimulate.png)

### Unsimulate all

![Unsimulate all](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-UnsimulateAll.png)

### Telnet is connected

![Telnet is connected](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/telnet-TelnetIsConnected.png)

## FTP

FTP gives access to the files of the controller, and reads and decodes the variable files (`.va`) and the diagnostic files (`.dg`).

### Get current position

![Get current position](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/ftp-GetCurrentPosition.png)

### Get IO states

![Get IO states](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/ftp-GetIOStates.png)

![Get IO states front](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/ftp-GetIOStates-front.png)

### Get safety status

![Get safety status](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/ftp-GetSafetyStatus.png)

### Get all errors list

![Get all errors list](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/ftp-GetAllErrorsList.png)

### Get numeric registers

![Get numeric registers](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/ftp-GetNumericRegisters.png)

### Get position registers

![Get position registers](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/ftp-GetPositionRegisters.png)

### Get string registers

![Get string registers](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/ftp-GetStringRegisters.png)

## SNPX

SNPX (also known as RobotIF, Robot Interface or SRTP) reads and writes data on the robot in a few milliseconds. The TCP port of the Robot IF Server (60008 by default) must be reachable.

- With the FANUC America parameters (R650 FRA, option "FANUC America Corp." in the "Advanced" tab of step 7 "Robot options" of the ROBOGUIDE workcell creation wizard), SNPX needs option R553 "HMI Device SNPX".
- With the FANUC Ltd. parameters (R651 FRL), no option is needed.

### Get world position

![Get world position](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-GetWorldPosition.png)

### Get user frame position

![Get user frame position](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-GetUserFramePosition.png)

### Read position register

![Read position register](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-ReadPosition-Register.png)

### Write position register

- Write a Cartesian position

![Write cartesian position register](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-WriteCartesianPositionRegister.png)

- Write a joint position

![Write joints position register](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-WriteJointsPositionRegister.png)

### Read numeric register

![Read numeric register](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-ReadNumericRegister.png)

### Write numeric register

![Write numeric register](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-WriteNumericRegister.png)

### Read string register

![Read string register](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-ReadStringRegister.png)

### Write string register

![Write string register](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-WriteStringRegister.png)

### SNPX is connected

![SNPX is connected](https://raw.githubusercontent.com/underautomation/Fanuc.vi/refs/heads/main/.github/assets/snpx-SnpxIsConnected.png)

## What to read next

- [Connect to your robot](/fanuc/documentation/connect): the protocols and their setup on the controller.
- [Test with ROBOGUIDE](/fanuc/documentation/simulator): work without a real robot.
- [Licensing](/fanuc/documentation/license): the 30 day trial and the license key.