Notes: Mitsubishi

Revision: 4.9

Following are some miscellaneous notes that may help you with the driver for this PLC.

Download this page along with the Memory Usage and Wiring Diagrams as a Microsoft Word file "Notes.doc" for best printing.  This file is included on the disks that come with the MSP and with all driver downloads.

  1. 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 Mitsubishi PLCs it requires one to three subroutines and in some models one lines of logic in the main program. In the FX the driver subroutine is called as a time interrupt. In the FXo the scan time is fixed and the subroutine is called from the main program. The driver subroutine may be the complete driver or in some versions it may call one or two other subroutines.

  2. The user can import the driver into their program or they can start with our driver and build their program from it.

  3. Drivers. The following is a list of drivers in the libraries for Mitsubishi PLCs. There are separate libraries for the FX and FXo models. The FX 2C can use the FX library. The FXon and FXos can use the FXo library. These drivers were prepared with Mitsubishi's Melsec Meldoc programming software. They are available on the Driver Installation disks. They contain rung comments and address comments that are viewable in the programming package and on printouts.

  4. 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

  5. Timing Parameters. These drivers are set up for the Delta protocol. Following are some of the key timing parameters:

  6. Input

    Protocol

    Delta

    Scan Time

    10 msec

    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

    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

  7. 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.

  8. Scan Time. The key to getting the driver to function properly is to get the I/O updated and code executed at constant time intervals.

  9. The FX executes the driver code in a time interrupt subroutine. It begins at pointer "I610" where I designates interrupt, 6 is the interrupt number, and 10 is the interrupt time in milliseconds. The interrupt time may be set to a time between 10 to 99 msec. by editing the interrupt pointer. Interrupt processing must be enabled with the EI instruction. Inputs are updated in the beginning time interrupt subroutine and Outputs are set at the end by using the REF instruction. Input filtering must be set to zero (0) the minimum value to allow rapid updates. This is done with the REFF instruction, which must be executed at the beginning of every normal scan.

    The FXo does not have a time interrupt but it allows the program scan time to be fixed. Turning on bit M8039 sets the constant time mode. Putting a value in register D8039 in milliseconds sets the time of the constant scan time. In many ways the constant scan mode of the FXo is really minimum scan time. If program execution exceeds the scan time set in D8039 then program execution will control scan time. The following registers allow scan time to be monitored:

    D8010

    Present Scan Time

    in 0.1 milliseconds

    D8011

    Minimum Scan Time

    in 0.1 milliseconds

    D8012

    Maximum Scan Time

    in 0.1 milliseconds

    These registers measure program execution and do not include the dwell time at the end of execution necessary for constant scan. Accounting for the decimal place D8012 must always be less than D8039. On power up the Min and Max sometimes contain incorrect data. They are reset on a program to run transition. The Min and Max are best observed when program to run transition is made while the unit is powered up. Since I/O updates are automatically synchronized with normal program scan immediate updates with the REF instruction are not necessary. Input filtering must be set to zero (0) the minimum value to allow rapid updates. Set D8020 for inputs X0 to X07 and D8021 for inputs X10 to X17.

  10. Program Error. Often when the "Prog-E" light comes on it is because of a watchdog timer fault. On other word the scan time has exceeded the time set in register D8000. This register must always be larger than the maximum scan time.

  11. Timing Parameters Exceptions. The drivers MSP_IO_M for both the FX and FXo have one exception to the previous timing parameters. Their scan time is 20 msec. This driver is longest of the set and on occasion takes more than 10 msec to execute. To insure reliable operation the scan time has been incased. Note that this driver effectively has 4 channels. For any of the multiplexed drivers that are expanded to 4 or more channels the scan time should be increased.

  12. Programming FX. Programming for the FX processor yields one of the cleanest and most understandable pieces of code of any PLC. It requires no deceptive special tricks. 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.

  13. Programming FXo. The programming in the FXo is longer for the multiplexed versions due to the lack of block moves and subroutine calls and returns. Block reads must be expanded to single word moves. Subroutine calls must be changed to jumps and a mechanism to return to the proper location must be added.

  14. Programming FXon. The FXon can use the drivers form the FXo library. The FXon contains block moves and the multiplexed drivers could be optimized further. However, it still does not contain subroutine calls and returns and can not be as optimized as the FX processor.

  15. FXo driver in FX. If you try to use the FXo driver in the FX you will encounter two problems:

    There is an off by one bug in the FX regarding running with fixed scan time. If you want 10 msec. you must enter 9 msec. If you want 50 msec. you must enter 49 msec.

    The input filtering works differently. In the FXo setting registers D8020 and D8021 sets filtering. In the FX filtering is set with the REFF(51) instruction.

  16. Programming Methods. One of the key programming methods is the use memory locations that are accessed both as registers and bits. We used the M memory for this purpose. In several cases counters are programmed by using a shift register. 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.

  17. Life Indicator. In the input only drivers we have included a life indicator on Y5. By watching this output on a scope one can check to insure that the desired scan time has been achieved. This rung is optional and can be deleted. On drivers that include an output the same thing can be accomplished by watch any output channel and this rung is not included.

  18. 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 "1-phase 1-input" mode counters. On the FXo and FXon only two (2) intput channels are possible. This limitation is due to the 5 kHz limit on the maximum sum off all counters. On the FXos four (4) channels would be possible if counter frequency is kept low enough to keep the sum less than 14 kHz. On the FX and FX2c there is no limit on the sum and six (6) channels would be possible. 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 set the PLC to a fixed scan of 10 msec for test purposes even though the logic scan time of the PLC was less than 1 msec. We found that we had to set the MSP scan time to 15 msec. This allows some room for the user to add their program. With only the driver program in the FXos used for testing the scan time was so fast that counter was not updated every scan. The scan time was fixed just to slow down the rate of execution. If the user program has a minimum scan time of more than 2 msec. the scan time limit could be removed.

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 fourth 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

Only units that transmitting temperatures (MSP-TC and MSP-RTD) transmit negative numbers. All MSP-RTD ranges always transmit both negative and positive numbers. For the MSP-TC it will vary depending on the TC type and range selected.

 


SensorPulse Corp. • P.O. Box 8886 • Michigan City, IN 46361 • Ph: (800) 447-5900 or (219) 393-7218 • Fax: (219) 393-7318

© 1998-2002 SensorPulse Corp., All Rights Reserved.
Updated July 2003