AVR web server, remote equipment control software
This is software to control the stare of 4 relays, read two digital IO-ports and
read two analog IO-ports. See subdirectory hardware for
more details. The software runs on atmega168/328.
All parts needed to build this AVR ethernet solution can be ordered from
http://shop.tuxgraphics.org/
---------------------------------------------------------------------------
!! READ THIS FIRST !!
---------------------
For the first device you build you don't have to change anything
in the software. To connect more than one board to the same LAN
you will need to change the mac address to something else.
Edit the file main.c and change the last digit in this line:
static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x29};
It does not matter to what value you change it as long as
there is no other ethernet board with the same value.
If you want a password protection then read below.
Check the file "Makefile" and make sure the MCU is set correctly:
MCU=atmega168
DUDECPUTYPE=m168
or
MCU=atmega328p
DUDECPUTYPE=m328
To compile the software use the command:
make
Note: windows users may use and modify the supplied winmake.bat to setup the
environment correctly.
There is also a pre-compiled file, eth_rem_dev_tcp_pre168.hex, which you can
load directly into an atmega168. For other CPUs you will need to compile your own.
The above command will compile the following hex files:
eth_rem_dev_tcp.hex test0.hex test1.hex test2.hex test_readSiliconRev.hex
The command
make load
will execute the avrdude command to load the software.
E.g something like:
avrdude -p m168 -c stk500v2 -e -U flash:w:eth_rem_dev_tcp.hex
! Note your programmer might interfere with the enc28j60! For the avrusb500
! with 30cm cable you can normally leave the cable on. For all other programmers
! it is however saver to remove the programmer cable and power down/up the device.
! This is because the SPI interface is used for loading of the software and
! communication to the enc28j60.
To see a list of all possible build targets run the command:
make help
Selecting the right clock source
--------------------------------
Tuxgraphics hardware sold as of march 2007 is prepared to use the clock
signal from the enc28j60. To use this you need to change the
low fuse byte once from 0x62 to 0x60:
avrdude -p m168 -c stk500v2 -u -v -U lfuse:w:0x60:m
or just type in your Linux shell:
make fuse
After programming the fuse settings of atmega168 and atmega88 should be:
low fuse: 0x60
high fuse: 0xdf
ext. fuse: 0x01
For the atmega328p the hfuse and efuse bytes look slightly different.
The idea is however the same. Just change the lfuse from factory default
to 0x60. The fuse settings of the atmega328 are after programming:
lfuse reads as 0x60
hfuse reads as 0xD9
efuse reads as 0x07
details of the lfuse bits:
CKDIV8 = 0
CKOUT = 1
SUT1 = 1
SUT0 = 0
CKSEL3 = 0
CKSEL2 = 0
CKSEL1 = 0
CKSEL0 = 0
If you are unsure what the current fuse setting are on the atmega
then you can read the fuse settings with a command like:
avrdude -p m168 -c stk500v2 -v -q
The result should be this (default factory settings for atmega168):
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 1
The result should be this (default factory settings for atmega328p):
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as D9
avrdude: safemode: efuse reads as 7
Compiling on non-Unix systems
-----------------------------
Please use the provided Makefile !!!
It will also work under Windows except for the loading
of the software. That is compiling will work but not
"make load". Use then whatever tools and commands to download
the resuting .hex file into the micrcontroller
Take also a look at the supplied winmake.bat file. This bat script
might be needed to set the environment correctly.
Password protection/login page
------------------------------
To remove or add a login page you need to edit main.c and change the following
two lines:
// set this to 1 if you want a login page, otherwise to 0
#define LOGINPAGE 1
// the password string, (only a-z,0-9,_ characters):
static char password[]="secret";
No UDP support
--------------
This software implements a webserver only.
Look at the software eth_rem_dev_tcp-2.17.tar.gz if you want
examples for UDP.
Changing the IP address
-----------------------
You can either change the IP addess in the source code:
static uint8_t myip[4] = {10,0,0,29};
or you can change it later:
1) power down the device
2) connect pin PD2 to GND with a short cable
3) power up the board and go to the compile-time IP address of
the board (default is http://10.0.0.29/ )
4) remove the cable and power cycle
The above is just a short summary. A detailed description of the exact
procedure can be found in the sub directory hardware and file howto_changeIP.htm
Using the web server
--------------------
Point your web browser to
http://10.0.0.29 (or what ever IP address you have given your hardware)
You should get as answer a web page with:
Line status:
PD4 output: off [change]
PD5 output: off [change]
PD6 output: off [change]
PD7 output: off [change]
digital input PD0: 1
digital input PD1: 1
analog input ADC0: 97
analog input ADC1: 104
[refresh page]
------------------------------------
version 2.17, tuxgraphics.org
Revision history
----------------
2009-03-22: version 2.17 -- first public version (based on eth_rem_dev_tcp-2.17.tar.gz)
2009-05-12: version 2.18 -- re-written for new stack, added optional password protection.
Version 2.18 is too big to run on atmega88. Use version 2.17
if you have an atmega88.
2009-05-17: version 2.19 -- updates after changes to new stack
vim:sw=8:ts=8:si:et