What is an MSP Driver? An MSP driver is a small ladder
logic program that is added to the user program. All code is standard ladder logic. In AB
PLCs it requires one to three subroutines and in some models two lines of logic in the
main program. Subroutine "5" is called as a time interrupt in most models. In
some models the logic in the main program fixes the scan time. Subroutine "5"
may be the complete driver or in some versions it may call one or two other subroutines.
The user can import the driver into their program by standard
Windows cut and paste or they can start with our driver and build their program from it.
Drivers. The following is a list of drivers in the MSP
Driver Library for Allen-Bradley PLCs. There are separate sections for MicroLogix, SLC500
fixed and SLC500 Modular models. These drivers were prepared with Allen-Bradley's RSLogix
500 programming software. They are available on the Driver Installation disks. They
contain rung comments, address descriptions, and address symbols that are viewable in the
programming package and on printouts.
DRIVER |
DESCRIPTION |
| Msp_I |
1 Channel Input |
| Msp_I_M |
2 Channel Input Multiplexed |
| Msp_I_H |
1 Channel Input High-Speed Counter |
| Msp_O |
1 Channel Output |
| Msp_O_M |
2 Channel Output Multiplexed |
| Msp_IO |
1 Channel Input, 1 Channel Output |
| Msp_IO_M |
2 Channel Input Multiplexed,
2 Channel Output Multiplexed |
Choosing Library for Model.
Due to the varying abilities of
the different processor choosing the right section of the library for your model may not
be obvious. The following table shows which section to use with which model.
SECTION |
MODEL |
| MicroLogix |
All MicroLogix Models |
| SLC500 Fixed |
All SLC500 Fixed |
|
5/01(See Note 9) |
| SLC500 Modular |
5/02(See Note 10) |
|
5/03 |
|
5/04 |
Timing Parameters.
These drivers are set up for the Delta
protocol. Following are some of the key timing parameters:
| Input |
|
| Protocol |
Delta |
| Scan Time |
10 msec (See Note 8) |
| Full Word Bits |
16 Bits |
| Delta Bits |
4 Bits |
| Delta Refresh Count |
16 Scan Refresh |
| ID Pulse Width |
1.2 Scans |
| Data Pulse Width |
3 Scans |
| Output |
|
| Protocol |
Delta |
| Scan Time |
10 msec (See Note 8) |
| Full Word Bits |
16 Bits |
| Delta Bits |
4 Bits |
| Delta Refresh Count |
16 Scan Refresh |
| ID Pulse Width |
3 Scans |
| Data Pulse Width |
3 Scans |
Quality Control File.
Included with the files for each driver
is a file of the same name with the ".sp" extension. This file contains the
model and serial numbers of all hardware and software used for testing. This file also
contains the setup parameters used for testing.
Programming Software.
All files in the Allen-Bradley
MicroLogix section of the driver library have also been saved away as APS files. Some of
the comments and symbols have been truncated in the process. Some of the symbols have been
lost. It is strongly recommended that you upgrade your Allen-Bradley programming software
to RSLogix. There are many good reasons but the most important is that in the long run it
will save you time and money. You will quickly recover the cost of the upgrade. For those
using the ICOM packages it is even more important that you make the upgrade. You will not
only recover the cost quickly but the newer models of MicroLogix do not work properly with
the ICOM packages.
Scan Time.
The key to getting the driver to function properly
is to get the driver code executed and MSP I/O updated at constant time intervals.
The MicroLogix and SLC500 Modular PLCs executes the driver code in
a time interrupt subroutine (STI). Ladder Logic file 5 is used for the STI. In the
MicroLogix this is fixed. In the SLC500 Modular the file number 5 must be set in S:31.
Interrupt processing must be enabled with bit S:2/1 by setting it to 1. Register S:30
contains the interrupt time interval. The units on this register are X10 msec. All of
these registers are accessible in the processor status. Inputs are updated in the
beginning the STI subroutine using the Immediate Input with Mask (IIM) instruction.
Outputs are set at the end by using the Immediate Output with Mask (IOM) instruction. See
the Allen-Bradley help files or manuals on how the immediate I/O instructions work. If
changing the I/O point used for the MSP the mask in these instruction may also have to be
modified.
The SLC500 Fixed PLCs do not have a time interrupt but the scan
time can be fixed with a little logic at the end of the program. This logic puts the scan
in a contiguous loop and watches the current scan time. When the scan time is equal to or
greater than a preset the loop is broken and the scan is allowed to complete. In many ways
this constant scan time mode is really minimum scan time mode. If program execution
exceeds the preset scan time set then program execution will control scan time. Current
scan time is stored in the lower byte of S2:3, the upper byte contains the watchdog time
limit. The lower byte only is stored in N7:3 which then contains only the current scan
time. The units on this register are X10 msec. The minimum scan time limit is stored in
N7:4 and its units are X10 msec. If the desired scan time is 10 msec then N7:4 must be set
to 1. Be sure that the watchdog timer in the upper byte of S2:3 is at least 50 msec more
than the preset scan time. Since I/O updates are automatically synchronized with normal
program scan immediate updates with the IIM and IOM instructions are not necessary.
By today's standards the SLC500 Fixed processors are slow and scan
time grows rapidly as the application program is written. During the course of the project
scan time will probably have to be increased several times. To find the shortest possible
scan time set the minimum in N7:4 to 0. Watch N7:3 and record the largest number observed.
N7:4 should be set 1 larger than the largest number observed in N7:3.
Scan Time Exceptions.
When possible the scan time is set at
10 msec. This is the fasted that Allen-Bradley PLCs can operate. Many of the older models
must be slowed down. On the SLC500 Fixed we used for driver testing the scan time had to
be set for 20 msec for all single and dual channel drivers. The longest scan time of any
tested drivers is 30 msec. for the Msp_IO_M driver on the SLC500 Fixed. Note that this
driver effectively has 4 channels. For any of the multiplexed drivers that are expanded to
4 or more channels on any model the scan time should be watched closely and may have to be
increased.
SLC500 Modular 5/01.
This model does not have the STI
ability. The library for the SLC500 Fixed must be used in this processor. After conversion
there will be a number of errors with the I/O addressing. To resolve these errors first
configuring the I/O to match your installation. Next change the I/O addressing to match
you I/O assignments. Pay careful attention to the masks on the immediate I/O instructions.
When next running "Verify Project" the errors should go away.
SLC500 Modular 5/02.
This model uses a different syntax of
the immediate I/O instructions than the 5/03 and 5/04. The syntax for these instructions
on the 5/02 has one less parameter than the 5/03 and 5/04. After conversion there will be
an error showing for each immediate I/O instruction used. In the ladder logic editor add
the same instructions to the same rung. You will now get the one for this model of
processor. Move the slot and mask entries form the old instruction to the new one and
delete the old instruction. When next running "Verify Project" the errors should
go away.
Programming Methods.
One of the key programming methods is
the use memory locations that are accessed both as registers and bits. In several cases
using a shift register programs counters. A seed is planted in bit zero of the shift
register word. To increment the counter by one the shift resistor is shifted one bit. This
allows the current value of counter to be checked by testing a single bit in ladder, which
is much more efficient than a whole register compare. These programs have been extremely
optimized for both minimum scan time and memory usage.
Programming MicroLogix and SLC500 Modular.
Programming for
these processors yields clean and understandable code. One deceptive method of programming
shift registers is used. The Allen-Bradley's bit shift register is a very powerful
instruction but for a simple 16-bit shift register it takes to much memory and execution
time. Simply multiplying a register by 2 and putting the results back into that register
is much more efficient. In order to get a 16-bit shift register the process must be set
for 32-bit math while the driver is executing. This is done by enabling S2:2/14. The
ladder logic has been refined and optimized to a very high degree. In someway this may
make the driver programs harder to read but it is felt that efficient use of memory and
execution time are the most important factors.
Programming SLC500 Fixed.
The lack of an STI or direct method
to fixed scan makes these PLCs somewhat harder to use but not much. The programming for
controlling scan time is simple and easy to understand. These processors do not support 32
bit math therefore a 16 bit shift register cannot be built using multiplies by two. The
more complicated "Bit Shift Left" instruction must be used. This requires two
extra "R" elements per channel and the overhead to move them around in the
multiplexed version. When adding more channels to the multiplexed driver the length of the
new "R" elements must be set to 16 in the data file before running the program.
Note that the shift register for the scan counter can still me built with a multiply by 2
since only a 4 bit shift register is required.
Math Overflow Trap.
There are several methods used in the
driver that can produce a math overflow error. This is expected. If the math overflow trap
bit S2:5/0 is not reset before the end of scan then a processor error will occur. We clear
the overflow trap if it occurred during the driver. If a math error occurred outside the
driver we save this error. At the end of the driver we return this bit to its original
status. This could be an important diagnostic tool for trouble shooting your program. If
you get a math overflow error that shuts down the PLC it is not coming from our driver.
High Speed Counter (HSC).
The HSC driver uses less ladder
logic memory. Depending on the value transmitted it may be faster or much slower than the
Delta protocol. Unlike the Delta protocol the update time for the HSC protocol is not
deterministic.
The HSC driver uses "Up" mode Counters. Only one (1)
input channel is possible on the MicroLogix, SLC500 Fixed, and SLC 5/01. The built in HSC
is not available usable on the other modular SLC processors. It would be possible using a
similar approach with the high-speed counter module but the cost would be uneconomical.
See the manuals for additional information on the HSC.
The scan time on the MSP must be set greater than the maximum scan
time of the PLC. We used 10 msec for test purposes even though the scan time of the PLC
was less than 1 msec. This allows some room for the user to add their program. On the
MicroLogix the logic was put in the STI. With only the driver program in the MicroLogix
the scan time was so fast that C5:0 was not updated every scan. The logic was put in the
STI just to slow down its rate of execution. If the user program has a minimum scan time
of more than 2 msec. the logic could be place in the main program.
In order to send a value of zero (0) or negative values an offset
is added to the pulse count before transmission. The driver then subtracts this offset
after counting the received pulses. Note the subtraction that occurs in the second rung.
The value of the offset varies depending on the MSP model and scale factor in order to
keep the offset to a minimum. The following table shows the offset for the different
ranges. The constant in the second rung must be changed to match the configuration of the
MSP.
MSP MODEL |
SCALE FACTOR |
OFFSET |
| MSP-RTD |
X1 |
50 |
| MSP-RTD |
X10 |
500 |
| MSP-TC |
X1 |
50 |
| MSP-TC |
X10 |
500 |
| All other models |
|
1 |