eZ80 Webserver Development Notes
Embedded Security System
JLAs Home Page
Electrical Engineering
Technology
Broome
Community College
You are visitor number since November 2001.
|
The official eZ80 Webserver User Group website is under construction. If you would like to submit material to be posted on the website, visit www.ez80usergroup.com for more information. |
|
![]() |
Here is the security system mounted on two pieces of plywood. It sits on the computer desk in my office. At lower left is the laptop containing the ZDS, where I compile the project and download it into the eval board. I also use IE on this laptop to display the web pages generated by the eval board. At right is a laptop connected to the console output. Whenever a door changes state, a message showing the door, its new position (open/closed), and the time/date is output to the console. The door number (ex: 217) and a small o/c is output to the 7-segment display for 2.5 seconds. |
Introduction
This page contains tips and techniques, code, and other useful items related to my eZ80 Webserver conversion project. I am converting a Visual C++ Win32 network-based security system application (which runs on a PC) over to an embedded application running on the eZ80 Webserver.
Some initial progress on the project was reported in my January 2002 Circuit Cellar Online article. It is available at www.chipcenter.com. The information is duplicated here, with some simple changes.
November 2001
During this month, I accomplished the following:
FORM method="post" ACTION="/cgi-bin/doors"
There must be a file called doors_cgi.c added to the project to process the CGI request.
December 4, 2001
Major breakthrough today! Got my 4-digit 7-segment display working! It is controlled by three bits on my output port. Initially, I simply output the pattern to spell 'HELP' on the display, but then wrote a loop to output a decimal count from 0000 to 9999. Some intermittent flashing was eliminated by adding a few NOPs after each output instruction. Note: it is important to use the OUT0 instruction, not the OUT instruction, to access external I/O ports correctly.
The 7-segment display module contains four common-anode 7-segment displays. Each display is driven by its own 8-bit shift register. Thus, the entire display is controlled by outputting a serial bit stream of 32 bits in the following format:
The code to output the HELP message looks like this:
static int dtab[] = {0,1,1,1,0,0,1,1, // P
0,0,1,1,1,0,0,0, // L
0,1,1,1,1,0,0,1, // E
0,1,1,1,0,1,1,0}; // H
for(y = 0; y < 4; y++)
for(x = 0; x < 8; x++)
wxd(dtab[y][x]);
lat();
Each time the wxd() function is called, one bit is output to the display. This is done by wiggling the bits on output port 3C.
void wxd(int b)
{
if(b)
{
_asm("\t ld a,6");
_asm("\t out0 (%3c),a");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t ld a,4");
_asm("\t out0 (%3c),a");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t ld a,6");
_asm("\t out0 (%3c),a");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
}
else
{
_asm("\t ld a,7");
_asm("\t out0 (%3c),a");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t ld a,5");
_asm("\t out0 (%3c),a");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t ld a,7");
_asm("\t out0 (%3c),a");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
}
}
I discovered, through trial-and-error, that I needed to use NOPs after each OUT0 instruction to get reliable outputs to my hardware. This is due to the fact that the eZ80 is running at 40 MHz, making the OUT0 last only 25 ns. With the inverters, NAND gate, and OR gates eating up 15ns to 20ns, you may agree that I was cutting it close regarding the setup time for the 374 latch.
The lat() function outputs a latch pulse to the 7-segment display module, updating all displays at the same time to avoid flickering.
void lat()
{
_asm("\t ld a,7");
_asm("\t out0 (3ch),a");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t ld a,3");
_asm("\t out0 (3ch),a");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t ld a,7");
_asm("\t out0 (3ch),a");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
_asm("\t nop");
}
Since CS3 is the only programmable wait-state generator output free to use, I incorporated it into my hardware to extend the cycle time of the OUT0 instruction. Here are the statements I used to program it:
_asm("\t ld a,3");
_asm("\t out0 (%b1),a");
_asm("\t ld a,3");
_asm("\t out0 (%b2),a");
_asm("\t ld a,%f8");
_asm("\t out0 (%b3),a");
December 5, 2001
Wrote a subroutine to output a room number, followed by an 'o' or 'c', to the display board. For example, when room 217s door closes, the display reads 217c. When door 215 opens, the display shows 215o. Here are the data tables for the numeric digits 0 through 9, as well as the 'o' and 'c' letters:
static int nums[10][8] = {
{0,0,1,1,1,1,1,1}, // 0
{0,0,0,0,0,1,1,0},
{0,1,0,1,1,0,1,1},
{0,1,0,0,1,1,1,1},
{0,1,1,0,0,1,1,0},
{0,1,1,0,1,1,0,1},
{0,1,1,1,1,1,0,1},
{0,0,0,0,0,1,1,1},
{0,1,1,1,1,1,1,1},
{0,1,1,0,1,1,1,1} // 9
};
static int opcl[2][8] = {
{0,1,0,1,1,1,0,0}, //little o
{0,1,0,1,1,0,0,0} //little c
};
January 3, 2002
I had to take some time off due to other pressing activities, but am now working to complete the security system software. I've added sample code and schematics to the above material, as well as additional comments.
January 7, 2002
New accomplishments:
To launch dsniff() as a thread, I used the following statements in main.c:
pid = create(dsniff, 1024, 20, "DoorSniffer", 0);
kprintf("Starting dsniff() thread [%d]...\n",pid);
resume(pid);
Januray 9, 2002
I've been cleaning up the source code and standardizing the look of the web pages. Click on any of the following to examine a page and its associated code.
The system is now working at my home. Next week I'll take it to my office at the college and install all the hardware in its cabinet, and do the final testing. After I am satisfied that it is working correctly (I always forget if a door switch is a zero for open or a one for open), I'll post the entire set of project files.
January 18, 2002
I added a photo of the security system prefab board to the beginning of this web page. Then I took the system apart and began mounting it on the wall in my laboratory. Holes need to be made in the chassis of the mounting to allow for the console, ZPAK, and UTP cables. Hopefully, this will accomplished next week and the final test/debug can take place. My semester begins on the 22nd and my fourth child is 2 days overdue, so I may not post anything for a week or so.
May 30, 2002
See how one week can easily stretch to four months in the blink of an eye? I am finally able to get back to this project and will be using a student worker to do mechanical mods to the security enclosure. Hopefully, we'll be up and running by the end of June.
Last updated May 30, 2002 by JLA