Low cost serial to Wi-Fi interface for TERN controllers Technical Manual 1950 5 th Street, Davis, CA 95616, USA Tel: 530-758-0180 Fax: 530-758-0181 Email: sales@tern.com http://www.tern.com
COPYRIGHT WiFi-Adaptor, TDU, A-Engine and ACTF are trademarks of TERN, Inc. Am186ES is a trademark of Advanced Micro Devices, Inc. XBee and XBee-PRO are registered trademarks of Digi, Inc. Paradigm C/C++ is a trademark of Paradigm Systems. Microsoft, Windows, Windows98/2000/ME/NT/XP are trademarks of Microsoft Corporation. IBM is a trademark of International Business Machines Corporation. Version 1.02 July 12, 2012 No part of this document may be copied or reproduced in any form or by any means without the prior written consent of TERN, Inc. 1993-2012 1950 5 th Street, Davis, CA 95616, USA Tel: 530-758-0180 Fax: 530-758-0181 Email: sales@tern.com http://www.tern.com Important Notice TERN is developing complex, high technology integration systems. These systems are integrated with software and hardware that are not 100% defect free. TERN products are not designed, intended, authorized, or warranted to be suitable for use in life-support applications, devices, or systems, or in other critical applications. TERN and the Buyer agree that TERN will not be liable for incidental or consequential damages arising from the use of TERN products. It is the Buyer's responsibility to protect life and property against incidental failure. TERN reserves the right to make changes and improvements to its products without providing notice.
Chapter 1: Introduction Chapter 1: Introduction 1.1 Functional Description The WiFi-Adaptor is designed to provide a serial to Wi-Fi (802.11b) wireless networking solution for TERN controllers. The WiFi-Adaptor incorporates a WiFi210 wireless network module from WizNet. It can be driven by an RS232 serial port or a TTL UART at 115,200 baud. Data and configuration communication is supported by simple AT commands. Compatible TERN controllers include AE, EE, RE, TDU, 586E, or any TERN board with a TTL or RS232 UART. Features: * Provide WiFi (802.11b) ability to a TERN controller * Convert WiFi to RS232 or TTL UART * Operate a TERN controller with ipad or iphone * 2.03 x 1.21 inches, 135 ma at 5V DC power WiFi-232 TM WiFi210 TM Wi-Fi Module TERN Controller RS232 RS232-UART J1 RS232 Driver U3 WiFi-TTL TM TTL-UART Interface TERN Controller TTL-UART TTL-UART J2 Figure 1.1 WiFi-Adaptor TM Functional Diagram 1-1
Chapter 1: Introduction Physical Description Below shows the physical layout of the WiFi-Adaptor TM. RS232 Driver WiFi210 Wi-Fi Module J1 RS232 Header U.FL Antenna Connection Figure 1.2 WiFi-232 TM J2 TTL Header WiFi210 Wi-Fi Module U.FL Antenna Connection Figure 1.3 WiFi-TTL TM 1-2
Chapter 1: Introduction Figure 1.4 WiFi-232 TM + TDU Figure 1.5 WiFi-232 TM + BE + VE232 1-3
Chapter 1: Introduction Figure 1.6 WiFi-232 TM + BE + VE232 + D32 1-4
Chapter 1: Introduction Figure 1.7 WiFi-TTL TM + BE 1-5
Chapter 2: Installation Chapter 2: Installation 2.1 Software Installation Please refer to the software_kit.pdf technical manual on the TERN installation CD, under tern_docs\manual\software_kit.pdf, for information on installing software. 2.2 Hardware installation The WiFi-Adaptor TM can be connected to a TERN controller directly via a 10-pin ribbon connector. WiFi-232 TM versions will connect to the RS232 port of the TERN controller. WiFi-TTL TM versions will connect to the TTL UART pins of the TERN controller. Note: The WiFi-Adaptor TM is powered by 5V from the TERN controller. Additional wiring may be required to route 5V to VIN pin-1 on J1 or J2 on the WiFi-Adapptor TM. Figure 2.1 WiFi-232 TM connected to B-Engine + VE232 2-1
Chapter 2: Installation VE232 H1 pin 2 = VCC wired to VE232 J3 pin 1 = VIN on WiFi-Adaptor TM Figure 2.2 WiFi-232 TM 5V = VIN Power Connection 2-2
Chapter 2: Installation Figure 2.3 WiFi-TTL TM connected to B-Engine at header J2 2-3
Chapter 3: Hardware Chapter 3: Hardware 3.1 Introduction The WiFi-Adaptor is designed to provide a WiFi solution for TERN controllers. The WiFi-Adaptor supports a WizFi210 wireless module from WizNet. It can be driven by an RS232 serial port or a TTL (5V or 3.3V) UART at 115200 baud. Compatible TERN controllers include AE, EE, RE, i386e, 586E, or any TERN board with a TTL- UART or an RS232 UART. 3.2 WizFi210 Features The WizFi210 is a fully certified module that offers a quick, easy, and cost effective way to add Wi-Fi capabilities to TERN controller products. The module provides a serial UART interface which enables connection to any of TERN s controllers. The WizFi210 is an ideal solution for organizations with limited or no Wi-Fi or RF expertise, as it not only dramatically reduces RF design time but also removes the burden of testing and certification; allowing customers to focus on their core application, product, or expertise. The module supports data rates up to 11 Mbps, and is compliant with 802.11b. Features: Brings Wi-Fi connectivity to any device with a microcontroller and serial HOST interface (UART) Minimal Serial to Wi-Fi driver footprint on host microcontroller and minor changes to existing host MCU firmware Offloading of smaller host microcontrollers from the Wi-Fi and TCP/ IP networking Simple AT commands for configuration and data communication DHCP/Static IP, TCP/UDP, Server/Client, DNS Reduces development time, testing and certification burden, accelerating time to market Easy device provisioning through our utility or Wi-Fi Protected Set-up (WPS) Ultra low power consumption through dynamic power management Operates with standard 802.11 b/g/n access points at speed up to 11 Mbps (802.11b) 802.11i Security (WEP, WPA, WPA2-PSK, Enterprise) Rich I/O interfaces (SPI, UART, GTTL, I2C, ADC, JTAG) Low power modes, Alarm Input for wake-up High-throughput hardware AES and RC4 encryption/decryption engines Limited AP Feature (Direct Connection to iphone, ipad and Android-Phone without AP) 3-1
Chapter 3: Hardware 3.3 Wireless Interface TERN controllers can interface the WiFi-Adaptor either directly via TTL-UART with the WiFi-TTL or over an RS232 serial cable with the WiFi-RS232 WiFi-232 The WiFi-232 version of the WiFi-Adaptor connects using an onboard RS232 converter. The controller communicates with the WiFi-232 module over RS232. WiFi-232 TM RS232-UART WizFi210 TM Wireless Module TERN Controller RS232 Header TX-RS232 RX-RS232 J1 RS232 Converter TXD RXD UART Interface Figure 3.1 WiFi-232 TM WiFi-TTL The WiFi-TTL version of the WiFi-Adaptor connects directly to the UART on the WizFi210 module. The controller communicates with the WiFi-TTL module over a 0-5V or 0-3.3V UART connection. WiFi-TTL TM WizFi210 TM Wireless Module TERN Controller J2 Header TX-TTL RX-TTL J2 TXD RXD UART Interface Figure 3.2 WiFi-TTL TM 3.4 Power Supply The WiFi-Adaptor has an on-board 3.3V linear regulator by default. The linear regulator requires 5VDC input at pin VIN, J1 pin 1 or J2 pin 1. 3-2
Chapter 4: Software Chapter 4: Software 4.1 Introduction The WizFi210 chip is controlled by series of AT commands**. All of the Wi-Fi overhead is managed by the module and transparent to the user. The commands are used to set up the mode of the module and communicate data. The module can be configured to communicate with an existing wireless network or can act as a limited access point and allow devices to connect to it. Sample programs/projects for the WiFi-Adaptor TM can be found in the following directories depending on your controller: c:\tern\186\samples\wifi c:\tern\386\samples\wifi c:\tern\586\samples\wifi ** See WizFi210 User Manual for AT command reference 4.2 Wi-Fi Wireless Network In a typical Wi-Fi network setting, the WiFi-Adaptor TM logs into a wireless router. The WiFi-Adaptor TM can either use a static IP address or request an IP address from the wireless router. Once it has an IP address, the module can create a TCP server socket, which listens for incoming TCP requests, or a TCP client socket that establishes a connection to a TCP server. The figure below illustrates a Wi-Fi network with multiple WiFi-Adaptors TM configured as TCP clients connecting to a WiFi-Adaptor TM configured as a TCP server. Wi-Fi Network TCP Server TCP Clients Figure 4.1 Standard Wi-Fi Network 4-1
Chapter 4: Software TCP Server The following AT commands establish WiFi-Adaptor TM as a TCP server at port 5000 // Connect to TERNTEST WIFI network, password TernTest AT AT+WWPA=terntest // wifi network password AT+NDHCP=1 // enable dchp for dynamic ip address AT+WA=TernTest,,0 // wifi network name (ssid) //After connected to WIFI network, set as TCP Server "AT+NSTCP=5000" // Start a TCP server listening on port 5000 Figure 4.2 TCP Server Sample wifi_server.c Sample program wifi_server.c in the WiFi sample directory demonstrates creating a TCP server. Watch the following variables: wifi_data, wifi_ip, connect_id[0], and connect_id[1]. 4-2
Chapter 4: Software TCP Client The following AT commands establish WiFi-Adaptor TM as a TCP client: // Connect to TERNTEST WIFI network, password TernTest AT AT+WWPA=terntest // wifi network pasword AT+NDHCP=1 // enable dchp for dynamic ip address AT+WA=TernTest,,0 // wifi network name (ssid) //After connected to WIFI network, create client socket "AT+NCTCP=192.168.1.145,5000" // TCP client connection to 192.168.1.145 port: 5000 Auto Connection Auto connection mode acts as a cable replacement insofar that the interface acts like a serial interface and no commands or user intervention are required for connection management. In this mode, the WiFi-Adaptor TM transfers data transparently between the Host and Target in data mode. No status information is sent to the controller. Auto Server Connection AT+WWPA=terntest // wifi network password AT+NDHCP=1 // enable dchp for dynamic ip address AT+WAUTO=0,TernTest,,0 // wifi network name (ssid) AT+NAUTO=1,1,,5001 // TCP server, listen on port: 5001 ATA // start server auto connection Auto Client Connection AT+WWPA=terntest // wifi network password AT+NDHCP=1 // enable dchp for dynamic ip address AT+WAUTO=0,TernTest,,0 // wifi network name (ssid) AT+NAUTO=0,1,192.168.1.225,5042 // TCP client connection to 192.168.1.225 port: 5042 ATA // start client auto connection 4-3
Chapter 4: Software 4.3 Wi-Fi Limited Access Point The WiFi-Adaptor TM can also act as an access point for other wireless devices such as iphones, ipads and Android Smart Phones. As an access point, devices can log into the WiFi-Adaptor TM and communicate with it. It is considered limited because the WizFi210 can only manage a few connections at a time. Once a device is connected, telnet software or specifically designed software can communicate with the TERN controller via TCP/IP. Limited Access Point Wi-Fi Access Point Figure 4.3 Limited Access Point The following commands establish a limited access point named LimitedAP // Create limited access point LimitedAP AT+WM=2 // operating mode 2 = limited AP AT+WAUTH=1 // authentication = open AT+WWEP1=1234567890 // wep key = 1234567890 AT+NDHCP=0 // disable dhcp AT+NSET=192.168.55.1,255.255.255.0,192.168.55.1 //static ip address, mask and gateway AT+WA=LimitedAP,,8 // set network name = LimitedAP, channel = 8 AT+DHCPSRVR=1 // enable dhcp server to assign ip addresses AT+NAUTO=1,1,,5000 // enable auto connect as tcp server, port 5000 ATA2 // start auto connect See sample program s1_ipad.c in the WiFi sample directory. 4-4
VIN /RXD /TXD GND VIN RXDH TXDH GND J1 HDRD10 1 2 3 5 4 6 /RTS /CTS 7 8 9 10 J2 HDRD10 1 2 3 4 RTSH 5 6 CTSH 7 8 9 10 V33 C5 CAPNP C1-3.3V MAX3232 U3 C1+ 1 V+ 2 C1+ C1-3 V+ C2+ 4 C1- C2-5 C2+ V- 6 C2- /TXD 7 V- 8 T2O /RXD R2I MAX232D MAX232D R1 RXDH RXD 1K VCC 16 GND 15 T1O 14 R1I 13 R1O 12 T1I 11 T2I 10 R2O 9 R2 2K INSTALL R2 FOR 5V PIO R4 TXDH TXD 1K R5 2K V33 GND /RTS /CTS CTS RTS TXD RXD C1+ C2+ C2- V+ GND V- C2 CAPNP C3 CAPNP C6 CAPNP C7 CAPNP RN1 RN10S1 RN10S1 10 L_AP 9 P28L 8 P30L 7 P31L 6 COM/D 5 ALM1 4 P/RUN 3 /RST 2 LED 1 V33 J3 HDRD10 COM/D 1 2 ALM1 3 4 P/RUN 5 6 /RST 7 8 L_AP 9 10 GND LED G1 LED RESV G2 P28L P28 WIFI ASSOCIATE LED RESV G3 P30L P30 UART-RXD LED RESV G4 P31L P31 UART-WIFI LED RESV INSTALL R5 FOR 5V PIO U1 WIZFI210 D1 VIN +5V 1N5817 C1 10UF35V ALCAP2 R6 RTSH RTS 1K R7 2K INSTALL R7 FOR 5V PIO R8 R9 CTSH CTS 2K 1K INSTALL R9 FOR 5V PIO U2 GND 1 V33 2 GNG +5V 3 VO VO VI BB1117 4 V33 C4 10UF35V ALCAP2 GND 1 2 3 4 5 6 ALM1 7 8 V33 9 10 11 12 13 14 15 16 V18 17 GND 18 C8 CAPNP E_ANT 49 GND GND 48 GND P28 J_TCK WIFI210 P28 47 COM/D J_TDO P29 46 P30 J_TDI P30 45 J_TMS P31 44 J_NTRST P24 43 P31 ALARM1 P0 42 CTS RTC_O P25 41 RXD VBAT P1 40 RTS DC_CNTL P2 39 TXD ALARM2 P3 38 ADC1 P27 37 ADC2 P26 36 P/RUN WIFI210 P6 EX_RST 35 P7 VDDIO 34 /RST P5 EN_V18 33 V33 S P S V18 S I P SV33 32 GND P P P GND 31 C9 P _ I P GND CAPNP P P I C _ I P 1 P 1 1 2 2 P _ L C _ 4 3 9 0 9 0 1 8 O K S I 1 2 2 2 2 2 2 2 2 2 2 3 9 0 1 2 3 4 5 6 7 8 9 0 L_AP TERN Title WIZFI210, RS232 Size Document Number REV B WIFI.SCH Date: May 29, 2012 Sheet 1 of 1