Probotix Comet CNC Startup and Shutdown

These are my notes on starting and stopping the Probotix Fireball Comet CNC mill.

Danger

I’m not kidding about danger. There is one cardinal rule.

The motor control box must never have power without the AXIS control software running.

The AXIS control software (the Comet icon on the desktop) must and I repeat must be running before power is applied to the stepper motor control box, and must remain running as long as power is applied to the stepper motor control box.

Why This Is Important

The motor control box translates signals from the computer’s parallel port into motion and spindle control. The AXIS software controls the signals to the parallel port. If the motor control box is powered on before the AXIS software is running, or the AXIS software is exited before the motor control box has been powered off, then the parallel port and thus the motor control box will be thrown into an unknown, unpredictable, and uncontrolled state and the mill can start operating by itself.

Think about how dangerous this is:

  1. The spindle can start without warning and the red emergency stop button will not be operable. (I had this happen to me.)
  2. The motors can start moving  without warning and the red emergency stop button will not be operable. These motors are powerful and can crush fingers.

A powerful uncontrolled robotic cutting tool is not something to leave to chance.

Steps

Now that I’ve beat that horse to death, here are the steps to safely start up and shut down a Comet:

Start Up

  1. Start the computer
  2. Double click on the Comet program icon and leave it running.
  3. Power on the controller box.
  4. Ensure the emergency stop button on the machine is out (off). Twist the knob to reset it.
  5. Turn on the (virtual) machine power on. Push F2 or click on the orange power button icon on the top tool bar of the AXIS software.
  6. Use Home All button to put the CNC into a known state.
  7. Use the machine to make all manner of wonderful creations.

Shut Down

  1. Turn off the controller box.
  2. Exit the AXIS (Comet) program. You can use the X in the upper right-hand corner.
  3. Turn off the computer. In the top right hand corner of the screen there is a power symbol. Click on this to bring up the menu and select Shut Down….

Restarting LinuxCNC

If you ever need to restart LinuxCNC power off the stepper motor controller box first. The motor control box must never have power without LinuxCNC running. (Did you think that I was done beating that horse?)

I have had problems having LinuxCNC crash when trying to restart it. If this happens, reboot the computer. There is a power symbol in the top right corner of the screen. Click on this to bring up the menus and select Restart….

 

Posted in CNC & Robotics | Tagged , , , , , , , | Leave a comment

Contact Form Updated

The venerable cformII plugin has been retired as it’s not supported  any more, and spam bots started pinging my mailbox.

I’m hoping the that the shiny new contact form plugin works well.

 

Posted in Announcements | Leave a comment

Django 1.7, PyCharm, and Apache

I’ve had some ongoing problems with PyCharm support for Django since the 1.7 release. Here is a summary.

WSGI Broke

The entire app failed to run under Apache. This caused some moments of terror. The WSGI file needed to be edited.

This code started on version 1.3. The old WSGI configuration worked until 1.7. This discussion thread described the behaviour, which bites projects started pre-1.4. See also Issue #23437 describes the WSGI problem, and the official release notes under app-loading changes.

The correct call to initialize WSGI is:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

 

PyCharm Testing Broke

Tests in PyCharm broke. This a case of being bitten by older code again. Django uses the standard Python unittest module now. I had to go through dozens of files and tweak the import statements.

Update: LH asked for more information.

In my unit testing, I used the old-style Django test classes and had import statements like:

from django.test import TestCase

which must be changed to:

from unittest import TestCase

in order to use the built-in Python unit testing core.

PyCharm Django Console Broke

This is kind of annoying. The problem isn’t so much PyCharm itself but Django “fixed” a long-standing “bug”. Now what used to work fine doesn’t. Per the app-loading changes in the 1.7 release notes, one must, every time they start the Django console from within PyCharm, execute the following commands:

import django
django.setup()

This became annoying enough I hacked the Django helper

/Applications/PyCharm.app/helpers/pycharm/django_manage_shell.py

and added the two lines to that file. Problem resolved.

 

Posted in Programming | Tagged , , , , , , , | 2 Comments

Hair Donated

I’ve been blessed with a full head of thick hair and decided to share that blessing with others. Today I had my pony tail cut off, harvesting approximately 13 inches for donating to charity. It will be used in making wigs for children with hair loss due to cancer or other conditions.

 

My hair, before harvesting it for charity.

My hair, before harvesting it for charity.

Posted in Extra Mile | Tagged , , , , , | Leave a comment

Control VMware Fusion from the Command Line

Background

Virtualization has been a key technology for me as a contractor. Because I have multiple clients, keeping their projects sequestered from each other is a snap: one or more VMs (virtual machines) per project. Development, testing, and in some cases deployment is all on separate VMs.

I’ve been using VMware Workstation since it first came out 1999. The ability for me to seamlessly move VMs between Windows, Linux, and OS X has been a key reason I’ve stuck with them for so long.

Automating tasks via scripting one of many reasons I insist that my workstation run  Un*x of some flavour. I’ve been using OS X for quite a while quite happily as a software developer, however VMware Fusion (for OS X) doesn’t present the full set of features available on VMware Workstation (for Linux and Windows). Fortunately hidden under the hood are the same tools.

The Executable vmrun

VMware provides a tool called vmrun that allows common operations to be performed on VMs — starting, suspending, taking snapshots, etc. On OS X it’s tucked away in the VMware Fusion bundle under Contents/Library.

In my shell startup I add the directory to PATH:

# VMware Fusion
if [ -d "/Applications/VMware Fusion.app/Contents/Library" ]; then
    export PATH=$PATH:"/Applications/VMware Fusion.app/Contents/Library"
fi

Find the Virtual Machine’s .vmx File

To use vmrun you need to have the path to the .vmx file that resides inside of the VM bundle on OS X. For example, I have a VM with an install of RedHat Enterprise Linux 7:

RHEL7 VM

This is actually not a single file, but a directory called RHEL7.vmwarevm. The contents can be seen in the Finder by right clicking:

Show Contents

This will open up the directory and show the various files that make up the virtual machine.

Inside the Bundle

As can be seen, the .vmx file is prominently displayed.

Put the Pieces Together

To start the VM from the command line one uses the “start” parameter. For example, if the above virtual machine were in one’s home directory one can type:

$ vmrun start ~/RHEL7.vmwarevm/RHEL7.vmx

vmrun Commands

If one runs vmrun without parameters it gives a farily long summary of commands that it accepts. One can:

  1. control the power state of the VM,
  2. control snapshots,
  3. perform various operations inside a running VM, and
  4. other operations such as installing tools and cloning.

A short list of common operations:

Description Command Parameters
List running VMs list
Start a VM start /path/to/vmx/file
Suspend a VM suspend /path/to/vmx/file
Take a snapshot snapshot /path/to/vmx/file snapshot name

 Additional Information

VMware has a PDF on vmrun here.

 

Posted in SysAdmin | Tagged , , , , | Leave a comment

Controlling RHEL 7 Services

One change from RHEL/CentOS 6 to the RHEL 7 beta is how services are controlled. The old service and chkconfig commands are replaced with systemctl. These are my quick and dirty notes compiled from the Fedora Project systemd and SysVinit to Systemd Cheatsheet pages.

Basic Control

The old system command’s replacement is very similar, with services having .service appended:

systemctl start|stop|restart|status name.service

For example:

systemctl restart httpd.service

Service Boot time Control

To get a list of available services and their boot time status:

systemctl list-unit-files --type=service

To set a service to start (or not) at boot time:

systemctl enable|disable <em>service</em>.service

For example:

systemctl enable mariadb.service
systemctl enable httpd.service

Run Levels

Run levels are called targets, have been simplified, and have names now. An incomplete list:

  1. poweroff.target (run level 0)
  2. rescue.target (single-user mode; run level 1)
  3. multi-user.target (normal run level 3)
  4. graphical.target (normal run level 5)

To set the default run level:

systemctl set-default multi-user.target

To change the run level:

systemctl isolate name.target

For example, to enter single user mode:

systemctl isolate rescue.target

And the appropriate services will be stopped and started.

Additional Reading

  • A description of how systemd fits into the boot process here.
  • Another nice summary here.

Updates

2014-07-17
Updated setting the default run level per CertDepot’s suggestion. Added the “Additional Reading” section.
Posted in SysAdmin | Tagged , , , , , , , | 2 Comments

Display a Server-Supplied Drop Down List Using AngularJS

These are my notes on displaying a list of server-supplied objects in a drop down list using AngularJS.

Background

I have a server that supplies lists of lookup objects that are used in an AngularJS-based single-page application (SPA). The SPA obtains a list through an API call to the server. The server returns an ordered list of JSON objects. Every object in every list includes a key value, a display value, and supplementary data. For the purposes of this article, only the key and display values are of any concern.

For example, the SPA needs a list of units of measure. The server supplies a list of objects along these lines. They key value is called code and the display value is called display:

[
    {
        code: "L",
        display: "L",
        description: "litres"
    },
    {
        code: "ML",
        display: "mL",
        description: "millilitres"
    },
    ... etc ...
]

In the SPA code, each lookup table is wrapped in its own Angular service.

From List of Objects to Dropdown Using <select>

Angular can be told to create a dropdown list using an array of objects thus:

<select ng-model="product.uom"
        ng-options="u.display for u in units" />

Here ng-options tells Angular to build the dropdown list showing the display attribute of each object. Whenever the user chooses an item, the entire associated object is stored in $scope.product.uom (uom means units of measure). For my purposes this is very handy since I want access to the entire object.

Defaulting to a Value

This works beautifully until an edit page is shown. When displaying data from the server, the dropdown shows a blank selection even though $scope.product.uom contains an object with all the correct values!

The problem is that Angular matches based on object references, not object contents. This can be illustrated thus:

var a = {foo: "bar"};
var b = {foo: "bar"};
var c = a;

Variables a and b contain two separate objects that by chance have attributes with the same values. Variables a and c contain the same object pointer.

In the example above, Angular will recognize the value in $scope.product.uom only if it points to an object in the master list $scope.units. The fact that the server-supplied object has identical attributes is irrelevant — Angular only cares whether the object pointers are identical.

[Edit]

There are a couple of ways around this. If there is a unique key on the object, one can use the AngularJS track by clause to tell AngularJS to compare the keys. Continuing the above examples, each object has a code attribute that has a unique string which JavaScript can compare.

<select ng-model="product.uom"
        ng-options="u.display for u in units track by u.code" />

[Original Article]

Otherwise,  when an object is loaded from the server for editing, the lookup values are replaced with pointers to the corresponding objects in the dropdown list. An unsophisticated but functional bit of code to perform this substitution might be:

// Wrapper function to retrieve a product
// from the server, keyed on productId.
apiProduct.lookup(productId, function(product) {
    $scope.product = product;

    // Replace the server-supplied lookup value
    // with the matching value
    // in the $scope.units array.
    $scope.product.uom = lookup_by_code(product.uom.code, $scope.units);
});

function lookup_by_code(code, data) {
    for(var i=0; i
        if(data[i].code == code)
            return data[i];

    return null;
};

Update

There is a JSFiddle that demonstrates the value/reference problem concisely.

Posted in Programming | Tagged , , , , , , | 5 Comments