Wednesday, December 23, 2015

Lab explosions and accidents

If you're working on serious projects there are often serious risks.  A lot of these can be mitigated by preventative measures and safety gear but ultimately some fallout is expected.  This is a compilation of various lab accidents I've been involved with, what caused them, and the outcome.  I've placed them roughly in order of increasing risk and/or actual injuries.  Of all of these, only a few resulted in any injuries at all.

I'm focusing on unintentional explosions or at least things that had unintended consequences.  There are also many things I've done that *could* have ended badly but didn't...leaving those off for now.  I'll update this list as things evolve and announce updates to Twitter.

Honorable mentions

Intentional or very minor incidents.  I'll save these for separate posts.

Miswired SCR

I had a Trygon power supply from a garage sale:


It got used for various tests as benchtop power supplies tend to.


I need to actuate the SCRs (high power switch) on my 400 V capacitor bank.  This power supply, along with a filter capacitor, provided sufficient current.  The test completed and everything was working fine.

As I cleaned up there was some interest to see a demo.  I then hastily hooked it back up and miswired the power supply to the wrong SCR terminal, putting 400 V into it.  This released profuse magic smoke and severely damaged the power supply.

Damage:
  • Blew up power supply
  • Street cred
 Lessons:
  • Double check wiring, especially on high power systems
  • Do a final dry run before a live demo (ask them to come back)
Circa 2005

Pyrex custard cup

 I've been experimenting with ways to decap metal-epoxy chips like Xilinx Virtex dice.  One way is to heat it to soften the epoxy and allow removing the metal cap:


Ultimately I did this with a hotplate but early tests used a torch.

I used a Pyrex custard cup to hold the die during torching.  These are heat resistant and so figured it would probably be okay.  And it more or less was as I completed the work without incident.

However, some months pass and I re-use the custard cup to insulate some molten solder:


I dropped something in the custard cup and went to gently pick it up with tweezers.  This light touch was sufficient to explosively shatter the dish:


I found pieces a few feet away.  I'm guessing after torching the glass cooled unevenly, putting it under high stress.  The heatgun somehow exacerbated that and pushed it over the edge.

Fortunately the solder beaker didn't tip over.

Damage:
  • Broken custard cup
  • Increased risk: spill molten solder
Takeaways:
  • Equipment history can be important
  • Safety gear did its job
2015-12-19

Mica implosion

Someone gave me a pile of photomultiplier tubes (PMTs) along with some alpha window GM tubes.  Mica is often used in alpha detectors as it passes most alpha particles, is strong, and is vacuum tight.

The PMTs had black covers to protect optical surfaces before use.  Naturally I peeled that off before use.  Similarly, when I picked up the mica window GM tube I attempted to remove the "cover" before use.  Some background...

This is what raw mica looks like:


However, my tube looked like this:


As I tried to remove the "cover" with tweezers it imploded in my face and left this:


Damage:
  • Broken sensor
  • Increased risk: eyes
Takeaways:
  • "Harmless" operations may warrant safety glasses
Circa 2015

Shouldn't be standing here



I occasionally use a cylotron's proton beam to qualify satellite electronics.  One of its many safety features is a (lead?) block that absorbs unused protons.  When workers need to enter the experiment chamber the block recedes into a box that then latches.  There is also a radiation monitor next to the chamber door to verify its safe to enter.


One time I checked the radiation monitor and verified it was safe to enter.  I then slid the several ton chamber door open and headed inside.  However, I was started as the beam stop was still up.  Thoughts going through my head:
  • Is the proton beam armed?
  • Is that block emitting hazardous ionizing radiation?
I immediately exited the area and it shortly thereafter receded into its box.  Fortunately there are many layers of safety (ex: interlocks on the door, radiation monitoring) and I wasn't under any danger.

Damage:
  • Mostly psychological
Takeaways:
  • Always check CCTV before entering
Circa 2014

Rosin decap



One way to decapsulate (open up / "decap") an IC is to use hot abietic acid as found in rosin



I wanted to try this but the hotplate was busy.  So I instead made a makeshift alcohol lamp.



I didn't run this for very long before the test tube cracked (uneven flame?) and the mess caught fire.  Fortunately the fire was small, contained to the metal plate, and easily extinguished.

Every time I tried rosin decap it ended badly. It was eventually abandoned in favor of superior nitric and sulfuric acid decap processes.

Damage:
  • Small fire
  • Broken test tube
  • Increased risk: broken mercury thermometer
  • Increased risk: larger fire
Takeaways:
  • Wait for proper equipment
Circa 2005

400V capacitor bank bringup

I love capacitors and easily have a half ton of them.  Mostly I blow stuff up but I'm starting to branch out into more constructive uses.  Anyway...

350 - 450 V range capacitors are great because you can raid inverters for low ESR/ESL versions.


For example, a Toyota Prius inverter has three such capacitors with beefy terminals.



Even still, I was on a shoestring budget and had to use what came my way.  I started by getting copper sheets from a local metal shop.  I then used tin snips to cut it up but it came out pretty rough.  I thought about carefully filing everything down but decided on a more practical approach: let the shorts blow themselves out.  So for the first bit of operation it would occasionally BANG as the splinters shorted across the high power 400 V rails.  And it seemed to work but I eventually also filed it down.

But this post is about the unplanned bits.  I kept costs low by buying well used capacitors from Jason Rollette.  These were capacitors that were probably okay but he didn't want to risk exploding.  And you don't want soda can sized capacitors exploding.

So I sort of had this coming.  After some operation I heard a large bang even though I hadn't fired the switch.  After an inspection found nothing, I dismissed it as a temporary short from metal shavings.  But it happened again and at that point I had to acknowledge there was a problem.  I inspected everything once more and didn't see any damage.

Without any leads it was time for a full rebuild.  I then got a nasty surprise: as a rail was unbolted one of its capacitors fell apart!



The root failure seems to be that the aluminum plates slid down.  Eventually they slid off the insulator and shorted.

The power bus bars held the failed unit firmly in place.  When the capacitor failed the bus bars gave way enough to vent gas but immediately clamped the capacitor back shut.

Damage:
  • Broken capacitor
  • Increased risk: shrapnel
Takeaways:
  • When you buy sketchy equipment be ready for the consequences
  • Even severe damage can be hard to see
Circa 2006

Hotplate meltdown

I originally decapped most chips with sulfuric acid because its easier to get than nitric acid.  However, if hot sulfuric acid concentration drops too low it can foam up...possibly overflowing quite badly.

I was doing a large batch of chips (SecurIDs maybe?) in a 1 L beaker.  It got too hot, not enough acid, etc, and overflowed.



The mess billowed awful smelling smoke and began eating my hot plate, removing most of the paint.  Fortunately I keep a large amount of baking soda ready and carpet bombed the area.  Despite cleanup, electrical corrosion ultimately required me to replace the hotplate.

Damage:
  • Hotplate, ultimately causing failure
  • Sample put at risk
  • Acid spill
Takeaways:
  • Watch large chemical batches carefully
  • Being ready for a large spill was a good idea
Circa 2012

Careless gunpowder storage

I had made some gunpowder and had some sitting on an outside table.  I was experimenting with fuse design and was burning a fuse 6 feet or so away.  A spark managed to land on the gunpowder pile and ignite it.  While it didn't burn the table, in surprise I jumped back and knocked over an graduated cylinder, breaking it on the concrete below.

Damage:
  • Broken glassware
  • (Larger) fire risk
  • Wasted gunpowder
Takeaways:
  • Store unused explosives better
  • Keep test area clear
Circa 2005

Thermometer handyman



Sometimes alcohol thermometers get bubbles in them which destroys the accuracy.  Unusually the best way to fix this is to cool it so that the alcohol completely recedes to the bottom reservoir.  Then its slowly warmed such that all the air is forced out first before the alcohol fills the column.  Alternatively, you can theoretically force out all the bubbles to the top and slowly cool it in a similar manner.

So I tried cooling it in a -100 C alcohol bath.  Unfortunately that was not cold enough to make it fully recede.

I decided I had nothing to loose at that point an decided to heat it.  I can't recall if I used a torch or a heatgun.  What I do recall though is there was no flame on it when it finally gave way.  The alcohol had been heated sufficiently though that when it glass broke it spontaneously combusted with the air, sending glass shrapnel about.  Once again, due to wearing safety equipment no injuries were sustained.

Damage:
  • Thermometer
Takeaways:
  • Should have explored more options
  • Safety gear did its job
Circa 2010

Red gas

Above: NO2 during RFNA distillation

In AP chemistry, a student asked the teacher if you should breath NO2.  He said he wasn't sure, but, based on the color, doesn't recommend it.  And he's right: it would turn into a mix of nitric and nitrous acid in your lungs if inhaled.  Similarly, like nitric acid, it yellows and dries out skin on contact.

Enough background.  Sulfuric acid with a nitrate group (KNO3 or HNO3) can be used to nitrate cellulose to make nitrocellulose for uh...DIY ping pong balls.  Yeah that's it.  Anyway, the reaction gives off a lot of heat and needs to be cooled to prevent thermal runaway (more heat => faster reaction => more heat).  The heat also causes the nitrate groups to decompose, releasing NO2.

One time this happened and I (for whatever poorly judged reason) decided to plug the bottle with my finger.  Maybe I was hoping the problem would go away if I ignored it?  Of course, I mean with my bare finger as I didn't have the budget for gloves and such.  After a bit I let go and ran away to let things cool off.  The NO2 left an orange circle on my finger that healed up within a few weeks.


Above: minor nitric acid exposure healing (produces similar burns).  Less extreme version of this incident

I also recall seeing a red plume of gas shooting out of my work area.  Wonder if any neighbors saw that?

Damage:
  • Dried out, discolored skin
  • Probably some repository exposure
  • Increased risk: explosion
Takeaways:
  • Wear gloves and respiratory protection
  • Cool exothermic reactions
Circa 2005

Nitric acid storage

Originally I made my own nitric acid and refined a streamlined process for it.  Here's a photo before I added cryocooling:


But its still a lot of work.  For a short period people sold white fuming nitric acid (WFNA) on eBay.  So I bought a bunch from a seller that probably used a similar process (I could see crystalline impurities).

The bottles also had other quality issues like poorly affixed low quality labels.  They taped the lids closed (good practice) but didn't bag anything or even put snug packaging when shipped.  Obviously not labeled as a hazardous shipment either.  While that was an accident waiting to happen, it hadn't caused any trouble.


I had previously stored Red Fuming Nitric Acid (RFNA) in similar bottles and discovered that the NO2 fumes eat through the lids (above).  However WFNA seemed to be fine so I didn't put much thought into it.  Three of the four 125 mL bottles were stored away in my acid storage cabinet (gutted microwave) while one was left out on the counter for general use.

One day I came out to find an exploded bottle.  Shards were scattered across the table along with some acid.  Fortunately, the bottle rested in a large custard cup that was damaged by the explosion but still contained most of the acid.

How did this happen?  The bottle stored outside was heated up by the hot days.  This caused HNO3 to decompose, building up NO2.  Eventually pressure buildup caused the bottle to burst.  Bottles in the cabinet stayed cooler and, while they were pressurized, hadn't reached dangerous levels.  Not knowing if they were ready to explode, opening them was a bit stressful but occurred without incident.

The acid was repackaged into larger half full FEP (plastic) bottles so that it had lots of room for gas release and would hopefully not break as easily.  All acid is now stored in a cool area when not in use.

Damage:
  • Broken glassware
  • Table corrosion
  • Increased risk: fire from uncontrolled acid reactions
Takeaways:
  • Store reactive chemicals properly
Circa 2013

80,000 V death capacitor



Items bear warnings like "may cause injury", "may cause death", etc.  However, this capacitor has no hedging: if you get shocked (when fully charged) you will die.

The capacitor has bleeder resistors to discharge to a safe level IIRC in a few minutes (a compromise between safety and high losses).  After firing I switch off and disconnect the high voltage power supply.  I then short / discharge the capacitor with a conductor on a stick.  Finally, I wrap a wire around the capacitor terminals.

Despite discharge, capacitors can slightly charge back up.  On small capacitors this tends to be negligible but ones this size give an uncomfortable shock.

I was doing a demo at Maker's Faire and had just used the shorting stick.  Rushing to get the next demo ready, I hastily wrapped the shorting wire around the terminals.  Usually I'm careful not to touch the terminals but my hand brushed against them and delivered a nasty shock.  Low power and unharmed, I kept working and proceeded with the demo.

Damage:
  • Temporary discomfort
  • Increased risk: lethal shock
Takeaways:
  • Wear insulating gloves
  • Add automatic/remote short system
Circa 2015

H2SO4 storage

Above: incident area in 2015

I bought some H2SO4 and used most of it immediately.  Unfortunately the original plastic bottle didn't fit in my cabinet.  So I transferred the contents to a couple of small plastic bottles.  Finally, the cabinet was temporarily blocked so I decided to temporarily store them on a shelf next to my bed.


The next morning I discovered acid melted through one of the bottles.  It then etched the shelf, took out some of the nearby wall, and melted a book on the floor.

Oops.

But it could have been much worse: imagine if the bottle splashed towards me sleeping, waking me to a concentrated sulfuric acid bath.


Above: the wall after painting

Damage:
  • Melted shelf a bit
  • Melted wall a bit
  • Destroyed book
  • Lost acid
Takeaways:
  • Don't store strong chemicals in your bedroom
  • Not all plastics are created equal
Circa 2005

    There used to be carpet there

    Of course I didn't just melt the wall.  Fuzzy on the timeline, but above and this occurred at roughly the same time.  I may have given my parents an ulcer or two.


    I had a few hundred mL of acetone and H2SO4 waste stored in a glass peanut butter jar.  At the time I didn't have an outside workspace and wasn't sure how to dispose of it.

    One day as I added more more waste it tipped over, immediately melting my carpet.

    To make it not look quite so bad to my parents, I used scissors to grab bits of carpet from other areas in the room and glued it on.  On the bright side, the very old carpet was finally replaced (with more durable Pergo) and I got an outside workspace.

    Above: after the floor was replaced.  Chemicals were stored in the wood cabinet and spilled in front of the door.

    Damage:
    • Foot wide area of missing carpet
     Takeaways:
    • Don't store powerful solvents in your bedroom
    Circa 2005

    Hot lead and water

    If you've ever cast bullets you've probably been warned about this.

    Above: gamma spectroscopy lead ingot castle

    Its best to take a gamma spectrum without background radiation.  One easy way to do this is to stack lead bricks around the detector and sample.  Crude ingots work okay but don't seal well, slightly degrading the signal.


    So I CNC'd some lead brick molds and successfully poured some bricks.  However, to accelerate cooling I would dunk molds in water.  I would dry out the molds before re-pouring such as the mold being preheated above.  This is important as any water trapped in hot lead gets superheated and causes a molten lead explosion.

    Scrap lead is recycled back to the pot.  One of the pieces evidently got splashed, trapping lots of water.  When it was thrown into the 20 lb lead pot, a large explosion sent most of the molten lead flying.  Some of it fused into plastic boxes a few feet away as well as onto my protective gear.  Had I not been wearing a full faceplate respirator I would have been blinded.

    Damage:
    • Minor equipment damage
    • Big mess
    • Increased risk: blindness, burns
    Takeaways:
    • Only throw dry lead into the pot
    • Safety gear did its job
    Circa 2014

    Burning man

    The only time I thoroughly caught myself on fire.

    There's a fun party trick where you cover your hand in a volatile flammable substance (ie alcohol) and light it.  Until the flame burns down it won't burn you.  I've intentionally lit my hand on fire this way without incident.

     Source

    And now things escalate.  I was scavenging with some college chums and we found a bottle of pure medical grade ethanol.  Most college students would probably drink it, but we just put it on the shelf.

    One day I was bored and came up with a "good" idea.  You see, I always wanted to make a Molotov cocktail and this seemed like the perfect opportunity.  Indoors of course; doing this outside would attract too much attention.  I grabbed a chemistry flask and partially filled it with alcohol.  Next I stuffed paper towels in as a pilot light.  Finally I lit it and immediately things went very wrong.

    Turns out that ethanol burns really well.  Well enough, for example, that its used as racecar fuel.  When I lit the towel the ethanol in the flask exploded, covering my left arm and left leg with flaming alcohol.  Surprised, I dropped the flask on the floor, lighting it on fire.

    I realized I wasn't in any immediate danger, remembering my previous hand lighting trick.  I quickly patted myself out and stomped out the floor.  Other than a few singed hairs on my arm, neither myself, my clothes, nor the floor received any damage.

    Damage:
    • Increased (larger) fire risk
    • Risk of burns
    Takeaways:
    • If you are going to do something stupid, film it
    • Think twice before "stop, drop, and roll" as the floor may be on fire
    • Party tricks are a survival skill
    Circa 2009

    Sulfuric acid burn

    As I washed out sulfuric acid coated beakers a drop fell onto my hand.  I immediately washed it off with the hose which, in foresight, may have actually been a bad idea.  The water momentarily superheated the acid and may have actually made it worse.  I would have been better off quickly wiping it off and then rinsing with water.

    The acid left a large burn where the drop hit as well as a small streak of skin where the drop rolled off my hand.

    Damage:
    • Small burn giving scar
    Takeaways:
    • Wear gloves
    • "Empty" glassware poses risks just like full glassware
    • Spray beakers with water before handling
    Circa 2005

    Soldering iron burn

    I'm no stranger to soldering iron burns but there is one incident that stands out. 


    When most people think about soldering irons, they think of something like my WES51.  But that's not the type of soldering iron I'm talking about.



    My dad has a high power pipe soldering iron.  IIRC I was soldering air ducts for my Tesla coil.  At some point my left hand accidentally touched the base, turning the skin to ash (third degree burn).  I still have a small scar.

    Damage:
    • Small third degree burn giving scar
    Takeaways:
    • Mind the whole tool, not just the tip
    • Use gloves
    Circa 2002

    Shell shocked

    The only time I've been paralyzed by an explosion.


    Hydrogen gas is fun to play with and is easy to get by using electrolysis to split water.  To that end, I took a plastic grape juice bottle and drilled holes in the lid for carbon electrodes.  I also fitted an electric solenoid to release gas.


    The machine was setup on the side of the house, a semi-enclosed area.  Usually my brother is smart enough to stay away when I do stuff like this but decided to tag along today.

    I actuated the solenoid and lit the output gas to get a satisfying flame jet.  For some reason I decided to change the nozzle.  However, it no longer worked smoothly: the hydrogen was stuttering and extinguishing.  I tried this a few times and then got a nasty surprise.

    Of course, it wasn't just hydrogen in the tank but a perfect mix of hydrogen and oxygen.  By chance, the first nozzle kept pressure such that the flame couldn't flash back into the tank.  However, the second nozzle didn't and the flame flashed into the bottle next to us, exploding in the semi-enclosed area.

    The blast numbed me and all the dogs in the neighborhood were barking.  A few seconds later my mom, who was in the kitchen not too far away, went to the window and asked if that was a hydrogen balloon popping.  She knew I was playing with hydrogen and earlier I mentioned hydrogen balloons pop louder than other gases.  My mind barely working, I muttered out a "yes" and she left and went back to the kitchen.

    Slightly wet and possibly some hearing lost, we were otherwise unharmed.

    Damage:
    • Hearing damage?
    • Increased risk: shrapnel
    • Increased risk: fire
    Takeaways:
    • Lighting a tank of mixed hydrogen and oxygen is a bad idea
    • Think carefully when things aren't working
    • Light remotely
    • Work in an open, flame resistant area
    Circa 2005

    Hydrofluoric acid burn


    Yes that's right, this isn't number 1.  Stay tuned for more fun.  In part its because I'm actually not entirely sure that this was an HF burn, but its my best guess as to what happened.


    I use HF to delayer integrated circuits for photos like this.  Don't be fooled by Breaking Bad: concentrated HF is extremely toxic.  Any skin contact and/or inhaled fumes can have dire consequences.


    Fortunately, I didn't start using HF until later in my chemistry "career" such that I had developed a lot more safety sense and funding to purchase safety supplies.  For example, when handling 48% HF I wear a full hazmat suite and keep calcium gluconate around.

    I believe for the incident in question I was using 12% HF.  A few days after the work I had a sore area on my right shin.  This wasn't so unexpected though because a bicycle chain had rubbed against there and tore up my leg a little.  Didn't think much of it at the time.

    However, weeks passed and it didn't entirely heal up.  One area was slow to heal and two areas didn't heal.  For months it would slowly heal but the skin was unusually weak and could basically just be rubbed off.

    I don't recall exactly at what point but at some time I suspected it could be (minor necrosis?) from an HF burn and rubbed some calcium gluconate on it.  I'm unclear if this helped but it did eventually heal.

    My theory: some dilute HF spilled (during cleanup?) and fell on the ground.  This splashed upwards past my socks and under my pants to land high on my shin.  Maybe usually this would not have caused a burn but my exposed wounds made me more vulnerable.

    Damage:
    • Minor skin damage
    • Long term health concerns
    Takeaways:
    • Use extreme caution when handling dangerous chemicals
    • While face and hand protection is important, don't skimp on other areas of the body that you might think are low risk
    Circa 2013

    Chlorine gas explosion


    I wanted some hydrochloric acid to play with for chemistry experiments but the local hardware store wouldn't sell me any (muriatic acid) because I was under age.  So I thought, what alternative sources could I find?

    I went to the local dollar store and scoured cheap cleaner ingredients lists.  After some rummaging I found some toilet bowl cleaner that was basically colored HCl.  I brought it home and it seemed to work: I could dissolve zinc and what not to my hearts content.  But it wasn't very pure or strong...what could I do to improve that?

    Next I bought some table salt (NaCl) and added it to the toilet bowl cleaner.  This forced HCl gas out which I then bubbled through some water to get a small quantity of pure, concentrated hydrochloric acid.

    But hmm...its going to be slow and expensive to make any real quantity.  How could I scale up?


    While the hardware store wouldn't sell me muriatic acid, they sold me Bull Dozer brand drain cleaner (98% H2SO4) along with solid calcium hypochlorite (pool bleach).  And, yes, this is the same bottle that melted the wall and carpet.  Anyway, these two chemicals can be mixed to produce copious amounts of chlorine gas (a highly corrosive war agent).  Similarly, copious amounts of hydrogen can be produced by reacting aluminum metal with lye solution.


    These reactions took place in two side arm flasks.  Hoses coupled evolved gases into a tee junction that fed the produced hydrogen chloride into a third flask to bubble it through water to produce hydrochloric acid.

    So an explosive gas and a WW I war gas...what could go wrong?

    I started each reaction and the system only ran for a few seconds before the heat in the T junction caused it to spontaneously combust.  This means the hydrogen reached 536 °C / 997 °F.

    Now one flask is spewing poison gas and the other has a one foot flame jet.  Once again, safety equipment was too expensive so no respirator/gloves but I may have had goggles.

    I uncapped the hydrogen flask which flashed and went out.  I then diluted the chlorine flask to slow down the reaction.  With both flasks under control I exited the area.

    While I wasn't there for very long that short exposure gave me minor difficulty breathing for about a week and a wheeze for about 6 months.  This makes it the only accident that gave me significant injury.  Fortunately today I seem to be fully recovered.

    Damage:
    • Minor difficulty breathing for 1 week
    • Wheeze for 6 months
    Takeaways:
    • Use safety gear (respirators, gloves, etc)
    • You should just let kids buy chemicals...its for their own good
    Circa 2004

    That's all folks

    Hope you enjoyed.  If you want more experimental madness check out Derek Lowe's excellent "Things I Won't Work With".

    Wednesday, September 9, 2015

    Gamma Spectacular first experiences write-up

    Link

    See top of page for a general discussion about issues I had getting started

    Saturday, August 29, 2015

    the twitters

    In an effort to provide more timely updates, I'm experimenting with a twitter account

    Fun fact: a spammer created my account a while back which, although I never formally activated it (ie never clicked on the activation e-mail send to me), somehow got it suspended.  Had to jump through some hoops to actually activate it and change the password

    Thursday, August 6, 2015

    github restructure

    In summary:
    • pr0nscope has been moved from pr0ntools into uvscada.  This eases code collaboration on more advanced projects like xy-ray
    • All files from uvscopetek repository have been moved to uvscada
    Also note that pr0nscope has had major code cleanup recently as part of the effort to switch to linuxcnc.

    Enjoy!

    xy-ray x-ray scanner

    In some previous posts I talked about getting an x-ray head working, reverse engineering an x-ray sensor, and working with LinuxCNC.  In this post I put them all together so that I can take a bunch of x-ray snapshots across an entire PCB.  This allows me to more quickly reverse engineer PCBs.




    Problem: with my previous work I can take a PCB x-ray at fairly high resolution (see bond wires like above) but the field of view is pretty small.  The above x-ray doesn't even cover an entire PDIP-40.  How can I see the entire PCB?

    Linear stage

    Linear stages are great for this sort of project.  As I'm moving on the order of inches they don't necessarily need to be high precision.  I looked around eBay and a few other places and settled on some stages as HSC.  I can't find a picture of the original setup, but something like this:



    These had several desirable properties:
    • Around the right scan area I'm looking for
    • Reasonably sturdy to support PCB weight
    • Motors with integrated drivers (MDrive 17Plus).  As a plus they are 3.3V compatible
    Not pictured is a Z cam motor that I didn't need for the x-ray setup.  However, this motor was perfect for running early integration tests.   My specific motor model is not listed on the manufacturer's website but seems to be pin compatible with their step/direction models.  As its 3.3V compatible I'm able to directly wire the control signals to a BBB running LinuxCNC.

    Next I made the PCB holder.  The Z axis motor mount makes a convenient anchor point to attach accessories.  To actually hold the PCBs I decided to use a PanaVice PCB holder left over from a previous project.  This is a great fit as it nearly wedges into the motor mount and is made out of aluminum which is mostly transparent to x-rays (minimal image impact).  With a little sanding I was able to sandwich it into the motor mount:


    And drill some holes to make it secure:



    Which then integrates onto the stages:


    Mounting the head

    Next I need to mount the x-ray head.  Its heavy so this could be a bit challenging.  I was originally thinking of making a t-slot gantry so that it would clear the stages nicely.  It would be a plus if I could adjust the height up and down but not strictly necessary.

    Thinking about the z axis, I recalled I had a spare heavy duty z stage.  And guess what?  The x-ray head fits onto it perfectly!


    Integrating into the system:


    In this configuration the stages can't travel their full range but given the low effort this is a great starting point.  You can also see the sensor in position.

    Software

    The software development is mostly covered in my previous post.  Here is an early integration test with the pr0nscope GUI I use to control my microscopes:



    AXIS would have worked fine but because I was focusing on rsh it was a bit of a pain to switch back and forth.  It may be possible to launch AXIS along side linuxcncrsh but I haven't looked into it.

    Notice the slopping wiring going everywhere.  Lets see what we can do about that...

    Control system

    Onto the control system.  In the above picture you can see an aluminum plate to the left of the stage.  This held the original indexer board that I decided not to use in favor of standardizing on LinuxCNC.  I drilled some holes for standoffs (not super great but sufficient):


    And started mounting electronics:



    A few boards are on standoffs but I'm DIN rail mounting what I can.

    I started routing cables and found that the Y power cable doesn't reach.  After splicing it to extend it:


    And then heat shrinking it to prevent it from snagging and hiding the splice:




    Going back to the electronics panel, you'll notice the e-stop button to the right.  In production:



    Unfortunately I don't have any drills large enough for the button.  My step drill got pretty close but not there.  I thought about putting it on my milling machine / rotary table but decided that since I only needed to shave off a little that probably wasn't the most expedient (notice I didn't say best) option.

    Instead we come to "Mr. Safety" on the left.  Although I didn't use a milling machine, I did put an endmill into my rotary tool and mill out the center a bit by hand.  This is a terrible idea and you really shouldn't do this for numerous reasons but it did get the job done.

    Following that I finished the button with a coat of Dykem Blue.  It already had some on there from marking holes and I decided it was going to be less work to coat it blue than to remove the layout fluid.

    Filling out the control system:



    I DIN rail mounted the BBB onto a Phoenix Contact PCB mount by screwing the case into the PCB mount

    There are two power rails:
    • 24V for stepper drivers.  It was supposed to be supplied by the DIN rail supply but I am missing a Combicon adapter.  For now an external power supply runs it
    • 5V from the BBB sets a control line in the stepper motors

    Like previous systems, a laptop orchestrates the whole thing.   At the core is my pr0ncnc which underwent a major, long overdue code cleanup for this project.

    Also like previous setups, the x-ray is powered by two Variacs switched through a DLI WPS-7.

    Putting it all together

    Viola:



    For my first scan I grabbed a scrap HDD PCB in arms length:


    And you can find the output files here (TODO: stitch, mapify).  A few sample images:




    Safety

    This system was a bit harder to shield due to the larger volume.  However, running the system at 60 kV seems to produce negligible radiation leakage even without shielding and gives pretty good copper resolution.  Still, I have lead shielding around the system as an added safety and in case I want to operate at higher voltages.

    Industrial units

    For comparison, here's an XD7500NT industrial x-ray scanner:





    Unlike my system, these allow real time imaging, HDR, and some other cool features.   Still, I'm sure my garage system costs a fraction of what these beasts go for and is considerably more compact.

    Summary

    The hardware came together pretty quickly and was mostly built over last weekend.  Figuring out how to configure and control the BBB took longer but is a good investment.  The integrated MDrive 17Plus stepper drivers make the system quite compact over my previous control systems.

    There are a number of things I can do to improve scan quality but should be good enough for most projects.  The system will get used in the near future for PCB reverse engineering projects.

    Got something cool you want scanned?  Drop me a line!

    EDIT: looks like you can get small x-ray units at industrial auction for 1k.  Still, this was well under that and was a fun project

    LinuxCNC/Machinekit, BBB, and Python

    Background

    My original computer controlled microscope ran LinuxCNC on an old laptop:


    You can see AXIS running on the laptop to the left along with a scan pattern.

    Unfortunately, it was difficult to make this system compact and reliable.  Laptops aren't really that great to run real time software because ACPI gets in the way.  Desktops can work but they are bulky and still need to be somewhat carefully selected.  My Sherline mill compromises by using a mini ATX motherboard connected to a laptop.  That way the laptop does all the display, keyboard, and mouse in a compact form factor while running all the real time tasks on a purpose built PC.

    But this was still too big and costly to generally deploy.  Instead, I made "pr0ndexer" which runs on inexpensive STM32 dev boards.  The firmware was written in an afternoon and seemed to work well to get the job done.

    Or did it?

    After a while one of my motors started to slip.  Evidently lack of acceleration was wearing out gears in the linear stage.

    Oops.

    So I patched up the software with some crude acceleration and production continued to hum along.  But still it was still pretty crusty:
    • Pulses are generated with sleep statements instead of timer ISRs.  Receiving serial characters (or other tasks) messes up the timing
    • Only one axis can be moved at a time

    Towards the BBB

    While this was happening it was brought to my attention that LinuxCNC had been ported to run on Beagle Bone Black (BBB) by the Machinekit.  At this point though things were working well enough that I decided not to pursue that.

    Fast forward to 2015.  I'm building more robots and need to decide what the next control system will look like.  I decided to revisit Machinekit/BBB which I'm just going to loosely call BBB.

    For most of these systems I'm moving some number of stages and doing some sort of image capture.  There are two ways the system could be used:
    • Run LinuxCNC on the BBB and also do image capture (ie through the USB port)
    • Use BBB as a remote control drone and run image capture on a laptop
    For a variety of small reasons  I decided to continue controlling the setup on laptops and use BBB's as control drones.

    linuxcncrsh/emcrsh API

    When you start LinuxCNC there are a variety of frontends you can use to interact with it with AXIS probably being the most common.  One alternative is the rsh frontend which launches a sort of telnet command server instead of a GUI.  The developers make no claim that its a robust interface but note that it may be good enough for quick and dirty projects.

    Seeming to be the easiest way to use in a drone fashion, I started with this.  I ran into a few snags though:
    • Axis homing takes a long time.  My theory is that this has something to do with the way that poll() works (see later) but I'm not really sure
    • No position feedback: a command is either running or completed
    Still, I was able to control things and get running pretty quickly using pyexpect.  Here is my python interface to it.

    Python API

    Unfortunately while I could get a quick PoC, rsh didn't seem to give enough control for what I wanted to do.  So next I tried the python API which is considerably more powerful.

    Although this API is much more complex, it is well documented and I was able to get it working reasonably quickly.  The API is much richer and allowed me to do everything I wanted to (ex: getting position feedback). For example, the Python API is aware of fine points like the target position vs the actual position from servo feedback.

    Remote python API

    Unfortunately above only works locally (at least as far as I can tell).  To use the BBB from a remote system I decided to use XML-RPC since I've used it before and its pretty easy to use.  I instantiate a linuxcnc object that looks just like the linuxcnc module.  This allows programs written against the normal Python module to nearly seamlessly my remote version.

    To make it run smoothly I do the following:
    • Copy LinuxCNC .ini file to BBB (SFTP)
    • Launch LinuxCNC on BBB using .ini file (SSH)
    • Copy XML-RPC server to BBB (SFTP)
    • Launch XML-RPC server on BBB (SSH)
    • Create SSH tunnel from BBB to localhost
    • Connect to BBB using XML-RPC client
    I'm using the paramiko API to copy files over and launch remove processes.  Although I'm not using rsh, its still convenient as I can wait for the rsh port to open to know that linuxcnc is ready.  There might be better ways but this was easy and seems to work.

    The core linuxcnc remote interface client and server are here.  The wrapper to remotely deploy it can be found here.   Here's an example program using the wrapper.

    Polishing

    I'm using the  CRAMPS configuration as a base.  This unfortunately has a lot of stuff I don't need and causes it to take a long time to start up.  I've started stripping down the config but there's still a lot to strip out (ex: thermal management).

    I'd also like linuxcnc to launch automatically at start up which probably isn't too hard.  I'd also like my config files to get versioned which may just mean I check out the uvscada git repo to the BBB.  This eliminates most of the above steps.

    XML-RPC has a lot of overhead: it creates a connection for every function call and XML isn't terribly efficient.  Fortunately I'm not doing anything super performant so this is probably okay.

    Applications

    I have several new imaging systems coming online.  This project was primary driven by my x-ray scanner:


    which I'll do a post on in the near future.  I'm also planning on deploying this to existing systems like pr0nscope and k2scope.

    Summary

    The Beagle Bone Black is a very compact platform to run LinuxCNC from.  The rsh API is good for very simple remote control applications but you should use the Python API (or C API) if you need better control.  I've provided some wrappers to use the API remotely almost as easily as the local API.

    For the amount of work put into this it came out pretty good.  There's still a lot of room for improvement but its mostly better than my pr0ndexer board.  The main disadvantage so far is that the BBB takes several minutes to start up where my board was ready in under a second.  For most of my applications this isn't a big deal.  That said, I'm eventually going to look into ways to cut down startup time.