A3504abstract

Document Sample
A3504abstract Powered By Docstoc
					Project #A3504 Circuit Cellar/ Atmel AVR Design Contest Abstract

The Internet has revolutionized the way we communicate. From sending e-mails that arrive at the recipient's inbox almost immediately, to the plethora of information instantly available on the web, the world has become a much smaller place. That same network of connectivity can also be used to provide real-time remote control and monitoring from within any two Internet accessible points in the world. PC’s have been a traditional solution to remote control and monitoring but that is changing since embedded web server modules have become commercially available. They are small, inexpensive and consume less power than complete PC installations. Unfortunately, these embedded web server modules are not end-user friendly as they often require an intermediate level of technical knowledge to add support circuitry as well as programming to make them work. Furthermore, they have limited I/O for interfacing with real-world devices. This is fine for techie types but not so useful for the general public. The goal of this project was to come up with an inexpensive remote Internet control and monitoring device that can be setup and operated by users with a minimal technical background. The AVR Ethernet I/O board with accompanying PC control software offers remote control of 4 relay activated devices and status monitoring of 4 opto-coupled inputs over the Internet. Remote control is accomplished using any web browser-abled computer, or by running the custom “Ethernet I/O Control Panel” Windows™ software on an Internet ready PC. Browser based access offers straightforward control of the relays and status monitoring of the opto-coupled inputs. The custom Control Panel software offers a few more features such as selectable on-off or momentary action of the relays and an audible WAV file alarm that is played on the remote PC whenever Input #1 is activated at the EIO Board. The alarm can be a simple beep or bell, or a more elaborative and descriptive user defined voice annunciation. Input and output labels can also be renamed by the user to be more descriptive. At the core of the hardware is the ATmega32 microcontroller which contains the necessary resources to store the code and data, and communicate with the peripheral components. The ubiquitous Realtek RTL-8019AS is used as the network interface controller (NIC) and a MAX232 level converter is used for RS-232 serial communication. A 74HC573 latch is connected to the ATmega32 to provide multifunction operation of Port A which is used as the data bus for the Realtek NIC, while four of the eight latched outputs are used to control the relays. The relays provide isolated normally-open dry contacts that are brought out to screw terminals. Four 4N25 optocouplers provide galvanic isolation and are also brought out to screw terminals. Software for the EIO board was written and compiled using Bascom-AVR. Web access uses the TCP protocol while the custom EIO Control Panel software communicates in the UDP protocol. The main routine of the firmware continuously loops to itself while waiting for an interrupt from the NIC controller. INT0 wakes up whenever a packet of data is received by the RTL-8019 and the incoming packet type is checked and then passed along to the appropriate handler routine. The data is extracted from the packet and tested to see if any action should be taken, like toggling a relay, fetching the I/O status, or updating the web page. The web based user interface is integrated into the ATmega firmware while the EIO Control Panel software was written in Visual Basic™.

The following is a snippet from the AVR Ethernet I/O code demonstrating the UDP handler and some routines that are called to toggle the relays.
' Routine to handle UDP-traffic ' Sub Udp Local Udp_port As Word Local Udp_porth As Byte Local Udp_portl As Byte Readeeprom Udp_porth , 11 Readeeprom Udp_portl , 12 Udp_port = Udp_porth Shift Udp_port , Left , 8 Udp_port = Udp_port + Udp_portl Triggerstr = "" Hulp1 = &HEA For Hulp2 = 1 To 20 Hulp3 = Peek(hulp1) Triggerstr = Triggerstr + Chr(hulp3) Incr Hulp1 Next Hulp2 'From within the VB-program If T_udp_destport = Udp_port Then Select Case T_udp_data Case &H01 : Call Relayon(1) Case &H02 : Call Relayon(2) Case &H03 : Call Relayon(3) Case &H04 : Call Relayon(4) Case &HA1 : Call Relayoff(5) Case &HA2 : Call Relayoff(6) Case &HA3 : Call Relayoff(7) Case &HA4 : Call Relayoff(8) End Select If Triggerstr = Triggerstring Then Call Lcdhome Lcd_t = "UDP request#Sending: " Call Lcd_txt Portpntr = Asc( "P") Tempstring = Bin(inputport1) Portval = Left(tempstring , 4) Lcd_t = "P" + Portval Relaypntr = Asc( "R") Tempstring = Bin(relaystatus) Relval = Right(tempstring , 4) Lcd_t = Lcd_t + "R" Lcd_t = Lcd_t + Relval Call Lcd_txt 'Build The Ip Header Call Setipaddrs 'swap the UDP source and destinations port Swap T_udp_srcport0 , T_udp_destport0 Swap T_udp_srcport1 , T_udp_destport1 Call Udp_checksum Call Write_rtl8019as(cr , &H22) Call Echopacket End If End If End Sub ' Routine to switch on relay X and update status ' Sub Relayon(x) Decr X Relaystatus.x = 1 Call Status End Sub

' Routine to switch off relay X and update status ' Sub Relayoff(x) X=X-5 Relaystatus.x = 0 Call Status End Sub

' Routine to switch on/off relay and get the status ' Sub Status Datadirection1 = &HFF Databus = Relaystatus Set Latch Reset Latch End Sub

5

4

3

2

1

EXAMPLE I/O

D

DOOR SWITCH

D

(COMPUTER 1)

(COMPUTER 2)

+
3-15VDC

ETHERNET I/O BOARD
-

LAN DEVICE 3

LAN DEVICE 2

4N28

WAN

H.S. MODEM

CABLE/ PHONE LINE

4N28
C

4N28

4N28

COMPUTER RESET SWITCH

RELAY

RELAY POWER

+ -

.

RELAY

.

RELAY

B

12VDC 7805

HIGH POWER DEVICE

RELAY

RELAY

A

Example I/O demonstrates some items that can be controlled and monitored by the Ethernet I/O board.

* Obey correct polarity on inputs. ** Relay outputs are N.O. dry contracts.
(NOT TO SCALE)
5 4 3 2

RS-232

.

MAX-232
B

E T H E R N ET

AVR ETHERNET I/O
74HC573

RTL8019
AVR ICSP RE SET

LAN DEVICE 1

C

ROUTER

ATMEGA

RS-232

.
+

.

-

Use a 12V "Wallwart" D/C converter with 2.1mm centrepositive barrel connector.

A

Title Size B Date:

Ethernet I/O Hookup Diagram
Document Number <Doc> Wednesday, June 23, 2004 Sheet
1

Rev 1 of 2

5

4

3

2

1

5V REGULATOR
P_IN 2.1mm COAXIAL 1N4006 C1 33uF/25V + +12V

+5V +5V V CC R1 1k

U1

D1

MC7805CT
1 3

J1
12VDC

R4 1K R5 +5V 1K R6 + 5V C5 0.1uF J4 1K +5V

(YELLOW) LED2 (GREEN) LED3 (RED) LED4
D

POWER IN
SCREW TERMINAL
D

1 2 2
C2 0.1uF

J16 5VDC

LED1

POWER

+ 5V

AVR ISP
1 3 5 7 9
+5V J2

+5V

2 4 6 8 10
SA0 SA1 SA2 SA3 SA4

C3 0.1uF

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 RESET VCC GND OSC1 OSC2 PD0 PD1 PD2 PD3 PD4 PD5 PD6

PA0 PA1 PA2 PA3 PA4 PA5 PA6

40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21

S D0 S D1 S D2 S D3 S D4 S D5 S D6 S D7 AR EF G ND V CC P C7 P C6 P C5 P C4 P C3 P C2 PC1/SDA PC0/SCL IOWB R26 10K R27 10K +5V

MISO S CK RST

80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51

C10 0.1uF S1

R8 100k

MOSI

2 3 4 5 6 7 8 9 11 1

D0 D1 D2 D3 D4 D5 D6 D7 LE OE

Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7

19 18 17 16 15 14 13 12

OP1 OP2 OP3 OP4 OP5 OP6 OP7 OP8

1 2 3 4 5 6 7 8 9 10

PORT A LATCHED OUTPUTS

U5

+5V

C4

0.1uF BD5 BD6 BD7 EECS

R7 200

+5V

Y2 20Mhz +5V C6

BD4 BD5 BD6 BD7 EECS BCSB BA14 BA15 BA16 BA17 VDD BA18 BA19 BA20 BA21 JP AUI LED2 LED1 LED0 LEDBNC TPIN+ TPINVDD RX+ RXCD+ CDGND OSCO

J3
9 8 7 6 5 4 3 2 1 10 SHLD CRX_INT TPINTPIN+ TPOUTTPOUT+ CTX_INT CRX_EXT CTX_EXT SHLD

U2 ATmega

PA7 AREF GND AVCC PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0 PD7

74HCT573

RESET

C11 0.1uF J6

V CC G ND OSC1 OSC2 RXD TXD

+5V

C7 0.1uF

R28 10K

R29 10K

EXT RST

J18

C

Y1 7.37 MHz

INT0 LE RSTDRV

C12 27pF

C13 27pF

P D5 IORB

INT0 SA0

SA1 SA2 SA3 SA4

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

INT3 INT2 INT1 INT0 SA0 VDD SA1 SA2 SA3 SA4 SA5 SA6 SA7 GND SA8 SA9 VDD SA10 SA11 SA12 SA13 SA14 SA15 SA16 SA17 SA18 SA19 GND IORB IOWB

R26-R29 NOT INSTALLED (FOR JTAG USE)

1 2 3 4 5 6 7 8 9 10

C14 0.1uF

+5V +5V

RS-232 POLARITY EXTERNAL EEPROM
R3 10K +5V C15 0.1uF

1 2 3

1 2 3

+5V J19

RS-232 LEVEL CONVERTER
16 15 14 13 12 11 10 9 VCC GND T1OUT R1IN R1OUT T1IN T2IN R2OUT C1+ V+ C1C2+ C2VT2OUT R2IN

C16 + 1µF

JP1 C17 1µF

JP2

1 2

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

BD3 BD2 GND BD1 BD0 GND SD15 SD14 VDD SD13 SD12 SD11 SD10 SD9 SD8 IOCS16B INT7 INT6 INT5 INT4

U3 RTL8019AS

OSCI TX+ TXVDD LD HD GND SD7 SD6 SD5 SD4 SD3 SD2 SD1 SD0 IOCHRDY AEN RSTDRV SMEMWB SMEMRB

50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31

0.1uF

RJ-45 ETHERNET CONNECTOR

PORT C I/O

S D7 S D6 S D5 S D4 S D3 S D2 S D1 S D0 RSTDRV

2 1

C8 0.1uF

C9 0.1uF

LF1S022
R9 22k +5V PIN P_IN
C

J15

P1
RS-232 TXD RS-232 RXD

I2C
B

1 2 3 4

R2 10K PC1/SDA PC0/SCL

U6
8 5 6 +5VDC SDA SCL A0 A1 A2 NC GND 1 2 3 7 4

J5

+12V

RELAY OUTPUT 1
COM

+12V J7 TERMINAL R19 2K D3 1N4006

RELAY OUTPUT 2
COM NO

+12V J8 TERMINAL R20 2K D4 1N4006

RELAY OUTPUT 3
COM NO

+12V J9 TERMINAL R21 2K D5 1N4006

RELAY OUTPUT 4
COM NO

R18 2K D2 1N4006

1 2 3 4 5 6 7 8 9

24LC256

UNUSED RS-232 I/O

U4 MAX232E

NO

LED5

COM NC NO

1 2 3

K1 2nd POLE

LED6

COM NC NO

1 2 3

K2 2nd POLE

LED7

COM NC NO

1 2 3

K3 2nd POLE

LED8

1

1

1

1 2 3

K4 2nd POLE

OP1

R10 1K

Q1 2N2222A

OP2 RELAY DPDT

R11 1K

K1

Q2 2N2222A

OP3 RELAY DPDT

R12 1K

K2

Q3 2N2222A

OP4 RELAY DPDT

R13 1K

K3

Q4 2N2222A

GROUND VIAS
RELAY DPDT

K4

VIA1 CON1

VIA2 CON1

VIA3 CON1

VIA4 CO N1

1

1

1

A

1

1

+5V

+5V

+5V

+5V

OPTO INPUT 1
R22 10K P C4 U7 LED9 R14 1K D6 5 .1v J11 TERMINAL R23 10K P C5 U8

OPTO INPUT 2
LED10 R15 1K D7 5 .1v J12 TERMINAL R24 10K P C6 U9

OPTO INPUT 3
LED11 R16 1K D8 5 .1v J13 TERMINAL R25 10K P C7 U10

OPTO INPUT 4
LED12 R17 1K D9 5 .1v J14 TERMINAL

1

1

1

6 5 4
4N25

1

+

6 5 4
4N25

1

+

6 5 4
4N25

1

+

6 5 4
4N25

1

+

2

-

2

-

2

-

2

-

Title Size C Date:

AVR ETHERNET I/O SBC
Document Number

1

5

4

3

2

+

1 2 3 4 5 6 7 8

+

C18 + 1µF

C19 1µF

GND

1 6 2 7 3 8 4 9 5

RS-232 DB-9 FEMALE

B

DB-9 BREAKOUT

J10 TERMINAL

MOUNTING HOLES
MH1 CON1 MH2 CON1 MH3 CON1 MH4 CO N1

COM NC NO

VIA5 CON1

VIA6 CON1

VIA7 CON1

VIA8 CO N1

A

02/04-001
Sheet
1

R ev 1 of 1

Wednesday, June 23, 2004


				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:59
posted:10/20/2009
language:English
pages:6