Merging modern software development with electrons and metal
Random header image... Refresh for more!

Posts from — June 2008

Best Industrial Equipment For The Garage

Let’s say you want to learnplay with real industrial automation equipment in your garage (or living room, if you’re single), not toys like the Lego Mindstorm. After all, learning is fun, and it’s cheaper than taking college classes (that’s what I tell my wife). Unless you’re rich, buying surplus is the way to go.

In the past, if you lived in the right area you could visit the local surplus store. Silicon Valley used to have a lot, but most of them disappeared during or after the dot-bomb bubble and subsequent crash. Still, there are a few places left, such as Triangle Machinery (the best place for mechanical stuff) and Excess Solutions. DeAnza College hosts the monthly Electronics Flea Market.

Now the overall situation is better because of on-line sites such as eBay (still the best overall), craigslist (worth checking, but probably best for test equipment), DoveBid (typically best for test equipment or large industrial equipment), and PlcCenter.

Mechanical items such as stages and motors are pretty easy to use. But when looking for equipment such as motion controllers or PLC’s, you need to consider:

  1. What software does the equipment require? The best case is when the equipment comes with software or you can download the software from the manufacturer’s web site. Next best is when the necessary software is at least somewhat reasonably priced (so you can afford to buy it (e.g. some PLC software)). The worse case is copy protected software (Allen-Bradley, Cognex, and many others).
  2. Does it come with documentation or can you download it?
  3. Are the necessary accessories readily available? If it’s a rack, backplane, or snap-together system (many PLCs, Opto 22, Beckhoff, Wago, etc), you have to be able to get all the required pieces (backplane, power supply, CPU, I/O modules, etc). For a motion controller, are the break out boards and cables readily available?
  4. What are the power requirements? Many servo drives are 3 phase 240V or 480V.
  5. Is it readily available surplus? Important if you want to expand later.
  6. Have you used it before? Familiarity obviously helps.

My recommended list:

  • Galil motion controllers. Yeah, the two letter commands are stone age. But Galil controllers are readily available on eBay, you can download all the essential software and documentation, the connectors and breakout boards are readily available (but if you buy them new they might cost more than the controller cost on eBay!), and it’s easy to get started.
  • Opto 22 PACs. I haven’t used them, but software for the SNAP controllers is free, and they’re often available on eBay.
  • DVT smart cameras. Software for the older models is free, and they’re often available on eBay. I’ve heard that software for newer (after Cognex bought DVT) models is protected.
  • CANOpen is a mixed story. CANOpen availability is good (AMC DX15C08 Digiflex drives are readily available at great prices, other drives such as Copley Accelnet, Copley Stepnet, Baldor MintDrive, and Kollmorgen Servo Star are occasionally for sale, and I/O controller such as Wago 751 series are sometimes seen). However, you will need a CANOpen interface (I recommend Acacetus VCCM or Peak USB-CAN because they’re supported by CanFestival). Getting started with CANOpen is still a lot of work; starting from no knowledge, it takes much more effort than getting a Galil system up and running.
  • Plenty of others, including many I haven’t heard of. Other possible examples include Logosol, Animatics SmartMotor (also stone age commands, but…), and JR Kerr’s PIC-Servo boards (quirky, but affordably priced new).

Not recommended:

  • MEI motion controller without software – nice boards (the XMP looks really nice), and occasionally seen on eBay, but IIRC the software is $4900 for the older systems and $19,000 for the XMP.
  • Cognex Insight smart cameras. Nice systems, often available on eBay – but every time you install the software you have to call Cognex to get a key for that particular PC.
  • Most PLC’s, especially any you have not used, unless they come with programming software and the appropriate licensing (dongles, disks, etc). The “big name” vendors like Allen-Bradley tend to like nasty copy protection schemes – software keys that have to transferred via floppy disks are the worst, since they are so easily lost (and who has floppy drives anymore?) . At least hardware dongles are harder to lose.
  • Anything you don’t know about or can’t find out about.

Some good sources for cables and breakout boards:

Sometimes it takes patience and multiple sources to put a working system together. I bought my Wago 751 series CANOpen controller from eBay, but I bought the I/O modules from PlcCenter (they were available at reasonables prices). I bought my Festo CPV-10 CANOpen control module from eBay about a year before I found the CPV-10 pneumatic manifold and valves available at a reasonable price.

Note: go here for my 2011 Update

Tony

June 26, 2008   23 Comments

The Case of the Disappearing Exception

I was doing some debugging recently on an inherited Visual Basic.NET codebase. Something odd was going on – the code that reads a PLC’s input was always returning True, but I could see the input changing. The problem? The original programmer, who I’ll call “Bugs Bunny”, didn’t understand exception handling at all.

The function, part of a class that communicated with a PLC, went roughly like this:

Function bubba() As Boolean
    bubba = True
    Try
        bubba = getResultFromPlc()
    Catch ex As Exception
        logException()
    End Try
End Function

Since all Exceptions are caught and not handled any Exceptions raised in bubba()’s Try block just disappear. So all the code calling bubba() has no way of knowing if there are problem (such as the PLC isn’t powered or the serial port isn’t connected) . Instead, because the return value is initially set to True (bubba = True), if an Exception occurs, bubba() always return True.

Sometimes you do need to ignore Exceptions. For example, on a maintenance screen that repeatedly reads a PLC’s inputs, it’s good to indicate if there are any problems reading the inputs, but it’s not helpful to pop up a dialog box or exit the maintenance screen. Exceptions should be ignored occasionally as needed in the calling code, not completely swallowed up in the base library code.

Another common anti-pattern in Bug’s code is:

Sub joe()
    Try
        blah()
        blahblah()
    Catch ex As Exception
        logException()
        Throw ex
    End Try
End Sub

Sub groovy()
    Try
        joe()
    Catch ex As Exception
        logException()
        Throw ex
    End Try
End Sub

What’s the point? All that happens is the exception gets logged multiple times (adding confusion to the log file), more useless code is added (making the code harder to understand), and the program runs slower (throw, catching, and re-throwing Exceptions takes time).

Tony

June 24, 2008   2 Comments