Search
PLCIO Blog
 
11/2017 - Version 4.5.2
02/2017 - Version 4.5.1
12/2015 - Version 4.5.0
10/2014 - Version 4.4.1
01/2013 - Version 4.4.0
06/2011 - Web Site Update
02/2011 - Version 4.3.1
01/2011 - Version 4.3.0
06/2010 - Version 4.2.1
12/2009 - Version 4.2.0
01/2008 - Version 4.1.1
10/2007 - Using "testplc" for basic communications testing
08/2007 - Replacing A-B INTERCHANGE with PLCIO
08/2007 - Determining array size in a ControlLogix PLC
Replacing Allen-Bradley INTERCHANGE Software with PLCIO
Often there are requests for porting/replacing Allen-Bradley INTERCHANGE with our PLCIO product.
While there is not a direct call by call translation between the tools, the coding is still very similar
Here is an example of an INTERCHANGE code snippet that opens a PLC and makes a write request:


{
   char ac_buf[64];
   unsigned short ai_data[2]={100, 200};
   unsigned long io_stat, handle;
   int j_ret;

   /* Initialize Interchange */
   if((j_ret=DTL_INIT(1)) != DTL_SUCCESS) {
     DTL_ERROR(j_ret);
     return;
   }

   /* Define a handle for writing 2 words (4 bytes) starting in N7:10 */
   sprintf(ac_buf, "N7:10,2,WORD,MODIFY,,,SLC500,%d", ni_id);
   if((j_ret=DTL_DEFINE_C(&handle, ac_buf)) != DTL_SUCCESS) {
     DTL_ERROR(j_ret);
     DTL_DISCONNECT(ni_id);
     return;
   }

   /* Ping the PLC for 5 seconds to see if it's there first. Otherwise we can't
    * control how long the connect command takes to error out */
   if((j_ret=DTL_SNMP_PING("192.168.1.10", 5000)) != DTL_SUCCESS) {
     DTL_ERROR(j_ret);
     return;
   }

   /* Now attempt to connect to the PLC */
   if((j_ret=DTL_C_CONNECT(ni_id, "192.168.1.10", 0)) != DTL_SUCCESS) {
     DTL_ERROR(j_ret);
     return;
   }

   /* Perform a write request with a timeout of 1.5 seconds */
   if((j_ret=DTL_WRITE_W(handle, (unsigned char *)ai_data, &io_stat,
                         1500)) != DTL_SUCCESS) {
     DTL_ERROR(j_ret);
     DTL_DISCONNECT(ni_id);
     return;
   }

   /* Write successful! Close the connection to the PLC */
   DTL_DISCONNECT(ni_id);
}

-------------------------------------------------------------------------------
PLCIO equivalent:

{
   PLC *plc_ptr;
   unsigned short ai_data[2]={100, 200};
   int j_ret;

   /* Attempt to connect to the PLC using the default timeout of 5 seconds */
   plc_ptr=plc_open("abeth slc500 192.168.1.10");
   if(!plc_ptr) {
     plc_print_error(plc_ptr, "plc_open");
     return;
   }

   /* Perform a write request of 2 words (4 bytes) starting in N7:10, with a
    * timeout of 1.5 seconds */
   if((j_ret=plc_write(plc_ptr, PLC_WREG, "N7:10", ai_data, 4, 1500,
                       PLC_CVT_WORD)) == -1) {
     plc_print_error(plc_ptr, "plc_write");
     plc_close(plc_ptr);
     return;
   }

   /* Write successful! Close the connection to the PLC */
   plc_close(plc_ptr);
}

                                                        
 
© 2018 Commercial Timesharing, Inc. (CTI) All Rights Reserved      |     PLCIO is product of CTI      |     www.comtime.com     |     ph: 330.644.3059