Home
Display - Internet
Contents
1. ooo o Wo W nana Wite ar 6100 100210 an a E NET VILLEN pur ON an aon aan ea an Nana An E nenne Ra at nan Menma mau aman aan CGonnechontor nenn nn nn nnnnnnnnnnnnnnene nenn nnnnnneneen RO lM SEE CHANGE EE ScanFinished POPES na PROTO GORING CU EEE ee ee CONTENUTO EEE euere ENDEN CANON EE EN RO Type Definitions ne ImageDataT ypeConstants o o Woo Woo WoW om mn Beleg RER ee Je Se leie e E ee ee ae Error return e Le TE Example Project Using S7ProSim ActiveX Control oom Code othe Example ee an aa aa nie S7ProSim Overview S7ProSim provides an ActiveX MN Control that provides programmatic access to the process simulation interface of S7 PLCSIM You can use S7ProSim in any application that can accept ActiveX controls to attach to an S7 PLCSIM process simulation This online document describes how to add S7ProSim to an application as well as the features interface and operations of S7ProSim including software object definitions of the methods and events The example project demonstrates the use of S7ProSim methods and events The figure below shows the sequence chart for the different methods and events used in the example project HI Ch of Prosim Time SscanMode SingleScan Enabled True BeginScankotif vrtelnputPoimnt Vyrtelnputlmage i ExecutellmsScan ExecuteNScans ExecutesingleScan Loop by Scanfinished only f Enabled True the User Progr
2. ScanFinished Generated when unable to connect to control engine Generated when a new PLC switch state is detected Generated when single scan is done 19 Events Q ConnectionError HRESULT ConnectionError BSTR ControlEngine long Error Description Generated when unable to connect to control engine visual Basic Usage Event ConnectionErron ConfrolE ngine As String Error As Long 20 Q PLCSimStateChanged HRESULT PLCSimStateChanged BSTR NewState Description Generated when a new PLC switch state is detected visual Basic Usage Event PLCSimStateChanged YewsSisis As String Events 21 22 Events Q ScanFinished HRESULT ScanFinished VARIANT ScanInfo Description Generated when single scan is done visual Basic Usage Event ScanFinished scaninioy Properties Er AutoConnect S ControlEngine Enabled i ScanMode Determines whether the control is connected to S7 PLCSIM automatically at startup or at the change from design mode to run mode Defines the name of the control engine read only to which the S7ProSim Control connects The name is S7 PLCSIM Toggles whether the control is registered for callbacks for ScanFinished and PLCSimStateChanged events Sets returns the current control engine scan mode 23 Properties ES AutoConnect boolean AutoConnect Description Determines whether the control is connected to S7 PLCSIM automatically at start
3. errMessage amp and connect with Connect method MsgBox errMessage vbExclamation Connection Error End Sub PLCStateChanged Private Sub S7ProSiml_PLCSIMStateChanged ByVal NewState As String Dim cMessage As String cMessage PLCSIM changed the operating state to amp NewState MsgBox cMessage vbInformation S7ProSim Example End Sub ScanFinished Private Sub S7ProSiml ScanFinished ByVal ScanInfo As Variant Dim cMessage As String Dim vArrayInfo As Variant xxxxk Before this section of code the calculations xxx4xx for the Process Simulation should be done vArrayInfo ScanInfo cMessage Last scan took amp vArrayInfo 0 amp vbCrLf cMessage cMessage amp _ minimum cyle time amp vArrayInfo 1 amp vbCrLf cMessage cMessage amp _ 42 Largest Execution time took amp vArrayInfo 2 amp vbCrLf cMessage cMessage amp Average scan took amp vArrayInfo 3 MsgBox cMessage vbInformation S7ProSim Example End Sub Private Sub cmdBeginScanNotify Click S7ProSiml BeginScanNotify End Sub Private Sub cmdEndScanNotify Click S7ProSiml EndScanNotify End Sub Private Sub cmdExecuteNmsScan Click Dim ReturnValue As Long ReturnValue S7ProSiml ExecuteNmsScan Int txtScanNumber Text If ReturnValue lt gt 0 Then MsgBox Failed vbOKOnly End If End Sub Private Sub cmdExecuteNScan_Click Dim ReturnValue As Long ReturnValue S7ProSiml ExecuteNScans I
4. from the peripheral output image PQ memory area Writes elements to the peripheral input image PI memory area of S7 PLCSIM starting at the StartIndex of the data pointed to by pData Writes either a particular bit Boolean byte Byte a two byte word Integer or a four byte word Long from the Data Variant to the peripheral input image PI memory area Methods Q AboutBox void AboutBox visual Basic Usage Sub AboutBox D BeginScanNotify Methods STDMETHOD CS7ProSim BeginScanNotify bescription Registers S7ProSim for callbacks from the controller The ScanFinished event and PLCSimStateChanged event will be sent when these events occur parameters None Return Value Value S_OK E FAIL PS E NOTCONNECTED PS E POWEROFF visual Basic Usage Function BeginScanhotihy As Long Meaning 0x00000000 Success code 0x80004005 Unspecified error 0x80040211 S7ProSim is not connected to S7 PLCSIM 0x80040212 S7 PLCSIM is powered off Methods Y Connect STDMETHOD CS7ProSim Connect bescription Connects S7ProSim to S7 PLCSIM parameters None Return Value Value S_OK E FAIL PS E NOTCONNECTED PS E POWEROFF visual Basic Usage Function Connect As Long Meaning 0x00000000 Success code 0x80004005 Unspecified error 0x80040211 S7ProSim is not connected to S7 PLCSIM 0x80040212 S7 PLCSIM is powered off L Disconnect STDMETHOD
5. CS7ProSim Disconnect bescription Disconnects S7ProSim from S7 PLCSIM parameters None Return Value Value Meaning S_OK 0x00000000 Success code E FAIL 0x80004005 Unspecified error PS E POWEROFF 0x80040212 S7 PLCSIM is powered off visual Basic Usage Function Disconnecti As Long Methods Methods Q EndScanNotify STDMETHOD CS7ProSim EndScanNotify Description Unregisters S7ProSim for callbacks from the controller The ScanFinished event and PLCSimStateChanged event will not be sent parameters None Return Value Value Meaning S OK 0x00000000 Success code E FAIL 0x80004005 Unspecified error PS E NOTCONNECTED 0x80040211 S7ProSim is not connected to S7 PLCSIM PS E POWEROFF 0x80040212 S7 PLCSIM is powered off PS E NOTREGISTERED 0x80040209 S7ProSim is not registered for callbacks from S7 PLCSIM visual Basic Usage Function End amp canWNotifyt As Long lt ExecuteNmsScan Methods STDMETHOD CS7ProSim ExecuteNmsScan long MsNumber bescription Forces S7 PLCSIM to execute scan cycles for a specified time duration Nms and does not wait for the execution of the current scan to finish If scan notification is enabled the program will be notified when S7 PLCSIM has finished the scans S7 PLCSIM must be in single scan mode to use this method parameters heb VisNumber Time duration in milliseconds for which scan cycles are to be executed return
6. Long from the Data Variant to the peripheral input image PI memory area parameters han saingan Represents the starting byte position in the peripheral input image buffer to write Valid y values for Bytelndex are dependent on the CPU Represents the Bit position in bytes in the peripheral image buffer to write Valid pBitindex values are 0 to 7 I oData Pointer to the data to write Valid values for data are dependent on the data type notes If Boolean is given as the data type then Byte ndex and Bitindex must both be set to valid indexes If successful the method writes the given bit at pData If Byte Integer or Long is given as the data type then Bytelndex must be set to a valid index Bitindex is ignored If successful the method writes the elements in pData Return Value Value Meaning S_OK 0x00000000 Success code E FAIL 0x80004005 Unspecified error PS E BADBYTENDX 0x80040201 Byte index is invalid PS E BADBYTECOUNT 0x80040202 Size of data array is invalid for given starting byte index PS E WRITEFAILED 0x80040204 Write operation failed PS E BADBITNDX 0x80040205 Bit index is invalid PS E BADTYPE 0x80040206 Invalid data type PS E NOTCONNECTED 0x80040211 S7ProSim is not connected to S7 PLCSIM PS E POWEROFF 0x80040212 S7 PLCSIM is powered off visual Basic Usage Function WritelnputPointi By te nodex As Long Bndex As Long Data As Long Events ConnectionError S PLCSimStateChanged
7. MsgBox MSG ALLWRITESNOTPOSSIBLE vbExclamation S7ProSim Example Case PS E NOTCONNECTED MsgBox MSG NOTCONNECTED vbExclamation S7ProSim Example Case PS E POWEROFF MsgBox MSG POWEROFF vbExclamation S7ProSim Example Case Else MsgBox System Error occured amp H amp Hex ErrorNumber vbExclamation S7ProSim Example End Select End Sub 44 Index A AboutBox Method en nennnnn Adding S7ProSim to VB application AutoConnect property oW WWW B B BeginScanNotify meihod C Code example Droe Connect method ConnectionError event Constants wo When ImageDataTypeConstants PointDataTypeCOnStaNIS ooo ScanModeConstanis ccccccceceseessseseeeeees Continuous scan execution SCAN MO ee nn ScanModeConstants ooooooo Control engine name ControlEngine property oo Bl D Defined constants ooooWooo Woo Image at Type onsiants Homt joataTvpe onstante ScanModeConstants o oooooooooo Disconnect method I E Enabled property o ooooooooooooooo EndScanNotify method Enumerated types nenne ImagefiataTvpetonstante PointDatafvpeConstants ScanModeConstants o oooooooo Error return codes oWo W W WWW mma Event handlers oooWo Woo oom nennen ENEE CGonnechontror aa PLC im tatecChanged ScanFinished o oooooooooooooooooo Example Pro
8. Value Value S OK E FAIL PS E NOTSINGLESCAN PS E PLCNOTRUNNING PS E NOTCONNECTED visual Basic Usage Meaning 0x00000000 Success code 0x80004005 Unspecified error 0x8004020A S7 PLCSIM is not in single scan mode 0x8004020E S7 PLCSIM is not running 0x80040211 S7ProSim is not connected to S7 PLCSIM Function ExecuteNmsScan MsNunber As Long As Long Methods D ExecuteNScans STDMETHOD CS7ProSim ExecuteNScans long NScanNumber bescription Forces S7 PLCSIM to execute a specified number of scan cycles and does not wait for the execution of the current scan to finish If scan notification is enabled the program will be notified when S7 PLCSIM has finished the scans S7 PLCSIM must be in single scan mode to use this method parameters NScanNumber Number of scan cycles to be executed Return Value Value S OK E FAIL PS E NOTSINGLESCAN PS E PLCNOTRUNNING PS E NOTCONNECTED visual Basic Usage Meaning 0x00000000 Success code 0x80004005 Unspecified error 0x8004020A S7 PLCSIM is not in single scan mode 0x8004020E S7 PLCSIM is not running 0x80040211 S7ProSim is not connected to S7 PLCSIM Function ExecuteNScans Scanvumber As Long As Long L ExecuteSingleScan Methods STDMETHOD CS7ProSim ExecuteSingleScan bescription Forces S7 PLCSIM to execute one scan cycle and does not wait for the execution of the current scan to finish If scan notification is enabled the
9. a control program e Working with STEP 7 Getting Started Manual This manual explains how to use the STEP 7 automation software This manual provides you with an overview of the procedures used to configure a PLC and to develop control programs e S7 PLCSIM Testing Your S7 CPU Program This manual explains the user interface and operation of S7 PLCSIM the S7 PLC simulator To find these and other manuals select the Start gt Simatic gt Documentation menu command from the Start menu of the computer where STEP 7 is installed Additional Assistance For assistance in answering technical questions for training on this product or for ordering contact your Siemens distributor or sales office H North America and South H Europe and Africa LT Asia and Pacific region America Telephone 1 800 333 Telephone 49 0 180 Telephone 86 10 64 75 75 7421 5050 222 75 Fax 1 423 262 2200 Fax 49 0 180 5050 223 Fax 86 10 64 74 74 74 simatic hotline siemens com adsupport siemens com adsupport asia siemens com Contents S7ProSim Overview oooocoo oo oo oo oo oo oo Wo W Wo WWW Inserting the S7ProSim Control into a Visual Basic Application Accessing S7ProSim Control Properties in Visual Haec nennen Programming an Interface to S7 PLCSIM with G brotsum WWW Celia ele re ADOUIBOX EEN BUSAN SOMEONE era ee Di ee ie EIN UV E Eee EN PENE ne HN An ehren icicle t le gt EV EE ee ee ReadOutputPoint
10. at the change from design mode to run mode e Control Engine The ControlEngine property read only defines the address of the control engine to which the S7ProSim Control connects The address is S7 PLCSIM e Enabled The Enabled property determines whether the control is registered or not ScanFinished event and PLCSIMStateChanged event are available e Scan Mode The ScanMode property sets the scan mode of S7 PLCSIM The valid execution modes are SingleScan Mode or Continuous Mode S7ProSim Overview Programming an Interface to S7 PLCSIM with S7ProSim To use S7ProSim to programmatically operate the S7 PLCSIM simulated controller you must perform these tasks e Include the Siemens S7ProSim Control in the project as a project component e Program event handlers for the S7ProSim events optional Within each event handler you can insert any custom code for your application Example Visual Basic 6 0 Private Sub S7ProSiml_ScanFinished ByVal ScanInto As Variant End Sub Private Sub S7ProSiml PLCSimStateChanged ByVal NewState As String Ena sub Private Sub S7ProSiml_ConnectionError ByVal ControlEngine As String ByVal error As Long MsgBox Connection Error End Sub e Add command buttons textboxes or other objects to your application as needed to access the various S7ProSim methods Program the code for each command button handler to call S7ProSim methods and set corresponding values for textboxes as appropriate for you
11. errDisconnect End If End Sub cmdEnableTrue Private Sub cmdEnableTrue Click S7ProSiml Enabled True End Sub cmdEnableFalse Private Sub cmdEnableFalse Click S7ProSiml Enabled False End Sub Example Project 37 Example Project cmdScanModeSingle Private Sub cmdScanModeSingle Click S7ProSiml ScanMode SingleScan End Sub cmdScanModeCont Private Sub cmdScanModeCont Click S7ProSiml ScanMode ContinuousScan End Sub cmdExecuteSingleScan Private Sub cmdExecuteSingleScan Click Dim errExecuteSingleScan As Long errExecuteSingleScan S7ProSiml ExecuteSingleScan If errExecuteSingleScan S_OK Then MsgBox MSG OK vbInformation S7ProSim Example Else ShowError errExecuteSingleScan End If End Sub cmdReadOutput Image Private Sub cmdReadOutputImage Click Long Dim errReadOutputImage As Long Dim 1StartIndex As Long Dim lElementsToRead As Long ImageDataTypeConstants Dim DataType As ImageDataTypeConstants Variant Dim vData As Variant xxxxx Read 2 Bytes at the starting address Q 8 0 DataType S7Byte Read type Byte lStartIndex 8 Start at address Q 8 0 lElementsToRead 2 Read 2 elements Bytes errReadOutputImage S7ProSiml ReadOuputImage lStartIndex _ lElementsToRead DataType vData If errReadOutputImage S OK Then MsgBox Value of OB 8 is amp CByte vData 0 amp vbCrLf amp _ Value of OB 9 is amp CByte vData l _ vbInformation S7ProSim
12. program will be notified when S7 PLCSIM has finished the scan S7 PLCSIM must be in single scan mode to use this method parameters None Return Value Value S OK E FAIL PS E PLCNOTRUNNING PS E NOTSINGLESCAN PS E MODENOTPOSSIBLE visual Basic Usage Function ExecuteSingleScan As Long Meaning 0x00000000 0x8004020E 0x8004020C Success code 0x80004005 Unspecified error S7 PLCSIM is not running 0x8004020A S7 PLCSIM is not in single scan mode S7 PLCSIM could not set specified scan mode Methods L ReadOutputimage STDMETHOD CS7ProSim ReadOutputImage long StartIndex long ElementsToRead ImagebataTypeConstants DataType VARIANT pData bescription Reads elements from the peripheral output image PQ memory area of S7 PLCSIM Parameters hastartin ay Represents the byte starting position in the peripheral output image buffer to read Valid values for StartIndex are dependent on the CPU Leb ElementsToRead Represents the number of bytes words or double words to read from the image buffer Valid values for Elements ToRead are dependent on the CPU he DataT 2 Represents the type of data to read The DataType value must be one of the yp ImageDataTypeConstants Pointer to the space for returned elements Valid values for data are dependent Data on Elements ToRead You must allocate and free this memory area in your application Return Value Value Meaning S OK 0x00000000 Success
13. vbInformation S7ProSim Example Else ShowError errWriteInputPoint End If xxxxx Write 1 Byte to the address I 1 0 cByteIn 1 Write value 1 lByteIndex 1 Start at address 1 0 vData cByteIn errWriteInputPoint S7ProSiml WriteInputPoint 1ByteIndex 1BitIndex vData If errWriteInputPoint S OK Then MsgBox MSG OK vbInformation S7ProSim Example Else ShowError errWriteInputPoint End If Example Project 41 Example Project xxxxx Write 1 Word to the address I 2 0 iWordIn 2 Write value 2 lByteIndex 2 Start at address 2 0 vData iWordIn errWriteInputPoint S7ProSiml WriteInputPoint 1ByteIndex 1BitIndex vData If errWriteInputPoint S_OK Then MsgBox MSG_OK vbInformation S7ProSim Example Else ShowError errWriteInputPoint End If xxxxx Write 1 DoubleWord to the address I 4 0 lDoubleWordIn 4 Write value A lByteIndex A Start at address 4 0 vData lDoubleWordIn errWriteInputPoint S7ProSiml WriteInputPoint 1ByteIndex 1BitIndex vData If errWriteInputPoint S_OK Then MsgBox MSG_OK vbInformation S7ProSim Example Else ShowError errWriteInputPoint End If End Sub Private Sub S7ProSiml ConnectionError ByVal ControlEngine As String ByVal Error As Long Dim errMessage As String errMessage Unable to connect to amp ControlEngine amp vbCrLf errMessage errMessage amp vbCrLf amp _ Start amp ControlEngine amp vbCrLf errMessage
14. 0 vData iWordArray errWriteInputImage S7ProSiml WriteInputImage lStartIndex vData If errWriteInputImage S_OK Then MsgBox MSG OK vbInformation S7ProSim Example 40 Else ShowError errWriteInputImage End If x Write 2 DoubleWords and start at address I 14 0 lDoubleWordArray 0 14 Write 14 in first element DoubleWord lDoubleWordArray 1 18 Write 18 in second element DoubleWord lStartIndex 14 Start at address I 14 0 vData 1DoubleWordArray errWriteInputImage S7ProSiml WriteInputImage lStartIndex vData If errWriteInputImage S_OK Then MsgBox MSG OK vbInformation S7ProSim Example Else ShowError errWriteInputImage End If End Sub cmdWriteInputPoint Private Sub cmdwriteInputPoint Click Boolean Dim bBoolIn As Boolean Byte Dim cByteIn As Byte Integer Dim iWordIn As Integer Long Dim errWriteInputPoint As Long Dim 1BitIndex As Long Dim 1ByteIndex As Long Dim lDoubleWordIn As Long Variant Dim vData As Variant xxxxx Write 1 Bit to the address I 0 5 bBoolIn 1 Write value 1 lByteIndex 0 Start at address 0 0 1BitIndex 5 Write specific Bit 5 of Byte 0 vData bBoolIn errWriteInputPoint S7ProSiml WriteInputPoint lByteIndex _ 1BitIndex vData After this section the calculations for the xxxxx Process Simulation can be done if the return xxxxx value is S_OK If errWriteInputPoint S_OK Then MsgBox MSG OK
15. Example Else ShowError errReadOutputImage End If kk x k Read 2 Words at the starting address Q 10 0 DataType S7Word Read type Word lStartIndex 10 Start at address Q 10 0 lElementsToRead 2 Read 2 Elements Words errReadOutputImage S7ProSiml ReadOuputImage lStartIndex _ lElementsToRead DataType vData If errReadOutputImage S OK Then MsgBox Value of QW 10 is amp CInt vData 0 amp vbCrLf amp _ Value of QW 12 is amp CInt vData l vbInformation S7ProSim Example Else ShowError errReadOutputImage End If 38 Example Project xxxxx Read 2 DoubleWords at the starting address Q 14 0 DataType S7DoubleWord Read type DoubleWord lStartIndex 14 Start at addresse Q 14 0 lElementsToRead 2 Read 2 Elements DoubleWords errReadOutputImage S7ProSiml ReadOuputImage lStartIndex _ lElementsToRead DataType vData If errReadOutputImage S OK Then MsgBox Value of OD 14 is amp CLng vData 0 amp vbCrLf amp _ Value of OD 18 is amp CLng vData l vbInformation S7ProSim Example Else ShowError errReadOutputImage End If xxxxx After this section the calculations for the xxxxx Process Simulation can be done if the return xxxxx value is S_OK End Sub cmdReadOutputPoint Private Sub cmdReadOutputPoint Click Long Dim errReadOutputPoint As Long Dim 1ByteIndex As Long Dim 1BitIndex As Long PointDataTypeConstants Dim DataT
16. PU Pointer to the data for S7 PLCSIM to write Valid values for data are dependent on the epData CPU You must allocate and free this memory area in your application notes The type of elements to be written is determined by the type of the elements of Data All elements have to be the same data type An array of Bytes writes bytes an array of Integer writes words and an array of Long writes double words The values written will be raw and not interpreted or converted by the method in any way The number of elements written is determined by the size of the array pointed to by Data Return Value Value Meaning S OK 0x00000000 Success code E FAIL 0x80004005 Unspecified error PS E BADBYTENDX 0x80040201 Byte index is invalid PS E BADBYTECOUNT on Size of data array is invalid for given starting byte PS E WRITEFAILED 0x80040204 Write operation failed PS E BADTYPE 0x80040206 Invalid data type PS E NOTALLWRITESWORKED 0x80040210 All write operations did not succeed PS E NOTCONNECTED 0x80040211 S7ProSim is not connected to S7 PLCSIM PS E POWEROFF 0x80040212 S7 PLCSIM is powered off visual Basic Usage Function Writelnputlmage Startndex Js Long Data As Long Methods lt WritelnputPoint STDMETHOD CS7ProSim WriteInputPoint long ByteIndex long BitInNdex const VARIANT pData bescription Writes either a particular bit Boolean byte Byte a two byte word Integer or a four byte word
17. S E BADBYTENDX PS E BADTYPE PS E INVALIDCALLBACK PS E INVALIDDISPATCH PS E INVALIDINPUT PS E INVALIDSCANTYPE PS E MODENOTPOSSIBLE PS E NOTALLREADSWORKED PS E NOTALLWRITESWORKED PS E NOTCONNECTED PS E NOTIFICATION EXIST PS E NOTREGISTERED PS E NOTSINGLESCAN PS E PLCNOTRUNNING PS E POWEROFF PS E READFAILED PS E WRITEFAILED EE FAIL EI E INVALID STATE EIS OK EI STG E CANTSAVE 0x80040205 0x80040202 byte index 0x80040201 0x80040206 0x80040207 0x80040208 0x80040213 0x8004020B Bit index is invalid Size of data array is invalid for given starting Byte index is invalid Invalid data type Invalid callback Invalid dispatch Invalid input Invalid scan type must be one of the ScanModeConstants 0x8004020C mode 0x8004020F 0x80040210 0x80040211 0x8004020D 0x80040209 S7 PLCSIM 0x8004020A S7 PLCSIM is not running S7 PLCSIM is powered off Read operation failed 0x8004020E 0x80040212 0x80040203 0x80040204 0x80004005 0x00008002 0x00000000 S7 PLCSIM could not set specified scan All read operations did not succeed All write operations did not succeed S7ProSim is not connected to S7 PLCSIM S7ProSim is already registered for notification S7ProSim is not registered for callbacks from S7 PLCSIM is not in single scan mode Write operation failed Unspecified error Invalid state Success cod
18. SIEMENS SIMATIC S7ProSim V5 3 incl SP1 ActiveX Control User Manual Edition 01 2005 A5E00425523 01 Copyright and Safety Guidelines This manual contains notices which you should observe to ensure your own personal safety as well as to protect the product and connected equipment These notices are highlighted in the manual by a warning triangle and are marked as follows according to the level of danger Danger Indicates an imminently hazardous situation that if not avoided will result in death or serious injury Warning Indicates a potentially hazardous situation that if not avoided could result in death or severe injury Caution Used with the safety alert symbol indicates a potentially hazardous situation that if not avoided may result in minor or moderate injury Caution Used without the safety alert symbol indicates a potentially hazardous situation that if not avoided may result in property damage Notice Used without the safety alert symbol indicates a potential situation that if not avoided may result in an undesirable result or state Qualified Personnel The device system may only be set up and operated in conjunction with this manual Only qualified personnel should be allowed to install and work on this equipment Qualified persons are defined as persons who are authorized to commission to ground and to tag circuits equipment and systems in accordance with established safety practice
19. Siml ReadOutputPoint lByteIndex _ 1BitIndex DataType vData If errReadOutputPoint S_OK Then MsgBox The current value of QD 4 is amp CLng vData _ vbInformation S7ProSim Example Else ShowError errReadOutputPoint End If xxxxx After this section the calculations for the kk k k Process Simulation can be done if the return x value is S_OK End Sub cmdWriteInputImage Private Sub cmdwriteInputImage Click Byte Dim cByteArray 0 To 1 As Byte Integer Dim iWordArray 0 To 1 As Integer Long Dim errWriteInputImage As Long Dim lDoubleWordArray 0 To 1 As Long Dim 1StartIndex As Long Variant Dim vData As Variant xxxxx Write 2 Bytes and start at address I 8 0 cByteArray 0 8 Write 8 in first element Byte cByteArray 1 9 Write 9 in second element Byte 1StartIndex 8 Start at address I 8 0 vData cByteArray errWriteInputImage S7ProSiml WriteInputImage lStartIndex _ vData xxx4xx After this section the calculations for the Process Simulation can be done if the return kx k k value is S OK If errWriteInputImage S_OK Then MsgBox MSG OK vbInformation S7ProSim Example Else ShowError errWriteInputImage End If xxxkxx Write 2 Words and start at address I 10 0 iWordArray 0 10 Write 10 in first element Word iWordArray 1 12 Write 12 in second element Word lStartIndex 10 Start at address I 10
20. am EndSscan Notif ScanMode ContinuousScan AutoConnect True or Disconnect Legend Event Method or Property Change Actions of the User Program S7ProSim Overview Inserting the S7ProSim Control into a Visual Basic Application The S7ProSim ActiveX Control can be used in a variety of third party containers Use the following procedure to add the S7ProSim Control to a Visual Basic form 4 2 3 4 Select the Project gt Components menu command to display the Components dialog box From the list of controls select Siemens S7ProSim Control Click OK An S7ProSim Control appears in the toolbox on the left of the Visual Basic form Select the S7ProSim Control in the toolbox and paste it into the form You can now access any of the S7ProSim Control properties methods and events from your Visual Basic program S7ProSim Overview Accessing S7ProSim Control Properties in Visual Basic When you right click the S7ProSim Control on the form and select Properties from the context menu Visual Basic displays a Property Pages dialog Froperty Pages x General Control Engine 5 FLESIM Scan Mode fe Single Scan C Continuous Kk Auto Connect Cancel Spy Help The property window allows you to configure the following properties of the S7ProSim ActiveX control e Auto Connect The AutoConnect property determines whether the control is connected to S7 PLCSIM automatically at startup or
21. ate Const PS E NOTREGISTERED amp H80040209 Private Const PS E NOTSINGLESCAN amp H8004020A Private Const PS E MODENOTPOSSIBLE amp H8004020C Private Const PS E NOTIFICATION EXIST amp H8004020D Private Const PS E PLCSIMNOTRUNNING amp H8004020E Private Const PS S ALLREADSNOTPOSSIBLE amp H8004020F Private Const PS_S_ALLWRITESNOTPOSSIBLE amp H80040210 Private Const PS E NOTCONNECTED amp H80040211 Private Const PS E POWEROFF amp H80040212 Default Error Text Private Const MSG OK amp HO Method was successful Private Const MSG FAIL amp H80004005 Unknown error occurred Private Const MSG BADBYTENDX _ amp H80040201 ByteIndex value out of Range Private Const MSG BADBYTECOUNT _ amp H80040202 ByteIndex size of Data array out of range or BytesToRead out of Range Private Const MSG READFAILED amp H80040203 S7 PLCSIM refused read request Private Const MSG WRITEFAILED _ amp H80040204 S7 PLCSIM refused write request Private Const MSG_BADBITNDX amp H80040205 BitIndex value out of range Private Const MSG_BADTYPE amp H80040206 Invalid data type Private Const MSG_NOTREGISTERED _ amp H80040209 The application is not registered Private Const MSG NOTSINGLESCAN _ amp H8004020A S7 PLCSIM is not in single scan mode Private Const MSG_NOTIFICATION_EXIST amp H8004020D Application is already registered Private Const MSG_PLCSIMNOTRUNNING amp H8004020E S7 PLCSIM i
22. code E FAIL 0x80004005 Unspecified error PS E BADBYTENDX 0x80040201 Byte index is invalid PS E BADBYTECOUNT zz Size of data array is invalid for given starting byte index PS E READFAILED 0x80040203 Read operation failed PS E BADTYPE 0x80040206 Invalid data type PS E NOTALLREADSWORKED 0x8004020F PS E NOTCONNECTED 0x80040211 PS E POWEROFF 0x80040212 visual Basic Usage All read operations did not succeed S7ProSim is not connected to S7 PLCSIM S7 PLCSIM is powered off Function ReadOuputlmagei Startindex As Long ElemenisTokesd As Long Uata Type As lmageDatalypeConstants Dafa As Long Methods Q ReadOutputPoint STDMETHOD CS7ProSim ReadOutputPoint long ByteIndex long BitIndex PointDataTypeConstants DataType VARIANT pData bescription Reads a particular bit Boolean a byte Byte a two byte word Integer or a four byte word Long from the peripheral output image PQ memory area parameters Represents the starting byte position in the peripheral image buffer to read Valid pByteindex values for Bytelndex are dependent on the CPU Represents the Bit position in bytes in the peripheral image buffer to read Valid values are 0 to 7 Yb Bitindex eeDataType One of the PointDataTypeConstants heb Data Pointer to the data to read Valid values for data are dependent on the data type notes If the DataType parameter is S7 Bit then Bytelndex and Bitindex must both be set to valid i
23. e 0x80030103 Can t save 33 Example Project Using S7ProSim ActiveX Control This Visual Basic example shows the usage of all properties methods and events of the S7ProSim ActiveX Control You can see the code behind each of the command button handlers in the topic Example Code Project Using S7ProSim ActiveX Control Form of the example project w Example of an 57ProSim Project Il x AutoConnect True in Design Time Connect during Run Time Begins can otity EndS cant otify ScanMode Singlescan EsecuteMmescan po Enabled True ExecuteN Scans HEG WntelnputPoint Writelmputlmage Calculate Values of the ExecuteSingles can g Process Simulation Read lutouttiomt Read Qutputl mage Enabled False Scanklode Continuous AutoLonnect True Disconnect during Design T ime during Run Time 35 Example Project Code of the Example Project The following code listing shows the implementation of the example project Variables must be declared Option Explicit Default Error Code Values of S7ProSim Private Const S OK amp HO Private Const E FAIL amp H80004005 Private Const PS E BADBYTENDX amp H80040201 Private Const PS E BADBYTECOUNT amp H80040202 Private Const PS E READFAILED amp H80040203 Private Const PS E WRITEFAILED amp H80040204 Private Const PS E BADBITNDX amp H80040205 Private Const PS E BADTYPE amp H80040206 Priv
24. ed subsequent editions Suggestions for improvement are welcomed Siemens Energy amp Automation PCbA Siemens Energy amp Automation Inc 2005 One Internet Plaza Johnson City TN 37602 4991 USA Technical data subject to change Preface S7ProSim provides programmatic access to the simulated PLC interface of S7 PLCSIM With S7ProSim you can write software to perform such tasks as changing the keyswitch position of the simulated PLC stepping through the control program a scan at a time reading or writing controller values and many other tasks Audience This manual is intended for engineers programmers and maintenance personnel who have knowledge and experience with S7 programmable logic controllers and with developing software in Visual Basic 6 0 or NET or Visual C 6 0 or NET Scope This document describes the features and the operation of S7ProSim V5 3 incl SP1 Other Manuals You can find additional information in the online help for STEP 7 and S7 PLCSIM and in the following manuals e Programming with STEP 7 Manual This manual provides basic information on designing and programming control programs Use this manual when creating a control program with the STEP 7 automation software e System Software for S7 300 400 System and Standard Functions Reference Manual This manual provides you with descriptions of the system functions organization blocks and standard functions that you use when developing
25. eeseseserereseseees d ScanModeConstants ooo oWoo oo Woo CN Single scan execution ExecuteNmsScan rrvrvrvrvrvevenrsvnveveerevenene ExecuteNScans ooooooo anna ExecuteSingleScan o ooooooooo ScanMode rrornannnnnsnnsvnnnnnnnnnvnnnesnnnnnnnnennener GcanMocdet onsiamte Woo T TYPE Deh ON S Laser ImageDataTypeConstants PointDataTypeConstant ooooo ScanModetonstante V Visual Basic project adding S7ProSim W Writelnputlmage method WritelnputPoint method Writing Apung Oa ee La 6014 ON be EE Response Form Your comments and recommendations will help us to improve the quality and usefulness of our publications Please take the first available opportunity to fill out this questionnaire and return it to Siemens Please give each of the following questions your own personal mark within a range from 1 very good to 5 very poor Do the contents meet your requirements Is the information you need easy to find Is the text easy to understand Le Does the level of technical detail meet your requirements Please rate the quality of the graphics and tables Additional comments Please check any industry that applies to you Automotive Chemical _ Electrical Machinery Food Instrument and Control Non electrical Machinery Petrochemical Pharmaceutical Plastic Pulp and Paper Textiles Transp
26. ject DE OVEIVIEW ccccceeseecceeseeeceeseeeceenseecseuseessaseeeees ExecuteNmsScan Method ExecuteNScans method ExecuteSingleScan method ImageData IT ypeConstants o Inserting S7ProSim into VB application Introduction nennen M MENS er ADODO ee ee le BeginScanNotify nen ME Reen OE bl Nr ExecuteNmsScan eccseseseseseeeseeeevevererereeeres ExecuteNScans ooooooo Wanna Eaecute ingle can HeadCutpoutlmage een ReadOutputPoint ooooooo Wa Wrtelonputlmage Woo WWW WritelnputPoint Wo Wb ma O OLE ALEN menanam P PLCSimStateChanged event PointData I ypeConstants oo Programming S7ProSim interface to S7 PLCSIM EN Index 1 Index Project Components VR Properties jn mmmmmmmnnnininimnnninen AutoConnect EE CGontroltngne Wah Enabled ER EN Se lee R Reading output Image output point ReadOutputlmage method ReadOutputPoint meibod REIN Re S S7ProSim adding to VB pro EE interface to S7 PLCSIM programming H OVEIVIEW aneennnennnnnennnnnnnnnnnnnnnnnnnnnennnnnnnnnnnnnennennnnn Drop ee naar een Scan execution methods Eaecutehmepcan JJ mna ExecuteNScans oo JJ mana ExecuteSingleScan ccccsssssseseseeeeseeseeen Scan mode GRAN EN NE SERING 22u2u0 enenennnnnnnnnnnnnnennnnnn nennen nennen nn Index 2 Scan notification u H ScanFinished event ScanMode property ceceseceseces
27. ndexes If successful the method returns the given bit in pData and its Variant data type is Boolean If the DataType parameter is S7 Byte S7 Word or S7 DoubleWord then Bytelndex must be set to a valid index BitIndex is ignored If successful the method returns the value in pData The Variant data type is Byte Integer or Long depending on the DataType parameter Return Value Value Meaning S OK 0x00000000 Success code E FAIL 0x80004005 Unspecified error PS E BADBYTENDX 0x80040201 Byte index is invalid PS E BADBYTECOUNT 0x80040202 Size of data array is invalid for given starting byte index PS E READFAILED 0x80040203 Read operation failed PS E BADBITNDX 0x80040205 Bit index is invalid PS E BADTYPE 0x80040206 Invalid data type PS E NOTCONNECTED 0x80040211 S7ProSim is not connected to S7 PLCSIM PS E POWEROFF 0x80040212 S7 PLCSIM is powered off Visual Basic Usage Function ReadOutputPointi Byte ndex 45 Long Andex As Long Dala Tepe 45 PointDatalypeConstants posta As Long Methods Q Writelnputlmage STDMETHOD CS7ProSim WriteInputImage long StartIndex const VARIANT pData bescription Writes elements to the peripheral input image Pl memory area of S7 PLCSIM starting at the StartIndex of the data pointed to by pData parameters Represents the byte starting position in the peripheral input image buffer to write Valid pstartindex values for StartIndex are dependent on the C
28. nt txtScanNumber Text If ReturnValue lt gt O Then MsgBox Failed vbOKOnly End If End Sub Private Sub Form_Unload cancel As Integer Dim errDisconnect As Long errDisconnect S7ProSiml Disconnect If errDisconnect S_OK Then MsgBox MSG OK vbInformation S7ProSim Example Else ShowError errDisconnect Private Sub ShowError ErrorNumber Select Case ErrorNumber Case E FAIL MsgBox MSG FAIL vbExclamation S7ProSim Example Case PS E BADBYTENDX MsgBox MSG BADBYTENDX vbExclamation S7ProSim Example Case PS E BADBYTECOUNT MsgBox MSG BADBYTECOUNT vbExclamation S7ProSim Example Case PS E READFAILED Example Project 43 Example Project MsgBox MSG_READFAILED vbExclamation S7ProSim Example Case PS_E_WRITEFAILED MsgBox MSG_WRITEFAILED vbExclamation S7ProSim Example Case PS E BADBITNDX MsgBox MSG BADBITNDX vbExclamation S7ProSim Example Case PS E BADTYPE MsgBox MSG BADTYPE vbExclamation S7ProSim Example Case PS E NOTREGISTERED MsgBox MSG NOTREGISTERED vbExclamation S7ProSim Example Case PS E NOTSINGLESCAN MsgBox MSG NOTSINGLESCAN vbExclamation S7ProSim Example Case PS E NOTIFICATION EXIST MsgBox MSG NOTIFICATION_EXIST vbExclamation S7ProSim Example Case PS E PLCSIMNOTRUNNING MsgBox MSG PLCSIMNOTRUNNING vbExclamation S7ProSim Example Case PS S ALLREADSNOTPOSSIBLE MsgBox MSG ALLREADSNOTPOSSIBLE vbExclamation S7ProSim Example Case PS S ALLWRITESNOTPOSSIBLE
29. ortation Other Mail your response to Siemens Energy amp Automation Inc ATTN Technical Communications One Internet Plaza Johnson City TN USA 37604 Include this information From Name Job Title Company Name Street City and State Country Telephone
30. r application Methods AboutBox BeginScanNotify Connect Disconnect EndScanNotify ExecuteNmsScan ExecuteNScans ExecuteSingleScan ReadOutputimage ReadOutputPoint Writelnputimage WritelnputPoint Displays the AboutBox dialog Registers S7ProSim for callbacks from the controller The ScanFinished event and PLCSimStateChanged event will be sent when these events occur Connects S7ProSim to S7 PLCSIM Disconnects S7ProSim from S7 PLCSIM Unregisters S7ProSim for callbacks from the controller The ScanFinished event and PLCSimStateChanged event will not be sent Forces S7 PLCSIM to execute scan cycles for a specified time duration Nms and does not wait for the execution of the current scan to finish If scan notification is enabled the program will be notified when S7 PLCSIM has finished the scans Forces S7 PLCSIM to execute a specified number of scan cycles and does not wait for the execution of the current scan to finish If scan notification is enabled the program will be notified when S7 PLCSIM has finished the scans Forces S7 PLCSIM to execute one scan cycle and does not wait for the execution of the current scan to finish If scan notification is enabled the program will be notified when S7 PLCSIM has finished the scan Reads elements from the peripheral output image PQ memory area of S7 PLCSIM Reads a particular bit Boolean a byte Byte a two byte word Integer or a four byte word Long
31. s and standards Correct Usage Note the following Warning a This device and its components may only be used for the applications described in the catalog or the technical descriptions and only in connection with devices or components from other manufacturers which have been approved or recommended by Siemens This product can only function correctly and safely if it is transported stored set up and installed correctly and operated and maintained as recommended Trademarks Siemens and SIMATIC are registered trademarks of SIEMENS AG STEP 7 and S7 Mare trademarks of SIEMENS AG Microsoft Windows Windows 95 Windows 98 Windows NT Windows ME and Windows 2000 are registered trademarks of Microsoft Corporation ActiveX is a trademark of Microsoft Corporation Copyright Siemens Energy amp Automation Inc 2005 Disclaimer of Liability All rights reserved We have checked the contents of this manual for agreement The reproduction transmission or use of this document or its with the hardware and software described Because contents is not permitted without express written authority deviations cannot be precluded entirely we cannot guarantee Offenders will be liable for damages All rights including rights full agreement However the data in this manual are created by patent grant or registration of a utility model or reviewed regularly and any necessary corrections included in design are reserv
32. s not in Run or Run P mode Private Const MSG_ALLREADSNOTPOSSIBLE _ amp H8004020F Only the configured outputs could be read successful Private Const MSG ALLWRITESNOTPOSSIBLE amp H80040210 Only the configured inputs could be written successful Private Const MSG NOTCONNECTED amp H80040211 The S7ProSim control is not connected to S7 PLCSIM Private Const MSG POWEROFF amp H80040212 S7 PLCSIM is in Power off state 36 Private Sub cmdAutoConnectTrueStart Click S7ProSiml AutoConnect True End Sub cmdAutoConnectTrueEnd Private Sub cmdAutoConnectTrueEnd Click S7ProSiml AutoConnect True End Sub cmdCalculateValuesOfProcessSimulation Private Sub cmdCalculateValuesOfProcessSimulation Click xxxxx TODO by the User xxxxx In this function you have to implement the xxxxx Code for the Process Simulation Take the xxxxx values from the Outputs of S7 PLCSIM and xxxxx Calculate the new values for the Input of KEKKK S7 PLCSIM kk kkk End Sub cmdConnect Private Sub cmdConnect Click Dim errConnect As Long errConnect S7ProSiml Connect If errConnect S OK Then MsgBox MSG OK vbInformation S7ProSim Example Else ShowError errConnect End If End Sub cmdDisconnect Private Sub cmdDisconnect Click Dim errDisconnect As Long errDisconnect S7ProSiml Disconnect If errDisconnect S OK Then MsgBox MSG OK vbInformation S7ProSim Example Else ShowError
33. up or at the change from design mode to run mode 24 Properties ControlEngine BSTR ControlEngine Description Defines the name of the control engine read only to which the S7ProSim Control connects The name is S7 PLCSIM 25 Properties Enabled boolean Enabled Description Toggles whether the control is registered for callbacks for ScanFinished and PLCSimStateChanged events 26 ScanMode ScanModeConstants ScanMode Description Sets returns the current control engine scan mode to either SingleScan or ContinuousScan Properties 27 Type Definitions ImageDataTypeConstants Constants for the ReadOutputlmage method F PointDataTypeConstants Constants for the ReadOutputPoint method EF ScanModeConstants Constants for the scan mode 29 30 Type Definitions enum S Byte 2 S7Word 3 S7DoubleWord 4 bescription Constants for the ReadOutputlmage method Gnmembers S7Byte S7DoubleWord S7Word I PointDataTypeConstants enum S7 Bit 1 S1 Byte 2 S7 Word 3 S _DoubleWord 4 bescription Constants for the ReadOutputPoint method members S7 Bit 57 Byte 57 DoubleWord 57 Word Type Definitions 31 Type Definitions r ScanModeConstants enum SingleScan 0 Continuousscan I bescription Constants for the scan mode mem bers ContinuousScan SingleScan 32 Error return codes PS E BADBITNDX PS E BADBYTECOUNT P
34. ype As PointDataTypeConstants Variant Dim vData As Variant xxxxx Read the Bit at the address Q 0 5 lByteIndex 0 Start at address 0 0 1BitIndex 5 Read specific Bit 5 of Byte 0 DataType S7 Bit Read type Bit errReadOutputPoint S7ProSiml ReadOutputPoint lByteIndex _ 1BitIndex DataType vData If errReadOutputPoint S_OK Then MsgBox The current value of Q 0 5 is amp CInt vData vbInformation S7ProSim Example Else ShowError errReadOutputPoint End If xxxxx Read the Byte at the address Q 1 0 lByteIndex 1 Start at address 1 0 DataType S7 Byte Read type Byte errReadOutputPoint S7ProSiml ReadOutputPoint lByteIndex _ 1BitIndex DataType vData If errReadOutputPoint S_OK Then MsgBox The current value of QB 1 is amp CByte vData vbInformation S7ProSim Example Else ShowError errReadOutputPoint End If xxxxk Read the Word at the address Q 2 0 lByteIndex 2 Start at address 2 0 DataType S7 Word Read type Word errReadOutputPoint S7ProSiml ReadOutputPoint lByteIndex _ 1BitIndex DataType vData 39 Example Project If errReadOutputPoint S_OK Then MsgBox The current value of QW 2 is amp CInt vData _ vbInformation S7ProSim Example Else ShowError errReadOutputPoint End If xxxxx Read the DoubleWord at the address Q 4 0 lByteIndex A Start at address 4 0 DataType S7 Doubleword Read type DoubleWord errReadOutputPoint S7Pro
Download Pdf Manuals
Related Search
Related Contents
Tristar BW-4753 Philips Flash audio player SA4121 Le fleurissement, un acte d`aménagement The Eisbach User Manual - Isabelle Frequency Inverter Convertidor de Frecuencia Inversor de GXP16xx User Guide - Grandstream Networks iVMS-7200 B/S Client 3 installation of indoor unit Stow MS-40M Music Mixer User Manual Sharp KB-3300J Installation manual Copyright © All rights reserved.
Failed to retrieve file