|
|
ABOUT PICNIC |
| ■ABOUT PICNIC 4. Exclusive control protocol for PICNIC
→Click here if you have some questions and comments. ←Back to the table of contents
Updated April 29, 2005 21:54
|
●Overview of PICNICWhat is PICNIC?/Features & Circuit Diagram/Necessary items for operation check/PICNIC Specifications 1.1.1 What is PICNIC?The name "PICNIC" comes from taking the initials of "PIC Network Interface Card", which is an I/O board kit to connect to Ethernet networks using the PIC microcomputer chip, Microchip PIC16F877. Compared to the previous ver. 1 kit, the ver. 2 which we are going to use here is more compact: 70mm x 100mm. (see Pic. 1) →Links to Microchip PIC series
Picture 1: network featured PIC microcomputer, PICNIC ver 2
PICNIC is a product of TriState and can be purchased from Akizuki Denshi Tsusyo. →Links to Akizuki Denshi Tsusyo By preparing an application program that can control PIC microcomputer's parallel I/O ports via a network, we can easily build systems to control the power of a peripheral device connected to the kit or collect data from various sensors. Controlling and observing parallel I/O ports via a network can be done through the http-server of the firmware of a PIC microcomputer. So, if we have a web browser on any kind of operating system, we can control the attached device without any programming. The network interface uses the Ethernet protocol. So we can build any experimental environment by simply preparing Ethernet network devices (such as hubs, etc.) and cables, which are cheaply and easily available on the market. Note, external networks (WAN or Internet connections) will require connections like ADSL, CATV which can access the global Internet. However, by building PICNIC control protocol on the client, a dedicated system which does not use a web-browser can also be built. The library for controlling the system can be downloaded from TriState's web site. 1.1.2 Features & Circuit Diagram* Uses PIC16F877 manufactured by Microchip (RISC Enhanced x16, DIP300/40pin CMOS Flash 8bit microcontroller, 87x series). → Data sheet (original) here * Uses NE2000(DP8390) compatible RTL-8019AS by Realtek Semiconductor (10BASE-T 100pin/QFP one-chip Ethernet controller, crab chip). * Main LSI, chip resistors, capacitors already soldered to circuit board. Simple kit assembly involving only implementation of connectors, DIP-IC sockets, I/O connectors, LEDs, etc.
<Figure 1> Functional block diagram <Figure 2> Circuit diagram(reprinted from ※ TriState company data sheet) ※ Additional notes* The PIC16F877 controller provides analog input pins on the RA port and general (digital) I/O pins on the RB port outside of the board. The input/output terminals are the CN2 connector (26 pin 100mil pitch) in the circuit diagram. * The output (temperature coefficient +10.0mV/degree Celsius) of the linear temperature sensor IC (LM35DZ) implemented on the board is connected to the analog input pin RA5. In this way, it is possible to monitor temperature (approximate room temperature) around the board. * If we connect the LCD module (option) to connector CN5, it will be shared with digital output port RB connector CN2 and number of external ports that can be used will be decreased. * In the serial EEPROM 93C46(U2), the unique MAC address for the EthernetNIC controller of this PICNIC is preset. * Jumper SW JP2 on the board is used to select whether to start in "normal mode" or "boot strap mode (initial setting)" on power up. 1.1.3 Necessary items for operation check* (AC adapter for)DC12V power supply (Akizuki DC12V adapter recommended) * PC with 10BASE-T NIC(for checking in bootstrap mode, connection by RS-232C serial interface is necessary)(Picture 2) * Ethernet hub (HUB) device and straight cables (2). * For one-to-one connections only, cross cables can be used. * Web browser * For firmware development, an MPLAB (MPASM) development environment and a PIC writer device are necessary. * For development using client-side drivers, a language development system such as Visual BASIC, Visual C++, GNU gcc, etc. is necessary.
<Picture 2> Connection of PC and operation check If the board is operating correctly, connecting from a browser will show this type of page. 1.1.4 PICNIC Specifications* Communication method: Ethernet 10BASE-T * Access method: CSMA/CD * Ethernet NIC: RTL-8019AS(NE2000 compatible) * Control CPU: PIC16F877-20/P(20MHz clock drive) * Built-in interface: * Built-in firmware protocols: ARP, DHCP, ICMP, IP, UDP, TCP, HTTP(GET method only) * Communication buffer: 16Kbyte(shares ring buffer in EthernetNIC) * Default IP address: 192.168.0.200/24 * Peripheral functions: RS-232C serial interface (SP232ACP), temperature sensor (LM35DZ), 16x2 LCD display module(SC1602B, option) * LED display: Input/output port output port states x4ch, Ethernet - NIC state LEDx3(TX,RX,LINK) * Power supply: DC 8-12V 100mA ●PICNIC FirmwareBuilt-in protocol stacks in firmware/Firmware downloading/Outline of firmware/Initial configuration sequence of firmware 1.2.1 Built-in protocol stack in firmwareThe protocol stack implemented in the firmware of this PICNIC is as follows. * Ethernet frame Tx/Rx processing 1.2.2 Firmware downloadingDownload the firmware (ver1.2) for MPASM assemblers for PICNIC ver.2 below. 1.2.3 Outline of firmwareThe size of the entire firmware code is 7380 lines. Lines 21-37: Definition of various constants Line 470: Program start point(ORG 0) Lines 820-889: Main loop Lines 902-1018: Ethernet frame Rx processing(RTL8019AS buffer management) Lines 2328-2393: A/D conversion input processing Lines 2771-3032: Initialization of RTL8019AS Lines 3352-3578: UDP → parallel I/O control, A/D conversion functions Lines 3879-4024: Socket management Lines 4295-4369: EEPROM data writes Lines 4379-4548: URL designated CGI analysis processing Lines 4651-4919: Startup routine(configurations on power up) Lines 5297-5404: Boot strap mode / initialization routine Lines 5952-6056: Notification processing for current socket status(currently unused) Lines 6139-6266: Processing for displaying acquired IP address to LCD panel Lines 6273-6424: Processing for serial port → UDP message Tx Lines 7061-7258: Web browser HTML reply message / format storage area
Because of the limitations on Ethernet frame length, we cannot send the entire HTML format text all at once. Instead, we break the text into four blocks (four transitions from ESTAB0 to ESTAB9) for sending. This transmission processing is implemented as a TCP packet processing sequencer from line 1690. To allow for recovery from various freeze states of protocol processing such as Ethernet cable or network disconnection, an automatic reset function is implemented in the timer interrupt routine. For example, after a freeze, the system is designed to force a return to the TCP LISTEN state after about 15 seconds. The PICNIC works as a simple HTTP server and based on the request from a web browser, the parameters contained in a URL are first analyzed, saved to the PIC internal EEPROM, and then each of the various external interfaces are controlled. After that, the currect PICNIC information (HTML text above) is sent to the browser. 1.2.4 Firmware initialization sequenceThe sequence of the firmware startup routine (configurations on power up, from line 4651) is as follows. (1) The necessary data for initialization (IP address, etc.) are copied from the built-in EEPROM to the RAM (2) Initialization of the LCD (liquid crystal display) panel (3) Initialization of EthernetNIC(RTL8019AS), loading of CONFIG register to NIC (4) MAC address acquisition from external serial EEPROM 93C46 (5) Writing of MAC address acquired in(4)to the PAR register of NIC (6) Confirmation of the operation mode from jumper SW state (normal or boot strap). Enter main routine of the indicated mode. (7) If IP address acquisition (IP =0.0.0.0) from a DHCP server is necessary, send out a DHCP protocol DISCOVER broadcast message. ※ When the above processing is completed, enter a wait for Rx frame state. ●Usage of PICNICRemote input/output control from a web browser/LCD module/Test program using an exclusive control protocol 1.3.1 Remote input/output control from a web browserIn Fig. 3, we see the screen shown when we connect to the IP address assigned to the PICNIC using Microsoft Internet Explorer via Ethernet.
<Figure 3>An example of the remote input/output control screen using a web browser (HTML version) The remote input/output control screen is divided roughly into three sections described below. (1) Input/output Ports sectionThe current states of the input/output ports are displayed. Since the values are not updated in real time, to obtain the current readings, we need to use the [Reload/refresh] button of the browser or we can click the [Reload] button at the bottom of the section. For the port states, the following information is displayed: analog input ports (RA0 to RA3), temperature sensor value (RA5, centigrade value), input and output states of digital input/output ports. Changing of the output values can be controlled only for the ports RB2 to RB7 which are indicated as OUT. On the server side, we assume a virtual CGI program called modify.cgi to respond and we can change the output values by passing parameters in the form output port number = value as parameters within the URL.
For example, in the case of setting this PICNIC, if we use the following URL: The URL specifications for input/output port control are summarized below. [Reloading of the current values] [Example: Changing output port RB7 -> H] [Example: Changing output port RB7 -> L]
The current configuration for IP address,netmask value, gateway IP address, port numbers for various functions is displayed. In the display example of Fig. 3, we see that the following configuration is used: IP address: 160.252.131.19, net mask 25bit, gateway: 160.252.131.1. To change the configuration values, it is necessary to input the new values in the corresponding text fields, click the [Save] button, shutdown the power,and power up or press the reset button. If the [Default] button is clicked, the defaults for a local IP segment, i.e., IP address: 192.168.0.200, net mask 24bit will be set. By using the IP address to 0.0.0.0, the mode will be set to obtain an IP address from a DHCP (Dynamic Host Configuration Protocol) server. The URL specifications for network configurations are summarized below. [default values] [Return to initial values] (3) Status sectionThe number of the packets and the current IP address value are displayed. In addition, the IP address display is meaningful only in the case of DHCP address acquisition. 1.3.2 LCD moduleWhen the LCD liquid crystal display panel is connected, the current IP address will be displayed. If in DHCP address acquisition mode an address has been successfully assigned, the IP address will be displayed. ※ Note: If there is no value assigned to LCD Port UDP:# (all 0), the LCD panel will show ■■■■■.In an IP address display, this value should be set to some number, such as 10000. When an LCD panel is not used: When an LCD panel is used: 1.3.3 Test program using an exclusive control protocolA test program (pictest.exe) using an exclusive control protocol which operates on Windows is distributed from the TriState company web site. http://www.tristate.ne.jp/picnic/menu.html Download the LZH file containing the sample program (pictest) + installer Then decompress the file using a tool such as Lhasa and run setup.exe. From [Start]→[Programs], run PICNIC test and set the IP address, LCD panel port number for displaying the acquisition time. By pressing the [Connect] button,connections to the PICNIC will be made at the intervals set and the currect I/O states will be displayed. On line 2 of the PICNIC LCD panel, the connection and data acquisition times of pictest will be displayed.
<Figure 4> Example of remote I/O state data acquisition using a test program ●Exclusive control protocol for PICNICControl API drivers for various platforms/languages can be downloaded from the TriState company web site below. The 1.3.3 test programs (pictest.exe) mentioned above was developed using the PICNIC.DLL library and Visual C++ on Windows. In this exercise, we will not address the exclusive control protocol. Please study it on your own. http://www.tristate.ne.jp/picnic/menu.html
|
|
wasaki@cs.shinshu-u.ac.jp |