Home
S7ProSim
Contents
1. Please check any industry that applies to you LJ Automotive Ll Chemical Electrical Machinery Ll Food LJ Instrument and Control LJ Non electrical Machinery E Petrochemical 2 Pharmaceutical je Plastic LJ Pulp and Paper LJ Textiles LJ Transportation E Other Mail your response to SIEMENS ENERGY amp AUTOMATION INC ATTN TECHNICAL COMMUNICATIONS M S 519 3000 BILL GARLAND ROAD PO BOX 1255 JOHNSON CITY TN USA 37605 1255 Include this information From Name Job Title Company Name Street City and State Country Telephone
2. Return Codes of the ReadOutputlmage Method The following table lists possible return codes for the return value result of the ReadOutputlmage method Constant Value Description S_OK amp HO Method was successful PS_E FAIL amp H80004005 Unknown error occurred PS E INVBYTENDX amp H80040201 Bytelndex value out of Range PS E INVBYTECOUNT amp H80040202 BytesToRead out of range PS E READFAILED amp H80040203 S7 PLCSIM refused read reguest PS E INVTYPE amp H80040206 Invalid data type PS S ALLREADSNOTPOSSIBL amp H8004020F The method could only read the E configured outputs successfully PS E NOTCONNECTED amp H80040211 The S7ProSim control is not connected to S7 PLCSIM PS E POWEROFF amp H80040212 S7 PLCSIM is in Power off state 16 Methods ReadOutputPoint Method The method 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 If the DataType parameter is set to S7 Bit then Bytelndex and BitIndex must both be set to valid indexes If successful the method returns the given bit in pData and its Variant data type is Boolean If the DataType parameter is set to 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 and its Variant data type is Byte Integer or Long depending on the DataType parameter Syntax result
3. 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 34 Index Index A AboutBox method jg Accessing S7ProSim control properties in Visual Basic AutoConnect property A B BeginScanNotif method f BitIndex 17 19 Bytelndex 17 C Code of the example project 26 Components Connect method elf ConnectionError event 22 Constants 23 ContinuousScan mode i ControlEngine 22 ControlEngine property lel D Data parameter 18 9 DataType parameter Disconnect method E an Enabled property 4 6l EndScanNotify method 10 Events of the S7ProSim control 21 Example project 25 26 ExecuteNmsScan method ExecuteNScans method ExecuteSingleScan method 15 l Inserting the eel control into a Visual 3 Basic application M Methods Methods of the S7ProSim control MsNumber 13 N NewState NScanNumber 14 O Overview P Data 16 j17 ae CIT event el 1 0 22 Predefined constants Properties of the S7ProSim control Property Pages dialog PSE FAIL elln fallia PS_E_INVBITNDX 17 19 PS S ALLW ch R ReadOutputImage method ReadOutputPoint method Return codes of the BeginScanNotify method Return codes of the Co
4. S7ProSim1 ReadOutputPoint Bytelndex BitIndex DataType pData where e Bytelndex is an input parameter of type Long and represents the byte position in the peripheral image buffer to read Valid values for Bytelndex are dependent on the CPU e BitIlndex is an input parameter of type Long and represents the bit position of the byte in the peripheral image buffer to read Valid values are 0 to 7 e DataType is an input parameter and is one of the PointDataT ypeConstants and can be set to S7_Bit S7_Byte S7_Word or S7_DoubleWord e pData is an output parameter of the type Variant and holds the read data Valid values for pData are dependent on the data type e result is a Long value that indicates whether an error has occurred The result is zero if no error occurs Return Codes of the ReadOutputPoint Method The following table lists possible return codes for the return value result of the ReadOutputPoint method Constant Value Description S_OK amp HO Method was successful PS_E FAIL amp H80004005 Unknown error occurred PS E INVBYTENDX amp H80040201 Bytelndex value out of Range PS E INVBYTECOUNT amp H80040202 Bytelndex and size of Data array out of range PS E READFAILED amp H80040203 S7 PLCSIM refused read reguest PS E INVBITNDX amp H80040205 Bitlndex value out of range PS E INVTYPE amp H80040206 Invalid data type PS E NOTCONNECTED amp H80040211 The S7ProSim control is not connected to S7 PLCSIM PS
5. Return Codes of the ExecuteNScans Method Woo Woo ExecuteSingleScan Method oooooooW WWW W mann Return Codes of the ExecuteSingleScan Method ooooooo oom oo ReadOutputlmage Method ooooo Woo Wo mo maan Return Codes of the ReadOutputlmage Method Woo ReadOutputBoin Melodi enam ana a Contents Return Codes of the ReadOutputPoint Method oooooooooW Wo Woo WritelnputImage Method sei isat ia ema amanat Maa asa Return Codes of the Writelnputlmage Method ooooooooooWoW Woo WritelnputPoint Method aa nila nan sa Return Codes of the WritelnputPoint Method oooooWWoWooWo Wo Wo Woo WWW ES ia 21 Events of the S7ProSim Control W kk LanndelisnErior eh kk ain Dn bana yaaa PECSIMS tate Changed Event node mi en an na asian Scania kn on on ab Reference Information mamak 23 Predetined Constants ac nu Example Project Renee ee ner ore ee aa ee eee er ab aan taman in Hanana anna Code of the Example io 2 01 sn naa aan ee S7ProSim Overview S7ProSim Overview S7ProSim is an ActiveX Control that provides programmatic access to the process simulation interface of S7 PLCSIM This control may be used in any application that can accept Activex controls You can use this control to attach a process simulation to S7 PLCSIM This online help describes the features and operations of the S7ProSim Control Version 5 0 All properties methods and events are used in an e
6. 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 xxxxx Before this section of code the calculations xxkxkk 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 _ 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 33 Reference Information Private Sub cmdExecuteNScan_Click Dim ReturnValue As Long ReturnValue S7ProSiml ExecuteNScans Int
7. s CByte vData 1 vbInformation S7ProSim Example Else ShowError errReadOutputImage End If 28 Reference Information kkkkk Read 2 Words at the starting address Q 10 0 DataType S7Word Read type Word 1StartIndex 10 Start at address Q 10 0 lElementsToRead 2 Read 2 Elements Words errReadOutputImage S7ProSiml ReadOuput Image 1StartIndex 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 1 vbInformation S7ProSim Example Else ShowError errReadOutputImage End If kkkkk 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 ReadOuput Image 1StartIndex lElementsToRead DataType vData If errReadOutputImage S_OK Then MsgBox Value of QD 14 is amp CLng vData 0 amp vbCrLf amp _ Value of QD 18 is amp CLng vData 1 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 kkkkk value is S_OK End Sub cmdReadOutputPoint Private Sub cmdReadOutputPoint Click Long Dim errReadOutputPoint As Long Dim 1ByteIndex As Long Dim 1BitIndex As Long P
8. txtScanNumber Text If ReturnValue lt gt 0 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 End If Private Sub ShowError ErrorNumber Select Case ErrorNumber Case PS E FAIL MsgBox MSG FAIL vbExclamation S7ProSim Example Case PS E INVBYTENDX MsgBox MSG INVBYTENDX vbExclamation S7ProSim Example Case PS E INVBYTECOUNT MsgBox MSG INVBYTECOUNT vbExclamation S7ProSim Example Case PS E READFAILED MsgBox MSG READFAILED vbExclamation S7ProSim Example Case PS E WRITEFAILED MsgBox MSG WRITEFAILED vbExclamation S7ProSim Example Case PS E INVBITNDX MsgBox MSG INVBITNDX vbExclamation S7ProSim Example Case PS E INVTYPE MsgBox MSG INVTYPE 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 MsgBox MSG ALLWRITESNOTPOSSIBLE vbExclamation S7ProSim Example
9. S7 Bit S7 Byte S7 Word S7 DoubleWord PS E INVBYTENDX PS E INVBYTECOUNT amp H80040202 Bytelndex and size of Data array out of range or BytesToRead out of range PS_E READFAILED amp H80040203 S7 PLCSIM refused read request PS E WRITEFAILED amp H80040204 S7 PLCSIM refused write reguest PS E INVBITNDX amp H80040205 Bitlndex value out of range PS E 4 4 amp HO PS E NOTREGISTERED The application is not registered PS E NOTSINGLESCAN amp H8004020A S7 PLCSIM is not in single scan mode PS E PLCSIMNOTRUNNING amp H8004020E S7 PLCSIM is not in Run or Run P mode PS S ALLREADSNOTPOSSIBLE amp H8004020F The method could only read the configured outputs successful PS S ALLWRITESNOTPOSSIBLE amp H80040210 The method could only write the configured inputs successful PS E NOTCONNECTED The S7ProSim control is not connected to S7 PLCSIM 23 _INVTYPE x x x Ro A IN I IJI IJI o o o o S Io S o gt AJA gt O Q o o O A N D N M O oO o oO o o 10 Reference Information Predefined constants continued PS E POWEROFF PS E INVALIDINPUT Number of elements in Scaninfo NUM_OF_SCANINFO_ELEMENTS Indexes of the Scaninfo EXECUTION_TIME_NDX MIN_CYCLE_TIME_NDX LARGEST_CYCLE_TIME_NDX AVERAGE_CYCLE_TIME_NDX 24 amp H80040212 S7 PLCSIM is in Power off state amp H80040213 Invalid input entered Programmed minimum cycle time ms Largest ex
10. Then MsgBox MSG OK vbInformation S7ProSim Example Else ShowError errDisconnect End If End Sub cmdEnableTrue Private Sub cmdEnableTrue Click S7ProSiml Enabled True End Sub cmdEnableFalse 27 Reference Information Private Sub cmdEnableFalse Click S7ProSiml Enabled False End Sub 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 cmdReadOutput Image 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 ReadOuput Image 1StartIndex 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
11. 10 Start at address I 10 0 vData iWordArray errWriteInputImage S7ProSiml WriteInputImage 1StartIndex vData If errWriteInputImage S_OK Then MsgBox MSG_OK vbInformation S7ProSim Example Else ShowError errWriteInputImage End If kkkkk Write 2 DoubleWords and start at address I 14 0 xx 1DoubleWordArray 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 1StartIndex 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 1DoubleWordIn As Long Variant Dim vData As Variant Reference Information En 32 xxxxx Write 1 Bit to the address I 0 5 bBoolIn 1 Write value 1 lByteIndex 0 Start at address 0 0 lBitIndex 5 Write specific Bit 5 of Byte 0 vData bBoolIn errWriteInputPoint S7ProSiml WriteInputPoint 1ByteIndex lBitIndex vData xxxxx After this section the calculations for the kkkkk Process Simulation can be done if the return kkkkk value is S OK If errWriteInputP
12. E POWEROFF amp H80040212 S7 PLCSIM is in Power off state Methods Writelnputlmage Method Starting at the StartIndex value the elements held in Data will be written to the peripheral input image PI memory area of S7 PLCSIM 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 Note that the number of elements written is determined by the size of the array held in Data Syntax result S7ProSim1 Writelnputlmage StartIndex Data where e Startindex is an input parameter of type Long and represents the byte starting position in the peripheral input image buffer to write Valid values for StartIndex are dependent on the CPU e Data is an input parameter of type Variant and represents the array containing the elements to write It is also dependent on the CPU The memory is allocated and freed by the application The elements will be written in S7 PLCSIM e result is a Long value that indicates whether an error has occurred The result is zero if no error occurs Return Codes of the Writelnputlmage Method The following table lists possible return codes for the return value result of the Writelnputlmage method Constant Value Description S OK amp HO Met
13. OutputPoint S7ProSiml ReadOutputPoint 1ByteIndex 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 kkkkk After this section the calculations for the kkkkk Process Simulation can be done if the return kkkkk value is S_OK End Sub cmdWriteInput Image 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 1DoublewordArray 0 To 1 As Long Dim 1StartIndex As Long Variant Dim vData As Variant 30 Reference Information kkkkk 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 lStartIndex 8 Start at address I 8 0 vData cByteArray errWriteInputImage S7ProSiml WriteInputImage 1StartIndex vData xxxkx After this section the calculations for the xxxxx Process Simulation can be done if the return kxkk k k value is S_OK If errWriteInputImage S_OK Then MsgBox MSG OK vbInformation S7ProSim Example Else ShowError errWriteInputImage End If kkkkk 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
14. SIEMENS SIMATIC S7ProSim Version 5 0 User Manual Edition 06 2001 2809923 0002 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 AN Danger Indicates an imminently hazardous situation which if not avoided will result in death or serious injury Warning Indicates a potentially hazardous situation which if not avoided could result in death or severe injury Caution Used with the safety alert symbol indicates a potentially hazardous situation which if not avoided may result in minor or moderate injury Caution Used without the safety alert symbol indicates a potentially hazardous situation which if not avoided may result in property damage Notice NOTICE used without the safety alert symbol indicates a potential situation which 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 practices and standards Correct Usag
15. WRITEFAILED amp H80040204 PS E INVBITNDX amp H80040205 PS E INVTYPE amp H80040206 amp H80040209 amp H8004020A PS E NOTREGISTERED PS E NOTSINGLESCAN PS E MODENOTPOSSIBLE amp H8004020C PS E NOTIFICATION EXIST amp H8004020D PS E PLCSIMNOTRUNNING amp H8004020E PS S ALLREADSNOTPOSSIBLE amp H8004020F PS S ALLWRITESNOTPOSSIBLE amp H80040210 PS E NOTCONNECTED amp H80040211 PS E POWEROFF amp H80040212 Default Error Text Private Const Private Const Private Const amp H80040201 Private Const amp H80040202 Range Private Const amp H80040203 Private Const amp H80040204 Private Const amp H80040205 Private Const Private Const amp H80040209 Private Const amp H8004020A Private Const amp H8004020D Private Const amp H8004020E Private Const amp H8004020F Private Const amp H80040210 Private Const amp H80040211 Private Const amp H80040212 26 MSG OK amp H0 Method was successful MSG_FAIL amp H80004005 Unknown error occurred MSG_INVBYTENDX _ ByteIndex value out of Range MSG_INVBYTECOUNT _ ByteIndex size of Data array out of range or BytesToRead out of MSG_READFAILED _ S7 PLCSIM refused read request MSG_WRITEFAILED _ S7 PLCSIM refused write request MSG_INVBITNDX _ BitIndex value out of range MSG_INVTYPE amp H80040206 Invalid data type MSG _NOTREGISTERED _ The applica
16. a Long value that indicates whether an error has occurred The result is zero if no error occurs e MsNumber is a Long value that indicates the time duration in milliseconds for which scan cycles are to be executed Note This method is used only in SingleScan mode Return Codes of the ExecuteNmsScan Method The following table lists possible return codes for the return value result of the ExecuteNmsScan method Constant Value Description S_OK amp HO Method was successful PS E FAIL amp H80004005 Unknown error occurred PS E NOTSINGLESCAN amp H8004020A S7 PLCSIM is not in single scan mode PS E PLCSIMNOTRUNNING amp H8004020E S7 PLCSIM is not in Run or Run P mode PS E NOTCONNECTED amp H80040211 The S7ProSim control is not connected to S7 PLCSIM Methods ExecuteNScans Method This method 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 the Enabled property is set to True the program will be notified when S7 PLCSIM has finished the scans Syntax result S7ProSim1 ExecuteNScans NScanNumber where e result is a Long value that indicates whether an error has occurred The result is zero if no error occurs e NScanNumber is a Long value that indicates the number of scan cycles to be executed Note This method is used only in SingleScan mode Return Codes of the ExecuteNScans Method The following table lists possible ret
17. e Note the following ae 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 are trademarks of SIEMENS AG Microsoft Windows Windows 95 Windows 98 Windows NT Windows ME and Windows 2000 are registered trademarks of Microsoft Corporation ActiveXTM is a trademark of Microsoft Corporation Copyright Siemens Energy amp Automation Inc 2001 Disclaimer of Liability All rights reserved We have checked the contents of this manual for The reproduction transmission or use of this document or its agreement with the hardware and software described contents is not permitted without express written authority Because deviations cannot be precluded entirely we Offenders will be liable for damages All rights including cannot guarantee full agreement However the data in this rights created by patent grant or registration of a utility model manual are reviewed regularly and any necessary or design are reserved corrections included in subsequent editions Suggestions for im
18. ecution time ms ob i Execution time ms 3s verage cycle time ms Reference Information Example Project This example shows the usage of all properties methods and events of the control The form below is a representation of the sequence chart in the S7ProSim overview All controls in the form are Visual Basic Buttons See also the code of the example project Form of the example project w Example of an S7ProSim Project iof x AutoConnect True in Design T ime ScanMode SingleScan Connect Aan iene BeaginScanNotify EndScanNotify ExecuteNmsScan NN Enabled True ExecuteNScans HL Ut WritelnputPoint Writelnputl mage Calculate Values of the ExecuteSingleScan Process Simulation ReadOutputPoint ReadOutputl mage Enabled False ScanMode Continuous AutoConnect True Disconnect during Design T ime during Run Time 25 Reference Information 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 Private Private Const Private Private Private Private Private Private Private Private Private Private Private Private Private Private S_OK amp HO PS E FAIL amp H80004005 PS E INVBYTENDX amp H80040201 PS E INVBYTECOUNT amp H80040202 PS E READFAILED amp H80040203 PS E
19. hod was successful PS E FAIL amp H80004005 Unknown error occurred PS E INVBYTENDX amp H80040201 Bytelndex value out of Range PS E INVBYTECOUNT amp H80040202 Bytelndex and size of Data array out of range PS E WRITEFAILED amp H80040204 S7 PLCSIM refused write reguest PS E INVTYPE amp H80040206 Invalid data type PS S ALLWRITESNOTPOSSIBLE amp H80040210 The method could only write the configured inputs successiully PS E NOTCONNECTED amp H80040211 The S7ProSim control is not connected to S7 PLCSIM PS E POWEROFF amp H80040212 S7 PLCSIM is in Power off state 18 Methods WritelnputPoint Method The method 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 If Boolean is given as the Varant s data type then Bytelndex and BitIndex must both be set to valid indexes If successful the method writes the given bit in Data If Byte Integer or Long is given as the Variant s data type then Bytelndex must be set to a valid index BitIndex is ignored If successful the method writes the elements in pData Syntax result S7ProSim 1 WritelnputPoint Bytelndex BitIndex Data where e Bytelndex is an input parameter of type Long and represents the starting byte position in the peripheral input image buffer to write Valid values for Bytelndex are dependent on the CPU e BitIndex is an i
20. ify Method The following table lists possible return codes for the return value result of the BeginScanNotify method Constant Value S_OK amp HO PS_E FAIL amp H80004005 PS_E NOTCONNECTED amp H8004021 1 PS E POWEROFF amp H80040212 Description Method was successiul Unknown error occurred The S7ProSim control is not connected to S7 PLCSIM S7 PLCSIM is in Power off state Methods EEE EndScanNotify Method The EndScanNotify method un registers the ActiveX control for callbacks from the control engine ScanFinished event and PLCSIMStateChanged event are not available Syntax result S7ProSim1 EndScanNotify where result is a Long value that indicates whether an error has occurred The result is zero if no error occurs Return Codes of the EndScanNotify Method The following table lists possible return codes for the return value result of the EndScanNotify method Constant Value Description S_OK amp HO Method was successful PS E FAIL amp H80004005 Unknown error occurred PS E NOTCONNECTED amp H80040211 The S7ProSim control is not connected to S7 PLCSIM PS E POWEROFF amp H80040212 S7 PLCSIM is in Power off state PS E NOTREGISTERED amp H80040209 The application is not registered 10 Methods Connect Method With this method the S7ProSim control can be connected programmatically to the S7 PLCSIM that is defined in the ControlEngine Syntax result S7ProSim1 Connect where result is a Long
21. ine As String ByVal Error As Long where e ControlEngine holds the name of the control engine e Error holds the Windows system error code For more information see the Windows documentation PLCSIMStateChanged Event This event occurs when a new PLC operating mode is detected Syntax PLCSIMStateChanged NewState As String where NewState holds the new operating state of S7 PLCSIM Valid values are STOP RUN and RUN_P ScanFinished Event This event occurs when one scan of S7 PLCSIM has finished Syntax ScanFinished ByVal Scanlnfo As Variant where Scanlnfo is a SafeArray of Longs that represent various pieces of information about the scan See the table below for detailed information about the array Elements of Scaninfo Index Information 0 Execution time ms 1 Programmed minimum cycle time ms 2 Largest execution time ms 3 Average cycle time ms 4 Running PLC flag 22 Reference Information Reference Information Predefined Constants The following constants are used in the S7ProSim ActiveX control Constants Nau Description Scan mode values for SetScanMode and GetScanMode Continucussean Simulation in ContinuousScan SingleScan Simulation in Single Scan Byte data type Word 2 byte data type Double Word 4 byte data type Read values for ReadOutputimage S7Bye 00k s7Wod bh Bit data byte fe l _E FAIL Unknown error occurred Bytelndex value out of Range ea
22. ion that specifies whether the ActiveX Control is automatically connected to S7 PLCSIM or not The settings for Boolean are e True default The ActiveX control is automatically connected to and disconnected from the ControlEngine specified in S7 PLCSIM e False The ActiveX control has to be connected and disconnected programmatically by the Connect method and Disconnect method ControlEngine Property This read only property defines the address of the control engine to which the S7ProSim Control connects The address is S7 PLCSIM Enabled Property The Enabled property determines whether the control is registered or not ScanFinished event and PLCSIMStateChanged event are available Syntax S7ProSim1 Enabled Boolean where Boolean is a boolean expression that specifies whether the ActiveX Control is registered for callbacks from the control engine or not determines if the ScanFinished event and the PLCSIMStateChanged event are available or not The settings for Boolean are e True The ActiveX control is registered for callbacks from the control engine e False default The ActiveX control will be unregistered for the ScanFinished event and the PLCSIMStateChanged event for callbacks from the control engine set ScanMode Property This property sets the scan mode of S7 PLCSIM The valid execution modes are SingleScan Mode or ContinuousScan Mode Syntax S7ProSim1 ScanMode ScanModeConstants where ScanModeConstan
23. nnect method Return codes of the Disconnect method hol codes of the EndScanNotify method 10 Return codes of the ExecuteNmsScan method 13 Return codes of the ExecuteNScans method 14 Return codes of the ExecuteSingleScan method 15 Return codes of the ReadOutputlmage method 16 Return codes of the ReadOutputPoint method 17 Index 1 Index Return codes of the Writelnputlmage method 18 hol codes of the WritelnputPoint method 19 S S7ProSim 1 Constants Events Methods Properties S7ProSim control 3 S7ProSim control Te 1 S7ProSim overview Index 2 ScanFinished event lel 1 0 22 Scaninfo ScanMode property lel Sequence chart SingleScan mode la el 8 Startindex 16 18 V Visual Basic W Writelnputlmage ech WritelnputPoint method 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 ia Do the contents meet your requirements LJ Is the information you need easy to find E Is the text easy to understand E Does the level of technical detail meet your requirements E Please rate the quality of the graphics and tables Additional comments
24. nput parameter of type Long and represents the Bit position in bytes in the peripheral image buffer for write Valid values are 0 to 7 e Data is an input parameter of type Variant and represents the value to write Valid values for Data are dependent on the data type e result is a Long value that indicates whether an error has occurred The result is zero if no error occurs Return Codes of the WritelnputPoint Method The following table lists possible return codes for the return value result of the WritelnputPoint method Constant Value Description S_OK amp HO Method was successful PS_E FAIL amp H80004005 Unknown error occurred PS E INVBYTENDX amp H80040201 Bytelndex value out of Range PS E INVBYTECOUNT amp H80040202 Bytelndex and size of Data array out of range PS E WRITEFAILED amp H80040204 S7 PLCSIM refused write reguest PS E INVBITNDX amp H80040205 Bitlndex value out of range PS E INVTYPE amp H80040206 Invalid data type PS E NOTCONNECTED amp H80040211 The S7ProSim control is not connected to S7 PLCSIM PS E POWEROFF amp H80040212 S7 PLCSIM is in Power off state Methods 20 Events Events Events of the S7ProSim Control The events of the S7ProSim ActiveX Control are the following e ConnectionError Event e PLCSIMStateChanged Event e ScanFinished Event 21 Events ConnectionError Event This event occurs when an error on the connection occurs Syntax ConnectionError ByVal ControlEng
25. oint S_OK Then MsgBox MSG_OK vbInformation S7ProSim Example Else ShowError errWriteInputPoint End If kkkkk 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 kkkkk 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 1DoubleWordIn 4 Write value 4 lByteIndex 4 Start at address 4 0 vData 1DoubleWordIn errWriteInputPoint S7ProSiml WriteInputPoint 1ByteIndex 1BitIndex vData If errWriteInputPoint S_OK Then MsgBox MSG_OK vbInformation S7ProSim Example Else ShowError errWriteInputPoint End If d Sub Reference Information 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 errMessage
26. ointDataTypeConstants Dim DataType 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 1ByteIndex 1BitIndex DataType vData If errReadOutputPoint S OK Then MsgBox The current value of O 0 5 is amp CInt vData vbInformation S7ProSim Example Else ShowError errReadOutputPoint End If 29 Reference Information kkkkk 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 1ByteIndex 1BitIndex DataType vData If errReadOutputPoint S_OK Then MsgBox The current value of OB 1 is amp CByte vData vbInformation S7ProSim Example Else ShowError errReadOutputPoint End If xxxxkx 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 1ByteIndex 1BitIndex DataType vData If errReadOutputPoint S_OK Then MsgBox The current value of QW 2 is amp CInt vData vbInformation S7ProSim Example Else ShowError errReadOutputPoint End If kkkkk Read the DoubleWord at the address Q 4 0 lByteIndex 4 Start at address 4 0 DataType S7_DoubleWord Read type DoubleWord errRead
27. ol Engine Scan Mode S7 PLCSIM Single Scan Continuous Ik Auto Connect Cancel Apply Help The property window allows you to configure the following parameters of the S7ProSim control e Auto Connect The AutoConnect property determines whether the control is connected to S7 PLCSIM automatically at startup or 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 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 Properties Properties Properties of the S7ProSim Control The properties of the S7ProSim ActiveX control are the following e AutoConnect Property e ControlEngine Property e Enabled Property e ScanMode Property Properties AutoConnect Property The AutoConnect property determines whether the control is connected to S7 PLCSIM automatically at startup or at the change from design mode to run mode If the AutoConnect property is set to False the control has to be connected by the Connect method and disconnected by the Disconnect method Syntax S7ProSim1 AutoConnect Boolean where Boolean is a boolean express
28. provement are welcomed Siemens Energy amp Automation ISBU Siemens Energy amp Automation Inc 2001 1 Internet Plaza Johnson City TN 37602 4991 USA Technical data subject to change Contents Contents S7ProSim Overview oo oo oo oo oo WWW ana Basic Tasks oo oo oo oo oo oo oo oo matan Inserting the S7ProSim Control into a Visual Basic Application ooooo Accessing S7ProSim Control Properties in Visual Basic oooooocc Properties NI rn eee err ert TA NT TI err hl 8 Properties of the S7ProSim Gonlrel unscn ee ee Autoconnect Property aa Ba kel ControlEngine Property benosis in nanas nasa mn isa bahkan Jel Enabled Open ea ae ee fel aan Moo PO Per AN maa ee ee lau fel 9 8 Methods of the S7ProSim Control WWW WWW AbovtBox Metoda kaya BeginScanNotify Method oooo o Wo W W maan Return Codes of the BeginScanNotify Method oooooo oo Woo Eng Scatri Natty Method sn Hb naa ab am ana ae Return Codes of the EndScanNotify Method ooooooWoWo oom connect Method ku kala an nen Return Codes of the Connect Method oooo oWo W W Woman Disconnect Method an Return Codes of the Disconnect Method oooooooooW WooWo Wo WWW WWW ExecuteNmsScan Method w c oo ccoco oocoo moo oooooco omoo yoo o wo mismbksnubansisusasadan Return Codes of the ExecuteNmsScan Method i ooooooooW om Woo oo ExecuteNScans Mathal u unsn asian
29. the peripheral output image PQ memory area the number words 2 bytes or double words 4 bytes ElementsToRead is read from the peripheral output image PQ memory area of S7 PLCSIM and placed in an array held in pData The type of element s to be read is determined by the type requested in DataType parameter All elements have the same data type S7_Byte returns bytes S7_Word returns words and S7_DoubleWord returns double words The values read will be raw and not interpreted or converted by the method Syntax where in any way result S7ProSim1 ReadOutputlmage StartIndex ElementsToRead DataType pData StartIndex is an input parameter of type Long and represents the byte starting position in the peripheral image buffer to read Valid values for Startindex are dependent on the CPU ElementsToRead is an input parameter of type Long and represents the number of bytes words or double words to read in the image buffer Valid values for ElementsToRead are dependent on the CPU DataType is an input parameter and is one of the ImageDataT ypeConstants It has to be S7 Byte S7 Word or S7 DoubleWord pData is an output variable of type Variant and represents the space for returned elements Valid values for pData are dependent on ElementsToRead The memory is allocated by the server and freed by the application resultis a Long value that indicates whether an error has occurred The result is zero if no error occurs
30. tion is not registered MSG NOTSINGLESCAN _ S7 PLCSIM is not in single scan mode MSG NOTIFICATION EXIST _ Application is already registered MSG PLCSIMNOTRUNNING _ S7 PLCSIM is not in Run or Run P mode MSG ALLREADSNOTPOSSIBLE Only the configured outputs could be read successful MSG ALLWRITESNOTPOSSIBLE Only the configured inputs could be written successful MSG NOTCONNECTED _ The S7ProSim control is not connected to S7 PLCSIM MSG POWEROFF _ S7 PLCSIM is in Power off state Reference Information Private Sub cmdAutoConnectTrueStart_Click S7ProSiml AutoConnect True End Sub cmdAutoConnectTrueEnd Private Sub cmdAutoConnectTrueEnd Click S7ProSiml AutoConnect True End Sub cmdCalculateValuesOfProcessSimulation Private Sub cmdCalculateValuesOfProcessSimulation Click kkkkk TODO by the User xxxx In this function you have to implement the kkkkk Code for the Process Simulation Take the kxxkk values from the Outputs of S7 PLCSIM and xxxxx calculate the new values for the Input of kxkkkk S7 PLCSIM kkkkk 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
31. ts determines the scan mode of the control Valid values are e ContinuousScan S7 PLCSIM is set to continuous scan mode e SingleScan default S7 PLCSIM is set to single scan mode S7 PLCSIM has to be in this mode for an attached process simulation Methods Methods Methods of the S7ProSim Control The methods of the S7ProSim ActiveX control are the following AboutBox Method BeginScanNotify Method EndScanNotify Method Connect Method Disconnect Method ExecuteNmsScan Method ExecuteNScans Method ExecuteSingleScan Method ReadOutputImage Method ReadOutputPoint Method Writelnputlmage Method WritelnputPoint Method Methods AboutBox Method With this method you can get specific information about the control and its version Syntax S7ProSim1 AboutBox The About Dialog Box can be seen in the figure below ps 5 ProSim Control OSTEP7 S7 M7 Version 5 0 Revision No 5 0 0 0 Copyright 1998 2001 Siemens AG All rights reserved Product licensed to Siemens Siemens The AboutBox method has no parameters and no return code Methods BeginScanNotify Method The BeginScanNotify method registers the ActiveX control for callbacks from the control engine ScanFinished event and PLCSIMStateChanged event are available Syntax result S7ProSim1 BeginScanNotify where result is a Long value that indicates whether an error has occurred The result is zero if no error occurs Return Codes of the BeginScanNot
32. urn codes for the return value result of the ExecuteNScans method Constant Value Description S_OK amp HO Method was successful PS E FAIL amp H80004005 Unknown error occurred PS E NOTSINGLESCAN amp H8004020A S7 PLCSIM is not in single scan mode PS E PLCSIMNOTRUNNING amp H8004020E S7 PLCSIM is not in Run or Run P mode PS E NOTCONNECTED amp H80040211 The S7ProSim control is not connected to S7 PLCSIM 14 Methods ExecuteSingleScan Method This method forces S7 PLCSIM to execute one scan cycle and does not wait for the execution of the current scan to finish If the Enabled property is set to True the program will be notified when S7 PLCSIM has finished the scan Syntax result S7ProSim1 ExecuteSingleScan where result is a Long value that indicates whether an error has occurred The result is zero if no error occurs Return Codes of the ExecuteSingleScan Method The following table lists possible return codes for the return value result of the ExecuteSingleScan method Constant Value S OK amp HO PS_E FAIL amp H80004005 PS_E NOTSINGLESCAN amp H8004020A PS E PLCSIMNOTRUNNING amp H8004020E PS E NOTCONNECTED amp H80040211 Description Method was successiul Unknown error occurred S7 PLCSIM is not in single scan mode S7 PLCSIM is not in Run or Run P mode The S7ProSim control is not connected to S7 PLCSIM Methods ReadOutputlmage Method Starting of bytes at the StartIndex location in
33. value that indicates whether an error has occurred The result is zero if no error occurs Return Codes of the Connect Method The following table lists possible return codes for the return value result of the Connect method Constant Value S OK amp HO PS E FAIL amp H80004005 PS E NOTCONNECTED amp H80040211 PS E POWEROFF amp H80040212 Description Method was successiul Unknown error occurred The S7ProSim control is not connected to S7 PLCSIM S7 PLCSIM is in Power off state Methods Disconnect Method With this method the S7ProSim control can be disconnected programmatically Syntax result S7ProSim1 Disconnect where result is a Long value that indicates whether an error has occurred The result is zero if no error occurs Return Codes of the Disconnect Method The following table lists possible return codes for the return value result of the Disconnect method Constant Value Description S_OK amp HO Method was successful PS_E FAIL amp H80004005 Unknown error occurred PS E POWEROFF amp H80040212 S7 PLCSIM is in Power off state 12 Methods ExecuteNmsScan Method This method 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 the Enabled property is set to True the program will be notified when S7 PLCSIM has finished the scans Syntax result S7ProSim1 ExecuteNmsScan MsNumber where e result is
34. xample project This ActiveX control provides all methods and events that are required for the interaction with S7 PLCSIM The figure below shows the sequence chart for the different methods and events S PLCSIM S ProSim Time WritelnputPoint Writelnput Image tenaga ExecuteSingleScan Loop by ScanFinished only if Enabled True the User Program BER ER SER SIR EI ei Enabled False EndScanNotif ScanMode ContinuousScan AutoConnect True or Disconnect Legend Event Method or Property Change o Actions of the User Program S7ProSim Overview Basic Tasks Basic Tasks Inserting the S7ProSim Control into a Visual Basic Application The S7ProSim Control can be used in a variety of third party containers Use the following procedure to use S7 controls in a Visual Basic form 1 Select the menu command Project gt Components to display the Components dialog box 2 From the scrollable list select Siemens S7ProSim Control 3 Click Apply An S7ProSim Control appears in the toolbox on the left of the Visual Basic form 4 Click OK 5 Select the S7ProSim Control in the toolbox and paste it into the form Basic Tasks Accessing S7ProSim Control Properties in Visual Basic When you select the S7ProSim Control Visual Basic displays a secondary window with a list of properties You can edit the properties in an additional Property Window Property Pages General Contr
Download Pdf Manuals
Related Search
S7ProSim s7prosimlib s7prosim download
Related Contents
MANUAL DE INSTRUCCIONES Y HP A909a Getting Started Guide 各部のなまえ 製品特長 ご使用前に 充電のしかた 仕 様 故障と思われ Kit Manual - Alere Technologies GmbH Copyright © All rights reserved.
Failed to retrieve file