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 Omron PLCs it
requires one line of logic in the main program and one to three subroutines. The line of
logic in the main program sets up a time interrupt. Subroutine "0" is called by
the time interrupt. Subroutine "0" 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 threw the
"Network/Block Manager" 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 the Omron CPM1 PLC. These drivers were prepared with Omron's Syswin 2.1
programming software. The single channel input and single channel output drivers are
available on the Driver Installation disks. All other drivers are available on our web
site. 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 |
Different Models.
All drivers for the CPM1 should work with very
little revision on other Omron models. Omron's programming language and memory layout is
very similar in all models.
a) The CPM1A is virtually identical to the CPM1 and the drivers should
work without revision.
b) The CPM1A is a subset of the CQM1 and the drivers should work without
revision. This model is available with solid state outputs therefore output speed can be
increased without worry about relay life. The output modules are available in both sink
and source versions. See the sections on inputs and output regarding these modules.
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 |
50 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 |
Scan Time.
The key to getting the driver to function properly is to
get the driver code executed and PLC I/O for the MSP updated at constant time intervals.
The CPM1 PLCs executes the driver code in a time interrupt subroutine. The
time interrupt is set up with the Scheduled Time Interrupt Mode (STIM) instruction. This
is a very powerful and complex instruction that has multiple uses. We found this
instruction worked slightly different than the manual described. It may also work slightly
different in your PLC.
The answer to many of the questions on the STIM instruction can be found
in the Omron manual "Sysmac CPM1 Programmable Controller, Programming Manual."
There are two sections that require special attention. The first is section 1.3.4
"Interval Timer Interrupts." The second is section 5.15.5 "Interval Timer -
STIM(69)". The second section is basically repeat the first but is more concise. If
you do not have this manual you it is strongly recommended that you get it.
One other nasty trick to remember is that STIM used this way uses Timer 0.
Timer 0 cannot be used in the program for any other purpose.
The MSP driver uses the STIM instruction set for mode 3, Scheduled
Interrupt Mode. The mode is set in "Data 1" as always a constant and does not
require the "#". "Data 2" is the interrupt time. When set as a
constant the units are msec. Normally it is set to 10 msec. "Data 3" is the
subroutine number set to "0" (zero). Note that when "Data 2" and
"Data 3" are entered as constants they must be proceeded by the "#".
If "Data 2" is entered as an address it actually uses two consecutive addresses
and the units can be different. See the Omron manuals for more details. We recommend that
it be left as a constant.
The STIM can be a difficult instruction and may require careful study and
trial and error experiments. It is a very powerful and versatile instruction. We put in a
life counter to tell when the time interrupt is running and to measure its time. Every
time the interrupt subroutine is run we added one to the life sign register. You should
see this register continually ramp up and then rap around and ramp up again. This rung may
be deleted after you get the driver running.
Inputs are updated in the beginning the STIM subroutine using the I/O
Refresh (IORF) instruction. Outputs are set at the end also by using the I/O Refresh
(IORF) instruction. See the Omron help files or manuals on how the I/O Refresh
instructions work. If changing the I/O point used for the MSP these instruction may also
have to be modified.
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.
Scan Time Exceptions.
When possible the scan time is set at 10 msec.
This is the default setting of the MSP. On some older models it may have to be slowed
down. Those models with relay outputs must be slowed down when using MSP analog outputs.
The mechanical relays are slow when compared to solid state and we us a scan time of 50
msec. Note that the Msp_IO_M 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.
Programming Methods.
One of the key programming methods is the use
of memory locations that are accessed both as registers and bits. We used the HR memory
for this purpose. Other memory types are acceptable with the exception of DM memory. In
several cases we use a shift register as a 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. Omron's ASL
instruction makes this very efficient. These programs have been extremely optimized for
both minimum scan time and memory usage.
Programming Results.
Programming for these processors yields fairly
clean and understandable code. The ASL instruction make shift register counters very
efficient. Omron's register compare is very clumsy when considering inline compares in
many other brands. In some stances it adds a considerable number of parallel branches.
Much of Omrons math is centered around BCD although it has both
Binary and BCD math. Our protocol and many of the programming methods used are binary. Our
input and output data are in binary. Care must be taken when using analog values in the
program to avoid improper mixing of data types. You must also remember that binary
multiplies put the result in two memory locations.
The ladder logic has been refined and optimized to a very high degree. In
someways 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.