Fri Sep 8 18:52:47 PDT 2017

Making a DIY 2018 Planner

I decided to make a simple DIY planner for 2018. Here is a link to the PDF: 2018-DIY-Planner.pdf. If you have access to a printer that can print on both sides of a piece of paper, you can print a letter sized, two pages per week, 2018 planner using this file. You can then hole punch the pages and put the planner in a binder.

To create this, I used an awk program to write PostScript for the main planner and ps2pdf to convert the PostScript into a PDF. The initial calendar pages came from a combination of Excel and the 'cal' program.

Wow - one year since my last post! I will try to post a few more items!


Posted by ZFS | Permanent link
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]

Fri Sep 16 17:44:04 PDT 2016

A Solar Powered Flag Waver

Solar Powered Flag Waver
(Solar Powered Flag Waver)

This is a solar powered flag waver. It uses a solar cell from an old calculator to charge up an electrolytic capacitor. When the voltage across the capacitor reaches a trigger threshold the charge on the capacitor is released through an electric motor taken from an old video recorder waving a small flag.

I am not the original author of this circuit! Tinker Jim of instructables is! The original article is here: http://www.instructables.com/id/The-Easter-Solar-Engine. It is a really interesting article with lots of carefully researched information. The circuit seems to be nicely reliable - as Tinker Jim describes. It sits on a bookshelf and gradually converts photons into mechanical energy - constantly and gently surrendering to the passage of time.

The power of the flag waving motion is not overly dramatic, it has to be said. But the circuit is a nice example of the concentration of energy in a capacitor followed by its controlled release when a threshold is reached - which is the basis of a wide variety of different circuit types.

 
Solar Powered Flag Waver Schematic
(Solar Powered Flag Waver Schematic)

The circuit diagram is shown here for completeness - but visit Tinker Jim's excellent Instructable article for all the details.

 

Posted by ZFS | Permanent link | File under: electronics
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]

Thu Sep 15 07:55:14 PDT 2016

Sound to Light Converter

A 1.5 volt (AA battery) Audio to LED Circuit
(A 1.5 volt (AA battery) Audio to LED Circuit>

The circuit diagram on the left is an audio to light converter (click the image for a larger view). It lights up a pair of red LEDs based on the sound that it picks up. I made it several years ago - and I think it was based on circuit which drove a meter (or metre if that is your spelling preference) that I saw on Watson's blog - back when that blog was on blogspot. Since then Watson has moved on to his www.rustybolt.info site, and the circuit is no longer present. What I did was combine the drive with a Joule Thief circuit and this seems to nicely light a pair of red LEDs - from a single AA battery.

 

I always like to have circuits that run on 1.5 volt batteries - such batteries are inexpensive and you mainly buy battery and not padding and packaging - which is not alway the case with higher voltage batteries. So a sound to light converter using a single AA battery is appealing. The circuit uses only a few milliamps so the battery will last for a good long time. Nevertheless, I have an on off switch so that I do not always have the device switched on.

As is always the case, anyone building the circuit would be well advised to start with a breadboard version to check that everything is going to work with your particular component choices. When I made the circuit I clearly could not find a suitable bias resistor for Q2, so I have two resistors in series to get to about 680k ohms. This is one example of the use of a breadboard to check everything prior to assembly makes good sense.

The most important variables in this circuit will be the microphone and the Joule Thief drive for the LEDs. In the case of the microphone, I used a piezo insert type microphone that came to me via an old electronics set. So, I do not precisely know the part number of this component. However, if you start up with a breadboard prototype you can test what will work for you.

The Joule Thief section that I used employs an interstage audio transformer. This is rather unusual for a Joule Thief, but I suspect that the circuit will work fine with a traditional Joule Thief toroidal transformer. (But I should note that I have not tested this). I empirically found that the interstage transformer uses very little power, and I figured that this might be helpful in this particular circuit. The base transistor for the Joule Thief is 120k ohms which is much higher than what would be used in a traditional Joule Thief. But, my empirical observation was that with this transformer, a high value base resistor led to low current consumption. If you are trying out this circuit on a breadboard, you can obviously experiment in this region. Perhaps start by measuring the voltage switched by Q4 and then figure out how you can use that voltage to do something interesting - like drive some LEDs or a motor (etc.).

A final comment is the role of R9, which is a variable resistor that is used to set the sensitivity. In use, you adjust this control such that the LEDs are just switched off in a quiet room. This adjustment point is easy to set and once you have suitably adjusted the device, the LEDs will be nicely sensitive to the sound picked up by the microphone.

As an experimental application, I recorded three videos of the LEDs lighting up in time with sound. The three topical cultural examples chosen were: Hillary Clinton, Donald Trump, and Ozzy Osbourne. I will post the embedded movies below, along with a quick video which shows the device in its transparent box. Naturally, the device works just as well without projecting its lights through a static image of a cultural icon - but this particular application results in an interesting visual effect...and I am sure that other applications can be found.

Ozzy Osbourne

Donald Trump

Hillary Clinton

And the device with no picture...


Posted by ZFS | Permanent link | File under: electronics
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]

Wed Sep 14 05:37:17 PDT 2016

1.5 Volt AM Transistor Radio Schematic and Layout

A 1.5 volt (AAA battery) am receiver circuit diagram
(A 1.5 volt (AAA battery) am receiver circuit diagram)

The image on the left is a schematic circuit diagram of the small four transistor AM radio I mentioned a month or two ago (here). I will also attach the component layout and an image of the radio in its plastic box to this page. In each case, click the image for a high resolution version of the image.

 
A 1.5 volt (AAA battery) am receiver component layout
(A 1.5 volt (AAA battery) am receiver component layout)

If you want to make yourself one of these radios, I recommend that you start by making a 'breadboard' version so that you can test the coil (for example) and trimmer to insure that they can tune the region of the AM dial that you are interested in receiving. I used the NPN signal transistors that Radio Shack used to sell in my version - these are typically 2N3904's - I believe. But, it will not hurt to try out the transistors that you intend to use in a breadboard version before you solder the components.

 
A 1.5 volt (AAA battery) am receiver in a transparent plastic box
(A 1.5 volt (AAA battery) am receiver in a transparent plastic box)
 

Posted by ZFS | Permanent link | File under: electronics
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]

Sun Jul 17 21:19:51 PDT 2016

1.5 Volt Transistor Radio

A 1.5 volt (AAA battery) am receiver
(A 1.5 volt (AAA battery) am receiver)

Another way to use up batteries...This is a 1.5 volt AAA batter radio that drives a pair of earbuds. It works surprisingly well - it has few controls - in a minimalist quasi high quality high-fidelity Scandinavian audio buff sort of a way (not really). It is quite loud too. It uses about 3ma - so a fresh AAA battery lasts something in the region of 10 days (that is an estimate - I have not checked).

I made this a while ago - inspired by various pictures of matchbox size radios on the web. I made it using a standard tuner circuit and adding a couple of stages of amplification - initially it was a little unstable and prone to oscillate - which often happens with simple radios - but this was cured using a filtering capacitor which removes much of the RF before it gets to the audio amplifying transistors (I learned about this by looking at the pages here - which is also where the basic circuit came from). Thank you Andy Collinson!

The circuit is a little vulnerable to volume fluctuations if you have it in a pocket as you move around (changing the orientation of the direction ferrite antenna). In practice this is not too problematic. I have considered putting in an automatic gain control (AGC) of the types described here and here. Perhaps one day...

One interesting observation about making something like a little am radio is that (of course) I could buy such an item for a small sum of money and likely have a better radio. So I have been puzzling as to why I want to make one. One of the attractions of making something yourself - with relatively vague instructions and objectives - is that you need to solve various problems and make various compromises as you go. So there is an element of enjoying the journey as well as the destination. Well, that is my current excuse...

I will post the circuit soon - it has a few variations relative to the design published by Andy Collinson.


Posted by ZFS | Permanent link | File under: electronics
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]

Mon Jul 4 11:34:54 PDT 2016

Draining an Alkaline AA Battery - Voltage Versus Time

Joule Thief AA alkaline battery voltage versus time
(Joule Thief AA alkaline battery voltage versus time)

I thought I would use a relatively new AA battery to power a flickering Joule Thief to see how its battery voltage varied with time. The image here shows the resulting voltage versus time relationship.

The ACDelco alkaline AA battery was bought a couple of years ago from Fry's Electronics. It was unused initially (if a little old) and ran the Joule Thief for 6.75 days. I must admit that I was disappointed by this performance - I had been expecting more than 7 days. (I am not sure why I expected more, the device draws 38 milliamps from a fresh battery. A typical alkaline AA battery is rated at 2000 milliamp hours, so should only power the device for 2000/38 or approximately 50 hours). Anyway, I was optimisitic, because I figured that as the batteries voltage went down, so the current drain would drop. To some extent this was true, because 6.75 days is much more than 2 days (!) but the Joule Thief did not run down the battery as far as I thought it would in voltage terms. The LEDs stopped flickering somewhere between 0.67 and 0.63 volts, and I had been expecting something more like 0.45 volts.

This particular Joule Thief circuit (as shown here) has voltage stabilization and this is probably costing quite a few wasted milliamps. The coil is also likely not the most efficient - I used a ferite rod rather than a torroidal core. Taking a battery that can hardly light the flickering LEDs in this circuit and using it with a standard Joule Thief shows the expected behavior with the LEDs still being powered down to about 0.48 volts.

You can make semiconductors which operate at lower voltages and so can extract energy from batteries down to very lower voltage. For example, germanium transistors work down to about 0.2 volts and JFETs and CMOS devices even lower voltages I believe.

So this device could be improved, but it does get something extra from with otherwise useless batteries - and I quite like it.


Posted by ZFS | Permanent link | File under: electronics
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]

Mon Jun 20 15:30:29 PDT 2016

Joule Thief in Obligatory Tic Tac Box with Flickering LEDs

The 'Big Clive' Joule Thief runs to low voltages - as is well known - so if you want to extract energy from an old AA battery and have something possibly useful with that energy happen - a Joule Thief is a perfect vehicle to that end.

There is lots of experimentation documented on the web with different approaches and circuit variations. Some circuits yield improved efficiency and others provide enhancements like current or voltage control.

Here is a Joule Thief variant I put together at the weekend, as one does. It uses two flickering light emitting diodes (LEDs) taken from Dollar Store 'tea light' plastic candles (2 for one dollar). These Dollar Store candles are in themselves wonderful devices. They use 3 volt 2032 lithium cells - so perhaps their only limitation is that they run for a decidedly finite 5 days (according to the packet). The Joule Thief circuit allows you to use AA batteries that are no longer able to energize modern electronic equipement - the inductor based Joule Thief circuit extracts energy from the cell all the way down to about 0.4 volts (and lower if you are prepared to seek out special transistors).

 
Flickering LED Joule Thief Circuit
(Flickering LED Joule Thief Circuit)

The circuit used is shown in the image near this text (click on the image for a larger view). This is an extension of the Joule Thief circuit, adjusted to provide a specific output voltage. In the original Talking Electronics version (from here), the target voltage was 5 volts. The place of the solar cell in the original circuit has been taken by a 1.5 (in principle) AA battery. For the flickering LEDs, a voltage of about 3 volts was required, so I changed the resistor network of the original circut a little so that the control of the oscillating transistor cuts in at 3 volts. This means that the output is a steady 3 volts. I also added a series resistor for the LEDs - I did this to mimic the behavior of the original flickering LEDs in the Dollar Store tea lights - super bright is not particularly candle like.

As a finishing touch, American style Tic Tac boxes are the perfect enclosure for a small circuit - providing an aesthetically satisfying blend of transparency, amateurishness, and thriftiness. Once installed in the Tic Tac box the flickering LEDs can be conveniently covered with the plastic tube fake flame cover of the original lights, yielding a quasi-nixie tube flickering display - both fetching and enchanting.

The flickering LEDs contain a chip which handles the random fluctuations, as discussed here. So although this is a two transistor Joule Thief, it contains two substantial integrated circuits as well.

From a chemical perspective, what happens in an alkaline battery is that zinc is oxidized to form zinc oxide, and manganense in the form of MnO2 is reduced. (The name 'alkaline' refers to the fact that their are hydroxide ions added to the water in the battery in the form of potassium hydroxide). The basic chemical reaction of an alkaline battery is:

Zn(s) + 2MnO2(s) = ZnO(s) + Mn2O3(s)

This reaction liberates a fair amount of energy as the zinc is effectively burned, and that energy is released in the form of electrons flowing between the zinc and the MnO2. That is the energy that powers the Joule Thief and flickers the LEDs.

As an alkaline battery ages, its internal resistance increases, reducing the voltage that is available to drive electronic devices. The Joule Thief, because it boosts voltage using a transformer, is able to keep going with lower voltages than many pieces of equipment. Hence the Joule Thief is the perfect device for squeezing the last few drops of zinc oxidation from old batteries prior to handing them over to the recycler.

The Joule Thief on the video above has been running for about 24 hours. I may exert myself and measure how long it takes to run down sufficiently to be unable to light the LEDs - I am expecting several weeks of run time. I will report back on my observations.


Posted by ZFS | Permanent link | File under: chemistry, electronics
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]

Wed Jun 15 19:27:39 PDT 2016

Making a Book from HTML Pages

I spent a little time recently in figuring out how to compile various pages into a pdf book. The key to doing this, I found, is to use 'htmldoc' - which can be downloaded for various platforms easily.

Here is a summary of the scripts that I used.

make_pdf.sh controls the overall processing, it uses a list of files stored in 'chapters.txt' to determine the files to process.

#!/bin/sh

rm -f missing_files
rm -f image_files 

i=0
while read CHAPTER
do
  i=`expr $i + 1`
  TMP=`echo $i | awk '{printf "tmp%04d.html", $1}'`
  echo $TMP 
  ./txttohtml.sh $CHAPTER | sed -f greek.sed > $TMP
  if [ $i -eq "500" ]
  then
    break
  fi
done < chapters.txt

htmldoc --book --linkstyle plain --toctitle "The Molecular Universe"  -f output.pdf --no-title --headfootfont times --headfootsize 10 --charset iso-8859-7 --embedfonts --size letter tmp*.html --titlefile title.html

./make_index.sh output.pdf 12

# make a report on the current status to append to the book
WORDS=`wc output.txt | awk '{print $2}'`
MISSING=`wc missing_files | awk '{print $1}'`
IMAGES=`wc image_files | awk '{print $1}'`
echo "<pre>" > status.html
echo "PDF file created:" >> status.html
date >> status.html
echo "" >> status.html
echo "Current word total: " $WORDS >> status.html
echo "" >> status.html
echo "Number of image files that should be enlarged: " $MISSING >> status.html
echo "" >> status.html
echo "Missing file names follow: " >> status.html
cat missing_files >> status.html
echo "" >> status.html
echo "Current image file count: " $IMAGES >> status.html
echo "All image file names follow: " >> status.html
cat image_files >> status.html
echo "</pre>" >> status.html

htmldoc --webpage -f status.pdf --no-title --size letter status.html

pdftk A=output.pdf B=output.index.pdf C=status.pdf output output.pdf

rm -f output.pdf output.txt output.index.pdf output.data.txt status.html status.pdf

if [ -f missing_files ]
then
  echo "THERE ARE " `wc missing_files | awk '{print $1}'` " MISSING FILES"
  cat missing_files
fi

txttohtml.sh is a very crude script that converts the raw nanoblogger txt file into a crude html file which can be used as the input to the htmldoc processor.

#!/bin/sh

awk '{
  if(match($0,"TITLE:")){
    title=substr($0,7)
    print "<h1> " title " </h1>"
  }
  if(match($0,"<blockquote>")){
    print "<table border=\"1\" cellpadding=\"10\"><tr><td>"
    getline
    sub("Note:","<b>Note:</b>");
    print $0
    next
  }
  if(match($0,"</blockquote>")){
    print "</td></tr></table>"
    next
  }
  if(match($0,"BODY:")){
    intext=1
    next
  }
  if(!intext)next
  if(match($0,"END-----")){
    intext=0
    exit
  }
  if(match($0,"<table class=\"image")){
    imagetable=1 
  }
  if(match($0,"\"left\"") && imagetable){
    sub("\"left\"","\"center\"");
  }
  if(match($0,"\"right\"") && imagetable){
    sub("\"right\"","\"center\"");
  }
  if(match($0,"<img src=")){
    record=$0
    sub("^.*<img src=","",record);
    sub(" .*$","",record);
    sub("^.*/","",record);
    sub("\"","",record);
    sub("_scale","",record);
    largefile=record
    largefile="../../../images/" largefile
    located=0
    # look for file with original extension
    line=""
    getline line < largefile
    close largefile
    if(length(line)>0){
      largefile="\""largefile"\""
      sub("\".*\"",largefile)
      located=1
    }
    # look for file with .png extension
    line=""
    sub(".gif",".png",largefile)
    getline line < largefile
    close largefile
    if(length(line)>0){
      largefile="\""largefile"\""
      sub("\".*\"",largefile)
      located=1
    }
    if(!located){
      print "COULD NOT LOCATE " record > "/dev/tty"
      print record >> "missing_files"
    }
    print largefile >> "image_files"
  }
  if(match($0,"</table") && imagetable){
    imagetable=0
    print $0
    print "<table width=\"100%\" summary=\"\"><tr><td> </td></tr></table>"
    next
  }
  print $0
}' $1

make_index.sh comes from pdftk and uses two tools from the pdftk site to create a crude book-like index for the the book. I modified the make_index.sh script a little - so I am including it here.

#!/bin/sh
# make_index.sh, version 1.0
# usage: make_index.sh <PDF filename> <page window>
# requires: pdftk, kw_catcher, page_refs,
#           pdftotext, enscript, ps2pdf
#
# by Ross Presser, Imtek.com
# adapted by Sid Steward
# http://www.pdfhacks.com/kw_index/

# modified somewhat from the original distributed version to correct
# problems encountered in initial testing

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
LANG=C

fname=`basename $1 .pdf`
pdftk ${fname}.pdf dump_data output ${fname}.data.txt && \
sed 's/LowercaseRomanNumerals/DecimalArabicNumerals/' ${fname}.data.txt > j && \
mv j ${fname}.data.txt && \
pdftotext ${fname}.pdf ${fname}.txt && \
  page_refs ${fname}.txt index-terms.dat ${fname}.data.txt \
| sed 's/PageLabelNumStyle://g' \
| enscript --columns 2 --font 'Times-Roman@10' \
  --header '|Index' --header-font 'ArialBold@20' \
  --margins 54:54:36:54 --word-wrap --output - \
| ps2pdf - ${fname}.index.pdf


Posted by ZFS | Permanent link | File under: bash, blogging
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]

Sat Jun 4 21:31:49 PDT 2016

Fentanyl: Molecule that Actually Killed Prince

The official autopsy report has revealed that fentanyl killed Prince. (Originally it was thought that oxycodone was the culprit).

The structure of a fentanyl molecule is shown above. Like oxycodone, fentanyl is an opioid drug, and like oxycodone it operates on the receptors that transmit pain.

Although fentanyl is medically employed for pain relief it delivers a 'high' to people who take the drug.

Fentanyl is a flexible drug molecule (unlike oxycodone). It has more than five torsions or dihedral angles by which its conformation can be altered.

Hence, in some respects it resembles the peptide endorphins that are thought to be the natural equivalents of opioids.

Despite its flexibility, fentanyl is a powerful drug. It is approximately 100 times more active than morphine, for example. Given its activity, fentanyl is a dangerous drug - overdoses are unfortunately common because a small quantity of fentanyl can cause substantial respiratory depression and death.


Posted by ZFS | Permanent link | File under: chemistry
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]

Thu May 26 07:24:59 PDT 2016

The Tough Molecule that Killed Prince

The molecule above is oxycodone, the molecule that very likely killed Prince.

The shape and chemistry of oxycodone are very similar to morphine and heroin.

Although oxycodone blocks pain and produces euphoria it is very addictive. It is hard to stop taking oxycodone because of the painful withdrawal symptoms that lack of the drug produces.

Like morphine and heroin, oxycodone binds to receptors which are normally the home of peptide hormones. The peptide hormones are the neurotransmitters which make humans feel good, scared, hungry, or satisfied. Such receptors have a hard time dealing with generally rigid molecules like oxycodone. Such molecules are not broken down like flexible peptide neurotransmitters and exert their influence on the receptor for extended periods of time.


Posted by ZFS | Permanent link | File under: chemistry
[StumbleUpon] [Digg] [Reddit] [Facebook] [Google]