Allen-Bradley documentation on the operation of the Allen-Bradley hardware. Under no conditions will ProSoft Technology, Inc. be responsible or liable for indirect or consequential damages resulting from the use or application of the product.
ADM_init_socket ........................39 ADM_open_sk ...........................40 ADMNET API Release Socket Functions ..................41 ADM_release_sockets .......................41 ADM_close_sk ...........................42 ADMNET API Send Socket Functions ..................43 ADM_send_socket........................43 ADM_send_sk..........................44 ADMNET API Receive Socket Functions ..................45 ADM_receive_socket .........................45 ADM_receive_sk........................46 ProSoft Technology, Inc. Page 3 of 90 December 13, 2006...
Page 4
SUPPORT, SERVICE & WARRANTY..................... 85 Module Service and Repair ......................85 General Warranty Policy – Terms and Conditions ..............86 Limitation of Liability........................87 RMA Procedures ......................... 87 INDEX............................... 89 Page 4 of 90 ProSoft Technology, Inc. December 13, 2006...
Refers to a contiguous block of data that is written by the module application and read by the controller. The input image is read by the controller once each scan. Also referred to as the input file. ProSoft Technology, Inc. Page 5 of 90 December 13, 2006...
Note: DOS programs that try to access the video or keyboard hardware directly will not function correctly on the MVI module. Only programs that use the standard DOS and BIOS functions to perform console I/O are compatible. Page 6 of 90 ProSoft Technology, Inc. December 13, 2006...
MVI-ADMNET Communication Ports The MVI-ADMNET module has three physical connectors; two application ports and one debugging port, with an RJ45 plug and Ethernet port located on the front of the module. Page 8 of 90 ProSoft Technology, Inc. December 13, 2006...
Configuring Digital Mars C++ 8.49 The following procedure allows you to successfully build the sample ADM code supplied by Prosoft Technology using Digital Mars C++ 8.49. After verifying that the sample code can be successfully compiled and built, you can modify the sample code to work with your application.
Page 10
This is a normal occurrence. If you are building existing code written for a different compiler you may have to replace calls to run-time functions with the Digital Page 10 of 90 ProSoft Technology, Inc. December 13, 2006...
Page 11
Creating a New Digital Mars C++ 8.49 ADM Project Start Digital Mars C++ 8.49, and then click Project → New from the Main Menu. Select the path and type in the Project Name. ProSoft Technology, Inc. Page 11 of 90 December 13, 2006...
Page 12
Select the first source file necessary for the project. Click Add. Repeat this step for all source files needed for the project. 10 Repeat the same procedure for all library files (.lib) needed for the project. Page 12 of 90 ProSoft Technology, Inc. December 13, 2006...
Page 13
11 Choose Libraries (*.lib) from the List Files of Type field to view all library files: 12 Click Next. 13 Add any defines or include directories desired. 14 Click Finish. ProSoft Technology, Inc. Page 13 of 90 December 13, 2006...
Page 14
17 These settings were set when the project was created. No changes are required. The executable must be built as a DOS executable in order to run on the MVI platform. Page 14 of 90 ProSoft Technology, Inc. December 13, 2006...
Page 15
The output files will be placed in this directory as well. 20 Click on the Build tab, and choose the Compiler selection. Confirm that the settings match those shown in the following screen: ProSoft Technology, Inc. Page 15 of 90 December 13, 2006...
Page 16
21 Click Code Generation from the Topics field and ensure that the options match those shown in the following screen: 22 Click Memory Models from the Topics field and ensure that the options match those shown in the following screen: Page 16 of 90 ProSoft Technology, Inc. December 13, 2006...
Page 17
23 Click Linker from the Topics field and ensure that the options match those shown in the following screen: 24 Click Packing & Map File from the Topics field and ensure that the options match those shown in the following screen: ProSoft Technology, Inc. Page 17 of 90 December 13, 2006...
Page 18
If you are building existing code written for a different compiler you may have to replace calls to run-time functions with the Digital Mars equivalent. Refer to the Digital Mars documentation on the Run-time Library for the functions available. Page 18 of 90 ProSoft Technology, Inc. December 13, 2006...
Configuring Borland C++5.02 The following procedure allows you to successfully build the sample ADM code supplied by Prosoft Technology. using Borland C++ 5.02. After verifying that the sample code can be successfully compiled and built, you can modify the sample code to work with your application.
Page 20
Click Project → Build All from the Main Menu to create the .exe file. The Building ADM window appears when complete: When Success appears in the Status field, click OK. Page 20 of 90 ProSoft Technology, Inc. December 13, 2006...
Page 21
In the Target Type field, choose Application (.exe). In the Platform field, choose DOS (Standard). In the Target Model field, choose Large. Ensure that Emulation is checked in the Math Support field. ProSoft Technology, Inc. Page 21 of 90 December 13, 2006...
Page 22
10 Click source file, then click Open to add source file to the project. Repeat this step for all source files needed for the project. 11 Repeat the same procedure for all library files (.lib) needed for the project. Page 22 of 90 ProSoft Technology, Inc. December 13, 2006...
Page 23
12 Choose Libraries (*.lib) from the Files of Type field to view all library files: 13 The Project window should now contain all the necessary source and library files as shown in the following window: ProSoft Technology, Inc. Page 23 of 90 December 13, 2006...
Page 24
Ethernet Module 14 Click Options → Project from the Main Menu. 15 Click Directories from the Topics field and fill in directory information as required by your project's directory structure. Page 24 of 90 ProSoft Technology, Inc. December 13, 2006...
Page 25
17 Click Memory Model from the Topics field and ensure that the options match those shown in the following screen: 18 Click OK. 19 Click Project → Build All from the Main Menu. ProSoft Technology, Inc. Page 25 of 90 December 13, 2006...
CD-ROM. Modify the example ladder logic to meet the needs of your application, and copy the ladder logic to the processor. Example ladder logic files are provided on the CD-ROM. Page 26 of 90 ProSoft Technology, Inc. December 13, 2006...
Enter the ladder logic to handle the blocks transferred between the module and the PLC. Download the program to the PLC and test the program with the module. ProSoft Technology, Inc. Page 27 of 90 December 13, 2006...
Page 28
After defining the files and populating them with the correct data, download the program to the processor, and place the processor in Run mode. If everything is configured properly, the module should start its normal operation. Page 28 of 90 ProSoft Technology, Inc. December 13, 2006...
Page 29
Refer to the Diagnostics and Troubleshooting of this manual if you encounter errors. Attach a terminal to Port 1 on the module and look at the status of the module using the Configuration/Debug Menu in the module. ProSoft Technology, Inc. Page 29 of 90 December 13, 2006...
Page 30
MVI-ADMNET ♦ 'C' Programmable Setting Up Your Development Environment Ethernet Module Page 30 of 90 ProSoft Technology, Inc. December 13, 2006...
The API library functions are specified using the C programming language syntax. To allow applications to be developed in other industry-standard programming languages, the standard Pascal calling convention is used for all application interface functions. ProSoft Technology, Inc. Page 31 of 90 December 13, 2006...
MVI family modules. 4.3.2 ADMNET API Architecture The ADMNET API is composed of a statically-linked library (called the ADMNET library). Applications using the ADMNET API must be linked with the ADMNET library. Page 32 of 90 ProSoft Technology, Inc. December 13, 2006...
// a logical OR of bits longword usertimer; // ip_timer_set, ip_timer_timeout dataHandler_t dataHandler; // called with incoming data eth_address hisethaddr; // ethernet address of peer ProSoft Technology, Inc. Page 33 of 90 December 13, 2006...
Page 34
// data to send } tcp_Socket; typedef struct _udp_socket { struct _udp_socket *next; word ip_type; // always set to UDP_PROTO char *err_msg; // null when all is ok char *usr_name; Page 34 of 90 ProSoft Technology, Inc. December 13, 2006...
Page 35
*queue; rdatalen; // must be signed word maxrdatalen; byte *rdata; byte rddata[ tcp_MaxBufSize + 1]; // if dataHandler = 0, len == 512 longword safetysig; } udp_Socket; ProSoft Technology, Inc. Page 35 of 90 December 13, 2006...
Page 36
MVI-ADMNET ♦ 'C' Programmable Understanding the MVI-ADMNET API Ethernet Module Page 36 of 90 ProSoft Technology, Inc. December 13, 2006...
Send socket according to name assign throughout initialization process as either UDP or TCP. This function also takes care of opening socket connection. Send socket with previously open ADM_send_sk with function ADM_open_sk. ProSoft Technology, Inc. Page 37 of 90 December 13, 2006...
Page 38
ADM_receive_sk Receive socket with previously open with function ADM_open_sk. Miscellaneous ADM_NET_GetVersionInfo Get ADMNET API version information. ADM_is_sk_open Test if the socket is still open. Page 38 of 90 ProSoft Technology, Inc. December 13, 2006...
= 5; int portNum = 5757; int buffSize = 1000; if(ADM_init_socket(numSK, portNum, buffSize, "ReceiveSK") != SK_SUCCESS) printf("\nFailed to open ADM API... exiting program\n"); ADM_release_sockets(); See Also: ADM_release_sockets (page 41) ProSoft Technology, Inc. Page 39 of 90 December 13, 2006...
ADM_init_socket(numSocket1, port_1, buffSize1, sockName1); while ((result = ADM_open_sk(sockName1, "0.0.0.0", USE_TCP))==SK_PROCESS_SOCKET); if (result==SK_SUCCESS) printf("successfully Opened a connection!\n"); } else { printf("Error Opening a connection! %d\n", result); See Also: ADM_close_sk (page 42) Page 40 of 90 ProSoft Technology, Inc. December 13, 2006...
IMPORTANT: After a socket has been generated, this function should always be called before exiting the application. Return Value: SK_SUCCESS API was successfully released all the sockets. Example:r ADM_release_sockets(); See Also: ADM_init_socket (page 39) ProSoft Technology, Inc. Page 41 of 90 December 13, 2006...
SK_NOT_FOUND API could not find an initialize socket with the name passed to the function. Example: char sockName1[ ] = "SendSocket"; ADM_close_sk(sockName1); printf ("Connection Closed!\n"); See Also: ADM_init_socket (page 39) Page 42 of 90 ProSoft Technology, Inc. December 13, 2006...
Socket is in the process of sending. Example: int sendLen = 10; int se; se = ADM_send_socket("sendSK", "1234567890", &sendLen, "192.168.0.148", USE_UDP); if(se == SK_SUCCESS) printf("send Success\n"); See Also: ADM_receive_socket (page 45) ProSoft Technology, Inc. Page 43 of 90 December 13, 2006...
APISeries[4]; short APIRevisionMajor; short APIRevisionMinor; long APIRun; }ADMNETVERSIONINFO; Return Value: None Example: ADMNETVERSIONINFO verinfo; /* print version of API library */ ADM_NET_GetVersionInfo(& verinfo); printf("Revision %d.%d\n", verinfo.APIRevisionMajor, verinfo.APIRevisionMinor); ProSoft Technology, Inc. Page 47 of 90 December 13, 2006...
Socket is successfully sent. SK_NOT_FOUND Socket could not be found. SK_SOCKET_CLOSE Socket is closed. Example: char sockName1[ ] = "SendSocket"; if(ADM_is_sk_open(sockName1) != SK_SUCCESS) { printf("Socket not Opened\n"); } else { printf("Socket Opened\n"); Page 48 of 90 ProSoft Technology, Inc. December 13, 2006...
(UDP or TCP). sock_established Check if connect has been established. ip_timer_init Initialize timing. ip_timer_expired Check if timer has been expired. set_timeout Set timer. chk_timeout Check timer if expired. ProSoft Technology, Inc. Page 49 of 90 December 13, 2006...
Page 50
Convert string dot address to host format. ntohs Convert network word to host word htons Convert host word to network word Convert network longword to host ntohl longword htonl Convert host longword to network longword Page 50 of 90 ProSoft Technology, Inc. December 13, 2006...
This function is used by an application to determine the connection status of the sockets. Return Value: disconnected or reset. >0 connected. Example: sock_type *socket; . . . if(tcp_tick(socket)) //check socket printf("Connected\n"); Page 52 of 90 ProSoft Technology, Inc. December 13, 2006...
Return Value: Connection cannot be made >0 Connection is made Example: tcp_Socket *socket; . . . if(tcp_open(socket, 0, resolve("192.168.0.1"), 5656, NULL)) printf("Open Successfully\n"); See Also: resolve (page 57) ProSoft Technology, Inc. Page 53 of 90 December 13, 2006...
Return Value: Connection cannot be made >0 Connection is made Example: tcp_Socket *socket; . . . if(tcp_open_fast(socket, 0, resolve("192.168.0.1"), 5656, NULL)) printf("Open Successfully\n"); See Also: resolve (page 57) Page 54 of 90 ProSoft Technology, Inc. December 13, 2006...
Return Value: Connection cannot be made >0 Connection is made Example: udp_Socket *socket; . . . if(udp_open(socket, 0, resolve("192.168.0.1"), 5656, NULL)) printf("Open Successfully\n"); See Also: resolve (page 57) ProSoft Technology, Inc. Page 55 of 90 December 13, 2006...
IP address into a longword-formatted variable. Return Value: Connection cannot be made >0 Connection is made Example: udp_Socket *socket; . . . if(udp_open_fast(socket, 0, resolve("192.168.0.1"), 5656, NULL)) printf("Open Successfully\n"); See Also: resolve (page 57) Page 56 of 90 ProSoft Technology, Inc. December 13, 2006...
Parameters: name String IP Address. Description: This function converts a string IP Address into a long. Return Value: longword Value of the IP Address in a long format. Example: resolve("192.168.0.1"); ProSoft Technology, Inc. Page 57 of 90 December 13, 2006...
TCP_NONAGLE used for real time application. Description: This function is used set the socket transfer protocol mode. Return Value: Current mode. Example: sock_type *socket; . . . sock_mode(socket, TCP_MODE_NONAGLE); Page 58 of 90 ProSoft Technology, Inc. December 13, 2006...
Current socket Type that will be used to check the connection. Description: This function is used check if the socket has been established. Return Value: Not established. Establish Example: sock_type *socket; . . . if(sock_established(socket)) printf("Socket has been established\n"); ProSoft Technology, Inc. Page 59 of 90 December 13, 2006...
Number of second to set the timer. 0 mean no timer out. Description: This function is used initialize the timer. Return Value: None Example: sock_type *socket; . . . ip_timer_init (socket, 100); Page 60 of 90 ProSoft Technology, Inc. December 13, 2006...
Current socket Type that will be used to check the connection. Description: This function is used check if the timer has been expired. Return Value: timer has been expired. Example: sock_type *socket; . . . if(ip_timer_expired (socket)) printf("time's up\n"); ProSoft Technology, Inc. Page 61 of 90 December 13, 2006...
); Parameters: seconds Number of second to set the timer. Description: This function is used set the timer. Return Value: Number of timeout. Example: set_timeout (100); Page 62 of 90 ProSoft Technology, Inc. December 13, 2006...
Number of timeout return from set_timerout. Description: This function is used check if the time is out. Return Value: timeout Example: int timeout = set_timeout (100); While(!chk_timeout (timeout)) printf("Not timeout yet\n"); ProSoft Technology, Inc. Page 63 of 90 December 13, 2006...
This function returns ASCII error message if there is any. Otherwise, NULL is returned. Return Value: String message or NULL if there is no error. Example: sock_type *socket; char *p; . . . if(p = sockerr(socket) != NULL) printf("Error: %s\n", p); Page 64 of 90 ProSoft Technology, Inc. December 13, 2006...
Current socket Type that will be used to check the connection. Description: This function returns ASCII message indicating current state. Return Value: String message. Example: sock_type *socket; char *p; . . . if(p = sockstate(socket) != NULL) printf("State: %s\n", p); ProSoft Technology, Inc. Page 65 of 90 December 13, 2006...
This function returns value of the IP address in host format. Return Value: String IP Address. Example: sock_type *socket; char *p; . . . if(p = gethostid(socket) != NULL) printf("My IP: %s\n", p); Page 66 of 90 ProSoft Technology, Inc. December 13, 2006...
); Parameters: None Description: This function is used by an application to release all the TCP/IP variables created by sock_init. Return Value: None Example: sock_exit(); See Also: sock_init (page 51) ProSoft Technology, Inc. Page 67 of 90 December 13, 2006...
Description: This function is used abort a connection. This function is common for TCP connections. Return Value: None Example: sock_type *socket; . . . sock_abort(socket); See Also: sock_close (page 69) Page 68 of 90 ProSoft Technology, Inc. December 13, 2006...
This function is used to permanently close a connection. This function is common for UDP connections. Return Value: None Example: sock_type *socket; . . . sock_close(socket); See Also: sock_abort (page 68) ProSoft Technology, Inc. Page 69 of 90 December 13, 2006...
Number of Bytes that are written to the socket or -1 if an error occurs. Example: sock_type *socket; char theBuffer [512]; int len, bytes_sent; . . . bytes_sent = sock_write(socket, (byte*)theBuffer, len); See Also: sock_fastwrite (page 71) Page 70 of 90 ProSoft Technology, Inc. December 13, 2006...
Number of bytes that are written to the socket or -1 if an error occurs. Example: sock_type *socket; char theBuffer [512]; int len, bytes_sent; . . . bytes_sent = sock_fastwrite(socket, (byte*)theBuffer, len); See Also: sock_write (page 70) ProSoft Technology, Inc. Page 71 of 90 December 13, 2006...
This function has no effect for UDP, since UDP is a connectionless protocol. Return Value: None Example: sock_type *socket; . . . sock_flush(socket); // Flush the output See Also: sock_flushnext (page 73) Page 72 of 90 ProSoft Technology, Inc. December 13, 2006...
This function is used after the write function is called to ensure that the data in a buffer is flushed immediately. Return Value: None Example: sock_type *socket; . . . sock_flushnext(socket); // Flush the output See Also: sock_flush (page 72) ProSoft Technology, Inc. Page 73 of 90 December 13, 2006...
The length that is written to the socket. Example: sock_type *socket; char data [512]; int len; . . . len = sock_puts(socket, data); printf("Put %d\n", len); See Also: sock_putc (page 75) Page 74 of 90 ProSoft Technology, Inc. December 13, 2006...
This function is used to put one character at a time to the socket. Return Value: Character put in is returned. Example: sock_type *socket; char in; . . . in = sock_putc(socket, 'A'); printf("%c", in); See Also: sock_puts (page 74) ProSoft Technology, Inc. Page 75 of 90 December 13, 2006...
Number of Bytes that are read to the socket or -1 if an error occurs. Example: sock_type *socket; char theBuffer [512]; int len, bytes_receive; . . . bytes_receive = sock_read(socket, (byte*)theBuffer, len); See Also: sock_fastread (page 77) Page 76 of 90 ProSoft Technology, Inc. December 13, 2006...
Number of bytes that are read to the socket or -1 if an error occurs. Example: sock_type *socket; char theBuffer [512]; int len, bytes_receive; . . . bytes_receive = sock_fastread(socket, (byte*)theBuffer, len); See Also: sock_read (page 76) ProSoft Technology, Inc. Page 77 of 90 December 13, 2006...
0 can be passed as an ina value if there is no specific IP Address to listen too. Example: tcp_Socket *socket; int port = 5656; . . . tcp_listen(socket, port, 0L, 0, NULL, 0); See Also: ADM_send_socket (page 43) Page 78 of 90 ProSoft Technology, Inc. December 13, 2006...
The length read from the socket is returned. Example: sock_type *socket; char data [512]; int len; . . . len = sock_gets(socket, data, 100); printf("Get %d\n", len); See Also: sock_getc (page 80) ProSoft Technology, Inc. Page 79 of 90 December 13, 2006...
This function gets one character at a time from the socket. Return Value: Character read in is returned. Example: sock_type *socket; char in; . . . in = sock_getc(socket); printf("%c", in); See Also: sock_gets (page 79) Page 80 of 90 ProSoft Technology, Inc. December 13, 2006...
This function is used check if there is data ready to be read. Return Value: Number of bytes ready to be read or -1 if error occurs. Example: int in; sock_type *socket; . . . in = sock_dataready(socket); printf("%d", in); ProSoft Technology, Inc. Page 81 of 90 December 13, 2006...
0 and the rest of them will not be defined. Return Value: Pointer to the new string. Example: char s; . . . s = sock_dataready("This is a test\n\r"); printf("%s", s); Page 82 of 90 ProSoft Technology, Inc. December 13, 2006...
IP address. The size of the buffer has to be at least 16 byte. Return Value: Pointer to the new string. Example: char buffer[ 20 ]; sock_init(); printf("My IP address is %s\n", inet_ntoa( buffer, gethostid())); ProSoft Technology, Inc. Page 83 of 90 December 13, 2006...
This function converts string dot address to host format. Return Value: Host IP address format. Example: char buffer[ ] = "192.168.0.1"; sock_init(); printf("My IP address is %ld\n", inet_addr( buffer )); Page 84 of 90 ProSoft Technology, Inc. December 13, 2006...
When purchased from ProSoft Technology, Inc., the device has a 1 year parts and labor warranty (3 years for RadioLinx) according to the limits specified in the warranty.
(12 months) from the date of original purchase (3 years for RadioLinx products) from ProSoft. If you need to return the device for repair, obtain an RMA (Returned Material Authorization) number from ProSoft Technology, Inc. in accordance with the RMA instructions below.
All replaced product and parts become the property of ProSoft. If ProSoft determines that the Product is not under warranty, it will, at the Customer's option, repair the Product using then current ProSoft standard rates for parts and labor, and return the product freight collect.
Page 88
MVI-ADMNET ♦ 'C' Programmable Support, Service & Warranty Ethernet Module Page 88 of 90 ProSoft Technology, Inc. December 13, 2006...
Need help?
Do you have a question about the MVI ADMNET Series and is the answer not in the manual?
Questions and answers