Archive for the ‘Uncategorized’ Category.

Serving server generated PNGs over HTTP in golang

Building on the PNG generation code. We can easily expand this to serve the content over HTTP.

The following example will serve content from the filesystem for everything but “/images”. This path will generate and send a random 100×100 PNG to the client.

package main

import (
    "github.com/daaku/go.httpgzip"
    "net/http"
    "image"
    "image/png"
    "image/color"
    "math/rand"
)

func handler(w http.ResponseWriter, r *http.Request) {
  myimage := image.NewRGBA(image.Rectangle{image.Point{0,0},image.Point{100,100}})

  // This loop just fills the image with random data
  for x := 0; x < 100; x++ {
    for y := 0; y < 100; y++ {
      c := color.RGBA{uint8(rand.Intn(255)),uint8(rand.Intn(255)),uint8(rand.Intn(255)),255}
      myimage.Set(x,y,c)
    }
  }

  png.Encode(w, myimage)
}

func main() {
  http.HandleFunc("/images", handler)  
  http.Handle("/", httpgzip.NewHandler(http.FileServer(http.Dir("."))))

  http.ListenAndServe(":8080", nil)
}

Creating a PNG image in golang

The following very simple example creates a PNG image file in golang. It first creates a Image structure and then populates this with random data.

A file is then creating using os.Create, this is used as a io.Writer to which golang’s PNG encoder in image/png writes the encoded PNG data via the png.Encode function.

package main

import (
    "image"
    "image/png"
    "image/color"
    "os"
    "math/rand"
)


func main() {

  myimage := image.NewRGBA(image.Rectangle{image.Point{0,0},image.Point{100,100}})

  // This loop just fills the image with random data
  for x := 0; x < 100; x++ {
    for y := 0; y < 100; y++ {
      c := color.RGBA{uint8(rand.Intn(255)),uint8(rand.Intn(255)),uint8(rand.Intn(255)),255}
      myimage.Set(x,y,c)
    }
  }

  myfile, _ := os.Create("test.png")

  png.Encode(myfile, myimage)
}

A short review of linear motion

This is a very short review of linear motion actuators and guides. This is I’m sure, far from complete. My hope is that people will comment and help fill out the information here.

In this post I want to address linear motion in terms of resolution, for nanoscale to millimeter scale and beyond (I know almost nothing beyond millimeter scale but would welcome contributions).

Nanoscale

I wont cover MEMS devices here, I’m rather interested in nanoscale resolution over millimeter travel. I have a short review of various piezo actuator types elsewhere.

Piezo actuators

Nanoscale resolution actuators are dominated by Piezos. Piezo electric materials directly convert electricity into motion and easily handle these kinds of tasks. In addition to this they provide high force.

Basic stacked actuators

These devices use multiple layers of Piezo electric material connected in parallel in a stack. They provide deflection in the micron range, in general 10s to 100s of microns.

They may be combined with a mechanical advantage to increase output force.

Inchworm actuators

Inchworms use piezo stacks to push a rod along. In this way they retain their nanoscale resolution, but vastly extend the travel of the system. Inchworms with 25mm travel and beyond are available and can be purchased for a few hundred dollars.

LEGS actuators

I strongly recommend you check out the video linked above, it’s awesome. LEGS (R) is a trademark of Piezomotor (R) I believe. They use a slightly different mechanism to the normal Inchworm, using bimorphic benders to walk along a shaft. Similarly with microstepping they can achieve nanometer resolution, and millimeters of travel.

legs

Magnetostrictive actuators

Magnetostrictive actuators have recently begun viable for nanoscale linear motion. These actuators use magnetostrictive materials (notably Terfenol-D) which when exposed to a magnetic field, change shape.

magnetstrictive

While nanometer precision can be achieved, magnetostrictive actuators exhibit hysteresis and non-linearity. While this issues are also present in stacked Piezo actuators they are mitigated against in Inchworm and LEGs actuators.

Electrostatic actuators

A far am I’m aware these have never been used commercially, but have been proposed as academic research tools.

Micron scale

Nanoscale actuators are dominated by DC driven Piezos largely because of their inherent precision and low vibration characteristics. Once we reach the micron scale things get much easier as we can begin to use motors again. A typical low force application at this scale would be a motorized microscope stage.

Vibration characteristics are again a concern here, and will need to be considered carefully.

Coreless DC motors

AMH-13

Coreless DC motors, coupled with a leadscrew are often employed for micron scale actuation. Unlike normal motors coreless motors have no Iron core to confirm the magnetic field. This lack of a core allows the magnetic field to be built up and broken down much more quickly resulting in faster and more precise acceleration. Chuo Seiki sell these with gearing and a leadscrew in a micrometer style configuration, and they often appear to be used as “motorised micrometers”.

I have a used Chuo Seiki actuator on order and will update here when it appears.

Steppers

Stepper motors are also employed for micron scale resolution actuation. In particular 5-phase steppers are favored here. oriental motors have a great write-up on why 5-phase motors are better, but overall it comes down to their reduced vibration:

vibration_steppers

They should of course also be operated in microstepping mode. Oriental motors appear to supply the majority of 5-phase steppers for micron resolution actuation. Again this are commonly employed for use as XYZ microscope stages or semiconductor fab applications. When coupled with a leadscrew and rail guides, micron resolution can be achieved. An example is again the Chuo Seiki stage. I have again purchased one of these second hand and will be updating with my experiences here.

Micron resolution can also be achieved here with 2-phase steppers, as can be seen in commodity electronics such as DVD players where the track spacing is on the order of 1micron. However the accuracy is likely low.

Millimeter scale and beyond

Steppers

At the millimeter scale (~100micron) things appear to be much easier and commodity 2-phase steppers coupled with a linear guide and lead screw are generally employed. Of course in commodity electrics belt driven systems as also used.

Servos

Servos have a number of advantages, in particular for CNC applications. Servos are able to operate at higher speeds. Because of their inherent feedback there is little potential for “missed steps”. And as servos do not operate a step at a time, their vibrational characteristics are different (and generally better) than those of steppers.

Vacuum pump types

Vacuum pumps come in a number of different configurations. There are three factors that determine the type of pump you want for a given project:

  • Required pressure
  • Cost
  • Potential for contamination

The first criteria breaks pumps down into two basic categories. Low vacuum and High vacuum.

Low vacuum – Roughing pumps

Low (also called rough) vacuum is defined as being between 760 and 25 Torr. 760 Torr is normal atmospheric pressure so low vacuum is up to 30times less pressure than normal atmosphere.

Roughing pump are pumps which deal with pressures in this range. In general these pumps can go down this far but no further. Conversely, higher vacuum pumps don’t function at such high vacuum levels. This means that in general when creating a high vacuum you first need a roughing pump to generate a low vacuum, and then can move onto a second pump which takes you from this moderate vacuum level up to a high vacuum.

It’s worth noting that the same is true for measurement tools. Some gauges operate at low vacuum only, while other operate at high vacuum only.

There are many types of roughing pump, but you’ll generally only need to know about two of them. Oil-seal pumps and dry pumps.

Oil-sealed roughing pumps

These are the most common and cheapest roughing pumps, they are suitable for a number of applications. Oiled-seal pumps are in general rotary pumps, they mechanically “squeeze” the air increasing it’s pressure and pushing it out of the pump. For this reason they also also called “compressors”. The following gif describes their operation:

rotary

Rotary pumps use oil to maintain good seals, however this makes them susceptible to “blow flow” or “back streaming”. This is when the oil gets sucked out of the pump and into the vacuum chamber, contaminating it.

Rotary pumps can be designed with multiple stages, this enables them to reach higher vacuums. Single stage pumps generally achieve ~0.1Torr, two stage pump can in some cases reach as low as 0.0007Torr.

Dry roughing pumps

Dry roughing pumps were designed to mitigate against the possibility of oil back flow. There are various kinds including rotary based designs (rotary lobe pumps). However Diaphragm pumps appear to be the most common type. As the name implies they use a diaphragm to compress the air, rather than a rotary action:

diaphrampump

For most applications (including things like SEMs, sputtering machines) a dry pump is not required.

High vacuum pumps

If you want to generate a high vacuum, once your vacuum chamber has been roughed down using the roughing (or backing) you will start a high vacuum pump. These pumps are able to generate a higher vacuum than a roughing pump, but only will only work when the pressure in the chamber has already been reduced by a roughing pump.

Turbo Molecular pumps

The most common type of high vacuum pump is the turbo molecular pump. There operation is fundamentally quite simple, and they work on the atomic level knocking individual atoms out of the vacuum chamber. Kind of like a pinball machine:

turbomolecular

Turbo molecular pumps operate at high speeds, and in general require dedicating controllers.

Other high vacuum pump types

While turbo molecular pumps are the most common various other high vacuum pump types exist. These include Diffusion pumps (which use jets of oil to carry molecules away), Cryo pumps (which condense and sequester the molecules), and Ion pumps (which apply a charge to stray atom and use this charge to move the atom out of the chamber .