| Smart Star User's Manual |
5. Using the TCP/IP Features
Chapter 5 discusses using the TCP/IP features on the CPU cards. Note that the TCP/IP feature is available only on the SR9150 CPU card.
5.1 Ethernet Connections
Before proceeding you will need to have the following items.
- If you don't have an Ethernet connection, you will need to install a 10Base-T Ethernet card (available from your favorite computer supplier) in your PC.
- Two RJ-45 straight-through Ethernet cables and a hub, or an RJ-45 crossover Ethernet cable.
The Ethernet cables and Ethernet hub are available from Z-World in a TCP/IP tool kit. More information is available at www.zworld.com.
- Install the CPU card on the backplane, and connect the power supply and the programming cable as shown in Chapter 2, "Getting Started."
- Ethernet Connections
- If you do not have access to an Ethernet network, use a crossover Ethernet cable to connect the installed CPU card to a PC that at least has a 10Base-T Ethernet card.
- If you have an Ethernet connection, use a straight-through Ethernet cable to establish an Ethernet connection to the installed CPU card from an Ethernet hub. These connections are shown in Figure 18.
Plug in the power supply. The Smart Star is now ready to be used.
NOTE A hardware RESET is accomplished by unplugging the power supply, then plugging it back in. The green LNK light is on the CPU card is on when the Smart Star is properly connected either to an Ethernet hub or to an active Ethernet card. The orange ACT light flashes each time a packet is received.
5.2 TCP/IP Sample Programs
We have provided a number of sample programs demonstrating various uses of TCP/IP for networking embedded systems. These programs require that you connect your PC and the Smart Star together on the same network. This network can be a local private network (preferred for initial experimentation and debugging), or a connection via the Internet.
5.2.1 How to Set IP Addresses in the Sample Programs
Most of the sample programs use macros to define the IP address assigned to the CPU card and the IP address of the gateway, if there is a gateway.
#define MY_IP_ADDRESS "216.112.116.155"
#define MY_NETMASK "255.255.255.248"
#define MY_GATEWAY "216.112.116.153"In order to do a direct connection, the following IP addresses can be used for the CPU card:
#define MY_IP_ADDRESS "10.1.1.2"
#define MY_NETMASK "255.255.255.248"
// #define MY_GATEWAY "216.112.116.153"In this case, the gateway is not used and is commented out. The IP address of the board is defined to be 10.1.1.2. The IP address of your PC can be defined as 10.1.1.1.
5.2.2 How to Set Up your Computer's IP Address for a Direct Connection
When your computer is connected directly to the OP6800 via an Ethernet connection, you need to assign an IP address to your computer. To assign the PC the address 10.1.1.1 with the subnetmask 255.255.255.248 under Windows 98, do the following.
Click on Start > Settings > Control Panel to bring up the Control Panel, and then double-click the Network icon. In the window find the line of the form TCP/IP > Ethernet adapter name. Double-click on this line to bring up the TCP/IP properties dialog box. You can edit the IP address directly and the subnet mask. (Disable "obtain an IP address automatically.") You may want to write down the existing values in case you have to restore them later. It is not necessary to edit the gateway address since the gateway is not used with direct connect.
The method of setting the IP address may differ for different versions of Windows, such as 95, NT, 2000, or XP.
5.2.3 Run the PINGME.C Demo
In order to run this program, edit the IP address and netmask in the
PINGME.Cprogram (SAMPLES\TCPIP\ICMP) to the values given above (10.1.1.2 and 255.255.255.248). Compile the program and start it running under Dynamic C. The crossover cable is connected from your computer's Ethernet adapter to the CPU card's RJ-45 Ethernet connector. When the program starts running, the green LNK light on the CPU card should be on to indicate that an Ethernet connection is made. (Note: If the LNK light does not light, you may not have a crossover cable, or if you are using a hub perhaps the power is off on the hub.)The next step is to ping the board from your PC. This can be done by bringing up the MS-DOS window and running the ping program:
ping 10.1.1.2
ping 10.1.1.2Notice that the orange ACT light flashes on the CPU card while the ping is taking place, and indicates the transfer of data. The ping routine will ping the board four times and write a summary message on the screen describing the operation.
5.2.4 Additional Demo Programs
The program
SMTP.C(SAMPLES\SMRTSTAR\TCPIP\) demonstrates a basic Smart Star system using the SMTP library to send an e-mail when a keypress is detected on an LCD/keypad module. In order to run this sample program, edit the IP address as for the pingme program, edit the "mail to" e-mail address, compile the program, and start it executing. An e-mail corresponding to the keypad button that was pressed is sent.The program
SSI.C(SAMPLES\SMRTSTAR\TCPIP\) demonstrates how to make the Smart Star CPU card a Web server. This program allows you to turn the LEDs on an attached LCD/keypad module on and off from a remote Web browser. In order to run these sample programs, edit the IP address as for the pingme program, compile the program, and start it executing. Then bring up your Web browser and enter the following server address: http://10.1.1.2. This should bring up the Web page served by the sample program.The program
SSI2.C(SAMPLES\SMRTSTAR\TCPIP\) demonstrates the use of I/O cards via instructions sent from a Web browser. You will need an A/D converter I/O card, a D/A converter I/O card, or a relay I/O card installed on the backplane in order for the Web browser to be able to initiate changes on one or more of these I/O cards. Before you run this sample program, edit the IP address as for the pingme program, compile the program, and start it executing. The analog outputs will change or the relays will open and close in response to instructions sent from the Web browser.5.2.5 LCD/Keypad Sample Programs Showing TCP/IP Features
The following sample programs, found in the
TCPIPsubdirectory inSAMPLES/LCD_Keypad/122x32_1x7, are demonstrate the features of the LCD/keypad module connected to the backplane. Remember to configure the IP address, netmask, and gateway as indicated in the sample programs.
MBOXDEMO.C--This program implements a web server that allows Web e-mail messages to be entered that are then shown on the LCD display. The keypad allows you to scroll within messages, flip to other e-mails, mark messages as read, and delete e-mails. When a new e-mail arrives, an LED turns on, and turns off once the message has been marked as read. A log of all e-mail actions is kept, and can be displayed in the Web browser. All current e-mails can also be read with the Web browser.
- When using
MBOXDEMO.C, connect the Smart Star CPU card and a PC (or other device with a Web Browser) to an Ethernet. If you connect the PC and the CPU card directly, be sure to use a crossover Ethernet cable; straight-through Ethernet cables and a hub may be used instead.
TCP_RESPOND.C--This program andTCP_SEND.Care executed on two separate single-board computers to demonstrate how the two boards communicate with each other. UsePCSEND.EXEon the PC console side at the command prompt if you do not have a second board.PCSEND.EXEis located with source code in theSAMPLES/LCD_Keypad/Windowsdirectory.
TCP_RESPOND.Cwaits for a message from another single-board computer. The message received is displayed on the LCD, and you may respond by pressing a key on the keypad. The response is then sent to the remote single-board computer.
TCPSEND.C--This program andTCP_RESPOND.Care executed on two separate single-board computers to demonstrate how the two boards communicate with each other. UsePCRESPOND.EXEon the PC console side at the command prompt if you do not have a second board.PCRESPOND.EXEis located with source code in theSAMPLES/LCD_Keypad/Windowsdirectory.
- When a key on the keypad is pressed, a message associated with that key is sent to a specified destination address and port. The destination then responds to that message. The response is displayed on the LCD.
- Note that only the LEFT and UP scroll keys are set up to cause a message to be sent.
When using
TCPSEND.CandTCP_RESPOND.C, connect the CPU card and the other single-board computer to an Ethernet. If you connect the them directly, be sure to use a crossover Ethernet cable; straight-through Ethernet cables and a hub may be used instead.5.3 Where Do I Go From Here?
NOTE If you purchased your Smart Star through a distributor or Z-World partner, contact the distributor or Z-World partner first for technical support. If there are any problems at this point:
- Check the Z-World Technical Bulletin Board at www.zworld.com/support/bb/.
- Use the Technical Support e-mail form at www.zworld.com/support/support_submit.html.
- Call Z-World Technical Support at (530)757-3737.
If the sample programs ran fine, you are now ready to go on.
Additional sample programs are described in the Dynamic C TCP/IP User's Manual.
Refer to the Dynamic C TCP/IP User's Manual to develop your own applications. An Introduction to TCP/IP provides background information on TCP/IP, and is available on Z-World's Web site.
| Z-World http://www.zworld.com Voice: (530) 757-3737 FAX: (530) 757-3792 sales@zworld.com |