Project Description
This project is dedicated to use S7-Plc's from every .Net language. It's possible to read and write variables in a very easy way.
There will be controls to generate variable-list and something more.

Generally it works.
Here are some samples how to use:

// create the plc-object
S7.PLC plc = new PLC(CPU_Type.S7300, "192.168.1.130", 0, 2); 
// open the plc S7300-type
ErrorCode errCode = plc.Open();      
// set bit 0 in marker-byte 20
plc.Write("M20.0", 1);            
 // read the word-value in DataBlock 100 Word-Position 40
UInt16 b1 = (UInt16)plc.Read("DB100.DBW40");          
 // close the plc
plc.Close();

// create the plc-object
S7.PLC plc = new PLC(CPU_Type.S7300, "192.168.1.130", 0, 2); 
// open the plc S7300-type
ErrorCode errCode = plc.Open();      
// set bit 0 in marker-byte 20
plc.Write("M20.0", 1);            
 // read the word-value in DataBlock 100 Word-Position 40
UInt16 b1 = (UInt16)plc.Read("DB100.DBW40");          
 // close the plc
plc.Close();

And now a new function:
You define a DataBlock in the plc like:
DB2.png

Then you add a struct into your .Net application that is similiar to the DB in the plc:
public struct testStruct
{
    public bool varBool0;
    public bool varBool1;
    public bool varBool2;
    public bool varBool3;
    public bool varBool4;
    public bool varBool5;
    public bool varBool6;

    public byte varByte0;
    public byte varByte1;

    public ushort varWord0;

    public double varReal0;
    public bool varBool7;
    public double varReal1;

    public byte varByte2;
    public UInt32 varDWord;
}

then you add the code to read or write the complete struct
// reads a struct from DataBlock 1
testStruct test = (testStruct)plc.ReadStruct(typeof(testStruct), 1);

// change one item
test.varDWord += 1;

// and writes it to DB2
S7.ErrorCode code = plc.WriteStruct(test, 2);


As you can see, it's very simple to read and write values in the plc of SIEMENS S7300-400.
I could'nt check this on S7200. If anyone can do this I would be very glad about that.

In future there will be some samples in the source-code.

This is the first of my controls working with the SIEMENS-plc.
You can see the input and outputs of one DI/DO module.

DIDO.jpg

Here are some in and output controls for the S7300 family.
DIDO2.jpg

Last edited Oct 4, 2009 at 12:16 PM by juergen1969, version 17