ProSoft Technology MVI69-ADM User Manual

MVI-ADM
'C' Programmable Application Development Module
February 20, 2013
DEVELOPER'S GUIDE
Your Feedback Please
We always want you to feel that you made the right decision to use our products. If you have suggestions, comments, compliments or complaints about our products, documentation, or support, please write or call us.
ProSoft Technology 5201 Truxtun Ave., 3rd Floor Bakersfield, CA 93309 +1 (661) 716-5100 +1 (661) 716-5101 (Fax) www.prosoft-technology.com support@prosoft-technology.com
Copyright © 2013 ProSoft Technology, Inc., all rights reserved.
MVI-ADM Developer's Guide
February 20, 2013
ProSoft Technology ®, ProLinx ®, inRAx ®, ProTalk ®, and RadioLinx ® are Registered Trademarks of ProSoft Technology, Inc. All other brand or product names are or may be trademarks of, and are used to identify products and services of, their respective owners.
In an effort to conserve paper, ProSoft Technology no longer includes printed manuals with our product shipments. User Manuals, Datasheets, Sample Ladder Files, and Configuration Files are provided on the enclosed CD-ROM, and are available at no charge from our web site: www.prosoft-technology.com.
Content Disclaimer
This documentation is not intended as a substitute for and is not to be used for determining suitability or reliability of these products for specific user applications. It is the duty of any such user or integrator to perform the appropriate and complete risk analysis, evaluation and testing of the products with respect to the relevant specific application or use thereof. Neither ProSoft Technology nor any of its affiliates or subsidiaries shall be responsible or liable for misuse of the information contained herein. Information in this document including illustrations, specifications and dimensions may contain technical inaccuracies or typographical errors. ProSoft Technology makes no warranty or representation as to its accuracy and assumes no liability for and reserves the right to correct such inaccuracies or errors at any time without notice. If you have any suggestions for improvements or amendments or have found errors in this publication, please notify us.
No part of this document may be reproduced in any form or by any means, electronic or mechanical, including photocopying, without express written permission of ProSoft Technology. All pertinent state, regional, and local safety regulations must be observed when installing and using this product. For reasons of safety and to help ensure compliance with documented system data, only the manufacturer should perform repairs to components. When devices are used for applications with technical safety requirements, the relevant instructions must be followed. Failure to use ProSoft Technology software or approved software with our hardware products may result in injury, harm, or improper operating results. Failure to observe this information can result in injury or equipment damage.
© 2013 ProSoft Technology. All rights reserved.
Printed documentation is available for purchase. Contact ProSoft Technology for pricing and availability. North America: +1.661.716.5100 Asia Pacific: +603.7724.2080 Europe, Middle East, Africa: +33 (0) 5.3436.87.20 Latin America: +1.281.298.9109
Important Installation Instructions
Power, Input, and Output (I/O) wiring must be in accordance with Class I, Division 2 wiring methods, Article 501-4 (b) of the National Electrical Code, NFPA 70 for installation in the U.S., or as specified in Section 18-1J2 of the Canadian Electrical Code for installations in Canada, and in accordance with the authority having jurisdiction. The following warnings must be heeded:
A WARNING - EXPLOSION HAZARD - SUBSTITUTION OF COMPONENTS MAY IMPAIR SUITABILITY FOR
CLASS I, DIV. 2;
B WARNING - EXPLOSION HAZARD - WHEN IN HAZARDOUS LOCATIONS, TURN OFF POWER BEFORE
REPLACING OR WIRING MODULES
C WARNING - EXPLOSION HAZARD - DO NOT DISCONNECT EQUIPMENT UNLESS POWER HAS BEEN
SWITCHED OFF OR THE AREA IS KNOWN TO BE NON-HAZARDOUS.
D THIS DEVICE SHALL BE POWERED BY CLASS 2 OUTPUTS ONLY.
MVI (Multi Vendor Interface) Modules
WARNING - EXPLOSION HAZARD - DO NOT DISCONNECT EQUIPMENT UNLESS POWER HAS BEEN SWITCHED OFF OR THE AREA IS KNOWN TO BE NON-HAZARDOUS.
AVERTISSEMENT - RISQUE D'EXPLOSION - AVANT DE DÉCONNECTER L'ÉQUIPEMENT, COUPER LE COURANT OU S'ASSURER QUE L'EMPLACEMENT EST DÉSIGNÉ NON DANGEREUX.
Warnings
North America Warnings
A Warning - Explosion Hazard - Substitution of components may impair suitability for Class I, Division 2. B Warning - Explosion Hazard - When in Hazardous Locations, turn off power before replacing or rewiring
modules. Warning - Explosion Hazard - Do not disconnect equipment unless power has been switched off or the area is known to be nonhazardous.
C Suitable for use in Class I, division 2 Groups A, B, C and D Hazardous Locations or Non-Hazardous Locations.
ATEX Warnings and Conditions of Safe Usage:
Power, Input, and Output (I/O) wiring must be in accordance with the authority having jurisdiction
A Warning - Explosion Hazard - When in hazardous locations, turn off power before replacing or wiring modules. B Warning - Explosion Hazard - Do not disconnect equipment unless power has been switched off or the area is
known to be non-hazardous.
C These products are intended to be mounted in an IP54 enclosure. The devices shall provide external means to
prevent the rated voltage being exceeded by transient disturbances of more than 40%. This device must be used only with ATEX certified backplanes.
D DO NOT OPEN WHEN ENERGIZED.
Electrical Ratings
Backplane Current Load: 800 mA @ 5 V DC; 3mA @ 24V DC  Operating Temperature: 0 to 60°C (32 to 140°F)  Storage Temperature: -40 to 85°C (-40 to 185°F)  Shock: 30g Operational; 50g non-operational; Vibration: 5 g from 10 to 150 Hz  Relative Humidity 5% to 95% (non-condensing)  All phase conductor sizes must be at least 1.3 mm(squared) and all earth ground conductors must be at least
4mm(squared).
CE
EMC-EN61326-1:2006; EN6100-6-4:2007
CSA/cUL
C22.2 No. 213-1987
CSA CB Certified
IEC61010
ATEX
EN60079-0 Category 3, Zone 2 EN60079-15
243333
ME06
ANSI / ISA
ISA 12.12.01 Class I Division 2, GPs A, B, C, D
CSA/cUL
C22.2 No. 213-1987
CSA CB Certified
IEC61010
ATEX
EN60079-0 Category 3, Zone 2 EN60079-15
243333
Markings - MVI56, MVI69, PTQ
Markings - MVI46, MVI71
Warning: This module is not hot-swappable! Always remove power from the rack before inserting or removing this
module, or damage may result to the module, the processor, or other connected devices.
Battery Life Advisory
The MVI46, MVI56, MVI56E, MVI69, and MVI71 modules use a rechargeable Lithium Vanadium Pentoxide battery to backup the real-time clock and CMOS. The battery should last for the life of the module. The module must be powered for approximately twenty hours before the battery becomes fully charged. After it is fully charged, the battery provides backup power for the CMOS setup and the real-time clock for approximately 21 days. When the battery is fully discharged, the module will revert to the default BIOS and clock settings.
Note: The battery is not user replaceable.
MVI-ADM 'C' Programmable Contents 'C' Programmable Application Development Module Developer's Guide
Contents
Your Feedback Please ........................................................................................................................ 2
Content Disclaimer .............................................................................................................................. 2
Important Installation Instructions ....................................................................................................... 3
MVI (Multi Vendor Interface) Modules ................................................................................................ 3
Warnings ............................................................................................................................................. 3
Battery Life Advisory ........................................................................................................................... 4
1 Introduction 13
1.1 Operating System .................................................................................................... 13
2 Preparing the MVI-ADM Module 15
2.1 Package Contents ................................................................................................... 16
2.2 Recommended Compact Flash (CF) Cards ............................................................ 17
2.3 Jumper Locations and Settings ............................................................................... 18
2.3.1 Setup Jumper .......................................................................................................... 18
2.3.2 Port 1 and Port 2 Jumpers ...................................................................................... 18
2.4 Cable Connections .................................................................................................. 19
2.4.1 RS-232 Configuration/Debug Port .......................................................................... 19
2.4.2 RS-232 Application Port(s) ..................................................................................... 19
2.4.3 RS-422 .................................................................................................................... 22
2.4.4 RS-485 Application Port(s) ...................................................................................... 22
2.4.5 DB9 to RJ45 Adaptor (Cable 14) ............................................................................ 23
3 Understanding the MVI-ADM API 25
3.1 API Libraries ............................................................................................................ 26
3.1.1 Calling Convention .................................................................................................. 26
3.1.2 Header File .............................................................................................................. 26
3.1.3 Sample Code ........................................................................................................... 26
3.1.4 Multi-threading Considerations ............................................................................... 27
3.2 Development Tools ................................................................................................. 28
3.3 Theory of Operation ................................................................................................ 29
3.3.1 ADM API .................................................................................................................. 29
3.4 ADM Functional Blocks ........................................................................................... 30
3.4.1 Database ................................................................................................................. 30
3.4.2 Backplane Communications .................................................................................... 30
3.4.3 Serial Communications ........................................................................................... 53
3.4.4 Main_app.c .............................................................................................................. 53
3.4.5 Debugprt.c ............................................................................................................... 54
3.4.6 MVIcfg.c................................................................................................................... 54
3.4.7 Commdrv.c .............................................................................................................. 56
3.4.8 Using Compact Flash Disks .................................................................................... 58
3.5 ADM API Architecture ............................................................................................. 59
3.6 ADM API Files ......................................................................................................... 60
3.6.1 ADM Interface Structure .......................................................................................... 60
3.7 Backplane API Files ................................................................................................ 64
3.7.1 Backplane API Architecture..................................................................................... 64
ProSoft Technology, Inc. Page 5 of 342 February 20, 2013
Contents MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
3.8 Serial API Files ....................................................................................................... 66
3.8.1 Serial API Architecture ............................................................................................ 66
3.9 Side-Connect API Files ........................................................................................... 67
3.9.1 Side-Connect API Architecture ............................................................................... 67
3.9.2 Data Transfer .......................................................................................................... 67
4 Setting Up Your Development Environment 69
4.1 Setting Up Your Compiler ....................................................................................... 70
4.1.1 Configuring Digital Mars C++ 8.49.......................................................................... 70
4.1.2 Configuring Borland C++5.02 ................................................................................. 80
4.2 Setting Up WINIMAGE ........................................................................................... 87
4.3 Installing and Configuring the Module .................................................................... 88
4.3.1 Using Side-Connect (Requires Side-Connect Adapter) (MVI71) ........................... 88
5 Programming the Module 91
5.1 ROM Disk Configuration ......................................................................................... 92
5.1.1 CONFIG.SYS File ................................................................................................... 92
5.1.2 Command Interpreter .............................................................................................. 94
5.1.3 Sample ROM Disk Image ....................................................................................... 95
5.2 Creating a ROM Disk Image ................................................................................... 97
5.2.1 WINIMAGE: Windows Disk Image Builder ............................................................. 97
5.3 MVIUPDAT ............................................................................................................. 99
5.4 MVI System BIOS Setup ...................................................................................... 101
5.5 Debugging Strategies ........................................................................................... 102
6 Creating Ladder Logic 103
6.1 MVI46 Ladder Logic .............................................................................................. 104
6.1.1 Main Routine ......................................................................................................... 104
6.2 MVI56 Ladder Logic .............................................................................................. 105
6.2.1 Main Routine ......................................................................................................... 105
6.2.2 Read Routine ........................................................................................................ 105
6.3 MVI69 Ladder Logic .............................................................................................. 106
6.3.1 Main Routine ......................................................................................................... 106
6.3.2 Read Routine ........................................................................................................ 107
6.3.3 Write Routine ........................................................................................................ 108
6.4 MVI71 Ladder Logic .............................................................................................. 109
6.4.1 Sample Ladder Logic ............................................................................................ 109
6.5 MVI94 Ladder Logic .............................................................................................. 115
6.5.1 Main Routine ......................................................................................................... 115
6.5.2 ADM ...................................................................................................................... 116
7 Application Development Function Library - ADM API 119
7.1 ADM API Functions .............................................................................................. 120
7.2 ADM API Initialization Functions........................................................................... 123
ADM_Open ................................................................................................................................ 123
ADM_Close ............................................................................................................................... 124
7.3 ADM API Debug Port Functions ........................................................................... 125
ADM_ProcessDebug ................................................................................................................. 125
Page 6 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Contents 'C' Programmable Application Development Module Developer's Guide
ADM_DAWriteSendCtl ............................................................................................................... 126
ADM_DAWriteRecvCtl ............................................................................................................... 127
ADM_DAWriteSendData............................................................................................................ 128
ADM_DAWriteRecvData ............................................................................................................ 129
ADM_ConPrint ........................................................................................................................... 130
ADM_CheckDBPort ................................................................................................................... 131
7.4 ADM API Database Functions .............................................................................. 132
ADM_DBOpen ........................................................................................................................... 132
ADM_DBClose ........................................................................................................................... 133
ADM_DBZero ............................................................................................................................. 134
ADM_DBGetBit .......................................................................................................................... 135
ADM_DBSetBit .......................................................................................................................... 136
ADM_DBClearBit ....................................................................................................................... 137
ADM_DBGetByte ....................................................................................................................... 138
ADM_DBSetByte ....................................................................................................................... 139
ADM_DBGetWord ...................................................................................................................... 140
ADM_DBSetWord ...................................................................................................................... 141
ADM_DBGetLong ...................................................................................................................... 142
ADM_DBSetLong ....................................................................................................................... 143
ADM_DBGetFloat ...................................................................................................................... 144
ADM_DBSetFloat ....................................................................................................................... 145
ADM_DBGetDFloat .................................................................................................................... 146
ADM_DBSetDFloat .................................................................................................................... 147
ADM_DBGetBuff ........................................................................................................................ 148
ADM_DBSetBuff ........................................................................................................................ 149
ADM_DBGetRegs ...................................................................................................................... 150
ADM_DBSetRegs ...................................................................................................................... 151
ADM_DBGetString ..................................................................................................................... 152
ADM_DBSetString ..................................................................................................................... 153
ADM_DBSwapWord .................................................................................................................. 154
ADM_DBSwapDWord ................................................................................................................ 155
ADM_GetDBCptr ....................................................................................................................... 156
ADM_GetDBIptr ......................................................................................................................... 157
ADM_GetDBInt .......................................................................................................................... 158
ADM_DBChanged ..................................................................................................................... 159
ADM_DBBitChanged ................................................................................................................. 160
ADM_DBOR_Byte ..................................................................................................................... 161
ADM_DBNOR_Byte ................................................................................................................... 162
ADM_DBAND_Byte ................................................................................................................... 163
ADM_DBNAND_Byte................................................................................................................. 164
ADM_DBXOR_Byte ................................................................................................................... 165
ADM_DBXNOR_Byte ................................................................................................................ 166
7.5 ADM API Clock Functions ..................................................................................... 167
ADM_StartTimer ........................................................................................................................ 167
ADM_CheckTimer ...................................................................................................................... 168
7.6 ADM API Backplane Functions ............................................................................. 169
ADM_BtOpen ............................................................................................................................. 169
ADM_BtClose ............................................................................................................................ 170
ADM_BtNext .............................................................................................................................. 171
ADM_ReadBtCfg ....................................................................................................................... 172
ADM_BtFunc .............................................................................................................................. 173
ADM_SetStatus ......................................................................................................................... 174
ADM_SetBtStatus ...................................................................................................................... 175
7.7 ADM LED Functions .............................................................................................. 176
ProSoft Technology, Inc. Page 7 of 342 February 20, 2013
Contents MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
ADM_SetLed ............................................................................................................................. 176
7.8 ADM API Flash Functions ..................................................................................... 177
ADM_FileGetString ................................................................................................................... 177
ADM_FileGetInt ......................................................................................................................... 178
ADM_FileGetChar ..................................................................................................................... 179
ADM_GetVal.............................................................................................................................. 180
ADM_GetChar ........................................................................................................................... 181
ADM_GetStr .............................................................................................................................. 182
ADM_SkipToNext ...................................................................................................................... 183
ADM_Getc ................................................................................................................................. 184
7.9 ADM API Miscellaneous Functions....................................................................... 185
ADM_GetVersionInfo ................................................................................................................ 185
ADM_SetConsolePort ............................................................................................................... 186
ADM_SetConsoleSpeed ........................................................................................................... 187
7.10 ADM Side-Connect Functions .............................................................................. 188
ADM_ScOpen ........................................................................................................................... 188
ADM_ScClose ........................................................................................................................... 189
ADM_ReadScFile ...................................................................................................................... 190
ADM_ReadScCfg ...................................................................................................................... 191
ADM_ScScan ............................................................................................................................ 192
7.11 ADM API RAM Functions ..................................................................................... 193
ADM_EEPROM_ReadConfiguration ......................................................................................... 193
ADM_RAM_Find_Section ......................................................................................................... 194
ADM_RAM_GetString ............................................................................................................... 195
ADM_RAM_GetInt ..................................................................................................................... 196
ADM_RAM_GetLong ................................................................................................................. 197
ADM_RAM_GetFloat ................................................................................................................. 198
ADM_RAM_GetDouble ............................................................................................................. 199
ADM_RAM_GetChar ................................................................................................................. 200
8 Backplane API Functions 201
8.1 Backplane API Initialization Functions .................................................................. 203
MVIbp_Open ............................................................................................................................. 203
MVIbp_Close ............................................................................................................................. 204
8.2 Backplane API Configuration Functions ............................................................... 206
MVIbp_GetIOConfig .................................................................................................................. 206
MVIbp_SetIOConfig .................................................................................................................. 208
8.3 Backplane API Synchronization Functions ........................................................... 210
MVIbp_WaitForInputScan ......................................................................................................... 210
MVIbp_WaitForOutputScan ...................................................................................................... 212
8.4 Backplane API Direct I/O Access ......................................................................... 214
MVIbp_ReadOutputImage ......................................................................................................... 214
MVIbp_WriteInputImage ............................................................................................................ 215
8.5 Backplane API Messaging Functions ................................................................... 216
MVIbp_ReceiveMessage .......................................................................................................... 216
MVIbp_SendMessage ............................................................................................................... 218
8.6 Backplane API Miscellaneous Functions .............................................................. 220
MVIbp_GetVersionInfo .............................................................................................................. 220
MVIbp_GetModuleInfo .............................................................................................................. 221
MVIbp_ErrorString ..................................................................................................................... 222
MVIbp_SetUserLED .................................................................................................................. 223
MVIbp_SetModuleStatus ........................................................................................................... 224
Page 8 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Contents 'C' Programmable Application Development Module Developer's Guide
MVIbp_GetConsoleMode .......................................................................................................... 225
MVIbp_GetSetupMode .............................................................................................................. 226
MVIbp_GetProcessorStatus ...................................................................................................... 227
MVIbp_Sleep ............................................................................................................................. 228
MVIbp_SetConsoleMode ........................................................................................................... 229
8.7 Platform Specific Functions ................................................................................... 230
MVIbp_ReadModuleFile (MVI46) .............................................................................................. 230
MVIbp_WriteModuleFile (MVI46) ............................................................................................... 231
MVIbp_SetModuleInterrupt (MVI46) .......................................................................................... 232
9 Serial Port Library Functions 233
9.1 Serial Port API Initialization Functions .................................................................. 235
MVIsp_Open .............................................................................................................................. 235
MVIsp_OpenAlt .......................................................................................................................... 237
MVIsp_Close .............................................................................................................................. 239
9.2 Serial Port API Configuration Functions ................................................................ 240
MVIsp_Config ............................................................................................................................ 240
MVIsp_SetHandshaking ............................................................................................................ 242
9.3 Serial Port API Status Functions ........................................................................... 243
MVIsp_SetRTS .......................................................................................................................... 243
MVIsp_GetRTS .......................................................................................................................... 244
MVIsp_SetDTR .......................................................................................................................... 245
MVIsp_GetDTR .......................................................................................................................... 246
MVIsp_GetCTS .......................................................................................................................... 247
MVIsp_GetDSR ......................................................................................................................... 248
MVIsp_GetDCD ......................................................................................................................... 249
MVIsp_GetLineStatus ................................................................................................................ 250
9.4 Serial Port API Communications ........................................................................... 251
MVIsp_Putch .............................................................................................................................. 251
MVIsp_Getch ............................................................................................................................. 252
MVIsp_Puts ................................................................................................................................ 253
MVIsp_PutData .......................................................................................................................... 255
MVIsp_Gets ............................................................................................................................... 257
MVIsp_GetData ......................................................................................................................... 259
MVIsp_GetCountUnsent ............................................................................................................ 261
MVIsp_GetCountUnread ........................................................................................................... 262
MVIsp_PurgeDataUnsent .......................................................................................................... 263
MVIsp_PurgeDataUnread .......................................................................................................... 264
9.5 Serial Port API Miscellaneous Functions .............................................................. 265
MVIsp_GetVersionInfo ............................................................................................................... 265
10 CIP Messaging Library Functions 267
10.1 CIP Messaging API Files....................................................................................... 268
10.2 CIP API Architecture ............................................................................................. 269
10.2.1 Backplane Device Driver ....................................................................................... 269
10.3 CIP API Initialization Functions ............................................................................. 270
MVIcip_Open ............................................................................................................................. 270
MVIcip_Close ............................................................................................................................. 271
10.4 CIP Object Registration ......................................................................................... 272
MVIcip_RegisterAssemblyObj ................................................................................................... 272
MVIcip_UnregisterAssemblyObj ................................................................................................ 274
ProSoft Technology, Inc. Page 9 of 342 February 20, 2013
Contents MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
10.5 CIPConnect® Data Transfer .................................................................................. 275
MVIcip_WriteConnected ............................................................................................................ 275
MVIcip_ReadConnected ........................................................................................................... 276
10.6 CIP Callback Functions ........................................................................................ 278
connect_proc ............................................................................................................................. 278
service_proc .............................................................................................................................. 282
rxdata_proc................................................................................................................................ 284
fatalfault_proc ............................................................................................................................ 286
flashupdate_proc ....................................................................................................................... 287
resetrequest_proc ..................................................................................................................... 288
10.7 CIP Special Callback Registration ........................................................................ 289
MVIcip_RegisterFatalFaultRtn .................................................................................................. 289
MVIcip_RegisterResetReqRtn .................................................................................................. 290
MVIcip_RegisterFlashUpdateRtn .............................................................................................. 291
10.8 CIP Miscellaneous Functions ............................................................................... 292
MVIcip_GetIdObject .................................................................................................................. 292
MVIcip_GetVersionInfo ............................................................................................................. 293
MVIcip_SetUserLED ................................................................................................................. 294
MVIcip_SetModuleStatus .......................................................................................................... 295
MVIcip_ErrorString .................................................................................................................... 296
MVIcip_GetSetupMode ............................................................................................................. 297
MVIcip_GetConsoleMode ......................................................................................................... 298
MVIcip_Sleep ............................................................................................................................ 299
11 Side-Connect API Library Functions 301
11.1 Initialization ........................................................................................................... 302
11.1.1 PLC Data Table Access ........................................................................................ 302
11.1.2 Synchronization .................................................................................................... 302
11.2 PLC Message Handling ........................................................................................ 303
11.2.1 Block Transfer ....................................................................................................... 303
11.2.2 PLC Status and Control ........................................................................................ 303
11.2.3 Miscellaneous ....................................................................................................... 303
11.3 Side-connect API Initialization Functions ............................................................. 304
MVIsc_Open .............................................................................................................................. 304
MVIsc_Close ............................................................................................................................. 305
11.4 Side-connect API PLC Data Table Access Functions .......................................... 306
MVIsc_GetPLCFileInfo .............................................................................................................. 306
MVIsc_WritePLC ....................................................................................................................... 308
MVIsc_ReadPLC ....................................................................................................................... 310
MVIsc_RMWPLC ...................................................................................................................... 312
11.5 Side-connect API Synchronization Functions ....................................................... 314
MVIsc_WaitForEos .................................................................................................................... 314
11.6 Side-connect API PLC Message Handling Functions .......................................... 315
MVIsc_PLCMsgRead ................................................................................................................ 315
MVIsc_PLCMsgWrite ................................................................................................................ 316
MVIsc_PLCMsgWait ................................................................................................................. 317
11.7 Side-connect API Block Transfer Functions ......................................................... 318
MVIsc_PLCBTRead .................................................................................................................. 318
MVIsc_PLCBTWrite .................................................................................................................. 319
11.8 Side-connect API PLC Status and Control Functions .......................................... 320
MVIsc_GetPLCStatus ............................................................................................................... 320
MVIsc_GetPLCClock ................................................................................................................. 322
Page 10 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Contents 'C' Programmable Application Development Module Developer's Guide
MVIsc_SyncPLCClock ............................................................................................................... 323
MVIsc_ClearFault ...................................................................................................................... 324
MVIsc_SetPLCMode.................................................................................................................. 325
11.9 Side-connect API Miscellaneous Functions .......................................................... 326
MVIsc_GetVersionInfo ............................................................................................................... 326
MVIsc_ErrorStr .......................................................................................................................... 327
MVIsc_GetLastPcccError........................................................................................................... 328
MVIsc_BCD2BIN ....................................................................................................................... 329
MVIsc_BIN2BCD ....................................................................................................................... 330
12 DOS 6 XL Reference Manual 331
13 Support, Service & Warranty 333
13.1 Contacting Technical Support ............................................................................... 333
13.2 Warranty Information ............................................................................................. 334
Glossary of Terms 335
Index 339
ProSoft Technology, Inc. Page 11 of 342 February 20, 2013
Contents MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
Page 12 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Introduction
In This Chapter
Operating System .................................................................................. 13
'C' Programmable Application Development Module Developer's Guide
1 Introduction
This document provides information needed for development of application programs for the MVI ADM Serial Communication Module. The MVI suite of modules is designed to allow devices with a serial port to be accessed by a PLC. The modules and their corresponding platforms are as follows:
MVI46: 1746 (SLC) MVI56: 1756 (ControlLogix) MVI69: 1769 (CompactLogix) MVI71: 1771 (PLC) MVI94: 1794 (Flex)
The modules are programmable to accommodate devices with unique serial protocols.
Included in this document is information about the available software API libraries and tools, module configuration and programming information, and example code for both the module and the PLC. This document assumes the reader is familiar with software development in the 16-bit DOS environment using the 'C' programming language. This document also assumes that the reader is familiar with Rockwell Automation programmable controllers and the PLC platform.
1.1 Operating System
The MVI module includes General Software Embedded DOS 6-XL. This operating system provides DOS compatibility along with real-time multi-tasking functionality. The operating system is stored in Flash ROM and is loaded by the BIOS when the module boots.
DOS compatibility allows user applications to be developed using standard DOS tools, such as Digital Mars C++ and Borland compilers. User programs may be executed automatically by loading them from either the CONFIG.SYS file or an AUTOEXEC.BAT file.
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.
Refer to the General Software Embedded DOS 6-XL Developer’s Guide (page 331) on the MVI-ADM CD-ROM for more information.
ProSoft Technology, Inc. Page 13 of 342 February 20, 2013
Introduction MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
Page 14 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Preparing the MVI-ADM Module
In This Chapter
Package Contents ................................................................................. 16
Recommended Compact Flash (CF) Cards .......................................... 17
Jumper Locations and Settings ............................................................. 18
Cable Connections ................................................................................ 19
'C' Programmable Application Development Module Developer's Guide
2 Preparing the MVI-ADM Module
ProSoft Technology, Inc. Page 15 of 342 February 20, 2013
Preparing the MVI-ADM Module MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
2.1 Package Contents
Your MVI-ADM package includes:
MVI-ADM Module ProSoft Technology Solutions CD-ROM (includes all documentation, sample
code, and sample ladder logic).
Null Modem Cable Config/Debug Port to DB-9 adapter
Page 16 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Preparing the MVI-ADM Module 'C' Programmable Application Development Module Developer's Guide
2.2 Recommended Compact Flash (CF) Cards
What Compact Flash card does ProSoft recommend using?
Some ProSoft products contain a "Personality Module", or Compact Flash card. ProSoft recommends using an industrial grade Compact Flash card for best
performance and durability. The following cards have been tested with ProSoft’s
modules, and are the only cards recommended for use. These cards can be ordered through ProSoft, or can be purchased by the customer.
Approved ST-Micro cards:
32M = SMC032AFC6E 64M = SMC064AFF6E 128M = SMC128AFF6E
Approved Silicon Systems cards:
256M = SSD-C25MI-3012 512M = SSD-C51MI-3012 2G = SSD-C02GI-3012 4G = SSD-C04GI-3012
ProSoft Technology, Inc. Page 17 of 342 February 20, 2013
Preparing the MVI-ADM Module MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
2.3 Jumper Locations and Settings
Each module has three jumpers:
Setup Port 1 Port 2 (Not available on MVI94)
2.3.1 Setup Jumper
The Setup jumper, located at the bottom of the module, should have the two pins jumpered when programming the module. After programming is complete, the jumper should be removed.
2.3.2 Port 1 and Port 2 Jumpers
These jumpers, located at the bottom of the module, configure the port settings to RS-232, RS-422, or RS-485. By default, the jumpers for both ports are set to RS-232. These jumpers must be set properly before using the module.
Page 18 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Preparing the MVI-ADM Module 'C' Programmable Application Development Module Developer's Guide
2.4 Cable Connections
The application ports on the MVI-ADM module support RS-232, RS-422, and RS­485 interfaces. Please inspect the module to ensure that the jumpers are set correctly to correspond with the type of interface you are using.
Note: When using RS-232 with radio modem applications, some radios or modems require hardware handshaking (control and monitoring of modem signal lines). Enable this in the configuration of the module by setting the UseCTS parameter to 1.
2.4.1 RS-232 Configuration/Debug Port
This port is physically an RJ45 connection. An RJ45 to DB-9 adapter cable is included with the module. This port permits a PC based terminal emulation program to view configuration and status data in the module and to control the module. The cable for communications on this port is shown in the following diagram:
2.4.2 RS-232 Application Port(s)
When the RS-232 interface is selected, the use of hardware handshaking (control and monitoring of modem signal lines) is user definable. If no hardware handshaking will be used, here are the cable pinouts to connect to the port.
ProSoft Technology, Inc. Page 19 of 342 February 20, 2013
Preparing the MVI-ADM Module MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
RS-232: Modem Connection (Hardware Handshaking Required)
This type of connection is required between the module and a modem or other communication device.
The "Use CTS Line" parameter for the port configuration should be set to 'Y' for most modem applications.
RS-232: Null Modem Connection (Hardware Handshaking)
This type of connection is used when the device connected to the module requires hardware handshaking (control and monitoring of modem signal lines).
Page 20 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Preparing the MVI-ADM Module 'C' Programmable Application Development Module Developer's Guide
RS-232: Null Modem Connection (No Hardware Handshaking)
This type of connection can be used to connect the module to a computer or field device communication port.
Note: For most null modem connections where hardware handshaking is not required, the Use CTS Line parameter should be set to N and no jumper will be required between Pins 7 (RTS) and 8
(CTS) on the connector. If the port is configured with the Use CTS Line set to Y, then a jumper is required between the RTS and the CTS lines on the port connection.
ProSoft Technology, Inc. Page 21 of 342 February 20, 2013
Preparing the MVI-ADM Module MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
2.4.3 RS-422
The RS-422 interface requires a single four or five wire cable. The Common connection is optional, depending on the RS-422 network devices used. The cable required for this interface is shown below:
2.4.4 RS-485 Application Port(s)
The RS-485 interface requires a single two or three wire cable. The Common connection is optional, depending on the RS-485 network devices used. The cable required for this interface is shown below:
Note: Terminating resistors are generally not required on the RS-485 network, unless you are experiencing communication problems that can be attributed to signal echoes or reflections. In these cases, installing a 120-ohm terminating resistor between pins 1 and 8 on the module connector end of the RS-485 line may improve communication quality.
RS-485 and RS-422 Tip
If communication in the RS-422 or RS-485 mode does not work at first, despite all attempts, try switching termination polarities. Some manufacturers interpret + and -, or A and B, polarities differently.
Page 22 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Preparing the MVI-ADM Module 'C' Programmable Application Development Module Developer's Guide
2.4.5 DB9 to RJ45 Adaptor (Cable 14)
ProSoft Technology, Inc. Page 23 of 342 February 20, 2013
Preparing the MVI-ADM Module MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
Page 24 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Understanding the MVI-ADM API
In This Chapter
API Libraries .......................................................................................... 26
Development Tools ............................................................................... 28
Theory of Operation .............................................................................. 29
ADM Functional Blocks ......................................................................... 30
ADM API Architecture............................................................................ 59
ADM API Files ....................................................................................... 60
Backplane API Files .............................................................................. 64
Serial API Files ...................................................................................... 66
Side-Connect API Files ......................................................................... 67
'C' Programmable Application Development Module Developer's Guide
3 Understanding the MVI-ADM API
The MVI ADM API Suite allows software developers to access the PLC backplane and serial ports without needing detailed knowledge of the module’s hardware design. The MVI ADM API Suite consists of three distinct components: the Serial Port API, the MVI Backplane/CIP API and the ADM API.
The MVI Backplane API provides access to the processor The Serial Port API provides access to the serial ports The ADM API provides functions designed to ease development. In addition to the MVI Backplane API, MVI71 also provides the MVI Side-
Connect API as an alternative interface.
Applications for the MVI ADM module may be developed using industry-standard DOS programming tools and the appropriate API components.
This section provides general information pertaining to application development for the MVI ADM module.
ProSoft Technology, Inc. Page 25 of 342 February 20, 2013
Understanding the MVI-ADM API MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
3.1 API Libraries
Each API provides a library of function calls. The library supports any programming language that is compatible with the Pascal calling convention.
Each API library is a static object code library that must be linked with the application to create the executable program. It is distributed as a 16-bit large model OMF library, compatible with Digital Mars C++ or Borland development tools.
Note: The following compiler versions are intended to be compatible with the MVI module API:
Digital Mars C++ 8.49 Borland C++ V5.02
More compilers will be added to the list as the API is tested for compatibility with them.
3.1.1 Calling Convention
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.
3.1.2 Header File
A header file is provided along with each library. This header file contains API function declarations, data structure definitions, and miscellaneous constant definitions. The header file is in standard 'C' format.
3.1.3 Sample Code
A sample application is provided to illustrate the usage of the API functions. Full source for the sample application is provided. The sample application may be compiled using Digital Mars C++ or Borland C++.
Important: The sample code and libraries in the 1756-MVI-Samples folder are not compatible with, and are not supported for, the Digital Mars compiler.
Page 26 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Understanding the MVI-ADM API 'C' Programmable Application Development Module Developer's Guide
3.1.4 Multi-threading Considerations
The DOS 6-XL operating system supports the development of multi-threaded applications.
Note: The multi-threading library kernel.lib in the DOS folder on the distribution CD-ROM is compiler-specific to Borland C++ 5.02. It is not compatible with Digital Mars C++ 8.49. ProSoft Technology, Inc. does not support multi-threading with Digital Mars C++ 8.49.
Note: The ADM DOS 6-XL operating system has a system tick of 5 milliseconds. Therefore, thread scheduling and timer servicing occur at 5ms intervals. Refer to the DOS 6-XL Developer’s Guide on the distribution CD-ROM for more information.
Multi-threading is also supported by the API. DOS and cipapi libraries have been tested and are thread-safe for use in
multi-threaded applications.
MVIbp and MVIsp libraries are safe to use in multi-threaded applications with
the following precautions: If you call the same MVIbp or MVIsp function from multiple threads, you will need to protect it, to prevent task switches during the function's execution. The same is true for different MVIbp or MVIsp functions that share the same resources (for example, two different functions that access the same read or write buffer).
WARNING: ADM and ADMNET libraries are not thread-safe. ProSoft Technology, Inc. does not support the use of ADM and ADMNET libraries in multi-threaded applications.
ProSoft Technology, Inc. Page 27 of 342 February 20, 2013
Understanding the MVI-ADM API MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
3.2 Development Tools
An application that is developed for the MVI ADM module must be executed from
the module’s Flash ROM disk. Tools are provided with the API to build the disk
image and download it to the module’s Config/Debug port.
Page 28 of 342 ProSoft Technology, Inc. February 20, 2013
MVI-ADM 'C' Programmable Understanding the MVI-ADM API 'C' Programmable Application Development Module Developer's Guide
3.3 Theory of Operation
3.3.1 ADM API
The ADM API is one component of the MVI ADM API Suite. The ADM API provides a simple module level interface that is portable between members of the MVI Family. This is useful when developing an application that implements a serial protocol for a particular device, such as a scale or bar code reader. After an application has been developed, it can be be used on any of the MVI family modules.
ProSoft Technology, Inc. Page 29 of 342 February 20, 2013
Understanding the MVI-ADM API MVI-ADM 'C' Programmable Developer's Guide 'C' Programmable Application Development Module
3.4 ADM Functional Blocks
3.4.1 Database
The database functions of the ADM API allow the creation of a database in memory to store data to be accessed via the backplane interface and the application ports. The database consists of word registers that can be accessed as bits, bytes, words, longs, floats or doubles. Functions are provided for reading and writing the data in the various data types. The database serves as a holding area for exchanging data with the processor on the backplane, and with a foreign device attached to the application port. Data transferred into the module from the processor can be requested via the serial port. Conversely, data written into the module database by the foreign device can be transferred to the processor over the backplane.
3.4.2 Backplane Communications
MVI46 Backplane Data Transfer
The MVI46-ADM module communicates directly over the backplane. All data for the module is contained in the module's M1 file. Data is moved between the module and the SLC processor across the backplane using the module's M-files. The SLC scan rate and the communication load on the module determine the update frequency of the M-files. The COP instruction can be used to move data between user data files and the module's M1 file.
The following illustration shows the data transfer method used to move data between the SLC processor, the MVI46-ADM module and the foreign network.
All data transferred between the module and the processor over the backplane is through the M0 and M1 files. Ladder logic must be written in the SLC processor to interface the M-file data with data defined in the user-defined data files in the SLC.
Page 30 of 342 ProSoft Technology, Inc. February 20, 2013
Loading...
+ 312 hidden pages