Hardware reset button with web interface
Just enter a password and click on the "reset/reboot" button
and a transistor/relay connected to pin PD7 will "click" for
a moment and can be used to reset any attached hardware.
This is the software for the tuxgraphics.org
ethernet remote device. See http://tuxgraphics.org/electronics/
Copyright of most software and all diagrams: Guido Socher
The libraries
ip_arp_udp_tcp, enc28j60 and websrv_help_functions
are licensed under LGPL V2
See http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html
All other parts are GPL V2
See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
---------------------------------------------------------------------------
All parts needed to build this AVR ethernet solution can be ordered from
http://shop.tuxgraphics.org/
Note that the magnetics need to fit exactly the requirements of the enc28j60
chip. You can not just take any transformer.
!! READ THIS FIRST !!
---------------------
! Edit the file main.c and change the 2 lines:
! static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x29};
! static uint8_t myip[4] = {10,0,0,29};
Check the file "Makefile" and make sure the MCU is set correctly:
#MCU=atmega88
#DUDECPUTYPE=m88
#MCU=atmega168
#DUDECPUTYPE=m168
MCU=atmega328p
DUDECPUTYPE=m328p
#MCU=atmega644
#DUDECPUTYPE=m644
#MCU=atmega644
#DUDECPUTYPE=m644p
Uncomment the correct lines.
For the first device you build you will not need to change the mymac line.
But you will probably need to change the IP address (myip). It must be a
free address from the address range in your home network.
There is a range of private addresses (not routed on the public internet)
which you can use:
Netmask Network Addresses
255.0.0.0 10.0.0.0 - 10.255.255.255
255.255.0.0 172.16.0.0 - 172.31.255.255
255.255.255.0 192.168.0.0 - 192.168.255.255
Example: you wlan router might have 192.168.1.1, your PC might have
192.168.1.2. This means you could e.g use 192.168.1.10 and leave some
room for more PCs. If you use DHCP then make sure that the address it not
double allocated (exclude it from the DHCP range).
You need an avr-gcc development environment in order to compile this.
You need at least avrlibc-1.4.x !! The atmega88 will not work with earilier
version. For atmega328 you will need avrlibc-1.6.4 or higher.
To compile the final software use the command:
make
Note: windows users may use and modify the supplied winmake.bat to setup the
environment correctly. See details below on how to compile this under windows.
More information about Makefiles can be found at:
http://tuxgraphics.org/electronics/200912/makefiles.shtml
The command
make load
will execute the avrdude command to load the main.hex software
E.g something like:
avrdude -p m328p -c stk500v2 -e -U flash:w:main.hex
! Note your programmer might interfer 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 (fuse settings)
------------------------------------------------
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 m88 -c stk500v2 -u -v -U lfuse:w:0x60:m
or
avrdude -p m168 -c stk500v2 -u -v -U lfuse:w:0x60:m
or
avrdude -p m328p -c stk500v2 -u -v -U lfuse:w:0x60:m
or
avrdude -p m644 -c stk500v2 -u -v -U lfuse:w:0x60:m
The above command can as well be executed by using the make
file. In a Linux shell you can just type:
make fuse
Note: windows users may use and modify the supplied winsetfuse.bat script.
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 atmega328p are after programming
should be as below (default factory settings for atmega328p, the
efuse has some not used bits and is dependent on the chip revision):
lfuse reads as 0x60
hfuse reads as 0xD9
efuse reads as 0x07
Fuses of the atmega644/atmega644a after programming:
Device signature = 0x1e9609
lfuse reads as 60
hfuse reads as 99
efuse reads as FF
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 below list of fuses shows for reference purpose the settings
of a new and never programmed chip.
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
The result should be this (default factory settings for atmega644/atmega644a):
avrdude: Device signature = 0x1e9609
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as 99
avrdude: safemode: efuse reads as FF
Compiling on non-Unix systems
-----------------------------
Please use the provided Makefile !!!
It will also work under Windows.
Take a look at the supplied winmake.bat and winload.bat file. The bat script
might be needed to set the environment correctly.
Take a look at the supplied winmake.bat and winload.bat file. The bat script
might be needed to set the environment correctly in order to use
the Makefile under windows.
Edit the Makefile to make the needed adjustments at the top
of the file.
More information about Makefiles can be found at:
http://tuxgraphics.org/electronics/200912/makefiles.shtml
Using the webserver based Reboot/Reset button
---------------------------------------------
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 (default password is "secret"):
Ethernet reset/reboot button:
Password: [ ]
[reboot]
------------------------------
ver 2.16
Revision history
----------------
2008-08-31: version 2.12 -- First version of the reset pushbutton code. Based
on eth_rem_dev_tcp-2.11
2008-12-18: version 2.13 -- the stepcounter should be declared volatile
2008-12-27: version 2.14 -- adaptations for atmega328
2009-01-18: version 2.15 -- corrections to adaptations for atmega328
bug fixes for silicon B4 errate in enc chip.
2011-06-11: version 2.16 -- updated with new avr network library
# vim:sw=8:ts=8:si:et