Example Code

MPI S7 Protocol Example

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

This example was manually migrated for Marcopolo5 - last modified <span class="documentModified">2008-02-07 08:10

 

Overview

This example provides a library of LabVIEW VI's that can be used to communicate with a Siemens S7-300 PLC via the MPI port.

 

Description

 

This example communicates with a S7-300 PLC through a Simatic S7 PC Adapter (MPI to RS-232 adapter). Communication with the Simatic PC MPI adapter is based on the 3964r protocol and communicates via RS-232. The example provides an API to read from / write to registers on the PLC.

 

This example was not created from a protocol specificaion, but through reverse engineering sample data sent between a PC and S7 PLC. Use at your own risk.

 

Also included is an example of using a cRIO-901x contoller as a data logger for MPI data. The program logs data from registers listed in the "MPI Read Write Array". Data is saved on the internal flash memory and is automatically transfered to USB drive when one is connected to the external USB port of the cRIO.

 

Steps to Implement

  1. Download and extract zip file.
  2. Open Siemens MPI.lvproj
  3. Run MI Test.vi or MI Test 2.vi

 

Requirements

Software

-LabVIEW

 

Hardware

-Siemens S7-300 PLC

-cRIO-901x

 

Additional Images

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Best,
JLSx
Sixclear
VI High - LabVIEW Programming Video Blog

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
effgee
Member
Member
on

Sounds good; can anyone downsave this to v7.1 or earlier ? Please !

cdiaz
Member
Member
on

I was looking for a example like this. But I wonder if you know what requirements are needed to establish communication between the PLC S7300 Siemens and a PC using the software Labview 8.6. I've already done all the steps that are in the tutorial video from NI, and also forums, however I was unable to establish this communication.

I appreciate being able to help with this problem

______________
Cesar Diaz
Ing. Mecatrónico
seriasoneub
Member
Member
on

Habe dieses Programm genutzt. Speichere damit Datenbausteine in Excel.Aber bei MPI-Adressen

größer 2 versagt der Kommunikationsaufbau. Warum ?

I used this program to save db's in excel files. Works more than fine. Except mpi-addresses greater

then 2. Why? Error 6201 is send back. I have no idea where to search.

In sub VI "MPI_PLC_Connect" answer of first mpi-state-machine is only 8 bytes long instead of 23.

And output ( content of this first mpi-state-mach. ) differs from the expected shown in array at "equal"-

element.

Contributors