Disappointment with CouchDB

I am looking for a no-sql database to simplify the management of some data I need for a project at work.  Tokyo Cabinet and MongoDB were recommended to me, but I decided I would give CouchDB a shot.  I read the Erlang mailing list regularly and CouchDB is often mentioned.  I also want to support software projects that use Erlang because I love working with Erlang and would love to help it spread.

Unfortunately I cannot recommend CouchDB.  Trying to install its dependencies were such a mess that I am no longer going to waste time with CouchDB.  Sorry guys, it looked really interesting, but I have work to do an other no-sql databases are much easier to setup.

Part of the issue is that I’m working on a Novell SLES 10 box, and as such it doesn’t get the most up-to-date packages. I don’t have the option of grabbing the latest version of Ubuntu or OpenSuSE due to audit department requirements.  I’m stuck with SLES 10 for now, if I’m lucky I will be able to upgrade the server to SLES 11 one day.

However, I was able to get Erlang installed without a hitch.  I have never once had an issue installing Erlang on a system: Solaris 10, Mac OS X, Windows, Ubuntu, and SLES.

sudo rpm -Uvh erlang-R13B01-13.1.x86_64.rpm   (from http://software.opensuse.org)

I went ahead and ran the CouchDB configure script just to see if all of the dependencies (libcurl, ICU, SpiderMonkey, OpenSSL) were optional.

checking for JS_NewContext in -lmozjs… no
checking for JS_NewContext in -ljs… no
checking for JS_NewContext in -ljs3250… no
checking for JS_NewContext in -ljs32… no
configure: error: Could not find the js library.

Is the Mozilla SpiderMonkey library installed?

Of course not, looks like I cannot skip SpiderMonkey.  And of course the Mozilla guys cannot make anything easy, I have to install Mercurial first just to get at the code.  Luckily there was a package for mercurial.  I think this server now has CVS, SVN, Bazaar, git and mercurial on it now.

sudo rpm -Uvh mercurial-1.8.3-45.2.x86_64.rpm

It took awhile for mecurial to clone the repistory, but it did grab everything.  I also had to install autoconf-2.13, and thankfully it also had a package for SLES 10.

hg clone http://hg.mozilla.org/mozilla-central/
cd mozilla-central/js/src
autoconf-2.13

I threw my hands up with the error that came up when I ran gmake as directed by the install.

gmake export
gmake[1]: Entering directory `/home/ptuser/nexttick/spidermonkey/mozilla-central/js/src’
gmake -C config/ nsinstall
gmake[2]: Entering directory `/home/ptuser/nexttick/spidermonkey/mozilla-central/js/src/config’
nsinstall.c
gcc -o host_nsinstall.o -c  -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -W -pedantic -Wno-long-long -fno-strict-aliasing -pthread -pipe  -DNDEBUG -DTRIMMED -g -O3 -DXP_UNIX -O3  -DUNICODE -D_UNICODE  -I. -I. -I../dist/include -I../dist/include/nsprpub
gcc: no input files
gmake[2]: *** [host_nsinstall.o] Error 1
gmake[2]: Leaving directory `/home/ptuser/nexttick/spidermonkey/mozilla-central/js/src/config’
gmake[1]: *** [config/nsinstall] Error 2
gmake[1]: Leaving directory `/home/ptuser/nexttick/spidermonkey/mozilla-central/js/src’
gmake: *** [default] Error 2

I don’t fault the CouchDB guys for SpiderMonkey’s build system, but the amount of work required just to get the prerequisties for CouchDB makes it not worth my time.  In the amount of time I spent tracking down packages and trying to get everything, I could have just installed SQLlite and written some code.

I’m going to give MongoDB a shot now.

UPDATE: MongoDB also depends on SpiderMonkey, so it is out the window too.  I tried to install their 64-bit Linux binary, but I just got a floating-point exception.  Looks like I’ll just stick with Sqlite.  Besides, Sqlite3 is built into Python.

Advertisements

Zener Voltage Regulator

A circuit often introduced in beginning electronics is the zener regulator circuit.  The zener regulator is a simple circuit for providing a constant DC voltage supply, and also a great way to learn more about how a zener diode works.

The idea with the zener regulator is to take advantage of the breakdown behavior of the zener diode.  In the zener diode I-V characteristics curve shown below (note: ignore the numerics, just observe the shape and relationships), when the diode is reverse-biased beyond a negative threshold voltage, the negative zener current flushes out of the gates.  The zener diode is doing all it can to hold the output voltage at the output level for the device, even in the face of large input voltage.  There key here is that the zener diode is reverse-biased and operating in its breakdown mode.

Diode I-V characteristic curve (wikibooks)

This lab will have both a SPICE model and a practical circuit demonstration.  To keep things simple, the input voltage will be +9V DC, which anyone can obtain with a simple 9V battery.  For the zener diode device, I selected a 1N4278, which is a 3.3V zener diode rated at 1W.  In order to select the right value for the resistor, I consulted the 1N4278 datasheet for the values Vz and Iz.  Vz for the 1N4278 is of course 3.3V, and Iz, the breakdown current threshold, is 76 mA.  With these values I could then calculate the acceptable resistor value.

(V – 3.3 V / R) >= Iz
R <= (9.0V – 3.3V) / 76mA
R <= 75 ohms

The resistor needs to be under 75-ohms, plus or minus our tolerances.  From my resistor grab bag, I selected a 47-ohm resistor to begin the experiment.

SPICE simulation

To model this circuit with SPICE, we only need three components: the input source, the resistor, and the zener diode.  The SPICE model for MacSpice is shown below.

* Zener Diode Voltage Regulator
Vin 1 0 DC 9V
R1 1 2 47
D1 0 3 zener
.model zener D (BV=3.3)
.control
dc Vin 0 9 0.5
print v(1) i(Vm) v(2)
.endc
.end

The SPICE model performs a DC sweep on the 9V input source, starting from 0V and increasing to +9V in 0.5V increments.  The output of the DC sweep is shown below.

Circuit: * Zener Diode Voltage Regulator

                        * Zener Diode Voltage Regulator
             DC transfer characteristic  Mon May 16 23:30:20  2011
--------------------------------------------------------------------
Index     sweep         v(1)          v(2)
--------------------------------------------------------------------
0         0.00000e+00   0.00000e+00   -2.51984e-35
1         5.00000e-01   5.00000e-01   5.00000e-01
2         1.00000e+00   1.00000e+00   1.00000e+00
3         1.50000e+00   1.50000e+00   1.50000e+00
4         2.00000e+00   2.00000e+00   2.00000e+00
5         2.50000e+00   2.50000e+00   2.50000e+00
6         3.00000e+00   3.00000e+00   3.00000e+00
7         3.50000e+00   3.50000e+00   3.33298e+00
8         4.00000e+00   4.00000e+00   3.36744e+00
9         4.50000e+00   4.50000e+00   3.38260e+00
10        5.00000e+00   5.00000e+00   3.39209e+00
11        5.50000e+00   5.50000e+00   3.39849e+00
12        6.00000e+00   6.00000e+00   3.40378e+00
13        6.50000e+00   6.50000e+00   3.40829e+00
14        7.00000e+00   7.00000e+00   3.41213e+00
15        7.50000e+00   7.50000e+00   3.41548e+00
16        8.00000e+00   8.00000e+00   3.41845e+00
17        8.50000e+00   8.50000e+00   3.42112e+00
18        9.00000e+00   9.00000e+00   3.42353e+00

As can be seen from the output, when the input source is reaches a level above +3.3V, the zener diode, which is reverse biased, see this as -3.3V and opens the flood gates for the zener current.

Demonstration

In the picture below, the 47-ohm resistor is the horizontal device, and the diode is the vertical device to the right.

Output of the zener regulator

I hooked up my multimeter to the output port of the zener regulator, as expected enough the output voltage was 3.309V.  With such a large voltage drop over the small 47-ohm resistor, it heats up very quickly; after all, that difference in energy has to be dissipated somehow, and the resistor dissipates energy via heat.

What if we hooked up a potentiometer to the output of the circuit?  I had a 10k-ohm potentiometer in my toolbox, so I hooked it up to the output of the zener regulator.

Potentiometer hooked up to zener regulator output

I started at zero ohms and slowly turned the dial.  The zener regulator was able to hold the output voltage until I had turned the dial about three-quarters of the way, or roughly 7.5k-ohm.  The output dropped to 0.556V.

And what if I swapped the 47-ohm resistor and the  potentiometer?

Potentiometer between zener diode and input source

Unless I had the dial almost completely at the zero position, the zener diode was not able to regulate 3.3V, as shown above.  The resistor between the zener diode and the input source must be small enough to meet the threshold Iz from the datasheet.

Conclusions

Both the SPICE simulation and practical demonstration backed up the theory of the zener diode as depicted by the I-V characteristic curve.  The regulator circuit provides a steady 3.3V DC while operating under the correct parameters.  For practical regulator circuits, however, the zener regulator is quite in efficient and dissipates a lot of energy through heat in the resistor.  For simple lab experiments and learning purposes, however, the zener regulator is a convenient and simple way to create a fixed DC voltage supply.  Of course it is easier to purchase a few three-terminal linear regulators as well, such as the LM series regulators (3V, 5V, 6,V, 9V, etc.)

For more on the zener diode and regulator circuit, make sure to check out All About Circuit’s page on zener diodes and WikiBooks.