True's beaked whale.jpg

Western spotted skunk

Hooded skunk

Yellow-throated Marten

Wolverine

Putting video clips on my blog

November 19th, 2009

Putting video clips on my blog was a bit harder than I expected. I first tried converting the .MOV files the camera writes into .avi files using ffmegX and posting them using <embed> tag code. The files showed up great on my Mac but not at all on a Windows computer.

Flash format files, .flv, are the easiest cross-platform way to post video clips. Flash does require that the site supply a Flash player. There are many Flash players available. I tried OS FLV and it worked nicely.

To edit video files I used avidemux, then ffmegX to convert them to .flv, and I put them on the site using the ‘noscript’ <embed> code suggested by OS FLV with the OS FLV player.swf.

PIC servo control

November 19th, 2009

Second PIC program, this one moves a hobby servo motor to one of two positions. The switch needs to be pulled up with a resistor.

It has one light that is always on and a second that switches on/off when the servo moves.

PIC12F683 servo motor movie:

Here are the code files: p12_servo1.asm and p12_servo1.hex.

Assembly of the .asm to a .hex:
>gpasm p12_servo1.asm

Write it to the PIC12 using:
wine “C:\Program Files\PICPgm\WinPICPgm.exe”

It is wired as shown in the video.

The servo timing is off from what I calculated. A calculated 1ms to 2ms gave about 60 degrees of movement, what’s shown is 0.75 to 1.25 ms pulses every 20 ms. I haven’t measured the pulse lengths with a scope.

PIC first light!

November 17th, 2009

Got my first PIC microprocessor program running on a PIC12F683.

It has one light that is always on and a second that switches on/off.

PIC12F683 LED lighting movie:

The assembler code:

----------------------------------------------------------------------------
;************************************
;written by: Jim Lund
;date: 11-09
;version: 1.00
;for PIC: PIC12F683
;Memory: 2048=800h, RAM 128, EEPROM 256
;clock frequency:
;************************************
; PROGRAM FUNCTION: Light one LED
;
;************************************

        list      P = PIC12F683

        include  /usr/local/share/gputils/header/p12f683.inc

        __config _MCLRE_OFF & _INTRC_OSC_NOCLKOUT & _CP_OFF & _WDT_OFF

        errorlevel -302

;------------------------
;Declarations:
        org     0x000
        goto    Start

;-----------------------
;Subroutines:

Init

        clrf    STATUS;
        clrf    GPIO ; resets input/output ports

        bsf     STATUS,RP0 ;Bank 1
        ;movlw  b'00000000'
        ;movwf  OSCTUNE

        bcf     STATUS,RP0 ;Bank 0
        movlw   b'00000111'     ;comparator off
        movwf   CMCON0  ;digital IO
        bsf     STATUS,RP0 ;Bank 1
        clrf    ANSEL   ; digital IO

        movlw   b'001111'      ; sets up which GPIO pins are inputs and which
        movwf   TRISIO          ; are outputs

        movlw   b'00000111'      ; option bits
        movwf   OPTION_REG
        bcf     STATUS,RP0 ;Bank 0
        retlw   0
;-------------------------
;Program Start:
Start
        call   Init
Main
        bsf     GPIO, 4  ; turns on LED

        btfss   GPIO, 0 ;test pin 7, next if pin is 0
        goto LEDoff
        bsf     GPIO, 5 ; turns on LED
        goto Main

LEDoff  bcf     GPIO, 5 ; turns off LED
        goto Main

        END
----------------------------------------------------------------------------

Assembly of the .asm to a .hex:
>gpasm p12_led.asm

Write it to the PIC12 using:
wine “C:\Program Files\PICPgm\WinPICPgm.exe”

and wire it up as shown in the video!

Hobby molecular biology

November 16th, 2009

What would be required to set up an inexpensive system for hobbyists to experiment with biology? Consider PCR for example. PCR requires heat stable polymerase, primers, nucleotides, buffer.

The DNA polymerase is easy to purify from E. coli carrying the plasmid. Grow bacteria containing plasmid expressing Taq DNA polymerase, boil, spin down denatured proteins, and you are left with the DNA polymerase.

Primers can be bought inexpensively–$0.35 per base, a pair of 18-mers cost less than the shipping. Though they are inexpensive only if one set gets used repeatedly.

The cost of buffer (NaCl, MgCl2, Tris) is negligible.

Nucleotides are expensive up front, $150 for a set of dNTPs (dATP, dCTP, dGTP, dTTP), but this works out to about $0.06 per 50 ul PCR reaction.

Can nucleotides be prepared by a hobbyist? Nucleotides are easy to obtain-DNA is a major constituent of cells and is easy to purify. DNA + DNAase = dAMP, dCMP, dGMP, and dTMP. How can the trinucleotides be regenerated?

One route is to do it enzymatically using
polyphosphate:AMP phosphotransferase (PPT) and adenylate kinase (AdK) with polyphosphate (polyP) as the energy source (Resnick and Zehnder, 2000). It is not clear how the trinucleotide product would be separated and purified. Presumably different enzyme pairs could be used to regenerate the other dNTPs from the monophosphates.

These other enzymes could be cloned in E. coli expression vectors and purified either by tagging them with His6 and using a Ni or Co resin. Or by cloning heat-stable isoforms from one of the extremophiles and using a one-step boiling purification like that used for Taq polymerase.

Update: Bochkov et al., 2006 describe a method of preparing dNTPs from digested DNA. DNA is digested with DNAase and Nuclease S1. DNAase chews DNA into show oligonucleotides and the nuclease breaks them down to single dNMPs.

Then a crude extract of E. coli is prepared that contains the kinases to convert dNMPs to dNTPs along with the acetokinase. The kinases use ATP. ATP must be regenerated, and this is done using acetokinase with acetyl phosphate ($30/g) as an energy source. Combined dNMPs were converted to dNTPs with at least 86% regeneration and separated from reactants by chromatography on a Dowex 1×2 anion exchanger. The conversion was followed by thin-layer chromatography.

For PCR it may be possible to use a crude purification of nucleotides, but purification protocols would need to be developed and tested.

Water on the moon!

November 16th, 2009

Last October, NASA’s LCROSS mission slammed a spent rocket booster then the LCROSS spacecraft itself into the moon. No debris plume was seen from Earth, but observations from LCROSS of the booster hitting indicate the presence of water on the moon. How much water? Most news accounts don’t say, but the Science magazine article does.

100 kilograms of water was detected from an impact that created a crater estimated to be 20 m wide and 3 meters deep. So 100 kg water in about 500 m3 of regolith = 0.1 g/kg. (Googled a reference giving 2.3 to 2.6 g/cm3 as lunar regolith density).

The article gives a higher estimate for water, 0.1% to 10%, higher than my crude 0.01% estimate. Which is great–enough water to extract easily and live off. Best news for space exploration in thirty years!

LCROSS impact plume
(Credit: NASA)

Evolution of the glucocorticoid receptor

October 21st, 2009

Interesting letter about the evolution of the glucocorticoid receptor from Joe Thornton, a biologist at the University of Oregon. Thornton’s lab has figured out some of the details on how this receptor evolved. Thornton’s writing this because creationist Behe is passing off a mangled version of his work as evidence for ‘intelligent design’.

The first Discover magazine blog post gives a good overview of what Thornton’s lab learned about the glucocorticoid receptor.

GR receptor pathway

Stepper motor controller

October 18th, 2009

Stepper motors are easier to control than servos, but they typically produce lower power. A number of people have built stepper motor run CNC projects, so for small or mid-size CNC control they work.

I have three bipolar stepper motors, but seven 6-wire unipolar steppers plus other unipolar steppers with other wire counts so it makes sense to design a unipolar stepper controller.

A unipolar stepper has three coils all of which get driven in the same direction by PWM signals amplified and isolated by a driver circuit. Because the drive current is always in the same direction an H-bridge is not required, rather a simpler driver can be used.

The simplest way to drive the stepper is to activate each coil in turn slowly enough that the motor has time to move a step before the next step is given. A smoother and more power efficient method called microstepping uses PWM to transition gradually from one step to the next (Microchip App Note). This requires four signals from the PIC to the driver. The PIC18F4x31 chips can output 8 PWM signals and so could drive two motors.

An intelligent driver with integrated stepping like the Allegro SLA7070MR ($7) at only requires a direction and step signal. A PIC16F88 has 16 IO lines, enough to drive 4+ unipolar steppers, and PIC18 or PIC30 can run 4+ unipolar steppers plus has PWM lines to drive additional hobby servos. The PIC18 can have a USB interface and so could run a CNC by itself.

A more robust stepper controller interfaced to an SLA70xx driver would have a RESET pin, a common one running to all the drivers, and M0 line monitoring the each stepper, and shared M1 and M2 lines running to all the drivers, so three common lines, and three per driver, so fifteen for four motors. Then figure each axis would have a pair of end stop switches, so four input lines for those, and one input line for a big STOP button. So altogether 20 IO lines for four axis control.

Two IO lines are required for USB. The PIC18F46K20 ($3), a 40-pin DIP, has 36 IO lines, four of which can be PWM and several A/D input lines. This PIC could run four axes and have separate lines for USB, in circuit programming, and still have lines available to run PWM hobby servos, input temperature, etc.

Some CNC setups have centering switches, so that could be useful. Other CNC systems use the axis end stop switch to find their initial position.

Stepper and servo motor control

October 15th, 2009

So I have a box of motors scavenged from old electronic equipment. The first step was figuring out what I have.

I have four identical Pittman servo motors with attached optical encoders. They have two leads for motor control and four leads for the encoders, Vc, Gnd, quadrature A & B signals. So these motors need a sophisticated servo driver that can do PID (Proportional, Integral, Derivative) control. Basically the controller senses motor movement and direction by counting encoder tick marks and then juices the motor in the desired direction using a PWM (Pulse Width Modulation) applied driver voltage.

It’s common to run the these servos with PIC18 chips ($4.50). They have a built in quadrature encoder reader and can be programed to do PID.

Then the low power PWN signal gets run through a power driver like the L298 ($2.60). Here’s a well-documented L298 project. The L298 can driver two servo motors. A LMD18200 H-bridge ($12.50) is another power driver option, used in the Jeffery Kerr boards. Here’s a project using a PIC16 and the LMD18200 driver. The Allegro A3953 is another driver option.

Typically one PIC16 or PIC18 would control each servo motor. The recent dsPIC33 chips ($3.00) have dual encoders and should be able to run two servos. These chips came out in 2008 so I haven’t found any projects on the web describing dual servo projects.

The PIC18 and dsPIC33s are available as DIPs or as SMDs. They can interface to a computer through USB and so can be controlled directly, though connecting them to a programmable controller, a PIC, a BASIC stamp, an Arduino, etc is more common.

Hobby servos are much easier to drive and a single PIC18 can drive several, six to eight depending on the chip variation. Typically a hobby servo would not need a driver as the PWM is its control signal.

Mouse coat colors

October 13th, 2009

Here’s a web page at the The Jackson Labs site showing the most common mouse coat color mutations [link].

Here is white-bellied agouti with head blaze, greyish coat:

white-bellied agouti

Ebola

October 12th, 2009

In a passing during a discussion of the lack of a system for naming viral strains and diseases, Greg Laden mentions that Ebola was named after the town in Zaire/Congo where it was first found.

That has to depress the local real estate market!