ProSoft Technology MVI56-BAS User Manual

MVI56-BAS
ControlLogix Platform
BASIC Module (DB/BAS Compatible)
December 13, 2011
USER MANUAL
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.
How to Contact 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 © 2011 ProSoft Technology, Inc., all rights reserved.
MVI56-BAS User Manual
December 13, 2011
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.
ProSoft Technology® Product Documentation
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 in Adobe® Acrobat Reader file format (.PDFs). These product documentation files may also be freely downloaded from our web site: www.prosoft-technology.com
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:
WARNING - EXPLOSION HAZARD - SUBSTITUTION OF COMPONENTS MAY IMPAIR SUITABILITY FOR CLASS I, DIV. 2; WARNING - EXPLOSION HAZARD - WHEN IN HAZARDOUS LOCATIONS, TURN OFF POWER BEFORE REPLACING OR WIRING MODULES WARNING - EXPLOSION HAZARD - DO NOT DISCONNECT EQUIPMENT UNLESS POWER HAS BEEN SWITCHED OFF OR THE AREA IS KNOWN TO BE NON-HAZARDOUS. 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
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, Division 2. B Warning - Explosion Hazard - When in hazardous locations, turn off power before replacing or rewiring modules. C 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.
D 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.
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.
Markings
Electrical Ratings
Backplane Current Load: 800 mA @ 5.1 Vdc; 3 mA @ 24 Vdc  Operating Temperature: 0°C to 60°C (32°F to 140°F)  Storage Temperature: -40°C to 85°C (-40°F to 185°F)  Shock: 30 g, operational; 50 g, non-operational; Vibration: 5 g from 10 Hz to 150 Hz  Relative Humidity: 5% to 95% with no condensation  All phase conductor sizes must be at least 1.3 mm(squared) and all earth ground conductors must be at least
4mm(squared).
Label Markings
ATEX II 3 G EEx nA IIC T6 0°C <= Ta <= 60°C
cULus E183151 Class I Div 2 Groups A,B,C,D T6
-30°C <= Ta <= 60°C
Agency Approvals and Certifications
Agency Applicable Standard
RoHS CE EMC-EN61326-1:2006; EN61000-6-4:2007 ATEX EN60079-15:2003 cULus UL508; UL1604; CSA 22.2 No. 142 & 213 CB Safety CA/10533/CSA
IEC 61010-1 Ed.2; CB 243333-2056722 (2090408) GOST-R EN 61010 CSA EN 61010 Korea KCC KCC-REM-PFT-MVI56-AFC
243333
ME06
E183151
MVI56-BAS ♦ ControlLogix Platform Contents BASIC Module (DB/BAS Compatible) User Manual
Contents
Your Feedback Please ........................................................................................................................ 2
How to Contact Us .............................................................................................................................. 2
ProSoft Technology® Product Documentation .................................................................................... 2
Important Installation Instructions ....................................................................................................... 3
MVI (Multi Vendor Interface) Modules ................................................................................................ 3
Warnings ............................................................................................................................................. 3
Battery Life Advisory ........................................................................................................................... 4
Markings .............................................................................................................................................. 4
Guide to the MVI56-BAS User Manual 13
1 Start Here 15
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.6.1
System Requirements ............................................................................................. 16
Package Contents ................................................................................................... 17
Setting Jumpers ...................................................................................................... 18
Installing the Module in the Rack ............................................................................ 19
Connecting Your PC to the ControlLogix Processor ............................................... 21
Using the Sample Ladder Logic .............................................................................. 22
Configuring the RSLinx Driver for the PC COM Port .............................................. 22
Downloading the Sample Program to the Processor .............................................. 24
Connecting Your PC to the Module ......................................................................... 25
2 Module Configuration 29
2.1
Installing and Configuring the Module ..................................................................... 29
3 BASIC Programming 33
3.1
3.2
3.3
3.4
The Argument Stack ................................................................................................ 34
Using CALLs ........................................................................................................... 35
Using Strings ........................................................................................................... 36
ControlLogix Processor Interrupt ............................................................................ 37
4 Backplane Data Transfer 39
4.1
4.2
Data Transfer from Output Buffer to CLX Processor .............................................. 40
Data Transfer from CLX Processor to MVI Input Buffer .......................................... 43
5 Using the Program Port (PRT1) 45
5.1
5.2
5.3
5.4
5.4.1
5.4.2
5.4.3
Interfacing the PC and the MVI56-BAS ................................................................... 46
Creating BASIC programs ....................................................................................... 47
EDIT Command ....................................................................................................... 50
Permanently Saving BASIC Programs .................................................................... 51
EPROM File Storage ............................................................................................... 51
Erasing EPROM Programs ..................................................................................... 51
Editing EPROM Programs....................................................................................... 51
ProSoft Technology, Inc. Page 7 of 234 December 13, 2011
Contents MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
5.4.4
5.5
5.6
5.7
5.8
5.9
5.10
5.11
5.12
5.13
5.4.5
5.5.1
5.5.2
5.5.3
5.6.1
5.6.2
5.7.1
5.7.2
Using XRAM and EPROM Programs as Subroutines ............................................ 52
Automatically Executing ROM 1 at Power-up ......................................................... 52
Creating Offline BASIC programs ........................................................................... 53
Downloading BASIC Files From a PC to the MVI56-BAS ...................................... 53
Uploading BASIC files from the MVI56-BAS to a PC ............................................. 56
Loading a BASIC Program ..................................................................................... 58
Module Backup ....................................................................................................... 59
Backup with a Compact Flash Card Reader .......................................................... 59
Backup without a Compact Flash Card Reader ..................................................... 59
Module Restoration ................................................................................................. 61
Restoration with a Compact Flash Card Reader .................................................... 61
Restoration without a Compact flash Card Reader ................................................ 61
Program Copies ...................................................................................................... 63
Running a BASIC Program ..................................................................................... 64
Debugging a BASIC Program ................................................................................. 65
Commenting a BASIC Program .............................................................................. 70
Checking Available and Used RAM Memory .......................................................... 71
Exit a BASIC Program (Ctrl+C) .............................................................................. 72
6 Using ASCII Communications 73
6.1
6.2
6.3
Port Transmit and Receive Buffers ......................................................................... 74
ASCII Data Transfer from MVI56-BAS Serial Port to CLX ..................................... 75
ASCII Data Transfer from CLX to MVI56-BAS Serial Port ..................................... 78
7 Using DF1 Protocol Communications 81
7.1
7.2
7.3
7.4
7.5
7.6
7.7
Operation ................................................................................................................ 82
Communication ....................................................................................................... 83
DF1 Commands ...................................................................................................... 84
Sending a DF1 Read Command ............................................................................. 85
Sending a DF1 Write Command ............................................................................. 87
Receiving a DF1 Write Command .......................................................................... 89
Transmitting a DF1 Packet ..................................................................................... 91
8 Using DH-485 Communications 93
8.1
8.2
8.3
8.4 Data File 98
8.5
8.6 File (CIF) 101
8.6.1
Data Transfer Between the CLX and a Remote SLC DH-485 Data File ................ 94
Writing to a Remote DH-485 SLC Data File (CALL 28).......................................... 95
Reading From a Remote DH-485 SLC Data File (CALL 27) .................................. 97
Data Transfer Between a MVI56-BAS Internal String and a Remote DH-485 SLC
Data Transfer Between the MVI56-BAS and Remote DH-485 Data Files ............. 99
Transfer Data Between the MVI56-BAS Module and a Remote Common Interface
Using the MVI56-BAS Common Interface File (CIF) ............................................ 102
9 BASIC CALLs Syntax 105
9.1
9.1.1
CALL 14: Convert 16-Bit Signed to Float Point ......................................................................... 106
Data Conversion CALLs ....................................................................................... 106
Input CALLs .......................................................................................................... 106
Page 8 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Contents BASIC Module (DB/BAS Compatible) User Manual
CALL 15: Convert 16-Bit Unsigned to Float Point ..................................................................... 108
CALL 89: CLX Floating Point to BASIC Float Point ................................................................... 109
9.1.2
CALL 24: Convert Floating Point Data to 16-Bit Signed Integer ............................................... 109
CALL 25: Convert Floating Point Data to 16-Bit Binary ............................................................. 111
CALL 88: Convert BASIC Floating Point Data to CLX Floating Point ....................................... 112
9.2
CALL 51: Check CLX Output Image .......................................................................................... 113
CALL 53: Transfer CLX Output Image to BASIC Input Buffer ................................................... 114
CALL 54: Transfer Data from BASIC Output Buffer to CLX Input Image .................................. 115
CALL 55: Check CLX Input Image ............................................................................................. 116
CALL 56: Transfer Data from CLX to BASIC Input Buffer using MSG ...................................... 117
CALL 57: Transfer BASIC Output Buffer to CLX using MSG .................................................... 118
CALL 58: Check CLX MSG ....................................................................................................... 119
CALL 59: Check CLX MSG ....................................................................................................... 120
CALL 75: Check CLX Status ..................................................................................................... 121
CALL 120: Clear Module Input and Output Buffers ................................................................... 122
9.3
CALL 30: Set PRT2 Port Parameters ........................................................................................ 123
CALL 31: Display PRT2 Port Setup ........................................................................................... 124
CALL 35: Get Input Character From PRT2................................................................................ 125
CALL 36: Get Number of Characters in PRT2 Buffer ................................................................ 126
CALL 37: Clear PRT2 Buffers .................................................................................................... 127
CALL 78: Set Program Port Baud Rate ..................................................................................... 128
CALL 94: Display PRT1 Port Setup ........................................................................................... 129
CALL 95: Get Number of Characters in PRT1 Buffer ................................................................ 130
CALL 96: Clear PRT1 Buffers .................................................................................................... 131
CALL 97: Set PRT2 DTR Signal ................................................................................................ 132
CALL 98: Clear PRT2 DTR Signal ............................................................................................. 133
CALL 99: Reset Print Head Pointer ........................................................................................... 134
CALL 105: Reset PRT1 to Default Parameters ......................................................................... 135
CALL 119: Reset PRT2 to Default Parameters ......................................................................... 136
9.4
CALL 40: Set Clock Time .......................................................................................................... 137
CALL 41: Set Calendar Date ..................................................................................................... 138
CALL 42: Set Day of the Week .................................................................................................. 139
CALL 43: Retrieve Date and Time String .................................................................................. 140
CALL 44: Retrieve Date Numeric .............................................................................................. 141
CALL 45: Retrieve Date String .................................................................................................. 142
CALL 46: Retrieve Time Numeric .............................................................................................. 143
CALL 47: Retrieve Day of Week String ..................................................................................... 144
CALL 48: Retrieve Day of Week Numeric ................................................................................. 145
CALL 52: Retrieve Date String .................................................................................................. 146
9.5
CALL 60: Repeating a Character ............................................................................................... 147
CALL 61: Concatenating a String .............................................................................................. 148
CALL 62: Converting from Numeric Format to String Format ................................................... 149
CALL 63: Converting from String Format to Numeric Format ................................................... 150
CALL 64: Finding a String within Another String ....................................................................... 151
CALL 65: Replacing a String in Another String ......................................................................... 152
CALL 66: Inserting a String in Another String ............................................................................ 153
CALL 67: Deleting a String in Another String ............................................................................ 154
CALL 68: Determining the Length of a String ............................................................................ 155
9.6
Output CALLs ........................................................................................................ 109
Backplane CALLs .................................................................................................. 113
Serial Port CALLs .................................................................................................. 123
Wall Clock CALLs .................................................................................................. 137
String CALLs ......................................................................................................... 147
DH-485 CALLs ...................................................................................................... 156
ProSoft Technology, Inc. Page 9 of 234 December 13, 2011
Contents MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
CALL 27: Read Remote DH-485 SLC Data File ....................................................................... 156
CALL 28: Write to Remote DH-485 SLC Data File ................................................................... 158
CALL 83: Display DH-485 Port Parameters .............................................................................. 160
CALL 84: Transfer DH-485 Interface File to MVI56-BAS Input Buffer ...................................... 161
CALL 85: Transfer MVI56-BAS Output Buffer to DH-485 Interface File ................................... 162
CALL 86: Check DH-485 Interface File Remote Write Status .................................................. 163
CALL 87: Check DH-485 Interface File Remote Read Status .................................................. 164
CALL 90: Read Remote DH-485 Data File to MVI56-BAS Input Buffer ................................... 165
CALL 91: Write MVI56-BAS Output Buffer to Remote DH-485 Data File ................................. 167
CALL 92: Read Remote DH-485 Common Interface File to MVI56-BAS Input Buffer ............. 169
CALL 93: Write From BAS Output Buffer to Remote DH-485 CIF ............................................ 170
9.7
CALL 108: Enable DF1 Driver to PRT2 .................................................................................... 171
CALL 113: Disable PRT2 DF1 Driver ........................................................................................ 173
CALL 114: Transmit DF1 Packet............................................................................................... 174
CALL 115: Check DF1 XMIT Status ......................................................................................... 175
CALL 117: Get DF1 Packet Length ........................................................................................... 176
9.8
CALL 0: Reset BASIC ............................................................................................................... 176
CALL 16: Enable DF1 Packet Interrupt ..................................................................................... 177
CALL 17: Disable DF1 Packet Interrupt .................................................................................... 178
CALL 20: Enable Processor Interrupt ....................................................................................... 179
CALL 21: Disable Processor Interrupt ....................................................................................... 180
CALL 29: Read/Write To/From Internal String (DF1 or DH-485) .............................................. 181
CALL 70: ROM to RAM Program Transfer ................................................................................ 182
CALL 71: ROM/RAM to ROM Program Transfer ...................................................................... 183
CALL 72: ROM/RAM Return ..................................................................................................... 184
9.9
9.9.1
CALL 22: Transfer Data from a Serial Port to CLX ................................................................... 185
CALL 23: Transfer Data from CLX to a Serial Port ................................................................... 187
9.9.2
CALL 118: Receive DF1 or DH-485 Unsolicited Write .............................................................. 188
9.9.3
CALL 118: Receive DF1 or DH-485 Unsolicited Write .............................................................. 189
CALL 122: Read Remote DF1 PLC Data File ........................................................................... 192
CALL 123: Write Remote DF1 PLC Data File ........................................................................... 194
9.10
CALL 18: Enable ^C Check ....................................................................................................... 196
CALL 19: Disable ^C Check ...................................................................................................... 197
CALL 80: Check Battery Condition ........................................................................................... 198
CALL 81: EPROM Check .......................................................................................................... 199
CALL 109: Print Argument Stack .............................................................................................. 200
9.11
9.11.1
9.11.2
DF1 CALLs ........................................................................................................... 171
BASIC Program Flow Control CALLs ................................................................... 176
Background CALLs ............................................................................................... 185
ASCII Background CALLs .................................................................................... 185
DH-485 Background CALLs ................................................................................. 188
DF1 Background CALLs ....................................................................................... 189
Miscellaneous CALLs ........................................................................................... 196
LED Status Indicators ........................................................................................... 201
Clearing a Fault Condition .................................................................................... 202
Troubleshooting .................................................................................................... 202
10 BASIC-52 Implementation 203
10.1
10.2
10.2.1
10.2.2
Operators and Statements .................................................................................... 204
Control Expressions .............................................................................................. 210
IF-THEN-ELSE ..................................................................................................... 210
DO-UNTIL ............................................................................................................. 210
Page 10 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Contents BASIC Module (DB/BAS Compatible) User Manual
10.2.3
DO-WHILE ............................................................................................................ 210
10.2.4
FOR-TO- (STEP)-NEXT ........................................................................................ 211
10.2.5
GOTO .................................................................................................................... 211
10.2.6
END ....................................................................................................................... 211
10.2.7
GOSUB.................................................................................................................. 212
11 Reference 213
11.1
11.2
11.3
11.4
11.1.1
11.1.2
11.1.3
11.2.1
11.3.1
11.3.2
11.4.1
11.4.2
11.4.3
Product Specifications ........................................................................................... 214
General Specifications .......................................................................................... 214
Hardware Specifications........................................................................................ 215
Functional Specifications....................................................................................... 216
Functional Overview .............................................................................................. 217
General Concepts ................................................................................................. 217
Cable Connections ................................................................................................ 226
BASIC DH-485 Port ............................................................................................... 227
BASIC PRT1 and PRT2 ........................................................................................ 227
1746-BAS Comparison .......................................................................................... 228
CALLs Not Supported ........................................................................................... 228
New Commands .................................................................................................... 228
Differences ............................................................................................................ 228
12 Support, Service & Warranty 229
Contacting Technical Support ......................................................................................................... 229
Warranty Information ...................................................................................................................... 230
Index 231
ProSoft Technology, Inc. Page 11 of 234 December 13, 2011
Contents MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Page 12 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Guide to the MVI56-BAS User Manual BASIC Module (DB/BAS Compatible) User Manual
Guide to the MVI56-BAS User Manual
Function
Introduction (Must Do)
Diagnostic and Troubleshooting
Reference
Product Specifications
Support, Service, and Warranty
Index
Section to Read Details
Start Here (page 15) This section introduces the customer to the
Diagnostics and
Troubleshooting
Reference (page
213)
Product Specifications (page
214)
Support, Service
and Warranty (page
229)
Index
module. Included are: package contents, system requirements, hardware installation, and basic configuration.
This section describes Diagnostic and Troubleshooting procedures.
These sections contain general references associated with this product and its Specifications..
This section contains Support, Service and Warranty information.
Index of chapters.
ProSoft Technology, Inc. Page 13 of 234 December 13, 2011
Start Here MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Page 14 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Start Here BASIC Module (DB/BAS Compatible) User Manual
1 Start Here
In This Chapter
System Requirements ........................................................................... 16
Package Contents ................................................................................. 17
Setting Jumpers .................................................................................... 18
Installing the Module in the Rack ........................................................... 19
Connecting Your PC to the ControlLogix Processor .............................. 21
Using the Sample Ladder Logic ............................................................ 22
Downloading the Sample Program to the Processor ............................. 24
Connecting Your PC to the Module ....................................................... 25
To get the most benefit from this User Manual, you should have the following skills:
Rockwell Automation® RSLogix™ software: launch the program, configure
ladder logic, and transfer the ladder logic to the processor
Microsoft Windows: install and launch programs, execute menu commands,
navigate dialog boxes, and enter data
Hardware installation and wiring: install the module, and safely connect
BASIC and ControlLogix devices to a power source and to the MVI56-BAS module’s application port(s)
ProSoft Technology, Inc. Page 15 of 234 December 13, 2011
Start Here MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
1.1 System Requirements
The MVI56-BAS module requires the following minimum hardware and software components:
Rockwell Automation ControlLogix™ processor, with compatible power
supply and one free slot in the rack, for the MVI56-BAS module. The module requires 800 mA of available power.
Rockwell Automation RSLogix 5000 programming software version 2.51 or
higher
Rockwell Automation RSLinx communication software Pentium® II 450 MHz minimum. Pentium III 733 MHz (or better)
recommended
Supported operating systems:
o
Microsoft Windows XP Professional with Service Pack 1 or 2
o
Microsoft Windows 2000 Professional with Service Pack 1, 2, or 3
o
Microsoft Windows Server 2003
128 Mbytes of RAM minimum, 256 Mbytes of RAM recommended 100 Mbytes of free hard disk space (or more based on application
requirements)
256-color VGA graphics adapter, 800 x 600 minimum resolution (True Color
1024 × 768 recommended)
CD-ROM drive ProSoft Configuration Builder, HyperTerminal or other terminal emulator
program.
Note: You can install the module in a local or remote rack. For remote rack installation, the module requires EtherNet/IP or ControlNet communication with the processor.
Page 16 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Start Here BASIC Module (DB/BAS Compatible) User Manual
1.2 Package Contents
The following components are included with your MVI56-BAS module, and are all required for installation and configuration.
Important: Before beginning the installation, please verify that all of the following items are present.
Qty. Part Name Part Number Part Description
1 MVI56-BAS Module MVI56-BAS BASIC Module (DB/BAS Compatible) 1 Cable Cable #15, RS232
3 Cable Cable #14, RJ45 to
2 Adapter 1454-9F Two Adapters, DB9 Female to Screw
1 ProSoft Solutions CD Contains sample programs, utilities and
If any of these components are missing, please contact ProSoft Technology Support for replacement parts.
For RS232 Connection to the CFG Port
Null Modem
For DB9 Connection to Module’s Port DB9 Male Adapter cable
Terminal. For RS422 or RS485
Connections to Port 1 and 2 of the Module
documentation for the MVI56-BAS module.
ProSoft Technology, Inc. Page 17 of 234 December 13, 2011
Start Here MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
1.3 Setting Jumpers
If you use an interface other than RS-232 (default), you must change the jumper configuration to select the interface you wish to use. There are three jumpers located at the bottom of the module.
The following illustration shows the MVI56-BAS jumper configuration:
1 Set the PRT 2 (for application port 1) and PRT 3 (for application port 2)
jumpers select RS232, RS422, or RS485 to match the wiring needed for your application. The default jumper setting for both application ports is RS-232.
2 The Setup Jumper acts as "write protection" for the module’s flash memory.
In "write protected" mode, the Setup pins are not connected, and the module’s firmware cannot be overwritten. Do not jumper the Setup pins together unless you are directed to do so by ProSoft Technical Support.
Page 18 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Start Here BASIC Module (DB/BAS Compatible) User Manual
1.4 Installing the Module in the Rack
If you have not already installed and configured your ControlLogix processor and power supply, please do so before installing the MVI56-BAS module. Refer to your Rockwell Automation product documentation for installation instructions.
Warning: You must follow all safety instructions when installing this or any other electronic devices. Failure to follow safety procedures could result in damage to hardware or data, or even serious injury or death to personnel. Refer to the documentation for each device you plan to connect to verify that suitable safety procedures are in place before installing or servicing the device.
After you have checked the placement of the jumpers, insert MVI56-BAS into the ControlLogix chassis. Use the same technique recommended by Rockwell Automation to remove and install ControlLogix modules.
Warning: When you insert or remove the module while backplane power is on, an electrical arc can occur. This could cause an explosion in hazardous location installations. Verify that power is removed or the area is non-hazardous before proceeding. Repeated electrical arcing causes excessive wear to contacts on both the module and its mating connector. Worn contacts may create electrical resistance that can affect module operation.
1 Turn power OFF. 2 Align the module with the top and bottom guides, and slide it into the rack
until the module is firmly against the backplane connector.
ProSoft Technology, Inc. Page 19 of 234 December 13, 2011
Start Here MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
3 With a firm but steady push, snap the module into place. 4 Check that the holding clips on the top and bottom of the module are securely
in the locking holes of the rack.
5 Make a note of the slot location. You must identify the slot in which the
module is installed in order for the sample program to work correctly. Slot numbers are identified on the green circuit board (backplane) of the ControlLogix rack.
6 Turn power ON.
Note: If you insert the module improperly, the system may stop working, or may behave unpredictably.
Page 20 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Start Here BASIC Module (DB/BAS Compatible) User Manual
1.5 Connecting Your PC to the ControlLogix Processor
There are several ways to establish communication between your PC and the ControlLogix processor. The following steps show how to establish communication through the serial interface. It is not mandatory that you use the processor's serial interface. You may access the processor through whatever network interface is available on your system. Refer to your Rockwell Automation documentation for information on other connection methods.
1 Connect the right-angle connector end of the cable to your controller at the
communications port.
2 Connect the straight connector end of the cable to the serial port on your
computer.
ProSoft Technology, Inc. Page 21 of 234 December 13, 2011
Start Here MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
1.6 Using the Sample Ladder Logic
The sample program for your MVI56-BAS module includes custom tags, data types, and ladder logic for data I/O and status monitoring. For most applications, you can run the sample ladder program without modification, or, for advanced applications, you can incorporate the sample program into your existing application.
The inRAx Solutions CD provides one or more versions of the sample ladder logic. The version number appended to the file name corresponds with the firmware version number of your ControlLogix processor. The firmware version and sample program version must match.
1.6.1 Configuring the RSLinx Driver for the PC COM Port
If RSLogix is unable to establish communication with the processor, follow these steps.
1 Open RSLinx. 2 Open the C
OMMUNICATIONS
menu, and choose C
ONFIGURE DRIVERS
.
This action opens the Configure Drivers dialog box.
Note: If the list of configured drivers is blank, you must first choose and configure a driver from the
Available Driver Types list. The recommended driver type to choose for serial communication with the processor is RS-232 DF1 Devices.
Page 22 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Start Here BASIC Module (DB/BAS Compatible) User Manual
3 Click to select the driver, and then click C
ONFIGURE
. This action opens the
Configure RS-232 DF1 Devices dialog box.
4 Click the A
UTO-CONFIGURE
button. RSLinx will attempt to configure your
serial port to work with the selected driver.
5 When you see the message Auto Configuration Successful, click the OK
button to dismiss the dialog box.
Note: If the auto-configuration procedure fails, verify that the cables are connected correctly between the processor and the serial port on your computer, and then try again. If you are still unable to auto-configure the port, refer to your RSLinx documentation for further troubleshooting steps.
ProSoft Technology, Inc. Page 23 of 234 December 13, 2011
Start Here MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
1.7 Downloading the Sample Program to the Processor
Note: The key switch on the front of the ControlLogix processor must be in the REM or PROG position.
1 If you are not already online with the processor, open the Communications
menu, and then choose D communication with the processor. You do not have to download through the processor's serial port, as shown here. You may download through any available network connection.
2 When communication is established, RSLogix 5000 will open a confirmation
dialog box. Click the D processor.
OWNLOAD.
OWNLOAD
RSLogix 5000 will establish
button to transfer the sample program to the
3 RSLogix 5000 will compile the program and transfer it to the processor. This
process may take a few minutes.
4 When the download is complete, RSLogix 5000 will open another
confirmation dialog box. If the key switch is in the REM position, click OK to switch the processor from PROGRAM mode to RUN mode.
Note: If you receive an error message during these steps, refer to your RSLogix documentation to interpret and correct the error.
Page 24 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Start Here BASIC Module (DB/BAS Compatible) User Manual
1.8 Connecting Your PC to the Module
With the module securely mounted, connect your PC to the Configuration/Debug port using an RJ45-DB-9 Serial Adapter Cable and a Null Modem Cable.
1 Attach both cables as shown. 2 Insert the RJ45 cable connector into the Config/Debug port of the module. 3 Attach the other end to the serial port on your PC.
The communication port driver in RSLinx can occasionally prevent other applications from using the PC’s COM port. If you are not able to connect to the module’s configuration/debug port using ProSoft Configuration Builder (PCB),
HyperTerminal or another terminal emulator, follow these steps to disable the RSLinx driver.
1 Open RSLinx and go to C
OMMUNICATIONS
> RSWHO.
2 Make sure that you are not actively browsing using the driver that you wish to
stop. The following shows an actively browsed network.
ProSoft Technology, Inc. Page 25 of 234 December 13, 2011
Start Here MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
3 Notice how the DF1 driver is opened, and the driver is looking for a processor
on Node 1. If the network is being browsed, then you will not be able to stop this driver. To stop the driver your RSWho screen should look like this:
Branches are displayed or hidden by clicking on the or the icons.
4 When you have verified that the driver is not being browsed, go to
C
OMMUNICATIONS
> C
ONFIGURE DRIVERS
.
You may see something like this:
5 If you see the status as running, you will not be able to use this COM port for
anything other than communication to the processor. To stop the driver press the S
TOP
button on the side of the window:
6 After you have stopped the driver you will see the following.
Page 26 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Start Here BASIC Module (DB/BAS Compatible) User Manual
7 You may now use the COM port to connect to the Config/Debug port of the
module.
Note: You may need to shut down and restart your PC before it will allow you to stop the driver (usually only on Windows NT machines). If you have followed all of the above steps, and it will not stop the driver, then make sure you do not have RSLogix open. If RSLogix is open, you will not be able to stop the DF1 driver. If RSLogix is not open, and you still cannot stop the driver, then reboot your PC.
ProSoft Technology, Inc. Page 27 of 234 December 13, 2011
Start Here MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Page 28 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Module Configuration BASIC Module (DB/BAS Compatible) User Manual
2 Module Configuration
In This Chapter
Installing and Configuring the Module ................................................... 29
This section contains the setup procedure, data, and ladder logic for successful application of the MVI56-BAS module. Each step in the setup procedure is defined in order to simplify the use of the module.
2.1 Installing and Configuring the Module
This chapter describes how to install and configure the module to work with your application. The configuration process consists of the following steps.
1 Use RSLogix 5000 to identify the module to the processor and add the
module to a project.
Note: The RSLogix 5000 software should be in "off-line" mode to add the module to a project. Although some newer versions of RSLogix 5000 may allow new modules to be added while in "online" mode, it is always considered safer to add new modules off-line and test the new configuration in a test system before putting the modified program online.
2 Modify the example ladder logic to meet the needs of your application, and
download the ladder logic to the processor. Example ladder logic files are provided on the CD-ROM.
Note: If you are installing this module in an existing application, you can copy the necessary elements from the example ladder logic into your application.
The rest of this chapter describes these steps in more detail.
ProSoft Technology, Inc. Page 29 of 234 December 13, 2011
Module Configuration MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
First, define the module to the system. Right-click the mouse button on the I/O Configuration option in the Controller Organization window to display a pop-up menu. Select the New Module option from the I/O Configuration menu.
This action opens the following dialog box.
Page 30 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Module Configuration BASIC Module (DB/BAS Compatible) User Manual
Select the 1756-Module (Generic 1756 Module) from the list and click OK. The following dialog box is displayed.
Fill in the dialog box as shown adjusting the Name, Description and Slot options for your application. You must select the Comm Format as Data - INT in the dialog box. Failure to set the Assembly Instance and Size values correctly will result in a module that will not communicate over the backplane of the ControlLogix rack. Click Next to display the next dialog box.
Select the Request Packet Interval value for scanning the I/O on the module. This value represents the minimum frequency that the module will handle scheduled events. This value should not be set to less than 1 millisecond. Values between 1 and 10 milliseconds should work with most applications.
ProSoft Technology, Inc. Page 31 of 234 December 13, 2011
Module Configuration MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
After completing the module setup, the Controller Organization window will display the module’s presence. The data required for the module will be defined to the application, and objects will be allocated in the Controller Tags data area. An example of the Controller Organization window is shown below.
Download the new application to the controller and place the processor in run mode. If all the configuration parameters are set, the module’s Application LED (APP LED) should remain off and the backplane activity LED (BP ACT) should blink rapidly. Refer to Diagnostics and Troubleshooting if you encounter errors. Attach a computer or terminal to PRT1 on the module and look at the status of the module using the Configuration/Debug Menu in the module.
Page 32 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform BASIC Programming BASIC Module (DB/BAS Compatible) User Manual
3 BASIC Programming
In This Chapter
The Argument Stack .............................................................................. 34
Using CALLs ......................................................................................... 35
Using Strings ......................................................................................... 36
ControlLogix Processor Interrupt ........................................................... 37
This section presents an overview of the BASIC-52 implementation for the MVI56-BAS. It provides the information necessary to write a BASIC program for the MVI56-BAS.
ProSoft Technology, Inc. Page 33 of 234 December 13, 2011
BASIC Programming MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
3.1 The Argument Stack
The results of all BASIC expressions or operations are stored in the argument stack. The argument stack holds up to 20 values.
In order to insert a value in the top of the argument stack, the must be used.
In order to retrieve the value from the top of the argument stack, a must be used. It will remove the current value from the top of the argument stack moving the following value in its place.
For example, entering in the program port command line:
>PUSH 1 >PUSH 2 >PUSH 3 >POP A >POP B >POP C >PRINT A 3 >PRINT B 2 >PRINT C 1
Use CALL 109 to print the first 9 values in the argument stack to aid in troubleshooting.
For example:
>PUSH 1 >PUSH 2 >PUSH 3 >CALL 109 000 1 001 2 002 3 Argument Stack Pointer is 3
PUSH
command
POP
command
Page 34 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform BASIC Programming BASIC Module (DB/BAS Compatible) User Manual
3.2 Using CALLs
There are several pre-defined functions in BASIC referred to as CALLs. Each CALL can have zero or more input parameters and return zero more output values. The module uses the argument stack to read the input parameters and write the output results. The input parameters and the output result(s) are both located in the argument stack. functions that require input and output variables.
For example, if a CALL function requires 3 input parameters and returns 2 output values, it should be used in a BASIC program in the following way:
PUSH 4 PUSH 2 PUSH 4 CALL [CALLNUMBER] POP D POP E
The variables D and E will store the 2 output values returned by this CALL. The BASIC CALLs Syntax section provides information about each call supported by the MVI56-BAS.
PUSH
and
POP
commands are used with CALL
ProSoft Technology, Inc. Page 35 of 234 December 13, 2011
BASIC Programming MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
3.3 Using Strings
Strings are a group of characters that can be accessed in a BASIC program or command line by the following syntax:
$(num)
Where num varies between 0 and 254. Before using strings, you must allocate enough memory using the
command:
STRING(A,B)
Where:
A = total number of bytes for the all strings B = maximum number of bytes for each string The MVI56-BAS requires an extra byte for each string and an additional
overhead byte.
Example:
10 STRING 307, 50 20 $(0) = "TEST 1" 30 $(1) = "TEST 2" 40 $(2) = "TEST 3" 50 $(3) = "TEST 4" 60 $(4) = "TEST 5" 70 $(5) = "TEST 6"
The
STRING
for each string and one byte overall. There are several BASIC CALLs that allow string manipulation. Refer to String
CALLs (page 147).
command allocated space for 6 strings (50 bytes each) plus one byte
STRING
Page 36 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform BASIC Programming BASIC Module (DB/BAS Compatible) User Manual
3.4 ControlLogix Processor Interrupt
The MVI56-BAS allows the ControlLogix to interrupt the current BASIC program using CALL 20 (Enable Processor Interrupt). When word 0 bit 15 in the output image (Local:x:O:Data[0].15) toggles from OFF to ON, the program jumps to the line number specified by the CALL 20 parameter.
Use the being interrupted.
The following BASIC program shows how to use CALL 20:
10 PUSH 50: REM JUMPS TO LINE NUMBER 50 20 CALL 20 30 GOTO 30 35 PRINT "LINE 35" 40 PRINT "LINE 40" 50 PRINT "LINE 50" 60 PRINT "LINE 60" 70 RETI 80 END
While the program is running, the following ladder logic is executed:
RETI
command in order to return to the point the program was before
The result is:
LINE 50 LINE 60
To disable the processor interrupt, use CALL 21 (Disable Processor Interrupt). This routine has no arguments and does not return any value.
Refer to BASIC CALLs Syntax (page 105) for more information about CALLs 20 and 21.
ProSoft Technology, Inc. Page 37 of 234 December 13, 2011
BASIC Programming MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Page 38 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Backplane Data Transfer BASIC Module (DB/BAS Compatible) User Manual
4 Backplane Data Transfer
In This Chapter
Data Transfer from Output Buffer to CLX Processor ............................. 40
Data Transfer from CLX Processor to MVI Input Buffer ........................ 43
This section describes how to transfer data between the MVI56-BAS and the ControlLogix processor.
ProSoft Technology, Inc. Page 39 of 234 December 13, 2011
Backplane Data Transfer MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
4.1 Data Transfer from Output Buffer to CLX Processor
The MVI56-BAS module output buffer can be used to transfer data to the ControlLogix processor.
The first step is to move data to the output buffer using CALLs 24 and 25. These CALLs convert BASIC floating point data into integer values truncating the fractional part. The result is stored in the output buffer between addresses 0 and
231. After the data has been moved to the output buffer, there are 2 ways to transfer it
to the ControlLogix; writing to the CLX input image file (CALL 54) or using MSG instructions (CALL 57).
The following illustration shows how to transfer data between the MVI56-BAS output buffer and the ControlLogix processor.
The output buffer is divided into areas depending on the destination of the data transferred. The output buffer addressing is shown in the following table.
Address Definition
0 to 39 DH-485 Common Interface File - data read by other devices 40 to 99 Reserved 100 to 199 Data read by the CLX using MSG instruction
200 to 231
Data transferred to the CLX Input Image file
CALL 54 transfers words 200 to 207 (8 words) from the module output buffer to the CLX input image (Local:x:I.Data[ ]). No ladder logic is required to perform the data transfer.
Page 40 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Backplane Data Transfer BASIC Module (DB/BAS Compatible) User Manual
Note: The upper three bits in Word 200 are reserved and cannot be modified. The lower thirteen bits can be used. The upper three bits provide module status information to the ControlLogix, Where
Address Definition
bit 0 Modifiable bit 1 Modifiable bit 2 Modifiable bit 3 Modifiable bit 4 Modifiable bit 5 Modifiable bit 6 Modifiable bit 7 Modifiable bit 8 Modifiable bit 9 Modifiable bit 10 Modifiable bit 11 Modifiable bit 12 Modifiable bit 13 Battery status bit (0-battery good 1 -low voltage) bit 14 Reserved bit 15 MVI56-BAS program mode (0-run mode , 1-command)
CALL 57 will transfer data from the MVI56-BAS output buffer to a CLX data file using a Class 3 Message. In order to accomplish this, ladder logic is required
The following BASIC program transfers data to the output buffer using CALL 24 and executes CALL 57: 1 REM CALL 57 10 FOR I=100 TO 149 30 PUSH 200-I: REM VALUE TO BE TRANSFERRED 40 PUSH I: REM ADDRESS IN OUTPUT BUFFER 50 CALL 24 60 NEXT I 70 PUSH 50: REM NUMBER OF WORDS TO BE TRANSFERRED 80 CALL 57: 90 POP S: REM CALL 57 RESULT 130 END
ProSoft Technology, Inc. Page 41 of 234 December 13, 2011
Backplane Data Transfer MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Following CALL 57 execution, the ladder logic should perform a MSG instruction in order to read the data setup by CALL 57. The MSG instruction should be configured as shown in the following example:
The following ladder logic can be used to read the data:
Page 42 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Backplane Data Transfer BASIC Module (DB/BAS Compatible) User Manual
4.2 Data Transfer from CLX Processor to MVI Input Buffer
The following BASIC CALLs 14, 15, 53 and 56 are covered in this section. Refer to BASIC CALLs Syntax (page 105) for detailed syntax information about these CALLs.
The MVI56-BAS input buffer can receive data transferred from the CLX processor through the backplane using CALLs 56 or 53. The input buffer data can be read using CALLs 14 and 15.
The data transfer from the CLX to the MVI56-BAS input buffer is shown in the following diagram:
The input buffer is divided into areas depending on the source of the data transferred. The input buffer addressing is shown in the following table.
Address Definition
0 to 39 DH-485 Common Interface File - data written by other devices 40 to 99 Reserved 100 to 199 Data transferred from the CLX using Message instruction 200 to 231 Data transferred from the CLX Output Image file
CALL 53 transfers 8 words from the CLX output image file to the MVI56-BAS input buffer.
The following example BASIC code uses CALL 53 to transfer data from the CLX output image file to the input buffer. After that, it uses CALL 14 to read the data from the MVI56-BAS input buffer and prints it to PRT1.
10 CALL 53 20 POP X: REM CALL 53 status code 30 FOR I = 200 TO 207
ProSoft Technology, Inc. Page 43 of 234 December 13, 2011
Backplane Data Transfer MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
40 PUSH I: REM INPUT BUFFER ADDRESS 50 CALL 14 60 POP Y: REM INPUT BUFFER VALUE AT ADDRESS I 65 X = I - 200 70 PRINT "VALUE AT [", X, "] = ", Y 80 NEXT I 90 END
CALL 56 transfers up to 100 words from a CLX data file to the MVI56-BAS input buffer using Class 3 message instructions.
Ladder logic must execute a MSG instruction prior to CALL 56 execution in order to move the data to a temporary buffer. The MSG should have the following parameters:
The following ladder logic writes the data that will be read by CALL56.
After the ladder logic execution, a CALL 56 can be performed in order to transfer the data to the MVI56-BAS input buffer.
1 REM CALL 56 10 PUSH 10 20 CALL 56 30 POP X 40 PRINT X
Page 44 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
5 Using the Program Port (PRT1)
In This Chapter
Interfacing the PC and the MVI56-BAS ................................................. 46
Creating BASIC programs ..................................................................... 47
EDIT Command ..................................................................................... 50
Permanently Saving BASIC Programs .................................................. 51
Creating Offline BASIC programs .......................................................... 53
Module Backup ...................................................................................... 59
Module Restoration ............................................................................... 61
Program Copies .................................................................................... 63
Running a BASIC Program .................................................................... 64
Debugging a BASIC Program ................................................................ 65
Commenting a BASIC Program ............................................................. 70
Checking Available and Used RAM Memory ......................................... 71
Exit a BASIC Program (Ctrl+C) ............................................................. 72
The present section discusses important points while using the MVI56-BAS program port such as creating, editing, and transferring a BASIC program to the module. The program port by default is PRT1 (the middle port).
This section only describes PRT1 as the program port.
ProSoft Technology, Inc. Page 45 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
5.1 Interfacing the PC and the MVI56-BAS
The software required on your personal computer to interface with the configuration/debugger port is operating system dependent. Tested software includes the following:
DOS ProComm and several other terminal emulation programs Windows 3.1 Terminal Windows 95/98/2000/XP HyperTerminal Windows NT HyperTerminal Linux Minicom
Any ASCII terminal emulation software application provided with your operating system should work as long as it can be configured as follows for all MVI56-BAS ports:
Baud Rate 19,200 Parity None Data Bits 8 Stop Bits 1 Software Handshaking XON/XOFF
The following steps are required to interface with the configuration/debugger port:
1 Connect your computer to the module’s port using a Null Modem cable. 2 Start the terminal emulation program on your computer and configure the
communication parameters.
If there is no response from the module, look at the communication setup and the cable. In addition, make sure you are connected to the correct port on your computer and the module.
Page 46 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
5.2 Creating BASIC programs
Creating a BASIC program is simple. First, hit the enter key a couple of times. You should see the following response each time you hit the enter key:
Ready >
If you do not get the above response, it is possible that the module is already running a BASIC program. To stop a program that is already running, hit the 'C' while simultaneously holding the control key down. The short symbol for this key stroke combination is ^C. If you still do not get a response, check the module power, check the serial cable, and check port connections.
After you get the Ready prompt, type in the BASIC command:
print "Hello World!"
followed by and enter key. The BAS module should respond with the following:
Ready >print "Hello World!" Hello World! Ready >
You just typed in a PRINT command. Practically any BASIC statement can also be used as a command. For example:
Ready >for i=0 to 5:p. i:next i 0 1 2 3 4 5 Ready >
Note that the "p." is short hand for "PRINT". The above approach can be used for debugging a program, but there are a few
problems writing a program this way. First, there is no permanent copy of the program saved in memory. That is, the program disappears as soon as it is executed. Second, you cannot write a program any longer than one line in length. Third, someone has to be there to write the program each time it is executed.
You can write a program which is permanently saved and executes whenever you want by adding line numbers at the beginning of each line. The program is executed in the order matching the line number. For example:
Ready >10 for i = 0 to 5 Ready >20 p. i Ready >30 next i Ready >40 end Ready >list
ProSoft Technology, Inc. Page 47 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
10 FOR I = 0 TO 5 20 PRINT I 30 NEXT I 40 END Ready >
The LIST command allows you to see what you have done so far. You can now execute the program using the RUN command:
Ready >run 0 1 2 3 4 5 Ready >
If you want to add a line in the middle of your program, select an unused line number between the line numbers where you want to insert the line, and type in the new line:
Ready >list 10 FOR I = 0 TO 5 20 PRINT I 30 NEXT I 40 END Ready >25 p. "Hello World" Ready >list 10 FOR I = 0 TO 5 20 PRINT I 25 PRINT "Hello World" 30 NEXT I 40 END Ready >
If you want to remove a line from the program, type in that line number:
Ready >list 10 FOR I = 0 TO 5 20 PRINT I 25 PRINT "Hello World" 30 NEXT I 40 END Ready >20 Ready >list 10 FOR I = 0 TO 5 25 PRINT "Hello World" 30 NEXT I
Page 48 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
40 END Ready >run Hello World Hello World Hello World Hello World Hello World Hello World Ready >
ProSoft Technology, Inc. Page 49 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
5.3 EDIT Command
Sometimes you may have typed in a long line and made a mistake in the middle. You fear that you may make more mistakes if you attempt to re-type the entire line. To solve this dilemma, use the EDIT command. To edit a line, type EDIT followed by that line number. For example "EDIT 100".
The EDIT command will respond by printing the entire line to the screen with the cursor at the beginning of the line. At this point, EDIT has several sub-commands that must be explained.
EDIT Sub-command Description
<space> Hitting the space key will cause the cursor to move to the right. <backspace> Hitting the backspace key will cause the cursor to move to the left. Any character Hitting any character will replace the character above the cursor with the
^A ^A toggles between insert mode and non-insert mode. When you first
^D ^D will delete the character above the cursor. <enter> The enter key will cause the line to be re-typed as it exists after the
^C Typing ^C will exit EDIT mode without saving any changes. ^X Typing ^X will exit EDIT mode and save all changes.
new character.
enter the EDIT command, you are in non-insert mode. Typing a ^A will erase the line from the cursor to the end. At this point, you can type in any text which you want to insert into the line. When you type ^A again, the part of the line which was erased when you first hit ^A will reappear, and you will exit insert mode.
edits.
Page 50 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
5.4 Permanently Saving BASIC Programs
There are two ways to permanently save a BASIC program. The first method has already been shown. When you type the program into the module, it is permanently saved to a file on the Compact Flash drive called "XRAM.BAS". If you want to save more than one program, you can use the PROG command. Refer to the Using ROM Storage section for more information. The PROG command copies the program from the "XRAM.BAS" file to another file called "EPROM.BAS". The "EPROM.BAS" file differs from the "XRAM.BAS" file in two important points. First, up to 255 programs can be saved in "EPROM.BAS". The programs are stored as ROM 1, ROM 2 , ROM 3, and so on. Second, you cannot modify a program stored in "EPROM.BAS". All you can do is ERASE the last program stored in "EPROM.BAS".
5.4.1 EPROM File Storage
When you want to store a XRAM program in EPROM, you type the PROG command. The programs are stored sequentially starting with ROM 1.
Executing a Program in EPROM
If you want to execute a program in EPROM, use the ROM command. ROM without a number moves the BASIC pointer to point to ROM 1. If you want to select another program stored in EPROM, type ROM followed by the number of the program you wish to execute.
Note that the ROM command only changes the BASIC program pointer. It does not automatically execute the program. You can use the RUN command to execute the program.
If you want to select another EPROM program and execute that program, you can use the RROM (RUN ROM) command followed by the number of EPROM program you wish to execute (that is, RROM 3).
5.4.2 Erasing EPROM Programs
If you want to remove EPROM programs, you can use the ERASE command. The ERASE command removes the last program in EPROM. You cannot remove a program at the beginning or in the middle of the EPROM programs.
5.4.3 Editing EPROM Programs
You cannot modify programs stored in EPROM. If you must modify a program in EPROM, you can use ROM to change the pointer to the program that needs modification. Then you can XFER that program to XRAM. Then you change the BASIC program pointer back to XRAM using the RAM command. Now the program has been moved to XRAM, and the BASIC pointer is pointing to XRAM, so the program can be edited.
ProSoft Technology, Inc. Page 51 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
5.4.4 Using XRAM and EPROM Programs as Subroutines
The BASIC programs are limited to the size of program that you can squeeze into XRAM. However, you can create larger programs by using CALLs 70, 71, and 72. These three CALLs allow you to use XRAM and EPROM programs as subroutines.
5.4.5 Automatically Executing ROM 1 at Power-up
If the setup jumper is off, then the program in XRAM will automatically be executed at power-up. You can change the module to automatically execute ROM 1 at power-up by using the PROG2 command. The PROG2 will have the same effect at power-up as someone typing RROM 1 (or ROM 1, RUN). If at a later time you want to stop executing ROM 1 at power-up, use PROG0 to clear the effect of PROG2.
Page 52 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
5.5 Creating Offline BASIC programs
You can use a regular ASCII editor such as Notepad, Wordpad (Windows) or EDIT.EXE (DOS) in order to edit and save offline BASIC programs.
When saving programs, choose a name starting with a letter and containing no more than 8 (eight) characters. Save your BASIC program with a "BAS" extension (.BAS). For example: TEST.BAS would be a valid BASIC program name.
This section describes how to transfer BASIC programs between the local PC and the MVI56-BAS modules. After the program has been transferred to the MVI56-BAS module it should be loaded to RAM memory using the LOAD command in order to be ready to be executed.
5.5.1 Downloading BASIC Files From a PC to the MVI56-BAS
In order to download BASIC programs to the module, the MVI56-BAS running program will have to be interrupted. You must run the RY.EXE program which uses the Y-Modem protocol. All steps are described in this section:
Step 1
Remove the module from the rack and place the setup jumper ON. Put the module back into the rack.
Step 2
Connect the ASCII Terminal software to Port 2 (19200 baud rate) and enter "exit" in order to exit the MVI56-BAS program. The program (running at Port 1) should exit to DOS prompt.
ProSoft Technology, Inc. Page 53 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Step 3
Connect the ASCII Terminal software to Port 1 (19200 baud rate). Change the current driver from a: to c: by entering "c:" at the DOS prompt. Then, run the RY program by entering "ry" at the DOS prompt:
At this point, you should see the characters "C" and "G" being showed on the screen. This means that the module is ready to receive data. The module will wait approximately 1 minute for the user to select and transfer the file.
In a case that you do not send the file within 1 minute, the following message will appear:
"Receive Failed".
Step 4
Using the menu bar in the ASC Terminal software you are using, select the "Send File…" option.
Select the BASIC program you want to send and select the Ymodem protocol. The MVI56-BAS module only supports the Ymodem protocol, so it is required that the ASCII terminal used in this procedure also supports DH-485.
Page 54 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
While transferring the file, a window shows the remaining time:
You can type "dir" at the DOS prompt in order to verify that the BASIC module is in the module directory.
Step 5
Now it is time to restart the module. First remove the module from the rack and set the setup jumper in OFF mode:
Put the module back to the rack. The procedure is finished.
ProSoft Technology, Inc. Page 55 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
5.5.2 Uploading BASIC files from the MVI56-BAS to a PC
In order to upload BASIC programs from the MVI56-BAS to a PC, the running program will have to be interrupted. Once interrupted, you must run the SY program which uses the Y-Modem protocol. After the upload is complete, the user will have to restart the module. All steps are described in the present section:
Step 1
Remove the module from the rack and place the setup jumper ON. Put the module back into the rack.
Step 2
Connect the ASCII Terminal software to Port 2 (19200 baud rate) and enter "exit" in order to exit the MVI56-BAS program. The program (running at Port 1) should exit to DOS prompt.
Step 3
Connect the ASCII Terminal software to Port 1 (19200 baud rate). Change the current driver from a: to c: by entering "c:" at the DOS prompt. Then, run the SY program by entering ry "program_name.bas" at the DOS prompt:
At this point you should quickly refer to STEP 4 in order to receive the file before the sy program timeout (about 30 seconds).
If there are any problems during the file transmission, the message "Send Failed" will be displayed in the screen.
Page 56 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
Step 4
Using the menu bar in the ASCII Terminal software you are using, select the "Send File…" option.
Select the BASIC program you want to send and select the Ymodem protocol. The MVI56-BAS module only supports Ymodem protocol.
While transferring the file, a window shows the remaining time:
Step 5
Remove the module from the rack and set the setup jumper in OFF mode:
Put the module back to the rack and the procedure is finished.
ProSoft Technology, Inc. Page 57 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
5.5.3 Loading a BASIC Program
In order to load a BASIC program to RAM memory, use the shown in the ASCII terminal connected to the program port:
LOAD "NAME.BAS"
LOAD
command as
Page 58 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
5.6 Module Backup
There are two simple ways to backup all the program files associated with the MVI56-BAS. The first method assumes that your computer has access to a Compact Flash card reader. The second method assumes that you do not have access to a Compact Flash card reader and is more complicated.
5.6.1 Backup with a Compact Flash Card Reader
Backing up a MVI56-BAS with a Compact Flash card reader is simple. Remove the Compact Flash from the BAS module. Place the Compact Flash in your reader. Using your computer, make copies of three files:
XRAM.BAS BATTERY.BAS EPROM.BAS These three files contain all the information needed to duplicate your application
on another BAS module. These three files do not contain the dynamic battery backed data stored during program execution.
5.6.2 Backup without a Compact Flash Card Reader
There are three files on the Compact Flash which contain all the information needed to duplicate your application on another BAS module:
XRAM.BAS BATTERY.BAS EPROM.BAS These files should never be edited. Follow the following steps to make backup
copies of the files.
Step 1
Remove the module from the rack and place the setup jumper ON.
Step 2
Connect the ASCII Terminal software to PRT1 (19200,N,8,1) and apply power to the BAS module. When the sign-on message is displayed, enter the EXIT command at the Ready prompt. This will stop the BASIC execution and enter DOS.
Step 3
Change the ASCII cable from PRT1 to the DH-485 port (COM0).
Step 4
Change to the Compact Flash drive by typing "C:" at the DOS prompt. Then run the SY program by entering SY "XRAM.BAS":
[A:\]C: [C:\]sy "xram.bas"
ProSoft Technology, Inc. Page 59 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
At this point you should quickly refer to STEP 4 in order to receive the file before the SY program timeout (about 30 seconds).
In case there are any problems during the file transmission, the message "Send Failed" will be displayed in the screen.
Step 5
Using the menu bar in the ASCII Terminal software you are using select the "Receive File" option. Then select the directory where you want to place the file and select the Ymodem protocol. Then hit the receive button.
Step 6
Repeat STEPs 4 and 5 for "BATTERY.BAS" and "EPROM.BAS".
Step 7
Remove the MVI56-BAS and place the setup jumper OFF. Replace the MVI56­BAS in the rack. Connect the ASCII cable to PRT1.
Page 60 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
5.7 Module Restoration
There are two simple ways to restore all the program files associated with a MVI56-BAS application. The first method assumes that your computer has access to a Compact Flash card reader/writer. The second method assumes that you do not have access to a Compact Flash card reader/writer and is more complicated. Both methods assume that you have previously backed up a functioning BAS module application.
5.7.1 Restoration with a Compact Flash Card Reader
Restoration of an MVI56-BAS application with a Compact flash card reader/writer is simple. Remove the Compact flash from the BAS module. Place the Compact flash in your reader/writer. Using your computer, copy the backed up version of the following three files over the files on the Compact flash:
XRAM.BAS BATTERY.BAS EPROM.BAS These three files contain all the information needed to duplicate your application.
These three files do not contain the dynamic battery backed data stored during program execution.
5.7.2 Restoration without a Compact flash Card Reader
There are three files on the Compact flash which contain all the information needed to restore your application on another BAS module:
XRAM.BAS BATTERY.BAS EPROM.BAS These files should never be edited. Follow the following steps to restore the files
on another BAS module.
Step 1
Remove the module from the rack and place the setup jumper ON.
Step 2
Connect the ASCII Terminal software to PRT1 (19200,N,8,1) and apply power to the BAS module. When the sign-on message is displayed, enter the EXIT command at the Ready prompt. This will stop the BASIC execution and enter DOS.
Step 3
Change the ASCII cable from PRT1 to the DH-485 port (COM0).
Step 4
Change to the Compact flash drive by typing "C:" at the DOS prompt. Then run the RY program by entering RY:
ProSoft Technology, Inc. Page 61 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
[A:\]C: [C:\]ry
At this point you should quickly refer to STEP 4 in order to receive the file before the RY program timeout (about 30 seconds).
In case there are any problems during the file transmission, the message "Receive Failed" will be displayed in the screen.
Step 5
Using the menu bar in the ASCII Terminal software you are using select the "Send File" option. Then select the file and select the Ymodem protocol. Then hit the send button.
Step 6
Repeat STEPs 4 and 5 for all three files.
Step 7
Remove the MVI56-BAS and place the setup jumper OFF. Replace the MVI56­BAS in the rack. Connect the ASCII cable to PRT1.
Page 62 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
5.8 Program Copies
The BAS module tokenizes each line that is typed into the module. That is, it searches the line for BASIC commands, statements, and operators. These commands, statements, and operators are replaced with a single character non­printable token. This is the reason that "XRAM.BAS" and "EPROM.BAS" do not look anything like the program that you originally typed in. If you want to save a printable copy of the program, you have two options. First, you can log the data received by your terminal emulation software and LIST the program to the screen. Or, you can EXPORT your program to a file on the Compact Flash. For example,
Ready >export "myprog.txt"
Then, exit to DOS and use RY.EXE to copy the program to your host computer. Do not EXPORT to "XRAM.BAS", "BATTERY.BAS", or "EPROM.BAS"!
You can actually recover programs by using the LOAD command. For example,
Ready >load "myprog.txt"
At first glance, this approach appears to be a way to backup and recover BASIC programs. However, only the XRAM part of the backup data is stored here. The ASCII port (PRT1 and PRT2) parameters, the DH-485 port parameters, PGMPRT parameters, and other things are stored as a raw data structure in "BATTERY.BAS". Further, the EPROM programs are stored in "EPROM.BAS". For a full backup, "XRAM.BAS", "BATTERY.BAS", and "EPROM.BAS" must all three be backed up and recovered.
ProSoft Technology, Inc. Page 63 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
5.9 Running a BASIC Program
After the program is in RAM memory, it can be run by entering RUN in the command line:
RUN
The
RUN
command will also clear all BASIC variables to zero and clear all
interrupts.
Page 64 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
5.10 Debugging a BASIC Program
This section describes the BASIC commands that help the user debug BASIC code.
The
BRKPNT
means that the BASIC program exits, allowing the user to check all variables. Enter command.
To continue program execution, use the
Syntax:
BRKPNT [line number]
If the line number selected is zero, the The
SNGLSTP
stop first at the initial line number defined in the To continue program execution, use the
Syntax:
SNGLSTP [initial line number]
Error Recovery
Use the When an error occurs the program execution will skip to the line specified by the
ONERR
using the Definition of error codes generated with the
1 Missing "=" sign. 2 Bad or missing expression. 3 NOT USED. 4 Variable name too long. 5 Expected a variable, but did not find one. 6 Exceeded maximum number of variables. 7 Missing ")". 8 Missing "(". 9 Bad variable element number. 10 NOT USED. 11 Argument stack error. 12 Bad or missing operator in expression. 13 Too many operators in expression. 14 ELSE token found without prior IF token. 15 Invalid syntax. 16 Missing variable after "LET" token. 17 Missing quote. 18 Statement not terminated correctly. 19 Bad or missing line number 20 No line to return to after GOSUB. 21 Tried executing RUN while already in RUN mode.
ProSoft Technology, Inc. Page 65 of 234 December 13, 2011
command sets a program break point at the specified line. This
BRKPNT
before running a program in order to enable the break point
CONT
command.
BRKPNT
command will be disabled.
command allows the program to exit at all lines. The program will
SNGLSTP
CONT
command.
ONERR
command to recover from an error during program execution.
command.
command. Each error has an associated code which can be retrieved by
ERRCODE
operator or the
XBY
function.
ONERR
command:
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
22 Bad parameter. 23 DO stack error. 24 Control stack error. 25 GOSUB stack error. 26 Too many strings. 27 Requested STRING array size is bad. 28 Missing constant. 29 Missing comma. 30 Second STRING statement encountered. 31 STRING statement encountered after variable declaration. 32 Bad string number. 33 String encountered before STRING declaration. 34 File name too long. 35 Could not open file. 36 Statement not allowed in RUN mode. 37 Bad variable name. 38 NOT USED. 39 Too many variables. 40 Too much space needed for dimensioned variable. 41 Variable or statement must follow line number. 42 NOT USED. 43 UNTIL without preceding DO. 44 TO missing from FOR statement. 45 NEXT variable does not match FOR variable. 46 STEP size in FOR statement is zero. 47 NEXT statement without preceding FOR. 48 Missing "0" or "1" after CLOCK token. 49 DH-485 driver failure. 50 ONTIME TIME line number is out of range. 51 RETI without corresponding interrupt request. 52 Could not allocate any more memory. 53 Too many constants. 54 Could not find DATA statement. 55 Missing GOTO/GOSUB after ON expression. 56 ON expression is negative. 57 RENumber error (NUM1 must be >= NUM2). 58 Missing string. 59 Bad @ or # value. 60 Unknown CALL number. 61 Bad time parameter. 62 Bad date parameter. 63 String too small. 64 Bad argument. 65 Serial port failure. 66 Serial port failure. 67 Serial port failure. 68 Serial port failure. 69 Setup jumper in wrong position. 70 Backplane interface failure.
Page 66 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
71 Backplane interface failure. 72 Backplane interface failure. 73 Backplane interface failure. 74 Backplane interface failure. 75 Backplane interface failure. 76 Not enough space in EPROM. 77 No program in RAM to store. 78 No program in EPROM to erase. 79 ROM program # does not exist. 80 Cannot erase current program. 81 Too many programs stored in PROM. 82 Already executing in RAM. 83 DH485 port failed. 84 DF1 is already enabled. 85 Variable has already been DIMensioned. 86 Serial port failure. 87 DF1 transmit queue is full. 88 DF1 driver failure. 89 DF1 not enabled. 90 DF1 packet is too short. 91 DF1 driver failure. 92 DF1 driver failure. 93 DF1 driver failure. 94 DF1 Status variable not valid. 95 DF1 receive packet is too large. 96 Not legal operation when DF1 is enabled. 97 ONTIME has not been enabled. 98 Cannot IDLE inside ONTIME interrupt routine. 99 Clock has not been enabled. 100 DBY() is no longer needed nor allowed. 101 XBY() is no longer needed nor allowed. 102 No program in XRAM. 103 Domain math error (for example, sqr(-1)). 104 Singularity math error (for example, 0**(-2)). 105 Overflow. 106 Underflow. 107 Total loss of significant digits (for example, sin(10e70)). 108 Partial loss of significant digits. 109 Floating point unit stack overflow. 110 Unknown math error. 111 Divide by zero. 112 DF1 driver failure. 113 DF1 packet transmission already in process. 114 DH-485 is not enabled. 115 DH485 port failed. 116 DH485 port failed. 117 DH485 port failed. 118 Cannot mix foreground and background DF1 CALLs. 119 Cannot mix DH-485 and DF1 functions.
ProSoft Technology, Inc. Page 67 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
120 Invalid battery backed RAM location. 121 Second STRING value is invalid. 122 Unknown error
Syntax:
ONERR [line number]
Two new commands have been added to help programmers:
ERRCODE. ERRLINE
ERRCODE
PUSHes the offending error code onto the argument stack.
The following shows an example of how to use the
10 ONERR 100 20 LET = 5 30 PRINT "THIS IS LINE 1" 40 PRINT "THIS IS LINE 2" 50 PRINT "THIS IS LINE 3" 60 END 100 PRINT "ERROR CODE WAS ", ERRCODE 110 PRINT "ERROR LINE WAS ", ERRLINE 120 END Ready >run ERROR CODE WAS 16 ERROR LINE WAS 20
ERRLINE
and
PUSHes the offending line number onto the argument stack.
ONERR
command:
Lines 30 to 60 are skipped and the program execution continues at line 100. Alternatively, the XBY function can be used:
10 ONERR 100 20 LET = 5 30 PRINT "THIS IS LINE 1" 40 PRINT "THIS IS LINE 2" 50 PRINT "THIS IS LINE 3" 60 END 100 PRINT "ERROR CODE WAS ", XBY(257) 110 PRINT "ERROR LINE WAS ", ( 256*XBY(27133) + XBY(27134) ) 120 END Ready >run ERROR CODE WAS 16 ERROR LINE WAS 20
Note: The values passed as arguments to the
XBY
function in the above example are the only valid
variable locations. All other variable locations will return 0.
XBY()
can also be used on the left side of the equal sign; this assigns a value to any of the above variable locations, overriding the automatically generated error information. Again, the variable locations used in the above example are the only ones that can be accessed. Any other variable locations will cause an error. If you wish to store and retrieve user values in battery-backed SRAM, use the
XBYTE
function (see
Operators and Statements).
Page 68 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
After the error code value has been retrieved, it can be cleared using the
CLRERR
command; this allows debugging to continue. The following code shows how to use the
10 ONERR 100 20 LET =5 30 PRINT "THIS IS LINE 1" 40 PRINT "THIS IS LINE 2" 50 PRINT "THIS IS LINE 3" 100 E = ERRCODE 200 PRINT "ERROR CODE WAS ", E 300 CLRERR 400 PRINT "ERROR CODE NOW IS ", ERRCODE Ready >run ERROR CODE WAS 16 ERROR CODE NOW IS 0
CLRERR
command:
ProSoft Technology, Inc. Page 69 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
5.11 Commenting a BASIC Program
The
REM
command allows the user to insert comments in the BASIC program that will be ignored by the BASIC interpreter. Use the a program line.
Example:
10 REM BASIC PROGRAM 20 LET A=3: REM ASSIGN A VALUE TO A 30 PRINT A: REM PRINTS A
REM
command after a colon (:) in
Page 70 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using the Program Port (PRT1) BASIC Module (DB/BAS Compatible) User Manual
5.12 Checking Available and Used RAM Memory
To see the currently available RAM memory that can be used, use the operator as shown in the following example:
PRINT FREE
To see the RAM memory currently being used by the selected BASIC program, the
LEN
operator can be used:
PRINT LEN
FREE
ProSoft Technology, Inc. Page 71 of 234 December 13, 2011
Using the Program Port (PRT1) MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
5.13 Exit a BASIC Program (Ctrl+C)
If the module is currently running a BASIC program, you must enter "CTRL+C" (^C) in order to quit the program when connected to PRT1 (COM2). This will exit the program and return to the BASIC terminal prompt:
In order to disable the ^C function, CALL 19 (Disable the ^C Function) can be used. It has no parameters and it does not return any output values. Entering CALL 19 will disable the ^C function.
In order to re-enable the ^C function after a CALL 19 execution, CALL 18 must be used (Re-enable the ^C function)
Page 72 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using ASCII Communications BASIC Module (DB/BAS Compatible) User Manual
6 Using ASCII Communications
In This Chapter
Port Transmit and Receive Buffers ........................................................ 74
ASCII Data Transfer from MVI56-BAS Serial Port to CLX ..................... 75
ASCII Data Transfer from CLX to MVI56-BAS Serial Port ..................... 78
The MVI56-BAS can also be used to interface a serial communication device with the Rockwell Automation ControlLogix processor. Two ports (PRT1 and PRT2) can be used.
ProSoft Technology, Inc. Page 73 of 234 December 13, 2011
Using ASCII Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
6.1 Port Transmit and Receive Buffers
MVI56-BAS PRT1 and PRT2 have an internal transmit and receive buffer. Each buffer has a capacity for 1024 bytes.
The PRINT command sends characters to the two serial ports. PRINT sends characters to the program port, PRINT@ also sends characters to PRT1, and PRINT# sends characters to PRT2. The MVI56-BAS transmits one character at a time until the buffer is empty. If software handshaking (XON/XOFF) has been selected, and an XOFF character has been received, then the port will not transmit until an XON has been received. If hardware handshaking has been selected, and the CTS signal is OFF, then the port will not transmit until CTS transitions ON. In either case, the transmit buffer will accumulate characters until it is full.
In order to avoid a situation where the BASIC program tries to write characters to a transmit buffer that is already full, the following CALLs can be used to verify the current number of characters in PRT1 and PRT2:
CALL 36 = Get Number of Characters in PRT2 transmit buffer CALL 95 = Get Number of Characters in PRT1 transmit buffer If necessary, the BASIC program can clear the current transmit and receive
buffers using the following CALLs: CALL 37 = Clear PRT2 Transmit and Receive Buffers CALL 96 = Clear PRT1 Transmit and Receive Buffers The same idea applies when an ASCII device writes data to MVI56-BAS PRT1 or
PRT2: it will be stored in the receive buffer until is read by a INPUT statement (INPUT@ = PRT1 or INPUT# = PRT2)
Page 74 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using ASCII Communications BASIC Module (DB/BAS Compatible) User Manual
6.2 ASCII Data Transfer from MVI56-BAS Serial Port to CLX
The MVI56-BAS can interface serial devices such as printers and code bar readers to the ControlLogix processor. This section shows how to receive data from an ASCII device and transmit it to the CLX processor.
In order to transfer data from the MVI56-BAS serial port to the ControlLogix processor, CALL 22 is required to set up the transfer parameters. The following shows a CALL 22 example:
1 REM CALL 22 reads data from the MVIBAS to the CLX 2 REM BASIC Example Program 10 REM MAIN BODY 20 PUSH 1: REM PORT NUMBER 30 PUSH 10: REM RECEIVES 10 BYTES MAXIMUM 40 PUSH 13: REM <CR> IS THERE TERMINATION CHARACTER 50 PUSH 1: REM DESTINATION IS MSG INSTRUCTION 55 PUSH 0: REM DESTINATION FILE OFFSET 60 PUSH 0: REM STRING NUMBER (NOT USED HERE) 65 PUSH 0: REM BYTE SWAP 70 CALL 22 80 POP S: 90 IF ( S <> 0) THEN PRINT "error", S 99 GOTO 99
or
10 PUSH 1,10,13,1,0,0,0: CALL 22: POP S 20 IF ( S <> 0) THEN PRINT "error", S 30 IF ( S <> 0) THEN STOP 40 GOTO 40
After CALL 22 is executed, the serial port (PRT1 or PRT2) continues receiving data until the maximum number of characters is reached, or the character delimiter is received.
Both parameters are configurable when using CALL 22 (refer to "BASIC CALLs Syntax" section). The maximum number of characters transmitted depends on the destination file used:
CLX Input Image File => 60 characters maximum MSG Instruction => 198 characters maximum Internal String => 251 characters maximum
If using CLX input image file the destination file offset parameter in CALL 22 should be no less than 1 otherwise a CALL error will be returned.
ProSoft Technology, Inc. Page 75 of 234 December 13, 2011
Using ASCII Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
In order to use a CLX Message as the transfer destination, the following MSG instruction
has to be configured:
The transfer sequence is described in the following paragraphs: Step 1 - When the maximum number of characters is reached, or the character
delimiter is found, the data is transferred to the destination file. The MVI56-BAS also places the byte count in the lower byte of the first register in the destination file.
Step 2 - Next, the MVI56-BAS turns ON one of the following bits to indicate that new data is available:
PRT1 => Local:x:I.Data[0].8 PRT2 => Local:x:I.Data[0].9 Where x is the MVI56-BAS slot number. Step 3 - Next, the ladder logic reads the data and turns ON one of the following
bits to indicate the data was received: PRT1 => Local:x:O.Data[0].8 PRT2 => Local:x:O.Data[0].9
Step 4 - The MVI56-BAS resets the image file input bit. Step 5 - The ladder logic resets the image file output bit.
Page 76 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using ASCII Communications BASIC Module (DB/BAS Compatible) User Manual
The following shows the sample ladder logic that implements the previously described procedure when the MSG instruction is selected as the destination file:
Where Read_Bit_Number variable is either 8 or 9. Refer to BASIC CALLs Syntax (page 105) for more information about CALL 22.
ProSoft Technology, Inc. Page 77 of 234 December 13, 2011
Using ASCII Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
6.3 ASCII Data Transfer from CLX to MVI56-BAS Serial Port
The MVI56-BAS can interface serial devices such as printers and bar code readers to the ControlLogix processor. This section shows how to send data from the ControlLogix to a remote ASCII device.
In order to transfer data from the ControlLogix processor to a MVI56-BAS serial port, CALL 23 is required to set up the transfer parameters. The following shows a CALL 23 example:
10 REM BASIC CALL 23 20 PUSH 2: REM SERIAL PRT SELECTION 30 PUSH 1: REM SOURCE FILE 40 PUSH 0: REM SOURCE FILE OFFSET 50 PUSH 1: REM INTERNAL STRING NUMBER 60 PUSH 0: REM BYTE SWAP 70 CALL 23 80 POP S: REM CALL STATUS 9999 GOTO 9999
After CALL 23 is executes, the MVI56-BAS module gets the data from the selected source file and transfer it to the selected destination port (or internal string). CLX Input and Output image bits are used for handshaking purposes.
If using a MSG instruction as the data source, the following MSG parameters must be configured:
After CALL 23 is successfully executed, the required transfer parameters are configured.
At this point the transfer sequence can begin: Step 1 - The ladder logic sets the correct output image bit in order to inform the
MVI56-BAS there is new data to be transferred: Destination is PRT1 => Local:x:O.Data[0].6
Page 78 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using ASCII Communications BASIC Module (DB/BAS Compatible) User Manual
Destination is PRT2 => Local:x:O.Data[0].7 Where x is the MVI56-BAS slot number Step 2 - The MVI56-BAS transfers the data from the CLX to one of the serial
ports (PRT1 or PRT2). Step 3 - The MVI56-BAS sets the correct input image bit to inform to the CLX
that the data was successfully transferred: Destination is PRT1 => Local:x:I.Data[0].6 Destination is PRT2 => Local:x:I.Data[0].7 Step 4 - The ladder logic turns OFF the output image bit (Local:x:O.Data[0].6 or
Local:x:O.Data[0].7) Step 5 - The MVI56-BAS turns OFF the input image bit (Local:x:I.Data[0].6 or
Local:x:I.Data[0].7) The following shows the sample ladder required when the selected source of
data is the MSG instruction:
Refer to BASIC CALLs Syntax (page 105) for more information about CALL 23.
ProSoft Technology, Inc. Page 79 of 234 December 13, 2011
Using ASCII Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Page 80 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DF1 Protocol Communications BASIC Module (DB/BAS Compatible) User Manual
7 Using DF1 Protocol Communications
In This Chapter
Operation ............................................................................................... 82
Communication ..................................................................................... 83
DF1 Commands .................................................................................... 84
Sending a DF1 Read Command ........................................................... 85
Sending a DF1 Write Command ............................................................ 87
Receiving a DF1 Write Command ......................................................... 89
Transmitting a DF1 Packet .................................................................... 91
The MVI56-BAS PRT2 can be configured for DF1 protocol communication. The MVI56-BAS uses DF1 to communicate with external DF1 devices in Full-Duplex or Half-Duplex Slave modes.
The following figure shows possible DF1 applications and the BASIC CALLs for each application. Before running CALLs 118, 122 or 123, it is required that PRT2 is already enabled for DF1 protocol using CALL 108.
The MVI56-BAS supports:
ProSoft Technology, Inc. Page 81 of 234 December 13, 2011
Using DF1 Protocol Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
7.1 Operation
Full-Duplex with no handshaking Full-Duplex Modem Half-Duplex Slave with no handshaking Half-Duplex Slave Modem without Continuous Carrier Half-Duplex Slave Modem with Continuous Carrier
Page 82 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DF1 Protocol Communications BASIC Module (DB/BAS Compatible) User Manual
7.2 Communication
Duplicate packet detection CRC or BCC error checking Enable or auto-detect embedded responses
ProSoft Technology, Inc. Page 83 of 234 December 13, 2011
Using DF1 Protocol Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
7.3 DF1 Commands
The MVI56-BAS can send the following commands: PLC-2 unprotected READ command PLC-2 unprotected WRITE command PLC-3 word range READ command PLC-3 word range WRITE command PLC-5 typed READ command PLC-5 typed WRITE command The MVI56-BAS accepts the following commands: PLC (word range writes) PLC (typed writes) PLC (unprotected writes) SLC 5/02 (unprotected writes) SLC 5/02 (typed writes) The first step is to enable the DF1 driver using CALL 108, which will configure all
required parameters for the DF1 port such as the device node address, communication mode, number of Retries, and so on. Refer to BASIC CALLs Syntax (page 105) for more information about CALL 108.
At any point in the program, the DF1 protocol can be disabled using CALL 113. Refer to BASIC CALLs Syntax (page 105) for more information about CALL 113.
After the DF1 driver is enabled, the module can send read and write commands to other DF1 nodes in the network.
Page 84 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DF1 Protocol Communications BASIC Module (DB/BAS Compatible) User Manual
7.4 Sending a DF1 Read Command
In order to read data from a DF1 node, it is required to set up the data transfer parameters using CALL 122 after PRT2 has been enabled for DF1 communications using CALL 108. CALL 108 must configure PRT2 to a full­duplex node in order to send a DF1 read command. Some of the parameters are listed below:
Type of READ command Remote DF1 node address File number in remote DF1 node Number of elements to be transferred Destination file (input image, MSG instruction or internal string)
Refer to BASIC CALLs Syntax (page 105) for more information about CALL 122. The following shows an example BASIC program that shows how to enable the
DF1 driver using CALL 108. It then configures a remote READ command using CALL 122:
10 REM Enable DF1 Driver 20 MODE ( PRT2, 19200, N, 8, 1, N, R) 30 CALL 113: REM Disable any Existing DF1 Drivers 40 PUSH 18: REM NHS,ER,Disable DPD,CRC 50 PUSH 200: REM 10 Second Timeout 60 PUSH 2: REM ENQ Retries 70 PUSH 0: REM NAK Retries 80 PUSH 0: REM N/A 90 PUSH 2: REM Module Address 100 CALL 108 110 REM CALL 122 Test 120 REM Reads a DF1 Node 130 PUSH 2: REM PLC/2 File Type 140 PUSH 1: REM Remote Node Address 150 PUSH 7: REM Remote File Number 160 PUSH ASC( N): REM Integer File Type 170 PUSH 0: REM Starting Word Offset 180 PUSH 5: REM Number of elements to read 190 PUSH 10: REM Timeout in 0.1s increments 200 PUSH 1: REM Destination File (1=MSG) 210 PUSH 2: REM Destination file word offset 220 PUSH 0: REM String Number 230 CALL 122 240 POP S: REM Status of CALL 250 PRINT "CALL 122 return code was", S 260 GOTO 260
After the READ command is configured, ladder logic is required to actually send the READ command to the remote DF1 node. Input and output image file word 0 bit 10 are used for handshaking purposes. The transfer procedure is listed below:
Step 1: The CLX informs the MVI56-BAS that the READ command configured by CALL 122 should be executed, turning ON output image word 0 bit 10 (Local:x:O.Data[0].10).
Step 2: The MVI56-BAS module sends the READ command to the remote DF1 node which replies with the data.
ProSoft Technology, Inc. Page 85 of 234 December 13, 2011
Using DF1 Protocol Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Step 3: The MVI56-BAS transfers the data into the CLX destination file and also copies the status code to input image word 1, low byte (Local:x:I.Data[1]). After the transfer is done, the MVI56-BAS sets the input image word 0 bit 10 (Local:x:I.Data[0].10) to inform to the CLX that the data is available.
Step 4: The CLX copies the data and resets output image word 0 bit 10 (Local:x:O.Data[0].10) to inform the module that the data was received.
Step 5: The MVI56-BAS resets input image word 0 bit 10 byte (Local:x:I.Data[0].10)
The following ladder file shows an example of how to implement the procedure described above when the destination file is a MSG instruction:
The MSG parameters are described in the following example:
In case the destination file selected by CALL 122 configuration is the CLX image input buffer, the ladder logic for CALL 122 is showed in the following example:
Page 86 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DF1 Protocol Communications BASIC Module (DB/BAS Compatible) User Manual
7.5 Sending a DF1 Write Command
In order to write data from the CLX to a DF1 node, you must set up the data transfer parameters using CALL 123 after PRT2 has been enabled for DF1 communication using CALL 108. CALL 108 must configure PRT2 as a full-duplex node in order to send a DF1 write command. Some of the parameters are listed below:
Type of WRITE command Remote DF1 node address File number in remote DF1 node Number of elements to be transferred Source file (input image, MSG instruction or internal string)
Refer to BASIC CALLs Syntax (page 105) for more information about CALL 123. The following shows an example BASIC program that shows how to enable the
DF1 driver using CALL 108. It then configures a remote READ command using CALL 123:
10 REM Enable DF1 Driver 20 MODE ( PRT2, 19200, N, 8, 1, N, R) 30 CALL 113: REM Disable any Existing DF1 Drivers 40 PUSH 18: REM NHS,ER,Disable DPD,CRC 50 PUSH 200: REM 10 Second Timeout 60 PUSH 2: REM ENQ Retries 70 PUSH 0: REM NAK Retries 80 PUSH 0: REM N/A 90 PUSH 2: REM Module Address 100 CALL 108 110 REM CALL 123 Test 120 REM Reads a DF1 Node 130 PUSH 2: REM PLC/2 File Type 140 PUSH 1: REM Remote Node Address 150 PUSH 7: REM Remote File Number 160 PUSH ASC( N): REM Integer File Type 170 PUSH 0: REM Starting Word Offset 180 PUSH 5: REM Number of elements to read 190 PUSH 10: REM Timeout in 0.1s increments 200 PUSH 0: REM Destination File (0=Input Image) 210 PUSH 2: REM Destination file word offset 220 PUSH 0: REM String Number 230 CALL 123 240 POP S: REM Status of CALL 250 PRINT "CALL 122 return code was", S 260 GOTO 260
After the WRITE command is configured using CALL 123, ladder logic is required to actually send the WRITE command to the remote DF1 node. Input and output image file word 0 bit 11 are used for handshaking purposes. The transfer procedure is listed below:
Step 1: The CLX informs the MVI56-BAS that the WRITE command configured by CALL 123 should be executed turning ON output image word 0 bit 11 (Local:x:O.Data[0].11).
Step 2: The MVI56-BAS module transfers the data to the remote DF1 node.
ProSoft Technology, Inc. Page 87 of 234 December 13, 2011
Using DF1 Protocol Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Step 3: The MVI56-BAS copies the status code to input image word 1, low byte (Local:x:I.Data[1]). After the transfer is done the MVI56-BAS sets the input image word 0 bit 11 (Local:x:I.Data[0].11) to inform the CLX that the data was received .
Step 4: The CLX resets output image word 0 bit 11 (Local:x:O.Data[0].11). Step 5: The MVI56-BAS resets input image word 0 bit 11 byte
(Local:x:I.Data[0].11) The following ladder file shows an example of how to implement the procedure
described above when the destination file is a MSG instruction:
The MSG parameters are described below:
In case the destination file is the CLX input buffer, the ladder logic for CALL 122 is shown in the following example:
Page 88 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DF1 Protocol Communications BASIC Module (DB/BAS Compatible) User Manual
7.6 Receiving a DF1 Write Command
In order to receive a write command from a remote DF1 node, you must set up the data transfer parameters using CALL 118. Some of the parameters are listed below:
CLX destination file Word offset in destination file Maximum word length
Refer to BASIC CALLs Syntax (page 105) for more information about CALL 118. The following shows a BASIC program example that shows how to enable the
DF1 driver using CALL 108. It then allows PRT2 to receive DF1 WRITE commands using CALL 118:
10 REM Enable DF1 Driver 20 MODE ( PRT2, 19200, N, 8, 1, N, R) 30 CALL 113: REM Disable any Existing DF1 Drivers 40 PUSH 2: REM NHS,ER,Disable DPD,CRC 50 PUSH 200: REM 10 Second Timeout 60 PUSH 2: REM ENQ Retries 70 PUSH 0: REM NAK Retries 80 PUSH 0: REM N/A 90 PUSH 2: REM Module Address 100 CALL 108 110 REM CALL 118 120 REM Reads a DF1 Node 130 PUSH 1: REM CALL ENABLE/DISABLE 140 PUSH 1: REM DESTINATION FILE 150 PUSH 0: REM OFFSET IN DESTINATION FILE 160 PUSH 2: REM STRING NUMBER (NOT USED HERE) 170 PUSH 50: REM MAXIMUM WORD LENGTH 180 CALL 118 190 POP M: REM CALL 118 STATUS 200 PRINT "STATUS CALL 118 -> ", M 250 PRINT "CALL 118 return code was", S 260 GOTO 260
After CALL 118 is executed, ladder logic is required for handshaking when a new WRITE command is received at PRT2. Input and output image file word 0 bit 12 must be used in ladder logic. The transfer procedure is listed below:
Step 1: A DF1 write command is received at the MVI56-BAS PRT2. The MVI56­BAS module transfers the data into the CLX internal buffer. The BASIC module also places the byte count into the first available word of the destination file.
Step 2: The MVI56-BAS sets the input file word 0 bit 12 (Local:x:I.Data[0].12) to inform the CLX that the data is available.
Step 3: The CLX ladder logic retrieves the data from the buffer and sets the output file word 0 bit 12 (Local:x:O.Data[0].12) to inform the MVI56-BAS module that the data was received.
Step 4: The MVI56-BAS module resets input image word 0 bit 12 (Local:x:I.Data[0].12).
Step 5: The CLX resets output image word 0 bit 12 (Local:x:O.Data[0].12).
ProSoft Technology, Inc. Page 89 of 234 December 13, 2011
Using DF1 Protocol Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
The following ladder file shows an example on how to implement the procedure described above when the destination file is a MSG instruction:
The MSG parameters are described below:
The MSG instruction must have the following parameters configured:
Page 90 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DF1 Protocol Communications BASIC Module (DB/BAS Compatible) User Manual
7.7 Transmitting a DF1 Packet
Using CALL 114 (Transmit DF1 Packet) allows the user to transmit a DF1 data packet created by the BASIC program using PRINT#, PH0# or PH1# statements. If PRT2 is configured for full-duplex communication, the packet will be transmitted immediately. If PRT2 is configured as a half-duplex slave, the DF1 packet will be transmitted the next time PRT2 receives an ENQuiry from a DF1 master.
In order to check if the transfer was successful, use CALL 115 (Check DF1 XMIT Status).
Refer to BASIC CALLs Syntax (page 105) for more information about CALLs 114 and 115.
ProSoft Technology, Inc. Page 91 of 234 December 13, 2011
Using DF1 Protocol Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
Page 92 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DH-485 Communications BASIC Module (DB/BAS Compatible) User Manual
8 Using DH-485 Communications
In This Chapter
Data Transfer Between the CLX and a Remote SLC DH-485 Data File 94
Writing to a Remote DH-485 SLC Data File (CALL 28) ......................... 95
Reading From a Remote DH-485 SLC Data File (CALL 27) ................. 97
Data Transfer Between a MVI56-BAS Internal String and a Remote DH-
485 SLC Data File ................................................................................. 98
Data Transfer Between the MVI56-BAS and Remote DH-485 Data Files99 Transfer Data Between the MVI56-BAS Module and a Remote Common
Interface File (CIF) .............................................................................. 101
The DH-485 port can also be used by the module to connect the MVI56-BAS to a DH-485 network. The DH-485 port is not directly DH-485 compatible, since it requires an AIC+ module (AB) which is user-supplied.
The following shows an example application where the MVI56-BAS is connected to a DH-485 network. In this example, the MVI56-BAS communicates with the DH-485 port of a SLC 5/03 processor.
Important: The setup jumper (located at the bottom of the MVI56-BAS module) must be OFF in order for DH-485 communications to work properly.
ProSoft Technology, Inc. Page 93 of 234 December 13, 2011
Using DH-485 Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
8.1 Data Transfer Between the CLX and a Remote SLC DH-485 Data File
In order to transfer data between the ControlLogix and a remote DH-485 data file, the following CALLs can be used:
CALL 27: Read from a Remote DH-485 SLC Data File CALL 28: Write to a Remote DH-485 SLC Data File The following schematic shows the data transfer directions using CALLs 27 and
28.
CLX
CALL 28
Page 94 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DH-485 Communications BASIC Module (DB/BAS Compatible) User Manual
8.2 Writing to a Remote DH-485 SLC Data File (CALL 28)
Ladder logic is required to transfer data from the local ControlLogix rack to a remote DH-485 SLC data file using the MVI56-BAS through CALL 28.
The source of the data in the local SLC processor is either the CPU output image file, Class 3 MSG instruction, and/or an internal string in the within the MVI56­BAS module.
The data transfer procedure is described below:
Step 1: Run CALL 28 to set up the data transfer parameters. Step 2: The ladder logic sets output file word 0, bit 11 to inform the MVI56-BAS
that the data is ready to be transferred. Step 3: The MVI56-BAS transfer the data from the ControlLogix processor to the
remote DH-485 SLC data file. Step 4: The MVI56-BAS moves the transfer status into the input file word 1, bits
0 to 7. It then sets input file word 0, bit 11 to inform the ControlLogix that the data had been transferred.
Step 5: The ladder logic resets output file word 0, bit 11. Step 6: The MVI56-BAS resets the input file word, bit 11.
The following example BASIC code shows the simplest possible example that transfers data from the local SLC (source file = CPU output image file) to a remote SLC DH-485 data file:
10 REM TRANSFERS DATA FROM THE CLX TO THE SLC REMOTE DATA FILE 20 PUSH 2, 5, 9, ASC( N), 0, 5, 20, 0, 0, 0: CALL 28: POP S 30 PRINT "S =", S, 130 GOTO 130
After the program is running, the following ladder example transfers data from the Write_Data array to the remote SLC data file:
The following example BASIC code shows the simplest possible example that transfers data from the local SLC (source file = Class 3 MSG) to a remote SLC DH-485 data file:
10 REM TRANSFERS DATA FROM THE CLX TO THE SLC REMOTE DATA FILE 20 PUSH 2, 5, 9, ASC( N), 0, 5, 20, 1, 0, 0: CALL 28: POP S 30 PRINT "S =", S,
ProSoft Technology, Inc. Page 95 of 234 December 13, 2011
Using DH-485 Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
130 GOTO 130
Refer to BASIC CALLs Syntax (page 105) for more information about the CALL 28 syntax.
Page 96 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DH-485 Communications BASIC Module (DB/BAS Compatible) User Manual
8.3 Reading From a Remote DH-485 SLC Data File (CALL 27)
Ladder logic is required to transfer data from a remote DH-485 SLC data file to the local ControlLogix rack using the MVI56-BAS through CALL 27.
The destination at the local SLC processor is either the CPU output image file, Class 3 MSG instruction, and/or an internal string in the within the MVI56-BAS module.
The data transfer procedure is described below:
Step 1: Run CALL 27 to set up the data transfer parameters. Step 2: The ladder logic sets output file word 0, bit 10 to inform the MVI56-BAS
that the data is ready to be transferred Step 3: The MVI56-BAS transfers the data from the remote DH-485 SLC data file
to the ControlLogix processor. Step 4: The MVI56-BAS moves the transfer status into the input file word 1, bits
0 to 7. After that it sets input file word 0, bit 10 to inform the ControlLogix that the data had been transferred.
Step 5: The ladder logic resets output file word 0, bit 10. Step 6: The MVI56-BAS resets the input file word, bit 10.
The following example BASIC code shows the simplest possible example that transfers data from the remote SLC DH-485 data file to the local ControlLogix (destination file file = Class 3 MSG instruction):
10 REM SHOWS HOW TO TRANSFER DATA FROM A SLC REMOTE FILE 80 PUSH 2, 5, 9, ASC( N), 0, 5, 20, 1, 0, 0: CALL 27: POP S 100 GOTO 100
Refer to BASIC CALLs Syntax (page 105) for more information about the CALL 27 syntax.
ProSoft Technology, Inc. Page 97 of 234 December 13, 2011
Using DH-485 Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
8.4 Data Transfer Between a MVI56-BAS Internal String and a Remote DH-485 SLC Data File
In order to transfer data between a MVI56-BAS internal string and a remote DH­485 SLC data file, use CALL 29 with CALLs 27 or 28. This method does not require ladder logic:
The following is an example BASIC program that uses CALL 29 to read data from a remote DH-485 SLC data file:
10 STRING 100, 90 80 PUSH 2, 5, 9, ASC( N), 0, 5, 20, 2, 0, 0: CALL 27: POP S 90 PUSH 27: CALL 29: POP R 95 PRINT "S =", S, " R =", R 100 GOSUB 1000 130 END 1000 FOR M = 1 TO 20 1010 PH0. ASC( $ ( 0), M), 1020 NEXT M 1030 PRINT 1040 RETURN
The following is an example BASIC program that uses CALL 29 to write data to a remote DH-485 SLC data file:
10 STRING 100, 90 20 $ ( 0) = "Hello World" 30 PRINT $ ( 0) 80 PUSH 2, 5, 9, ASC( N), 0, 5, 20, 2, 0, 0: CALL 28: POP S 90 PUSH 28: CALL 29: POP R 95 PRINT "S =", S, " R =", R 130 END
Page 98 of 234 ProSoft Technology, Inc. December 13, 2011
MVI56-BAS ♦ ControlLogix Platform Using DH-485 Communications BASIC Module (DB/BAS Compatible) User Manual
8.5 Data Transfer Between the MVI56-BAS and Remote DH-485 Data Files
In order to transfer data from the MVI56-BAS output buffer to a Remote DH-485 data file, use CALL 91. It is necessary initially to transfer data from the MVI56­BAS to the internal Output Buffer (starting at address 0) before using CALL 91. Up to 40 words can be transferred using this method.
The following BASIC program is an example of how to transfer data using CALL
91. The program initially transfers 20 registers to the module output buffer using CALL 24. After the data has been moved, the program uses CALL 91 to transfer the 20-register block to the remote DH-485 data file.
10 FOR I=0 TO 19 20 K=100-I 30 PUSH K: REM VALUE TO BE TRANSFERRED 40 PUSH I: REM OUTPUT BUFFER ADDRESS 50 CALL 24 60 NEXT I 70 REM TEST CALL 91 80 PUSH 5: REM REMOTE NODE ADDRESS 90 PUSH 9: REM REMOTE DEVICE FILE NUMBER 100 PUSH ASC(N): REM REMOTE DEVICE TYPE 110 PUSH 0: REM OFFSET 120 PUSH 20: REM NUMBER OF ELEMENTS 130 PUSH 10: REM TIMEOUT 140 CALL 91 150 POP S: REM STATUS 160 PRINT S
Refer to BASIC CALLs Syntax (page 105) for more information about CALLs 24, 25 and 91.
ProSoft Technology, Inc. Page 99 of 234 December 13, 2011
Using DH-485 Communications MVI56-BAS ♦ ControlLogix Platform User Manual BASIC Module (DB/BAS Compatible)
In order to transfer data from a Remote DH-485 data file to the MVI56-BAS input buffer, use CALL 90. After the data has moved into the input buffer, the program must use CALL 14 or 15 to retrieve the data (starting at address 0). Up to 40 words can be transferred using this method.
The following BASIC program is an example of how to transfer data using these concepts. CALL 90 transfers data from the DH-485 remote data file to the MVI56­BAS input buffer. Then, use CALL 14 (or CALL 15) to retrieve the data from the input buffer.
10 REM EXAMPLE PROGRAM FOR BASIC CALL 90 20 PUSH 5: REM REMOTE NODE ADDRESS 30 PUSH 9: REM REMOTE FILE NUMBER 40 PUSH ASC(N): REM REMOTE FILE TYPE 50 PUSH 0: REM REMOTE OFFSET 60 PUSH 20: REM ELEMENT LENGTH 70 PUSH 5: REM TIMEOUT 80 CALL 90 90 POP E: REM CALL STATUS 100 IF E<>0 THEN GOTO 180 ELSE GOTO 110 110 FOR I=0 TO 19 120 PUSH I: REM THE ADDRESS NUMBER AT THE INPUT BUFFER 130 CALL 14: 140 POP V: REM VALUE AT ADDRESS I 150 PRINT "VALUE AT POSITION ",I," = ",V 160 NEXT I 170 GOTO 200 180 PRINT "CALL 90 ERROR - CODE = ",E 200 END
Page 100 of 234 ProSoft Technology, Inc. December 13, 2011
Loading...