Home
User manual
Contents
1. Industrial Automation APPLICATION NOTE BLxx FUNCTION BLOCKS FOR CODESYS w 8 zi gt iR Ir M BLT ae ruhige Hs i ui i A mat x 5 9 v tt a 31 eT al n ja x le ae Sense it Connect it Bus it Solve it All brand and product names are trademarks or registered trade marks of the owner concerned Edition 10 2012 Hans Turck GmbH Muelheim an der Ruhr All rights reserved including those of the translation No part of this manual may be reproduced in any form printed photocopy microfilm or any other process or processed duplicated or distributed by means of electronic systems without written permission of Hans Turck GmbH amp Co KG Muelheim an der Ruhr Subject to alterations without notice Industri A Table of contents 1 1 1 1 2 1 3 1 3 1 1 4 1 4 1 1 4 2 2 1 2 1 1 2 2 2 2 1 2 2 2 2 3 2 4 2 5 CoDeSys function blocks for programmable gateways Installation AAA E E EA EN E E AEA EA A E E A EE 1 2 Genial E EE AE E E E A A E E E E oe 1 3 BL20 function blocks sssssssssooooosecseccosssssoccososse BL20 1CNT 24VDC module BL20 BL67 function blockS ssesssesecsssssooooooescscssossscocococsceeccosscsoescccsesssssssooosossesecssssssosooooseseseceossssssososossesessss 1 8 BLxx 1RS232 and BLXX 1RS482 422 MOCUIES ccccsccsssssecscsssssssssesscsssssssssssssssssssssssssssssssssssussesssssessesessessssessesessesssssessesss
2. Base parameters Input Output Max length of input data nikof output data Max length of in outp Max number of modules 1024 Byte 1024 Byte data 2048 Byte Input Modules BL20 2D1 24VDC P BL20 2D1 24VDC N BL20 2D1 120 230VAC BL20 4D1 24VDC P BL20 4D1 24VDC N BL20 4DI NAMUR BL20 E 8D1 24VDC P BL20 16D1 24VDC P BL20 E 16D1 24VDC P BL20 32D1 24VDC P BL20 141 1 0 4 20MA4 BL20 141 U 10 0 10VDC BL20 241 1 0 4 20MA BL20 241 U 10 0 10VDC BL20 24I PT NI 2 3 BL20 2AI Thermo PI BL20 4AI U I Output Modules In Output Modules Empty Modules User parameters Length of input data Length of output data Length of in output data Number of modules Selected Modules E lp EN lt lt Delete ONLINE OV READ Figure 2 4 Parameteriza tion in Module Properties 2 4 Module Properties Name BL20 1R5232 Contig Length input Byte 8 Length output Byte 8 Symbolic names VW 0xC3 0xC3 0xC3 0x39 0 47 0x01 Cancel Paraneters diagnostic data rate data bits parity stop bits data flow control KON character XOFF character release 19 2 kbps 7 1 Allowed Valus Bit 7 1 0 1 BitArea 0 3 Bit 3 0 0 1 Bit rea 1 2 Bit 0 1 0 1 Bit rea 4 5 Unsigned8 17 Unsigned8 19 D301146 CoDeSys FBs for BLxx 1012 Setting up the communication parameters 2 2 2 Setting up the prop
3. BL20 IO SLOT Example Ta Global Variables e BL20 1SSI g Globale_Variablen Variablen_Konfiguration VAR E library BLex_PG_FB lib 11 3 08 0 AT OW2 WORD GI library BLxxloSys lib 1 9 1 07 08 2 AT OW3 WORD GI library SntpTime lib 16 1 08 08 07 SSI IN AT IWO WORD Gu Tools t A AT XIWL WORD A Alarm configuration AT IW2 WORD fff Library Manager EA Log i PLC Browser FEE PLC Configuration fe Sampling Trace A Target Settings A Task configuration Q Watch and Recipe Manager 2 Workspace AT XOW1 WORD WORD Aw AT QW6 WORD Zn RD A Hr OPN CNT IN AT IW4 WORD ZT TORD AT IW6 WORD AT IW WORD BL20 1RS232 BL20 4D0 24 DC 0 SA P Modbus Registers SLOT D301146 CoDeSys FBs for BLxx 1012 1 7 CoDeSys function blocks for programmable gateways 1 4 BL20 BL67 function blocks 1 4 1 BLxx 1RS232 and BLxx 1RS482 422 modules The same applies for the transmit data Structure of the function block The function blocks described in the following section can be used for both BL20 as well as BL67 modules The function block BLxx_1RSxxx_FB can be used for the data handling of the interface modules BL20 1RS232 BL20 1RS485 422 BL67 1RS232 und BL67 1RS485 422 It supports the simultaneous transmitting and receiving of data which means a full duplex mode for example wi
4. I gt L20_1R5232 RxBuf fer a POUs m GREG 2993 test HyperTerminal Eel v gt BL20_1RS232 A BLxx_1RSxxx_FB IptRxData x Busy Rx pa Fee IptTxData uiReceivedBytesHTEM uikeceivedBytes 16 0000 xEnableRx Busy Ti xEnableTx uiSentBytesHTEHIIEA uiSentBytes 16 0064 xQuit xSendBuf Not Emp t y p zClr_Buf_Rz vRetValHTEMM wRetVal 16 0000 zClr_Buf_Tx xDisableTxBuf fer ptRxBuf fer iMaxzRxByte 160064 uiMaxRzBytes ptTxBuf fer pMaxTxByte 16 0064 juiMaxTxBytes Eile Edit View Call Transfer Help 3 oB f RETURN Connected 0 00 11 Auto detect Auto detect v gt D301146 CoDeSys FBs for BLxx 1012 2 7 Application example for a BLxx_1RSxxx_FB with Hyper Terminal 2 5 Reception of data HyperTerminal module 1 Write the data to be sent into HyperTerminal 2 Then enable the data reception in the FB module Set the variable xEnableRx to TRUE 3 The received data will be shown in the receive buffer RxBuffer Figure 2 9 Reception 2 8 CoDeSys Sample_PG_FB_RS232 pro PLC PRG PRG CFC OA Eile Edit Project Insert Extras Online Window Help m delt Seas Bea 5
5. block Note It is also important to enter the maximum number or data to be transmitted and received in uiMaxTxByte or respectively uiMaxRxByte Without these entries no data is exchanged Figure 2 7 Max number of data to be transmitted and received 2 6 BL20_1RS232 ADR RS232 RX IptRxData ADR RS232_TX ptT zData xEnableRx EnableRx xEnableTx sEnableTx Witt Quit xClr_Buf_Rx xClr_Buf_Rx xClr_Buf_Tx xClr_Buf_Tx DisableTxBuf fer xDisableTxBuf fer ADR RxBuf fer iptRxBuf fer uiMaxRsByte juiMaxRaBytes ADR TxBuffer iptTxBuf fer uiMaxTxByte uiMaxTxBytes BLxx 1RSxxx FB BusyRzi xBusyRx uiReceivedBytesi uiReceivedBytes BusyTzi xBusyTx uiSentBytes uiSentBytes SendBufNotEnpt R BufNoEnpty wRetVal vRetVal D301146 CoDeSys FBs for BLxx 1012 Transmission of data module HyperTerminal Industri A 2 4 Transmission of data module gt HyperTerminal 1 The data to be transmitted is written to the transmit buffer TX_Buffer 2 Then the transmission has to be enabled in the FB module Set the variable xEnableTx to TRUE 3 HyperTerminal shows the received data in ASCII code CoDeSys Sample PG FB RS232 pro PLC_PRG PRG CFC File Edit Project Insert Extras Online Window Help Figure 2 8 Transmission oe a nat m jejej I ajel
6. xVarName data type BOOLEAN bVarName data type BYTE etc D301146 CoDeSys FBs for BLxx 1012 1 3 CoDeSys function blocks for programmable gateways 1 3 BL20 function blocks The function blocks in this sub directory are only valid for BL20 modules 1 3 1 BL20 1CNT 24VDC module The function block BL20_1CNT_FB is used for handling the data of the module BL20 1CNT 24VDC in counter mode or measurement mode The function block works with the starting addresses of the counter module s process in and output data On the one hand it shows the actual counter or measurement value and on the other hand the module s functions described in the manual BL20 I O modules D300717 can be controlled Figure 1 1 BL20_1CNT_FB BL20_1CNT_FB ptCNTInput POINTER TO ARRAY 0 7 OF BYTE diEncoderValue ptCNTOutput POINTER TO ARRAY 0 7 OF BYTE xERR_24 DC xCountOrMeasure BOOL ERR DO xSW GATE BOOL xERR_PARA xCTRL_SYN BOOL xERR_LOAD xCTRL_DO1 BOOL RES STS A xSET_DO1 BOOL xSTS LOAD BOOL xSTS GATE BOOL xSTS_DI BOOL STS 01 BOOL STS DO2 DINT xSTS_C_UP xLOAD_VAL BOOL xSTS C DN diLOAD_PREPARE DINT xSTS SYN xLOAD_PREPARE BOOL STS CMP1 diCMP VALI DINT xSTS CMP2 x LOAD CMP VALI BOOL STS OFLW diCMP_VAL2 DINT STS_UFLW LOAD_CMP_VAL2 BOOL STS ND udiVAL_INTTIME UDINT wRetVal xLOAD_INTTIME BOOL udiVAL_LOLIMIT UDINT LOAD_LOLIMIT BOOL LOAD D
7. 2 7 Bere Belo 1m lt gt domo EE Occ a EEE OEEEECEREEER 3 POUs a ne Buffer Buffer Buffer RxgBuf fer Buffer Buf fer Buffer Buffer Buffer BL20_1RS232 BLxx_1RSxxx_FB IptRxData xBusyRxy ptTxData uiReceivedBytesHTEHI7H uiReceivedBytes 16 0007 xEnableRx xBusyTx xEnableTx uiSentBytesHTEEHIIMH uiSentBytes 16 0000 xQuit xSendBufNotEmpt yi Clr Buf Ra vRetValHTEEMIMI wRetVal 16 0000 xClr_Buf_Tx DisableTxBuf fer ptRxBuf fer uiMaxRxBytes ptTxBuf fer hMaxTxByte 16 0064 uiNaxTxBytes test HyperTerminal EER Eile Edit View Call Transfer Help DS 83 28 _RETURN Auto detect Auto detect om ONUNE OV Ri D301146 CoDeSys FBs for BLxx 1012 Industrial Automation www turck com Hans Turck GmbH amp Co KG 45472 M lheim an der Ruhr Germany Witzlebenstra e 7 Tel 49 0 208 4952 0 Fax 49 0 208 4952 264 E Mail more turck com Internet www turck com D301146 1012
8. BL20 station consisting of a programmable gateway and amongst others one RS232 module and a Windows HyperTerminal is described The connection between RS23 module and PC is realized via the PC s COM interface Figure 2 1 Connection between BL20 1RS232 and D sub male connector 11 RxD 2 RxD 21 TxD 3 TxD 14 CTS 8 CTS 24 RTS 7 RTS SHLD Assignment of the signal types at a 9 pole Submin D male connector Table 1 Pin No Signal designation Assignment of i the signal types 1 DCD Data Carrier Detect RS232 2 RxD Receive Data 3 TxD Transmit Data 4 DTR Data Terminal Ready 5 GND Ground 6 DSR Data Set Ready 7 RTS Request To Send 8 CTS Clear To Send 9 RI Ring Indicator Note H The table rows highlighted in grey indicate signals that are also available at the terminals of the base module 2 2 D301146 CoDeSys FBs for BLxx 1012 General 2 1 1 Windows HyperTerminal Windows HyperTerminal is opened via Start All Programs Accessories gt Communication HyperTerminal Note A Enter your Area Code Entering the phone number is not necessary for a serial connection at the PC Enter a user defined connection name in the dialog box Connection Description and define the COM port via which the connection between PC and module has to be established Figure 2 2 Windows HyperTerminal test HyperTerminal File Edit Wie Call Transfer H
9. I IN AT IWO AT XIW2 WORD AT IW3 WORD 1 13 Industri A 2 Application example for a BLxx 1RSxxx FB with Hyper Terminal 2 1 GON GFA sss sceccssacsisssaccsicicscscsisssicoscesasocsincsaccssosassacseassasosseassadeseatonsesscnasassssancatessonssasessuas subs Kuva s ks aasa v s a 2 2 1 1 Windows HyperTerminal ssscssssccssscssssccssecsssecsssecsssecsscesssscsseecsascesssccssecesscessuecssnsecsnseessscssscecssecessecesscessseesancesaseceasecsaecessessneesneeees 3 2 2 Setting up the communication parameters sessesssssoesosssosoessossoscossocessesossessossosssossessoesosesssoesssssossesssssssess 4 2 2 1 Setting up the module parameters in CODESYS sssccssssecssssscessescesssserssssscessscessnscecsnsscesssssessnssseesseeesnssscessscessnseeesssscessnseeseee 4 2 2 2 Setting up the properties in HyperTerminal 2 3 CoDeSys calling the FB and variable declaration 0000s20s00n00n00ns0nnonnennssnnsnnsnnnsnnnsnnnnnnnnnnnnnsnnsnnnsnnne 6 2 4 Transmission of data module HyperTerminal resosesonessonesonennennnnennnennnennnssnnnennnsnnnennnssnnnennnenner 7 2 5 Reception of data HyperTerminal gt module sresssrsoosssosesonennnssnnnennnennnennonsnnnennnsnnenennnsnnnsnnnsnnnnennnnne 8 D301146 CoDeSys FBs for BLxx 1012 2 1 Application example for a BLxx_1RSxxx_FB with Hyper Terminal 2 1 General By means of the following example a RS232 communication between a
10. O PARAM BOOL Variable description For internal purpose the process input and process output data are converted into data type BYTE Therefore the variables ptCNTInput and ptCNTOutput are defined as data type POINTER Table 1 1 Variable Type Meaning Variable description BL20 1CNT FB ptCNTinput POINTER TO ARRAY POINTER to the counter module s process input 0 7 OF BYTE words e g ADR IW4 or ADR CNT IN gt Example for the PLC configuration of the module BL20 1CNT page 1 7 ptCNTOutput POINTER TO ARRAY POINTER to the counter module s process output 0 7 OF BYTE words e g ADR QW4 or ADR CNT OUT gt Example for the PLC configuration of the module BL20 1CNT page 1 7 xCountOrMeasure BOOL The module s operation mode as chosen in the PLC configuration 0 counter mode 1 measurement mode 1 4 D301146 CoDeSys FBs for BLxx 1012 BL20 function blocks Industri A Table 1 1 Variable description BL20_1CNT_FB Variable Type Meaning xSW_GATE BOOL Software release for counting or measurement xCTRL_SYN BOOL Release synchronization xCTRL_DO1 BOOL Release output DO1 xSET_DO1 BOOL Control bit output DO1 xCTRL_DO2 BOOL Release output DO2 xSET_DO2 BOOL Control bit output DO2 xRES_STS BOOL Reset status bits 0 1 start reset xEXTF_ACK BOOL Acknowledgment of diagnostic error diLOAD_VAL DINT for co
11. Val Variable description For internal purpose the process input and process output data are converted into data type BYTE Therefore the variables ptSSlinput and ptSSlOutput are defined as data type POINTER Table 1 3 Variable Type Meaning Variable description BLxx 1551 FB ptSSlinput POINTER TO ARRAY Pointer to the module s process input data e g 0 7 OF BYTE ADR IW0 or ADR SSI IN Example for the PLC configuration of the module BLxx 1SSI page 1 13 ptSSIOutput POINTER TO ARRAY Pointer to the module s process output data e g 0 7 OF BYTE ADR OW0 or ADR SSI OUT Example for the PLC configuration of the module BLxx 1SSI page 1 13 xStop BOOL Communication control 0 cyclic reading 1 communication stopped xEnCMP1 BOOL Release comparison 1 xCIrCMP1 BOOL Delete comparison bit 1 xEnCMP2 BOOL Release comparison 2 xCIrCMP2 BOOL Delete comparison bit 2 diREG_CMP1 DINT Comparison value 1 xLOAD_REG_CMP1 BOOL Load comparison value 1 D301146 CoDeSys FBs for BLxx 1012 1 11 CoDeSys function blocks for programmable gateways Table 1 3 Variable description BLxx_1SSI_FB Variable Type Meaning diREG_CMP2 DINT Comparison value 2 xLOAD_REG_CMP2 BOOL Load comparison value 2 diREG_LOWER_LIMIT DINT Value for lower limit xLOAD_REG_LOWER_ BOOL Load value for lower limit LIMIT diREG_UPPER_LIMIT DINT Value for upp
12. Variablen_Konfiguration VAR E library BLxx_PG_FB lib 11 3 08 0 YORD E library BLxxlo5ys lib 19 1 07 08 4 library SntpT ime lib 16 1 08 08 07 AT XQW10 WORD s Tools AT OU NORD AN Alarm configuration CEI RS232_RX AT 18 WORD T Library Manager 4 AT ZIG FD E Log AT IW10 WORD TES PLC Browser AT IW11 WORD E BL20 4D0 24VDC 0 5A P E Samping Trace Modbus Registers SLOT f A Target Settings 1 10 D301146 CoDeSys FBs for BLxx 1012 BL20 BL67 function blocks Industri A 1 4 2 BLxx 1SSI Modul The function block BLxx_1SSI_FB is used for the data handling of a module BL20 1SSI and BL67 1SSI Structure of the function block Figure 1 5 Structure of the BLEX ISSI FB function block ptSSIInput POINTER TO ARRAY 0 7 OF BYTE dwRegRdData ptSSIOutput POINTER TO ARRAY 0 7 OF BYTE bRegRdAdrStat BLxx 1551 FB Stop BOOL Regkd bort xEnCMP1 BOOL xRegWrakn xClrCMP1 BOOL Reglir cept xEnCMP2 BOOL xStsCMP1 xClrCMP2 BOOL xFlagCMP1 diREG CMP1 DINT xRelCMP1 LOAD REG CMP1 BOOL xStsCMP2 24 DINT xFlagCMP2 xLOAD_REG_CMP2 BOOL xRelCMP2 diREG LOVER LIMIT DINT xStsDn LOAD REG LOWER LIMIT BOOL xStsUp diREG_UPPER_LIMIT DINT xStsOf lw LOAD REG UPPER LIMIT BOOL xStsUflw xRegWR BOOL StsStop bRegRdAdr BYTE xSSIDiag bReglirAdr BYTE xSSIStsO dikegWrData DINT xSSISts1 xSSISts2 xSSISts3 ErrSSI xErrPara wRet
13. bit short circuit at output DO1 XERR PARA BOOL Error bit parameterization XERR LOAD BOOL Error bit load procedure xRES STS A BOOL Reset status bits active xSTS LOAD BOOL Load procedure running xSTS_GATE BOOL Status release counter module xSTS_DI BOOL Status hardware input xSTS_DO1 BOOL Status hardware output DO1 xSTS_DO2 BOOL Status software output DO2 xSTS_C_UP BOOL Status count direction up xSTS_C_DN BOOL Status count direction down xSTS_SYN BOOL Status synchronization xSTS_CMP1 BOOL Status comparator 1 xSTS_CMP2 BOOL Status comparator 2 2 xSTS_OFLW BOOL Status upper count limit xSTS_UFLW BOOL Status lower count limit xSTS_ND BOOL Status zero crossing wRetVal WORD Returned value Value gt 8000h Error 0x8101 Size of input data 8 Bytes abort FB 0x8103 Size of output data 8 Bytes abort FB 1 6 D301146 CoDeSys FBs for BLxx 1012 BL20 function blocks Industri A Example for the PLC configuration of the module BL20 1CNT In this example the assignment of the process input data to the variable ptCNTInput can be done in different ways 1 as ADR CNT_IN if a symbolic name has been assigned to the input address 2 ordirectly as ADR IW4 This is also valid for the process output data in variable ptCNTOutput 1 asADR CNT OUT if a symbolic name has been assigned to the output address 2 ordirectly as ADR QW4 Figure 1 2 B Cont iguration BL20 PG EN A g l 3 Resources E
14. c bit 0 xSSISts1 BOOL Diagnostic bit 1 xSSISts2 BOOL Diagnostic bit 2 xSSISts3 BOOL Diagnostic bit 3 XERR SSI BOOL Status encoder signal 1 error wire break 0 OK xERR_PARA BOOL Status parameterization 1 error 0 OK wRetVal WORD Return Value value gt 8000h error 0x8101 Size of array of input data 8 Bytes gt abort FB 0x8103 Size of array of output data 8 Bytes gt abort FB Example for the PLC configuration of the module BLxx 1SSI In this example the assignment of the process input data to the variable ptSSlinput can be done in different ways 1 as ADR SSI_IN if a symbolic name 2 ordirectly as ADR IWO has been assigned to the input address This is also valid for the process output data in variable ptSSI Output 1 asADR SSI OUT if a symbolic name has been assigned to the output address or directly as ADR QWO Figure 1 6 B Configuration BL20 PG EN a 9 a Resources B BL20 IO SLOT E Example 2 Global Variables i H Globale_Variablen 49 Variablen_Konfiguration VAR E library BLxx PG FB lib 11 3 08 0 a library BLxxloSys lib 1 9 1 07 08 2 E library SntpTime lib 16 1 08 08 07 m Tools f A Alarm configuration m Library Manager B Log Ei PLC Browser A Sampling Trace arget Settings D301146 CoDeSys FBs for BLxx 1012 E BL20 1CNT 24VDC C BL20 1RS232 BL20 4DO 24VDC 0 SA P 1 Modbus Registers SLOT WORD m ORD SS
15. elp Connect To B test Enter details for the phone number that you want to dial Country region Area code Phone number Connect using m v D301146 CoDeSys FBs for BLxx 1012 2 3 Application example for a BLxx_1RSxxx_FB with Hyper Terminal 2 2 2 2 1 Setting up the communication parameters Note In order to guarantee an error free RS232 communication the communication parameters of both RS232 nodes RS232 module and HyperTerminal have to be identical Setting up the module parameters in CoDeSys The RS232 module s parameter definition is done in the PLC configuration Mark the entry BLxx IO Slot and select the module BL20 1RS232 under Selected Modules in the Input Output tab After this open the parameterization dialog box Module Properties via the Properties button Figure 2 3 IO module properties CoDeSys Sample PG FB RS232 pro File Edit Project Insert Extras Online low Help lell aoak A alsa E PLC Configuration FA Resources EQ Global Variables B Configuration BL20 PG EN Vai E g Variablen_Konl library BLxx PG FE library BLxxloSys lik library SntpT ime lib Tools ES Alarm configuration Library Manager Log E PLC Browser FPLC Connon ey Sampling Trace as Target Settings E Task configuration Watch and Recipe oe a Workspace AT IW1 AT IW2 AT XIW3 i Modbus Registers SLOT
16. er limit xLOAD_REG_UPPER_ BOOL Load value for upper limit LIMIT xRegWR BOOL Release for writing a register 0 1 active bRegRdAdr BYTE Address for reading a register bRegWrAdr BYTE Address for writing a register diRegWrData DINT Data ofthe register to be written dwRegRdData DWORD Data of the register to be read bRegRdAdrStat BYTE Acknowledge of the register which was read xRegRdAbort BOOL Abort of reading registers xRegWrAkn BOOL Acknowledge WRITE register running xRegWrAcept BOOL Acknowledge WRITE register accepted xStsCMP1 BOOL Status bit COMP1 1 RegSSIPos RegCMP1 0 RegSSIPos RegCMP1 xFlagCMP1 BOOL Status bit COMP1 latch 1 RegSSIPos RegCMP1 0 RegSSIPos RegCMP1 xRelCMP 1 BOOL Status bit COMP1 1 RegSSIPos gt RegCMP1 0 RegSSIPos lt RegCMP1 xStsCMP2 BOOL Status bit COMP2 1 RegSSIPos RegCMP2 0 RegSSIPos RegCMP2 xFlagCMP2 BOOL Status bit COMP2 latch 1 RegSSIPos RegCMP2 0 RegSSIPos RegCMP2 xRelCMP2 BOOL Status bit COMP2 1 RegSSIPos gt RegCMP2 0 RegSSIPos lt RegCMP2 xSstDN BOOL Status count direction down D301146 CoDeSys FBs for BLxx 1012 BL20 BL67 function blocks Industri A Table 1 3 Variable Type Meaning Variable description BLxx_1SSI_FB xStsOflw BOOL Status overflow xStsUflw BOOL Status underflow xStsStop BOOL Status communication xSSIDiag BOOL Display diagnostic message present xSSISts0 BOOL Diagnosti
17. erties in HyperTerminal Configure HyperTerminal according to the application File Properties The configuration is only possible if the connection is inactive If necessary an active communication has to be disconnected via Call gt Disconnect first Note A Please note that the configuration for the RS232 module and for the HyperTerminal are identical Otherwise an error free communication can not be guaranteed Figure 2 5 test HyperTerminal Windows ARE HyperTerminal configuration COM1 Properties Port Settings Bits per second Data bits Parity Stop bits Flow cont Auto detect Auto detect D301146 CoDeSys FBs for BLxx 1012 2 5 Application example for a BLxx_1RSxxx_FB with Hyper Terminal 2 3 CoDeSys calling the FB and variable declaration Call the function block BLxx_RSxxx_FB for RS232 communication in the PLC_PRG If in the PLC configuration variables have been defined for the module s in and output word here in this example RS232_RX and RS232_TX then those variables have to be assigned to the pointers of the receive and transmit data buffers ptRxData and ptTxData see also page 1 9 Figure 2 6 Variable decla ration and usage in the FB CoDeSys Sample PG FB RS232 pro PLC_PRG PRG CFC CoDeSys Sample PG FB V1 p ld Eile Edit Project Insert Extra PLC Configuration ine Window Help eea EHETE Resou
18. esaseetsssoosdosscoessbassascscoudoossscsessossoasseassseasies 4 1 3 1 BL20 1 CNT 24VDC MOUIE sssessssssssesssesssesssssssessscsssecssessscssnscssecsnscsscssnscssecsnscsssssnssssscsnssssscsucsescesscsssccssscasccssscsscesnscascesscessessseessees 4 Variable ASSCRIPTI N sissssccssseccas vac sasshacetevecrtsschenssednSuaszecseckess0aasite ak arigsisvicatadelesOsszdatadddensshdsansosdestcacravsedsivdesantedliea eschnsscteseden eng 4 Example for the PLC configuration of the module BL20 1 CNT oun ceessssessccssseeccssesccssseccssseecesseccensssccsnseecsnsescessecceunseesunee 7 1 4 BL20 BL67 function blocks 1 ccsesesssscossconsseasesosoconseonsseasesvocssseonsceasensescssseusssenseusasonssousesessoosoesussousnsussooueses 8 1 4 1 BLxx 1RS232 and BLXx 1RS482 422 MOUIES ccssescsssscsscssesssesssesssecssesssecssccsnecsscssnssssecsuscssccssccasesssccsnssaseesuccaseesncesseesncesseesees 8 Structure of the function block Variable description csssscsssscsssccsnscesssecsseecsscccsscccsneecsuccesnecesnseesseeesseessecs Example for the PLC configuration of the module BLxx 1RSxxx he 1 4 2 leao a et EY oTo E E E Structure of the function blocksize aaa aii aliin Variable description ceeccsssssssssssssscsssecsscsssccessecessecsssecsnsecsnsccssscesuscessscesscesssscssusessusessuecsnsessnsecsnsecssscesuscessceesscessneessuccesneessneesses Example for the PLC configuration of the module BLXX 1SSI sssssssssssss
19. ge 1 10 ptTxData POINTER TO ARRAY Pointer to the module s process output data e g 0 7 OF BYTE ADR IQ8 or ADR RS232_TX Example for the PLC configuration of the module BLxx 1RSxxx page 1 10 xEnableRx BOOL Release for data reception xEnableTx BOOL Release for data transmission xQuit BOOL Acknowledgment of errors xClr_Buf_Rx BOOL Flushing of receive buffer 0 gt 1 and Quit 1 xClr_Buf_Tx BOOL Flushing of transmit buffer 0 1 and Quit 1 xDisableTxBuffer BOOL Disabling transmit buffer 0 release 1 disable ptRxBuffer POINTER TO BYTE Address of the buffer for receive data within the PLC Array of n elements of data type BYTE uiMaxRxBytes UINT Maximum number ofthe data byteto bereceived within one telegram Can be changed before a new job according to the expected telegram length Note Has to be gt 0 if not data are not received ptTxBuffer POINTER TO BYTE Address of the buffer for the transmit data within the PLC Array of n elements of data type BYTE uiMaxTxBytes UINT Maximum number of the data byte to be transmitted within one telegram Can bechanged before a new job according to the expected telegram length Note Has to be gt 0 if not data are not transmitted xBusyRx BOOL Displays an active data reception uiReceivedBytes UINT Counter forthe received data bytes xBusyTx BOOL Displays an active data transmission uiSentBytes UINT Counter for the transmitted data b
20. rces A Global Variables Globale vari H Variablen_Ko 2 1 library BLax_PG_F POUs o PLC_PRG PR PROGRAM PLC_PRG VAR BL20_1R5232 RxBuf fer ARRAY 0 TxBuffer ARRAY 0 xEnableTx BOOL xEnableRx BOOL xQuitt BOOL xClr_Buf_Rx BOOL xClr_Buf_Tx BOOL xDisableTxBuffer BOOL uiMaxRxByte UINT uiMaxTxByte UINT xBusyRx BOOL uiReceivedBytes UINT xBusyTx BOOL BLxx_1RSxxx_FB 2000 OF BYTE 2000 OF BYTE 1 BLxx PG FB 0 Globale_Varie A E library BLxxlo5y5 1 WORD WORD WORD T XIVO WORD oa WORD AT IW3 WORD Modbus Registers SLOT WORD BL20_1RS232 ONLINE 0 BLzx 1RSxxx FB ADR RS232 RX ptR zData BusyRx BusyRz ADR RS232 TX ptTxData uiReceivedByte uiReceivedBytes sEnobtehz ixEnableRx xBusyTx xBusyTx xEnableTx ixEnableTx uiSentByte uiSentBytes xQuitt Quit xSendBufNotEmpty RxBuf NoEnpty xClr_Buf_Rx xClr_Buf_Rx wRet Val wRetVal xClr_Buf_Tx xClr_Buf_Tx xDisableTxBut fer IxDisableTxBuf fer ADR RxBuf fer ptRxBuf fer uiMaxRsByte uiMaxRxBytes ADR TxBuf fer ptTxBuf fer uiMaxTxByte uiMaxTxBytes ONLINE OV READ All other variables are already defined within the function
21. sssssesssees 1 8 BISETSSEMOUU 2 ee a A A T E ATEEN EATE A 1 11 Application example for a BLxx_1RSxxx_FB with Hyper Terminal GOED Al A ST FUEL TEEREEENFEEN IEEEEEEEERFASEREEIEUREEEEEERSEREEEBRREECERESEREEN 2 2 Windows Hyperleriniimall a 2 3 Setting up the communication parameters Setting up the module parameters in CoDeSys Setting up the properties in HyperTerminal sscsssccssscccssccsssscsscscsscecsssccssccessccsssecsssecsnsccsnscessecssscesuscessucesssccessceessecesseessseessecs CoDeSys calling the FB and variable declaration eeereoneeovoveroveosesovovaseoeneeeasesore vene oeseesare vee eses 2 6 Transmission of data module gt HyperTerminal ssuesosesonessosenonenonennnnennnennnennossnnnennnsnnssnnnnsnnnsnnnennenee 2 7 Reception of data HyperTerminal gt module u sosssonesonssnnnennnennnnsnnnennnennnennnnsnnnsnnnennnnsnnnsnnnennensnnnennne 2 8 D301146 CoDeSys FBs for BLxx 1012 1 Industri A 1 CoDeSys function blocks for programmable gateways 1 1 Imstall ti i sincesisscsicssscsisssceccscsssedsssesacsissssssodssonsacscesassactosssseusissassesdssasseussscnsioscssesseuesactacsscssass essisoodossssassiessiee 2 1 2 GENEF L i s5s5sciseseesccsssecsscossescscessecoscsdesebesssssesssssossascssesseusisessssccssenseusisendeadcssesssessensosusdeast s si as usi seadustas s 3 1 3 BL20 f nction Blocks si s6053c cesciccsssensscesesssssocssscsacssssasssasssaceesoissbasess
22. ssssssssssessssseesessssteoesssssteessssstesssssstetesssstesssssste D301146 CoDeSys FBs for BLxx 1012 1 1 CoDeSys function blocks for programmable gateways 1 1 Installation In order to use the function block described in the next pages the file BLxx_PG_FB lib has to be copied into the following Windows folder choose the drive letter according to the installation path of the CoDeSys software C Programs CommonFiles CAA Targets Turck BLxx 1 2 D301146 CoDeSys FBs for BLxx 1012 General Industri A 1 2 General The gateways BL20 PG xx and BL67 PG xx support technology modules at the local module bus which provide command and control bits for the data exchange via the process data In order to use these module functions so called handshake mechanisms have to be programmed in the user program In the following functions which control this handling are described The functions are part of the BLxx_PG_FB lib This library is divided into two sub directories 1 BL20 PG FB with function block BL20_1CNT_FB for the module BL20 1CNT 2 BLxx_PG_FB with function block BLxx_1RSxx_FB for the modules BLxx 1RS232 as well as BLxx 1RS422 485 and BLxx_1SSI_FB for the module BLxx 1SSI Remark A prefix is added to the variable names This prefix is chosen according to recommendations in the IEC 61131 and of 3S Smart Software Solutions GmbH By means of this prefix the user can identify the variables data types Example
23. th the module BLxx 1RS232 is possible As only the in and output data are evaluated this function block can be chosen regardless of the type of interface which is used The function block recalls the process input data ptRxData and stores them to the data buffer ptRxBuffer The size and the location of the data buffer are determined by the user Additionally the user can define the number of bytes within a telegram uiMaxRxBuffer Figure 1 3 Structure of the function block BLxx_1RSxxx_FB 1 8 BLEX_1RSEXX_FB ptRxData POINTER TO ARRAY 0 7 OF BYTE ptTxData POINTER TO ARRAY 0 7 OF BYTE uiReceivedBytes xEnableRx BOOL BOOL _Buf_ BOOL xDisableTxBuffer BOOL ptRxBuffer POINTER TO BYTE uiMaxRaBytes UINT ptTxBuffer POINTER TO BYTE uiMaxTxBytes UINT BusyRz xBusyTx uiSentBytes xSendBufNotEmpty wRetVal D301146 CoDeSys FBs for BLxx 1012 BL20 BL67 function blocks Variable description Industri A For internal purpose the process input and process output data are converted into data type BYTE Therefore the variables ptRxData and ptTxData are defined as data type POINTER Table 1 2 Variable description BLxx_1RSXxx_ FB Variable Type Meaning ptRxData POINTER TO ARRAY Pointer to the module s process input data e g 0 7 OF BYTE ADR IW8 or ADR RS232_RX Example for the PLC configuration of the module BLxx 1RSxxx pa
24. unter mode Value for load value directly xLOAD_VAL BOOL for counter mode load load value directly diLOAD_PREPARE DINT for counter mode value for load value in preparation xLOAD_PREPARE BOOL for counter mode load load value in preparation diCMP_VAL1 DINT for counter mode value for reference value 1 xLOAD_CMP_VAL1 BOOL for counter mode load reference value 1 diCMP_VAL2 DINT for counter mode value for reference value 2 xLOAD_CMP_VAL2 BOOL for counter mode load reference value 2 udiVAL_INTTIME UDINT for measurement mode value for integration time xLOAD_INTTIME BOOL for measurement mode load integration time udiVAL_LOLIMIT UDINT for measurement mode value for lower limit xLOAD_LOLIMIT BOOL for measurement mode load lower limit udiVAL_HILIMIT UDINT for measurement mode value for upper limit xLOAD_HILIMIT BOOL for measurement mode load upper limit udiVAL_DO_PARAM UDINT Function and behavior output DO1 and DO2 xLOAD_DO_PARAM BOOL Change function and behavior output DO1 and DO2 xSTS_LOAD BOOL Load function and behavior output DO1 and DO2 diEncoderValue DINT Count value xERR_24VDC BOOL Error bit short circuit sensor or error at power supply D301146 CoDeSys FBs for BLxx 1012 1 5 CoDeSys function blocks for programmable gateways Table 1 1 Variable description BL20_1CNT_FB Variable Type Meaning xERR_DO BOOL Error
25. ytes D301146 CoDeSys FBs for BLxx 1012 1 9 CoDeSys function blocks for programmable gateways Table 1 2 Variable Type Meaning Variable description BLxx_1RSXxx_ FB xSentByteNotEmpty BOOL wRetVal WORD Return Value value gt 8000h error errorof size variables 0x8101 Size of receive buffer gt the max number of bytes to be received abort FB 0x8103 Size of array of input data 8 Bytes abort FB 0x8201 Size of transmit buffer gt the max number of bytes to be sent abort FB 0x8203 Size of array of output data 8 Bytes abort FB module errors 0x8000 Module not ready for communication 0x8008 Parameter error at module 0x8010 Hardware error at module 0x8020 Error in data flow control 0x8040 Frame error 0x8080 Receive buffer overflow Example for the PLC configuration of the module BLxx 1RSxxx In this example the assignment of the process input data to the variable ptRxData can be done in different ways 1 as ADR RS232_RX if a symbolic name has been assigned to the input address 2 or directly as ADR IW8 This is also valid for the process output data in variable ptTxData 1 as ADR RS232_TX if a symbolic name has been assigned to the output address or directly as ADR QW8 j A Configuration BL20 PG EN A Figure l 4 F Resources BL20 IO SLOT Example B Global Variables i og BL20 1SS1 D Globale_Variablen i i
Download Pdf Manuals
Related Search
Related Contents
取扱説明書 - 長府工産株式会社 Avaya 9103 Telephone User Manual Configuration manual LYCEE VAUGELAS 73000 CHAMBERY warning Nortel Networks 400-S User's Manual RDA AHVP60-6 NA Manual - Red-D Kyocera K325 Cell Phone User Manual 取扱説明書 - 3.4 MB Copyright © All rights reserved.
Failed to retrieve file