2009-11-27

SolarLight (2) and gEDA simulation

An update over SolarLight, I finally managed to print waveforms from ngspice in OpenSuse 11.2 . For some reason the interface is not what you would expect and it has become much more complicated to print a waveform than before.
The first time I installed gEDA from the sources (under OpenSuse 10.3), now I'm using a precompiled version from the OpenSuse Science repository, it could be that the precompiled version has the printer interface "disabled" in some way.
Back to waveform printing, under ngspice one would follow the following path to simulate and plot a waveform:
tran 100n 1.5m
plot v(501),v1000#branch

In the case of the SEPIC circuit of a previous post this would run transient simulation until t=1.5ms with a minimum time step of 100ns (try not to have more than a few thousand simulation points), the second line would open a new window with the output voltage and LED current displayed.
Previously when I pressed in the hardcopy button the print interface would appear and I could chose the printer and/or print to file. Now a message appears in the console:
The file "/tmp/hc4803" may be printed with the Unix "plot" command,or by using the '-g' flag to the Unix lpr command.

If you try the "lpr -g" command either the system complains that it is not supported or that no printer is installed.
lpr: Warning - 'g' format modifier not supported - output may not be correct!
lpr: Error - no default destination available.

After installing plotutils I managed to convert the plotted file (hc4803) to almost any known format (for example postscript or png) with the command:
plot --output-format ps hc4803 > hc4803.ps
plot --output-format png hc4803 > hc4803.png

This allows the plots to be printed and included in documents or webpages, the plot looks something like this:

Then I wanted to try out gwave, gwave is a waveform viewer, part of the gEDA package but its use is far from trivial. First in gwave you must run a simulation and then write the data to a file:

tran 100ns 1.5ms
write plotdata.dta

then run gwave with this data.

gwave plotdata.dta

The interface is far from trivial, I was unable to use colours for the plot and I also had error while trying to print a plot, but at least I could see some waveforms. Results may vary depending on your installed system, but here is a screenshot of the program, the waveforms are in gray on black background:


I'm now temped in building the gEDA toolsuite from scratch... but for that I need some more time...

2009-11-22

SolarLight

Some time ago I had the idea of building a LED lamp that was solar powered, harvesting the Sun during the day and charging the battery, while at night deliver some light. The idea was to extend the hours of light of my peppers during the winter, once the vase was inside the house.

For the initial design I wanted to use two old Ni-Cd batteries and for this supply voltage I would need to use a low voltage oscillator circuit as the minimum voltage would be around 2.0V. The converter would be a boost converter since the Luxeon K2 I had were rated for minimum 2.79V. I started by using a general Boost converter design procedure, and then simulate the circuit in gEDA/SPICE/ngspice.


I stumbled in two problems:
- after some tries with simple transistor oscillator circuits, low voltage comparators, and PWM modulators I decided to use a micro-controller. The biggest problem was the low voltage, even the low voltage circuits shut-down at 3.0V. Then I decided to use a low-voltage micro like the ATTiny45U capable of operating from 1.8V.
-The booster wasn't working, the LED was conducting slightly when the oscillator was off, a known problem with boosters, if the load consumes power at the input voltage minus a diode drop the circuit is always draining the battery.

Finally I decided to redesign the circuit using a 3 element battery, this time a scrap battery from a mobilephone Li-Mh with 3.7V, this would ease the micro selection (Attiny15L that I used before) and I had to change the type of converter to a SEPIC, that allows the use of a battery with a voltage close to the LED conduction voltage. The circuit has the advantage of being capable of boosting or dropping the input voltage, this application note and this one are quite useful for the design phase. Since the load is an LED I allowed a bigger fluctuation in the inductor currents and of the output current, then I chose the operating frequency function of inductors I had available.

Again, after calculating the circuit components I drew a circuit in gEDA and simulated the circuit. As a general design procedure the circuit I use to simulate is very different from the one that I'll build in the breadboard/PCB.

I placed some components inside green boxes to simulate real inductors with series resistance and real capacitors with series resistance. The voltage sources with zero voltage in some branches allow measurement of the current in the branch. I could not find the correct MOSFET (IRLD024) model, instead I used the model (IRFD024) of a similar one but with a different Gate Threshold Voltage. Also as a common procedure to minimize size of the files and speed up processing, I create a smaller library file, containing only the models used. I wanted to show a waveform but since I updated my OpenSuse install to 11.2 I'm unable to print ngspice plots...

After verifying that the circuit worked, I designed the final schematic with the micro-controller and the voltage dividers of the various analog inputs.


The software was straight forward, start the high speed oscillator, start the PWM generator, read voltages, take decisions and increase/decrease PWM output. One note worth mentioning is that the ATTiny85 and the ATTiny15 have two input ports exchanged (Port PB4/PB3 - Pins 2/3) although the ADC inputs are the same!
Here is a couple of pictures of the circuit, the first charging and the second working.


SBC6120 Developments - Casing and altri

After some consideration I decided not to use the plastic casing I had bought for the SBC6120. I thought that a metal casing would be much more appropriate, I found one from Hammond that could fit the SBC and a hard disk.
I want to use the services of these gentleman to design the front and back plane, but at about 20€ per panel, I might go for the front panel only. I found the old digital equipment corporation logo and I'm using Helvetica to do the "pdp-8".
I plan to use the power adaptor and the internal power supply (+5V,+12V) from an old external hard disk casing. The point is to be able to insert in the case any type of IDE hard disk, 3.5' 2.5' or even Compact Flash.
The SBC6120/OS-8 supports a maximum disk size of 2Mbytes, so with 16Mbytes you'd have the equivalent to 8 hard disks of the time and probably be able to fit all the "interesting" software ever compiled/assembled for the PDP-8.
My problem has been finding a IDE 3.5 inch hard disk with a few megabytes, something in the range of 32/64 Mega bytes... it's becoming almost impossible to find hard drives in the Megabyte range...
So to start with something, I went with a old CF of 64 Megabytes and an IDE adaptor, the SBC6120 recognized the drive. These old CFs were bought in a "spare-parts electronics" shop for 1€.I used HyperTerminal (in Windows) and Minicom (linux) to download an disk image, but I had to change the communication protocol is 9600 baud, 7 bits, mark parity, one stop bit (9600 7M1). I also added 100ms delay after each line feed so that the SBC6120 has time to write the sector. I believe this to be a CF problem as it does not have a disk cache, probably with a real hard disk it will work without the delay.
I've downloaded an image provided in the sparetimegizmos site and the next day I checked if it had loaded ok... Boot the SBC6120, type in a DIR and wait for results... Success!! a directory listing appears...
Now I just need to finish the case, find a hard drive and learn how to work with OS-8 :-)