FANUC FS0iD FOCAS Setup

Confirm FOCAS is installed

FOCAS is an optional function.  If it is installed, the setting screen will be available.  The screen is located under the system hard key; followed by the continuous menu soft key several times.

system

continuous menu softkey

Keep scrolling through the available softkeys until the [Embed Port] soft key is displayed.  All of the available ethernet interfaces will be shown.

ethernet softkeys

Of the three listed here, [Ether Board] is the best choice.   It is an add on hardware board for Ethernet communication.  Press the [Ether Board] soft key.  If the [FOCAS2] softkey is now displayed, FOCAS is installed !!!  Plug your Ethernet cable into the add on boards RJ45 plug.

focas2 softkey

If you didn’t find the [FOCAS2] softkey, then check to see if it exists under the [Embed Port] softkey.  If it does, then connect your Ethernet cable into the RJ45 plug directly on the mainboard of the FS0iD contol.   Setting FOCAS2 In order to set the FOCAS settings, we first need to be in MDI mode.  Parameter Write Enable (PWE) is then enabled under the <OFS/SET> hard key [SETTING] softkey.

set PWE

Once PWE is set the IP Address of the control is set by <SYSTEM>, [Ethe Board], [COMMON].  The IP address will be a fixed address assigned by the network administrator.

IPAddress Setting

Finally the TCP Port number is set under the [FOCAS2] settings.  This port is typically 8193, however, any valid TCP port number can be used.

TCPPort setting

Confirmation

If everything is set correctly the FANUC FS0iD CNC should be reachable from any computer on the same network.  In Microsoft Windows, start a new command prompt and ping the CNC.

pingsuccess

You are now ready to use FANUC FOCAS to read and write information to the CNC.  Although the FOCAS drivers and libraries is a programming interface for C/C++ or Visual Basic, there are many available options that don’t require programming such as MTConnect and OPC converters to FOCAS.

Good Luck!

MTConnect Agent on Ubuntu Linux

Preparation 

Before MTConnect can be installed some prerequisites must be in place.  A clean install of Ubuntu 14.04 LTS will not have many of the packages required.  Install these packages using the apt-get command.

$ sudo apt-get install libxml2 libxml2-dev cmake git libcppunit-dev build-essential screen ruby

After all the required packages are in place, the MTConnect source code needs to be downloaded from GutHub.  The source code should compile without any modifcation using cmake and make.

$ cd ~
$ git clone https://github.com/mtconnect/cppagent.git
$ cd cppagent
$ cmake .
$ make

MTConnect Agent Installation

Now that binaries are compiled from the MTConnect source, they just need to be put into appropriate directories.   The agent binary and the configuration file are first.

$ sudo mkdir /etc/mtconnect
$ sudo cp ~/cppagent/agent/agent.cfg /etc/mtconnect/
$ sudo cp ~/cppagent/agent/agent /bin/agent

The source from GitHub contains a script to run MTConnect as a daemon.  I instead opted to write a BASH script that suited my needs a little better.  The script is available at the end of blog.  The blog downloads it from this server.  After it is downloaded it is given permission to execute and added to the startup scripts.

$ cd ~
$ wget http://www.ellisware.com/downloads/agent.sh
$ sudo mv ~/agent.sh /etc/init.d/agent
$ sudo chmod +x /etc/init.d/agent
$ sudo update-rc.d agent defaults

The script requires the user ‘mtconnect’.  So we need to add that user.  Pick a password that is appropriate for you.  For security reasons, you probably should pick a different username and change it in the script, however, this blog uses the default.

$ sudo adduser mtconnect

MTConnect Simulator Installation

The default configuration file that was downloaded with the source code defines a simulator.  For the MTConnect agent to start, it needs to connect to all devices listed in its configuration file.  So now we setup the simulator device.

$ sudo mkdir /etc/mtconnect/simulator
$ sudo rsync -avr ~/cppagent/simulator/ /etc/mtconnect/simulator/

The default configuration file expects the simulator adapter to be one directory above where we placed it.  To correct this, edit the agent.cfg file and point to the correct path for the simulator.

$ sudo nano /etc/mtconnect/agent.cfg

Original Path::  “Devices = ../simulator/VMC-3Axis.xml”

New Path:: “Devices = ./simulator/VMC-3Axis.xml”

Finally, the simulator is started up in a fresh screen.  The simulator blocks the process so just detach the screen using control A, D, after it is up and running.

$ screen -S simulator
$ cd /etc/mtconnect/simulator
$ ruby -v run_scenario.rb -l VMC-3Axis-Log.txt

<cntrl><a> followed by <d>

Testing

Testing the MTConnect agent is very simple.  First the agent is started using the script we created, if the script completes successfully we can make sure it is listening for incoming connections.

$ sudo service agent start
$ netstat - tcp -l

Active Internet connections (only servers)
tcp 0 0 *:7878 *:* LISTEN
tcp 0 0 *:5000 *:* LISTEN

With the default configuration the agent is listening on port 5000 and the simulator is listening on port 7878.  If these are listed in the netstat, then everything is good.   For the final confirmation, any browser can be used as client.

agent.ellisware.com:5000/ or agent.ellisware.com:5000/probe

agent.ellisware.com:5000/current

agent.ellisware.com:5000/assets

agent.ellisware.com:5000/sample

 

Conclusion

Please let me know any mistakes, omissions or improvements in the code.  It took a great deal of patience to get this up and running, so feel free to ask any questions in the comments.

 

###### agent.sh #######

 #!/bin/bash
 # /etc/init.d/agent
 # version 0.0.1 2014-05-09 (YYYY-MM-DD)
 
 ### BEGIN INIT INFO
 # Provides: agent
 # Required-Start: $local_fs $remote_fs
 # Required-Stop: $local_fs $remote_fs
 # Should-Start: $network
 # Should-Stop: $network
 # Default-Start: 2 3 4 5
 # Default-Stop: 0 1 6
 # Short-Description: MtConnect server
 # Description: Starts the MTConnect Agent server
 ### END INIT INFO
 
 #Settings
 SERVICE='agent'
 OPTIONS='agent.cfg'
 USERNAME='mtconnect'
 CONFIGPATH='/etc/mtconnect/'
 INVOCATION="$SERVICE $OPTIONS"
 ME=`whoami`

as_user() {
if [ "$USERNAME" != "$ME" ]; then
  su - $USERNAME -c "$1"
else
  bash -c "$1"
fi
}

mc_start() {
if netstat - tcp -l | grep -q 5000
then
  echo "$SERVICE is already running!"
else
  echo "Starting $SERVICE..."
  cd $CONFIGPATH
  as_user "cd $CONFIGPATH && screen -dmS agent $INVOCATION"
  sleep 10
  if netstat - tcp -l | grep -q 5000
  then
    echo "$SERVICE is now running."
  else
    echo "Error! Could not start $SERVICE!"
  fi
fi
}

mc_stop() {
if netstat - tcp -l | grep -q 5000
then
  echo "Stopping $SERVICE"
  as_user "screen -p 0 -S agent -X stuff \"^C\""
  sleep 10
else
  echo "$SERVICE was not running."
fi
if netstat - tcp -l | grep -q 5000
then
  echo "Error! $SERVICE could not be stopped."
else
  echo "$SERVICE is stopped."
fi
}

#Start-Stop here
case "$1" in
start)
mc_start
;;
stop)
mc_stop
;;
restart)
mc_stop
mc_start
;;
status)
if netstat - tcp -l | grep -q 5000
then
  echo "$SERVICE is running."
else
  echo "$SERVICE is not running."
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
 
exit 0

<noinclude>[[Category:Guides]]</noinclude>

Installing WordPress in Ubuntu 14.04 LTS

Installing WordPress

Assuming your LAMP is up and running we start with downloading WordPress to the home directory.  It is unzipped, modified before being moved to our /www/html/ site.

$ cd ~$ wget http://wordpress.org/latest.tar.gz
$ tar -xzvf latest.tar.gz

From the mysql shell we will create a structure WordPress can use.

$ mysql -u root –p
> CREATE DATABASE wordpress;> CREATE USER wordpress@localhost;

> SET PASSWORD FOR wordpress@localhost= PASSWORD(“password”);

> GRANT ALL PRIVILEGES ONwordpress.* TOwordpress@localhost IDENTIFIED BY 'password';

> FLUSH PRIVILEGES;

> exit;

Now that the MySQL database is ready for the WordPress installer, a few items need to be set so WordPress knows how to reach the database.  This is done in the wp-config.php file.  Make sure to set the username, password, database and security salts.

$ cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php 
$ sudo nano ~/wordpress/wp-config.php

Lets copy all the WordPress files so they are served by Apache.

$ sudo rsync –avP ~/wordpress /var/www/html/
$ cd /var/www/html$ sudo chown www-data:www-data * -R 
$ sudo usermod -a -G www-datausername

Finally, open your browser and setup WordPress!

 

References:

How To Install WordPress on Debian 7

 

 

Setting up an Ubuntu 14.04 LTS Server

This blog is a reference for my current Ubuntu 14.04 setup.  I struggled to find correct information on-line especially with mysql setup.  This ensures its available in the future.  Digital Ocean servered as a great resource for the setup.

 

Setup a User

Add a user account for yourself. This is easy with the adduser command. Just follow the prompts to update set a password and any other information.

# adduser someuser

Since this is your account, you need to give all sudo privileges to the new account. Open up the list of sudoers with the visudo command and add your username below root with all privileges.

# visudo
   # User privilege specification
   root  ALL=(ALL:ALL) ALL
   someuser ALL=(ALL:ALL) ALL

Final switch from the root user to the sudo account you’ve created.

# su someuser

 

Updating packages

Several packages will be out of date and need to be updated. This is done with two commands. The update command retrieves a list of all packages and dependencies for updating purposes. Finally the

$ sudo apt-get update
$ sudo apt-get dist-upgrade

 

Add a Swapfile

How about adding a swapfile to decrease any chance of a memory overflow error. Use the fallocate command. The 2G is the size, 2 gigabytes. Finally check its OK using ls to confirm the size is 2GB.

$ sudo fallocate –l 2G /swapfile
$ ls –lh /swapfile

Enable the swapfile

$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile

The swapfile is now up and running, however, to have it permanently on the fstab file has to be edited. The swapfile is put at the bottom of the file.

$ sudo nano /etc/fstab
     /swapfile   none   swap   defaults   0   0

 

Install Apache Web Server

Next up the webserver apache2 is installed. After the server is installed the ServerName will need to be set to eliminate the “Could not reliably determine the server’s fully qualified domain name” nag. Finally restart apache2 to confirm the setting is correct.

$ sudo apt-get install apache2
$ sudo nano /etc/apache2/apache2.conf
      # Default ServerName
      ServerName www.mysite.com
$ sudo service apache2 restart

 

Install MYSQL Server

Time to setup MYSQL. Install the package and then secure it by running my_sql_install_db

$ sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql php5-gd
$ sudo mysql_install_db

 

Install PHP5 for Apache

Finally we need PHP in our LAMP. Once the packages are downloaded and installed, the extension .php has to be moved up the default order of extensions apache will search for when an extension is omitted. This is done by editing the dir.conf file.

$ sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
$ sudo nano /etc/apache2/mods-enabled/dir.conf
$ sudo service apache2 restart


Reference
How To Install Linux, Apache, MySQL, PHP (LAMP)stack on Ubuntu

How To Add Swap on Ubuntu 14.04