Avr Webserver Isactrl
  • Minicom Settings [Ctrl-A Z] for serial port:

9600 Baud 8N1

  • Minicom start:

minicom -D /dev/ttyS0

===AVR Webserver===

  • IP:
  • Compile and program (with STK500 on /dev/ttyS0):

make clean
make all
make program

  • In recent AVR Libc versions, some port-declarations changed. For example the "iomxx4.h": SPCR0 is now SPCR. For the V1.40 weserber sourcecode for ATMega644, the "mmc.h" has to be corrected to match the new lib (just see the commented defines):

#if defined (AVR_ATmega644)
#define SPI_DI 6 //Port Pin an dem Data Output der MMC/SD-Karte angeschlossen ist
#define SPI_DO 5 //Port Pin an dem Data Input der MMC/SD-Karte angeschlossen ist
#define SPI_Clock 7 //Port Pin an dem die Clock der MMC/SD-Karte angeschlossen ist (clk)
#define MMC_Chip_Select 3 //Port Pin an dem Chip Select der MMC/SD-Karte angeschlossen ist
#define SPI_SS 4 //Nicht Benutz muß aber definiert werden
//#define SPCR SPCR0
//#define SPE SPE0
//#define MSTR MSTR0
//#define SPSR SPSR0
//#define SPDR SPDR0
//#define SPIF SPIF0
//#define SPR0 SPR00
//#define SPR1 SPR01
//#define SPI2X SPI2X0

  • Modifications of sourcecode for switching Port high or low:

In "index.asp" on SD-card add:
<form method="get" action="">
<input type="radio" name="b12.0" value="1" >
<input type="radio" name="b12.0" value="0" >
<input name="submit" type="submit" value="Senden">

In "main.c" add:
if (vars.type_char[12] & 0x01) //Bit0
PORTD |= (1 « 6);
PORTD &= ~(1 « 6);

  • Understanding index.asp and httpd.c

Input values from website to webserver (index.asp —> httpd.c) e.g. to trigger an output via a radio button:
<pre> <input type="radio" name="b12.0" value="1" > </pre>
'b': Byte (could also be 'w' for a 16Bit integer)

'12': Adress for the BYTE in the array vars.type_char[12], here its the 13th byte (starting with [0])

'.': indicates the request for an input

'0': Position of the BIT inside the adressed BYTE (here it is BIT 0 in BYTE 12)

Output values from webserver to website (httpd.c —> index.asp) e.g. to show temperature of temp. sensor:
<pre> <p align="center">‘b2:u`.`b3:1u`</p> </pre>
’b': Byte (could also be 'w' for a 16Bit integer)

'12': Adress for the BYTE in the array vars.type_char[12], here its the 13th byte (starting with [0])

':': indicates the request for an output

'1u': format string for the output "u"=unsigned int, "1u"=unsigned int with precision 1, "i"=signed int (see http://en.wikipedia.org/wiki/Printf_format_string)

  • Modifications of source-code for using a NTC (different temperature function than KTY81) and reading out negative temperatures via index.asp. For information on NTC characterization and calculations see http://de.wikipedia.org/wiki/Hei%C3%9Fleiter)

Changes in analog.c (added new variables, commented out original code):

void GetTemperature(void)
int tmp;
double temperature;
double Vss=5; //reference voltage for ADC
double Rref=10000; //Reference resistor for voltage divider at ADC input
double RN=10000; //Resistance of NTC at 25deg (298,15 Kelvin)
double TN=298.15; //Reference Temp for RN
double B=3850; //B-factor for NTC characterization
double U_ntc;
double R_ntc;

for (unsigned char i=0;i<3;i++)
vars.type_int[i*2] = ReadADC(5 + i);
temperature = ((B*TN)/(B+log(R_ntc/RN)*TN))-273.15;
vars.type_int[i*2+1]= (int)(temperature);

Changes in index.asp (readout integer values to also show negative values):
<td><p align="center">AN5 <BR><BR></p> </td>
<td width="120"><p align="center">`w0:4u`</p>
<img src="blue.gif" width="`b2:u`" height="10"></td>
<td><p align="center">`w1:3i`</p> </td>

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License