Digital DC Power
================

Compile the software and program the microcontroller:

1) edit and adapt the file hardware_settings.h

2) load and compile:
make wrfuse4mhz
make 
make load

Note: You will get some warnings "#warning "This header file is obsolete."
during compilation with avr-libc-1.4.X. This is because this code will 
also work with avr-libc-1.2.X

The make wrfuse4mhz needs to be done only once
unless you change the Atmega8 chip. make/make load
need to be repeated everytime you change something
in the software (e.g update of hardware_settings.h). 

The poweresupply must be powered up during programming
but nothing should be connected to the output. Make
also sure that you do not accidently press any button
during the programming (loading the software into the uC).

Note to windows (WINAVR) users (linux users ignore this):
========================================================
To compile only the .hex file for the microcontroller
run make the command:

make ddcp.hex

After that the microcontroller has to be programmed (download
the file ddcp.hex to the microcontroller) and the clock frequency 
has to be set to 4MHz. How this is done depends on the programmer 
that you use.

Under other_os/win are source code and ready made 
win32 binaries for the remote control feature of this 
power supply.

---------------------------------------------------------------
Overview
========

This is the software and hardware description for the
tuxgraphics.org electronic power supply. 
A microncontroller controlled DC power supply. 

All of the control logic is implemented in software. This
saves a lot of parts compared to conventional lab-power 
supplies. This means it is cheaper, easier to build and
offers more functionallity.

Note however that this means also that the short circuit
protection is implemented in software. So be careful when
you change something in the software. If the microcontroller 
is not running properly due to a software fault then there
might not be any short circuit protection.


The software is prepared for 2 versions:
- 0-22V 0-2.5A
- 0-30V 0-2A

It is possible to build a different version without major
re-design. Check the article details for hardware limits and
to extend them.

The hardware has as of this release features which are not
yet supported by the software:
- store settings to survive a power off
- i2c driver interface to linux PC

The plan is that both features will be added in future versions
of the software. It will be software only changes.

---------------------------------------------------------------
IC2 commands
============
# set Imax to 0.20A:
i2ctalk i=20
# get current I value:
i2ctalk i
# store current settings
i2ctalk s
# set Umax to 2.1V:
i2ctalk u=21
# get current voltage value:
i2ctalk u
---------------------------------------------------------------
How the software works
======================

I have added a lot more comments to the software than usual. 
It should be possible even for somebody with little experience in
C programming to understand how this software works.

The circuit uses as internal units ADC steps. All external values
(Volt, Ampere) are converted to steps of the analog to digital 
converter (ADC). When you change the voltage then this is first
converted to ADC steps and then it will be further processed.


ddcp.c -- this is the main program. All initialisation starts here.
 It contains a infinite while loop which will execute the slow tasks
 one by one: 
   + Convert ADC results to display values
   + Update the LCD
   + Check push buttons
 
analog.c -- the analog to digital converter and the main control loop
         for the power supply. Everything is interrupt based here as
         it needs to be fast.
         Voltage control, current limitation and short circuit protection
         are all implemented here.

dac.c -- the digital to analog converter. Initalized from ddcp.c but
         used exclusivly from analog.c

kbd.c -- the keyboard driver

lcd.c -- the LCD driver. This is a special version which will not need
         the rw pin of the display. It uses instead an internal timer
         which should be long enough for the display to finish its task.
         The RW pin which is normally used to poll the display to see
         if it is ready is not needed.

-------------------------------------------------------------------
Copyright: GPL
Author: Guido Socher
Homepage: http://www.tuxgraphics.org/electronics/
-------------------------------------------------------------------
Change history:

digitaldcpower-0.2.2 -- first public version 2005-06-16
                        limitations: no i2c, no permanent storage of settings

digitaldcpower-0.2.3 -- 2005-06-25 update of circuit diagram

digitaldcpower-0.4.0 -- 2005-06-25 pre-relase with more functionallity

digitaldcpower-0.4.1 -- 2005-07-20 correctional update, never released officially 

digitaldcpower-0.4.3 -- 2005-07-25 fixed bus error handling in i2c code

digitaldcpower-0.4.4 -- 2005-09-29 faster scrolling on permanent button press,
                        software version shown if store button is pressed long

digitaldcpower-0.4.5 -- 2005-10-15 Improved Makefile to work also with the new
                        avrusb500 programmer

digitaldcpower-0.4.6 -- 2006-01-08 Hardware update for 30V version and configurable
                        short cirrcuit protection (via hardware_settings.h)

digitaldcpower-0.4.7 -- 2006-01-18 Bugfix in the i2c code (Thanks to Henno Heymans).
                        This fault was only seen in the interworking with Win XP.

digitaldcpower-0.4.8 -- 2006-03-03 Make code work with the new gcc-4.0.X compiler
digitaldcpower-0.4.9 -- 2006-03-24 editorial changes in hardware_settings
                        Improved timeout handling.
-------------------------------------------------------------------
