14.08.2013 Views

snap ethernet-based i/o units protocols and programming guide

snap ethernet-based i/o units protocols and programming guide

snap ethernet-based i/o units protocols and programming guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 4: USING THE IEEE 1394-BASED PROTOCOL<br />

Overview of Programming<br />

Developing custom applications for the SNAP Ethernet-<strong>based</strong> brain requires five basic steps:<br />

connect, send Powerup Clear, configure, read/write, <strong>and</strong> disconnect. This overview section leads<br />

you through these steps using a utility application called OptoEIEIO (Easy Interface Ethernet I/O),<br />

written in Microsoft ® Visual Basic ® 5.0. The utility is included on the CD that came with the<br />

brain <strong>and</strong> is installed with the typical software installation. To open OptoEIEIO, choose<br />

Start➞Programs➞Opto22➞OptoENET-IO➞OptoEIEIO.<br />

Connecting<br />

To connect with the SNAP Ethernet-<strong>based</strong> brain, OptoEIEIO uses the Microsoft Winsock control<br />

(variable name for this object in OptoEIEIO: tcpIOUnit) <strong>and</strong> a user-selectable Host Name/IP<br />

address <strong>and</strong> port. Note that the Remote Port defaults to 2001 for the SNAP Ethernet-<strong>based</strong> brain.<br />

tcpIOUnit.RemoteHost = “10.192.0.69” ‘IP address of brain<br />

tcpIOUnit.RemotePort = 2001<br />

tcpIOUnit.Connect<br />

Sending Powerup Clear<br />

Once a connection has been established, the host must send a Powerup Clear message (PUC) to<br />

the SNAP Ethernet-<strong>based</strong> brain. You can’t do anything except read the memory map’s<br />

Status area until the Powerup Clear is sent. Other requests will return a negative<br />

acknowledgment (NAK), <strong>and</strong> the error Powerup Clear Expected will appear in the Status area.<br />

(See page 107.)<br />

After the initial PUC is sent, you do not need to send another unless the brain has been turned<br />

off or restarted. To check whether a Powerup Clear is needed, you can read the PUC flag in the<br />

Status area. A zero means the PUC has been sent; anything else means you must send a PUC.<br />

OptoEIEIO sends a Powerup Clear as follows:<br />

Call SendString(BuildWriteQuad(MM_OPERATION_PUC, OPTO_MM_OPERATION_CODE),<br />

WRITE_QUAD_REQ)<br />

The BuildWriteQuad subroutine builds a Write Quadlet Request packet using the two pieces of<br />

information passed. One is the quadlet_data, 00000001, which is represented by the constant<br />

MM_OPERATION_PUC. The other is the destination_offset, FFFFF0380000, which is the memory<br />

map location for sending a Powerup Clear <strong>and</strong> is represented by the constant<br />

OPTO_MM_OPERATION_CODE. (The complete memory map is shown in Appendix A, starting on<br />

page 103.)<br />

82 SNAP Ethernet-Based I/O Units Protocols <strong>and</strong> Programming Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!