Merging modern software development with electrons and metal

Random header image... Refresh for more!

Initial Statechart Thoughts

I’ve finished my initial skim of Practical Statecharts in C/C++; my time was definitely well spent.

Startcharts are a type of hierarchical state machine.  Hierarchical state machines allow state machines to be nested inside state machines, which allows behavior to be inherited (analogous to inheritance in object oriented programming).

State machines are a way of modeling systems based on transitions from one state to another, with the transitions caused by events or conditions being met.  They are a very natural way of modeling many systems (for example, communications protocols) in semiconductors, embedded systems, automation systems, and more.

The UML (Unified Modeling Language) provides a standard statechart.  The author, Miro Samek, implements a simplified version of the UML statechart in object oriented C or C++ using message passing with a publish/subscribe message bus.  Although the author emphasizes implementation details, he does include some good advice on creating and structuring statecharts.  On the other hand, his quantum physics analogies detract from the text.

I will have to carefully re-read it and try using the concepts myself before I deeply understand it, but here are my initial, somewhat unorganized, thoughts:

  • The book is definitely aimed at embedded developers; the author is always focused on speed and small size.
  • The book was definitely worth reading; overall, it’s well written, and appropriate for its target audience.
  • The concurrency method used (messaging with publish/subscribe) looks similar to the now-trendy actor approach (used in Erlang, Scala, etc).
  • Not a good fit overall for my current project, but I think I will be able to use some concepts from the book.
  • This book, and others such as Functional Programming in C#, show a great strength of general purpose “traditional” languages such as C, C++, and C#: you can use them with all kinds of different programming styles, including imperative, object oriented, functional, dataflow, and statechart.  Try doing that with ladder logic!
  • Actually, I do wonder how well I could implement hierarchical state machines in structured text.  I definitely couldn’t use the more advanced implementations (since they relay on function pointers, which structured text does not have), but it could still be worthwhile.
  • Final note: I love this quote the author chose from Fred Brook’s The Mythical Man Month: “…software structure is not embedded in three-space, so there is no natural mapping from a conceptual design to a diagram, whether in two dimensions or more … one needs multiple diagrams, each conveying some distinct aspect, and some aspects don’t diagram well at all.”  That is why graphical programming is not inherently better than text.

October 5, 2011   No Comments

PLC Programming Best Practices?

One thing I really like about the software development books I’m reading is that most of them don’t just describe features, but give practical advice, based on experience, on the best ways to do things.

I’m wondering if they are any similar books for PLC programming?  Books that don’t just discuss how to write a ladder logic program, but the best way to do it — and why that recommended way works better.  (Note: I’m thinking books here, not websites or blogs, because this is the kind of topic that is best approached in a systemic way by a substantial book, not a serious of disconnected posts.  The Art of Unit Testing is a good example of what I’d like to see.)

September 27, 2011   No Comments

My Fall Software Development Books

I just bought a lot of software development books, mostly centered on Microsoft’s .NET Framework.  I have a code base that is getting old and creaky (for example, parts are written in VB6) and it’s time to look at re-doing it, using Visual Studio 2010.

I’m tempted to write everything in a mix of F# and Boo, but I won’t, because it would be hard for almost anyone else to maintain it.  Instead, I’m planning on mostly C#, with maybe some IronPython thrown in (for rapid customization).

I’m reading each book quickly first to get an idea of what I can learn, then I will go back in depth for the techniques that I will use.

So what is on my list?

  • C# In Depth, Second Edition — to make sure I’m up to speed with all the latest changes to C#.  I haven’t read it yet.
  • Functional Programming in C# — highly recommended; it’s well written and shows how to use a lot of the functional techniques I’ve come to love from using Python; in short, it makes C# much more usable.  However, if you aren’t already familiar with concepts such as closures, first class functions, and lambdas, it’s going to be slow going for a while — and consider learning them in another language first (such as Lua using Programming in Lua).
  • The Art of Unit Testing: With Examples in .NET — highly recommended; it provides lots of practical advice and best practices for creating unit tests that work well.
  • IronPython In Action — I haven’t read it yet, but it looks good, with a lot of best practices advice.
  • Practical Statecharts in C/C++, First Edition — I haven’t read it yet.  This book is really aimed at embedded developers, and although I don’t plan on using the author’s Quantum Programming framework, I think I will get some good ideas from it.

The Manning books all include a free PDF of the book when you register your book.  I haven’t done this yet, but I will soon.

All my books are real, not e-books, because I prefer real books when learning a new topic, the paper books were cheaper or about the same price, and I won’t buy ebooks that require a proprietary reader (such as Kindle or Apple books).

September 12, 2011   No Comments

New Cheap But Limited 3D MCAD Choices

If you want to learn MCAD or make models to build in your garage, there are a couple of new choices:

  • Siemens PLM Systems is making the student edition of Solid Edge available to basically anyone for free.  Limitations include no commercial use, files incompatible with commercial Solid Edge, and watermarked drawings.  See Deelip’s post for more details.
  • ASCON has introduced Kompas 3D-Home for $50.  David Levin says that Kompas 3D-Home cannot be used commercially, but otherwise has no limitations.

September 7, 2011   No Comments

Compiling Code for Visual Studio 2003 Without VS2003

Recently, I needed to compile some code for Visual Studio 2003, which I don’t have (I have VS 2002 and VS 2005).

The obvious approach is to convert the project to VS 2005, which uses .NET 2.0.  However, I wanted to compile to .NET 1.1 for various reasons, and VS2005 does not allow this out of the box.

The first approach I tried was using the MSBee program.  MSBee is a program for MSBuild to allow compiling a program in VS 2005 to .NET 1.1.  MSBee requires modifying the project file, and has to be run from the command line.  I gave it a try, and it gave me a lot of errors.

I probably could have figured out those MSBuild errors, but I found a better solution: SharpDevelop 2.2.  SharpDevelop typically allows you to compile to either the current .NET version or the previous one.  So SharpDevelop 2.2 can target either .NET 2.0 or .NET 1.1 — and it can read and convert VS 2003 project files.

Sharp Develop read my VS 2003 solution files without a problem, and I went to the Project menu, selected Project Options, clicked on the Compiling tab, and set the Target Framework to .NET Framework 1.1.  Success!

September 2, 2011   No Comments

Silicon Valley Automation Trade Shows

The reality: there aren’t any automation trade shows in Silicon Valley.  Here are my ratings for the closest:

  1. Semicon (July) has the most automated equipment (mostly wafer robots and back-end wire bonders) and vendors.  I’ve found some good new products at Semicon, but not many.  Heck, even most of the local automation distributors skip it, since the substantial exhibition costs outweigh the benefits.  I’ve skipped it the past few years.
  2. Photonics West (January) has very little; typically there are a few data acquisition vendors and some lab automation oriented vendors.  Last time I went, there were a bunch of companies with serial or USB stepper motor packages with horrible, “intuitive” simple protocols.  Sometime I’ll write a rant about how I hate those; maybe it’s OK if you’re truly doing something simple and you’ve only used one brand, but I’ve used way too many different ones.
  3. Embedded Systems Conference (April) typically has nothing directly related to factory automation, but I enjoy going because many of the underlying products are here, such as microcontrollers (MCUs), digital signal processors (DSPs), Field Programmable Gate Arrays (FPGAs), and Real Time Operating Systems (RTOS).

August 17, 2011   No Comments

The Turbulent MCAD Market

I’m not interested in being a 3D Mechanical CAD (MCAD) journalist, but since has lot happened in the last year, it’s time for my summary.

The “Big 4″ have been up to a lot:

  • SolidWorks is being brought closer to its parent (Dassault Systèmes).  It’s highly probably that a new version based on the CATIA V6 CGM kernel is coming, possibly cloud based.
  • PTC has put Pro/E out to pasture, and is busy trying to get its new Creo components out.  Creo is supposedly to be modular (including history based and direct modelling modules) and app-oriented.  The vision sounds nice, but I suspect that the actual operational and pricing details will make it evolutionary, not revolutionary.
  • AutoDesk is adding direct modelling to Inventor via the Fusion program.  The free 123D program is a cut-down, stand-alone version of Inventor fusion.  123D looks quite useful, but I expect it’ll be neutered if it starts to impact Inventor revenues.
  • Siemens PLM Systems is finally getting its Solid Edge act together.  They’re concentrating on making Solid Edge the best program for machine design, and Synchronous Technology V3 (direct and history based modelling) has been getting good reviews.

There’s been even more change with many of the smaller players:

  • 3D Systems recently bought Alibre.  A few months ago Alibre introduced a $1500 bundle consisting of a RapMan 3D printer, Alibre Design Personal, and MoI.  I’ll be interested to see what happens next.
  • The $97 Alibre Design Standard deal really was a great deal, just for the translators and 3D PDF output alone, but the recent pricing and capability changes (e.g. removing almost all import and export options from AD Personal) really neutered the entry level version.
  • I’m hopeful that 3DS will provide resources so Alibre can keep improving (especially since I just paid for Alibre maintenance!)
  • ZWCAD of China bought VX, and renamed it ZW3D.
    • On the positive side, ZWCAD is trying to treat customers well, there have been no US layoffs as far as I know, they have been investing money into ZW3D (licensing more components, adding more developers, etc), appear to be listening, and probably have a good upgrade policy.
    • On the other hand, it’s taking a  (long?) while for them to get up to speed, they’re going to a reseller-only approach (e.g. you have to contact your reseller to upgrade), and they really need to spend some money and hire some good US marketing folks.
    • For example, when ZWCAD took over, they gave all customers a free upgrade to the next level.  So if you had VX Innovate, you got upgraded to ZW3D 2010 Standard, if you had VX standard, you were upgraded to ZW3D 2010 Professional.  I think this was a great gesture, but ZWCAD never received any publicity for this.
  • Think3 users are in a huge mess, and should start looking elsewhere, since there are now two versions, one from Versata, and one from the Italian bankruptcy trustee.  Deelip is the place to go for all the details.
  • I plan on discussing my experiences with Alibre, ZW3D, and 123D, but I won’t make any promises on how often I’ll have time for such posts.

    August 2, 2011   No Comments

    Maxtor & Microchip: Somebody Has To Be Different

    There’s always one company has has to different.   Back when Maxtor was independent, they spun their disks backwards from everyone else, and numbered their heads from top to bottom, instead of bottom to top like everyone else does.

    Microchip is acting the same.  When everyone else, it seems, is using ARM cores for microcontrollers, they picked MIPS cores for the PIC32 micro-controller (MCU) family.  Their new IDE, MPLAB-X is based on NetBeans, instead of Eclipse.

    I don’t think the MIPS versus ARM core is a big deal; maybe Microchip got a much better deal from MIPS.  Switching between ARM MCU vendors isn’t easy because all the peripherals are different.  I wouldn’t be surprised if it’s easier to port C code from a PIC24 (16-bit proprietary) to a PIC32 (32-bit MIPS) than from (to take a random example) an Atmel SAM7 to a TI Stellaris MCU simply because the peripherals are much more similar on the PIC MCUs.

    On the other hand, I don’t see the advantages of NetBeans over Eclipse.  Both are Java-based IDEs.  Both are open source.  Both are cross-platform.  (Note that an IDE based on either one might not be cross-platform, depending on device drivers for emulators and such.  TI’s Code Composer Studio V4 (based on Eclipse) only runs on Windows; V5 adds Linux.  MPLAB-X has beta downloads for Windows, Linux, and Mac).

    NetBeans is primarily known for an excellent GUI builder, which typically isn’t important in embedded development.  I don’t know of any other companies using it for embedded development (or non-Java programming).  Even in the Java world, it’s been a distant second to Eclipse.

    Eclipse has been used for non-Java programming (e.g. the C Development Tools or CDT) and embedded programming for a long time, and has many companies supporting it.  So Eclipse should develop a lot faster than NetBeans, and has the advantage of many more plugins.  Plus, Eclipse is run by an independent foundation, not by a company (Oracle) that likes to get paid.

    Microchip is not very supportive of open source (unlike most ARM MCU companies).  On the good side, the PIC32 compiler lite version does not have any code size limitations; instead, Microchip removed optimization support.

    Microchip is also a good source of low pin count chips, and is one of the few companies still selling MCUs in easy to prototype plastic DIP packages.  For example, you can get a 16-bit dspPIC33F with a CAN controller in 28 pin SOIC, QFN, and DIP packages.

    I find Microchip’s mTouch Metal over Capacitor technology interesting: it allows capacitive sensing of metal buttons.

    July 26, 2011   No Comments

    Best Industrial Equipment For The Garage: 2011 Update

    Overall my original post on buying surplus industrial automation equipment is still on the mark.  I won’t repeat it again this year; instead, here are some comments based on 3 years of monitoring eBay and adding to my collection.

    In Silicon Valley there are only two decent electronic surplus stores: Excess Solutions and Advanced Component Electronics.  There hasn’t been a good local source for mechanical surplus since Triangle Research closed its doors.

    On the web, PLCCenter has a great selection, is great for getting an idea of what stuff costs new, but has premium pricing (except for some on-sale items).

    eBay is still the best source, but you need to be patient and know what equipment is worth.  In general, I’m willing to pay 10-20% of the original cost, but many eBay sellers try to get 50%, and a few even ask for more than 100%.  In general, “Buy It Now” means “I think my junk is worth a lot”.  Availability is very spotty; some months there’s a lot of interesting stuff, some months there is nothing.

    Also, be sure to check condition and return policies.  Many eBay sellers do not have the ability, equipment, or inclination to test industrial equipment, so if it says “as-is”, don’t pay a lot.  Most of the industrial equipment I’ve bought has worked, but I’ve bought a number of AMC and Elmo drives that don’t want to communicate (since the lights blink, I haven’t given up yet; I haven’t had time for extensive troubleshooting).

    Don’t forget new equipment; many vendors (including Siemens and Panasonic) have offered somewhat-affordable starter packages including equipment and software (e.g. PLC and programming software).  Some new PLCs are so inexpensive you don’t even need a starter kit: for example, Automation Direct’s Click PLC starts at $69 and the software is free.

    Comments on specific equipment:

    • Last time I checked, it appears the Cognex Insight smart camera software is now a free download (after registration).  But I recommend verifying this before buying an Insight camera (which will probably cost >$100).
    • DVT smart cameras are still often available on eBay, with pricing ranging from $50 (Legend 510 bought at the right time) to $500 or more (color model such as the 542C).
    • Galil motion controllers availability is good, with a wide range of pricing (there are many unrealistic sellers).  USB and Ethernet models are more expensive, although if you’re lucky you can buy one for under $250.
    • CANOpen interfaces from Kvaser and Ixxat are frequently available for $50-$150.  I’d recommend getting a used Kvaser or Ixxat instead of a new interface from someone else (which will be at least $100 anyway) because they have the best software support.
    • Copley CANOpen servo drives are available fairly often; a reasonable price for an Accelnet is $50-$120; the Xenus is more expensive (>$150).  The Accelnets are my favorite servo drive.  I avoid the older models (800-xxxx)  because I can’t find any documentation for them.
    • Elmo CANOpen servo drives are frequently available.
    • Ethernet Powerlink drives and EtherCAT drives are occasionally available , but the prices typically aren’t reasonable.
    • MEI controllers are often available, at a wide price range, but I’ve never seen the software included.  If you don’t have MEI software, don’t buy the board.
    • Panasonic PLC’s are frequently available, but in general I think the asking prices are too high.  At least Panasonic now provides a code-sized limited (but still quite useful) free version of FPWin Pro 6.
    • Opto 22 I/O controllers, such as the B3000 and LCSX, are frequently available, often at reasonable prices ($50 and up).  Opto 22 PACs are rare and expensive, especially the current models.  Opto 22 I/O module availability is good.
    • Wago 750 and Beckhoff K-bus availability is good, and, if you’re patient, you can get them at a reasonable price.
      • The most popular couplers are for DeviceNet, CANOpen ($25-$75), Profibus, and Ethernet (>$100 for 750-842); I’ve also seen Interbus, serial, and EtherCAT.
      • Digital input and output modules are the most common, and cheapest.
      • Analog modules are less common, and more expensive, but if you’re patient, you can get one for <$50.
      • Specialty modules, such as encoder interfaces and stepper drivers, are the least common and most expensive.

    June 20, 2011   5 Comments

    The Connector Addict?

    I love the Pen Addict’s slogan: There are worse addictions…..right?

    I’m not a connector addict, although I do like trying out new connectors.  Partly it’s because I haven’t found the ideal connector system (or systems; I often want some variety so that the same connector type isn’t used for a variety of incompatible uses, and thus you have to be careful where you plug a connector in).

    But I still enjoy receiving the occasional Mouser order with some new connectors.  So along with an order for some MDR connectors for my Copley Accelnets, I included connectors I haven’t tried such as:

    • Kycon USB B high retention force connector.  The big feature: minimum removal force is increased from 10N (standard USB) to 15N.  I like them; USB plugs come out too easily, but this connector makes it a lot harder for a USB cable to become accidentally unplugged.
    • Amphenol USB A locking connector.  The big feature: the connector has a locking tab that grabs onto the little square holes on a USB A-type plug.  That’s even better than the Kycon: it takes over 95N to separate the plug from the jack without unlocking.
    • TE/AMP MTE connector.  Nice, affordable IDC connectors, except you need really expensive tooling to use them easily.
    • Molex Micro-Fit Jr 3.0mm BMI.  I wanted to check out the blind mate version of the Micro-Fit; I’m still not a Micro-Fit fan.
    • Phoenix PST 1.3/8-LV-5.0 header with shroud.  The shroud provides polarization.  The Phoenix PST headers and PT terminal block plugs are a very affordable removable terminal block system.
      • One gotcha: you have to use the shrouded headers with the PT 2.5 series (e.g. PT 2.5/8-PVH-5.0) not the 1.5 series (e.g. PT 1.5/8-PVH-5.0).
    • Phoenix ST-Combi connector and ST-Twin terminal block.  I’m looking at using these for DC power distribution.

    May 23, 2011   No Comments