
VLT_PROFI_LIB_SIEMENS.zip
Function_Blocks_with_SIEMENS_TIA_Portal_PG_AU326537640107en-000101_M0021501.pdf

VLT_PROFI_LIB_SIEMENS.zap15 - SIEMENS TIA Portal V15 Example
VLT_PROFI_LIB_V1_12.zal15 - SIEMENS TIA Portal V15 Library
GSDML-V2.32-Danfoss-FC-20170530.xml - PROFINET GSDML Danfoss FC PN GSDML-V2.32-Danfoss-FC-20170530.xml
da02040a.gsd - da02040a.gsd PROFIBUS GSD Danfoss Drives A/S FC 300 Series FC100/200/300 series revision 2.14 DPV1
VLT_PROFIBUS_GSD_2010-11-03.zip - Danfoss Drives PROFIBUS GSD files
DA010409.GSD - DMS300 PROFIBUS DPV0
DA02040A.gsd - FC 100 200 300
da020406.gsd - FCD 300 3MB DPV0
da030406.GSD - FCD 300 3MB DPV1
da020407.gsd - FCD 300 12MB DPV0
da030407.GSD - FCD 300 12MB DPV1
DA01040B.gsd - FCD 302
da020403.gsd - FCM 300 3MB DPV0
da030403.GSD - FCM 300 3MB DPV1
da020408.gsd - FCM 300 12MB DPV0
da030408.GSD - FCM 300 12MB DPV1
SSPM08A8.GSD - MCD200
da020404.gsd - VLT 2800 3Mb DPV0
da030404.GSD - VLT 2800 3Mb DPV1
da020405.gsd - VLT 2800 12MB DPV0
da030405.GSD - VLT 2800 12MB DPV1
da030402.gsd - VLT 5000 6000 8000 DPV0
da040402.GSD - VLT 5000 6000 8000 DPV1

CPU 1516F-3 PN/DP 6ES7 516-3FN01-0AB0 V2.5
VLT_PROFI_FC_BASIC FC300
//-------------------------------------------------------------------------------------------------------------
// VLT_PROFI_FC_BASIC: Rev. V1.12
// Valid for S7-1200 and S7-1500 Type CPU's.
// Block handles communication with a VLT frequency converter. Either Trough PROFINET OR PROFIBUS.
// The FC handles basic needs and extraction of Motor current.
// PROFINET PPO type is PPO6 (4 words read/Write). PCD2 and PCD3 must be configured for Motor Current.
// PROFIBUS PPO type is PPO2 (6 words read/Write). PCD2 and PCD3 must be configured for Motor Current.
// Can be done in HW config of S7, on the Drive LCP or MCT10.
//-------------------------------------------------------------------------------------------------------------
//------------------------------------Standard - Control bits--------------------------------------------------
//Can be used locally in Block.
#AlwaysOff := false;
#AlwaysOn := TRUE;
//------------------------------------Standard - Control bits--------------------------------------------------
//------------------------------------Read data from fieldbus--------------------------------------------------
// Actual data size that is read depends on the Array size.
// Minimum size is 4 words.
// PPO type can be larger but only the 4 first words are read.
// Return value for DPRD and DPWR for PNET Comm. 0=No fault.
#RETVAL := DPRD_DAT(LADDR := #ADR, RECORD => #RDRaw_Data); // Read Raw Data
#COMM_ERR := #RETVAL;
//------------------------------------Read data from fieldbus--------------------------------------------------
//------------------------------------Read Raw Data is mapped with PCDRead------------------------------------------------------
#PCDRead.STW.BIT_00_CTRL_RDY := #RDRaw_Data[0].%X0;
#PCDRead.STW.BIT_01_DRV_RDY := #RDRaw_Data[0].%X1;
#PCDRead.STW.BIT_02_COAST_RDY := #RDRaw_Data[0].%X2;
#PCDRead.STW.BIT_03_TRIP := #RDRaw_Data[0].%X3;
#PCDRead.STW.BIT_04_ERROR := #RDRaw_Data[0].%X4;
#PCDRead.STW.BIT_05_RESERVED := #RDRaw_Data[0].%X5;
#PCDRead.STW.BIT_06_TRIPLOCK := #RDRaw_Data[0].%X6;
#PCDRead.STW.BIT_07_WARNING := #RDRaw_Data[0].%X7;
#PCDRead.STW.BIT_08_RUNNING_REF := #RDRaw_Data[0].%X8;
#PCDRead.STW.BIT_09_CTRL_SOURCE := #RDRaw_Data[0].%X9;
#PCDRead.STW.BIT_10_F_LIMIT_OK := #RDRaw_Data[0].%X10;
#PCDRead.STW.BIT_11_IN_OPR := #RDRaw_Data[0].%X11;
#PCDRead.STW.BIT_12_IN_AUTOSTART := #RDRaw_Data[0].%X12;
#PCDRead.STW.BIT_13_VOLT_MAX := #RDRaw_Data[0].%X13;
#PCDRead.STW.BIT_14_TORQ_MAX := #RDRaw_Data[0].%X14;
#PCDRead.STW.BIT_15_TIMER_EXD := #RDRaw_Data[0].%X15;
#PCDRead.MAV := #RDRaw_Data[1];
#PCDRead.PCD_02 := #RDRaw_Data[2];
#PCDRead.PCD_03 := #RDRaw_Data[3];
//------------------------------------Read Raw Data is mapped with PCDRead------------------------------------------------------
//------------------------------------Extraction of Main actual value--------------------------------------------
// Main Actual Value(MAV) is read from the Drive as 0 - 16384. Must be converted into 0 - 10000 (0.0 - 100.0 %)
IF #COMM_ERR = 0 THEN
#CalcSlope :=LREAL_TO_REAL (10000.0 / 16384.0);
#MAV := FLOOR_INT(#CalcSlope * #PCDRead.MAV); // Convert to percentage (0.0 - 100.0)
END_IF;
//------------------------------------Extraction of Main actual value--------------------------------------------
//------------------------------------Calculation of motor current----------------------------------------------
// Motor current is a 32 bit value hence 2 words read from the Drive need to be combined into a DWORD.
// Motor current is scaled with 2 decimal points (conversion index -2) hence division by 100.
IF #COMM_ERR = 0 THEN
#CurrentInternal := DINT_TO_DWORD(#PCDRead.PCD_02); // PCD02 is high word of Motor current
#CurrentInternal := SHL_DWORD(IN := #CurrentInternal, N := 16); // Shift high word of Motor current 16 bits to the left
#CurrentInternal := #CurrentInternal + DINT_TO_DWORD(#PCDRead.PCD_03); // PCD03 is low word of Motor current
#MOTORCURRENT := DINT_TO_LREAL(#CurrentInternal) / 100.0;
END_IF;
//------------------------------------Calculation of Motor current----------------------------------------------
//------------------------------------Mask out Drive status bit's-----------------------------------------------
IF #COMM_ERR = 0 THEN
#READY := (#PCDRead.STW.BIT_00_CTRL_RDY AND #PCDRead.STW.BIT_01_DRV_RDY AND #PCDRead.STW.BIT_02_COAST_RDY AND #PCDRead.STW.BIT_09_CTRL_SOURCE); // Drive ready to start from Fieldbus
#RUNNING := #PCDRead.STW.BIT_11_IN_OPR; // Drive is started but not necessarily running on reference speed.
#RUN_ON_REF := #PCDRead.STW.BIT_08_RUNNING_REF; // Running on reference
#WARNING := #PCDRead.STW.BIT_07_WARNING; // Warning present
#FAULT := (#PCDRead.STW.BIT_04_ERROR OR #PCDRead.STW.BIT_03_TRIP OR #PCDRead.STW.BIT_06_TRIPLOCK); // Fault present. Trip or Trip lock
ELSE
#READY := FALSE;
#FAULT := TRUE;
END_IF;
//------------------------------------Mask out Drive status bit's-----------------------------------------------
//------------------------------------Default settings of Controlword-------------------------------------------
// Prepare all Controlword Bit's to default values so that
// they are in a "ready to start" mode. CTW =043Ch
#PCDWrite.CTW.BIT_00_PRESET_REF_1 := FALSE;
#PCDWrite.CTW.BIT_01_PRESET_REF_2 := FALSE;
IF #DRV_EN THEN
#PCDWrite.CTW.BIT_02_DC_BRAKE_RAMP := TRUE;
#PCDWrite.CTW.BIT_03_COAST_INV := TRUE;
#PCDWrite.CTW.BIT_04_QSTP_RMP := TRUE;
#PCDWrite.CTW.BIT_05_HLD_RMP := TRUE;
ELSE
#PCDWrite.CTW.BIT_02_DC_BRAKE_RAMP := FALSE;
#PCDWrite.CTW.BIT_03_COAST_INV := FALSE;
#PCDWrite.CTW.BIT_04_QSTP_RMP := FALSE;
#PCDWrite.CTW.BIT_05_HLD_RMP := FALSE;
END_IF;
#PCDWrite.CTW.BIT_06_START := FALSE;
#PCDWrite.CTW.BIT_07_RESET := FALSE;
#PCDWrite.CTW.BIT_08_JOG := FALSE;
#PCDWrite.CTW.BIT_09_RAMP_1_2 := FALSE;
#PCDWrite.CTW.BIT_10_DATA_VALID := TRUE;
#PCDWrite.CTW.BIT_11_RLY_1_ON := FALSE;
#PCDWrite.CTW.BIT_12_RLY_2_ON := FALSE;
#PCDWrite.CTW.BIT_13_SETUP_SEL_1 := FALSE;
#PCDWrite.CTW.BIT_14_SETUP_SEL_2 := FALSE;
#PCDWrite.CTW.BIT_15_REVERSE := FALSE;
//------------------------------------Default settings of Controlword-------------------------------------------
//------------------------------------Drive control bit's-------------------------------------------------------
#PCDWrite.CTW.BIT_06_START := #RUN AND NOT #FAULT; // Start the Drive if there is no pending Fault.
#PCDWrite.CTW.BIT_15_REVERSE := #REVERSE; // Set Drive to Reverse Mode. Ensure Par. 4-10 is set to "Both Directions"
#PCDWrite.CTW.BIT_07_RESET := #RESET; // Reset pending Fault
//------------------------------------Drive control bit's-------------------------------------------------------
//------------------------------------Reference value limit check------------------------------------------------
// Must be between 0 - 10000. Ensure reference speed is within limits.
IF #REF_VALUE >= 10000 THEN
#REF_VALUE := (10000);
END_IF;
IF #REF_VALUE < 0 THEN
#REF_VALUE := 0;
END_IF;
//------------------------------------Reference value limit check------------------------------------------------
//------------------------------------PCDWrite is mapped with WriteRaw data--------------------------------------------------
#WRRaw_Data[0].%X0 := #PCDWrite.CTW.BIT_00_PRESET_REF_1;
#WRRaw_Data[0].%X1 := #PCDWrite.CTW.BIT_01_PRESET_REF_2;
#WRRaw_Data[0].%X2 := #PCDWrite.CTW.BIT_02_DC_BRAKE_RAMP;
#WRRaw_Data[0].%X3 := #PCDWrite.CTW.BIT_03_COAST_INV;
#WRRaw_Data[0].%X4 := #PCDWrite.CTW.BIT_04_QSTP_RMP;
#WRRaw_Data[0].%X5 := #PCDWrite.CTW.BIT_05_HLD_RMP;
#WRRaw_Data[0].%X6 := #PCDWrite.CTW.BIT_06_START;
#WRRaw_Data[0].%X7 := #PCDWrite.CTW.BIT_07_RESET;
#WRRaw_Data[0].%X8 := #PCDWrite.CTW.BIT_08_JOG;
#WRRaw_Data[0].%X9 := #PCDWrite.CTW.BIT_09_RAMP_1_2;
#WRRaw_Data[0].%X10 := #PCDWrite.CTW.BIT_10_DATA_VALID;
#WRRaw_Data[0].%X11 := #PCDWrite.CTW.BIT_11_RLY_1_ON;
#WRRaw_Data[0].%X12 := #PCDWrite.CTW.BIT_12_RLY_2_ON;
#WRRaw_Data[0].%X13 := #PCDWrite.CTW.BIT_13_SETUP_SEL_1;
#WRRaw_Data[0].%X14 := #PCDWrite.CTW.BIT_14_SETUP_SEL_2;
#WRRaw_Data[0].%X15 := #PCDWrite.CTW.BIT_15_REVERSE;
#WRRaw_Data[2] := #PCDWrite.PCD_02;
#WRRaw_Data[3] := #PCDWrite.PCD_03;
//------------------------------------PCDWrite is mapped with WriteRaw data--------------------------------------------------
//------------------------------------Reference value limit check------------------------------------------------
// Must be between 0 - 10000. Ensure reference speed is within limits.
IF #REF_VALUE >= 10000 THEN
#REF_VALUE := 10000;
END_IF;
IF #REF_VALUE < 0 THEN
#REF_VALUE := 0;
END_IF;
//------------------------------------Reference value limit check------------------------------------------------
//------------------------------------Prepare Reference value----------------------------------------------------
// PCD Write block position 1. Fit's with PPO type mapping
// Convert 10000 into 16384 which equals 4000h. 10000 = 100.00%
#CalcSlope := LREAL_TO_REAL (16384.0 / 10000.0);
#PCDWrite.MRV := FLOOR_INT(#CalcSlope * #REF_VALUE); // Convert to percentage (0.0 - 100.0)
#WRRaw_Data[1] := #PCDWrite.MRV; // Main reference value is Mapped with write Raw Data
//------------------------------------Prepare Reference value----------------------------------------------------
//------ADR------------------------------Send Data------------------------------------------------------------------
// Return value for DPRD and DPWR for PNET Comm. 0=No fault
IF #COMM_ERR = 0 THEN
#RETVAL := DPWR_DAT(LADDR := #ADR, RECORD := #WRRaw_Data); //#Write Raw Data);
#COMM_ERR := #RETVAL;
END_IF;
//------------------------------------Send Data------------------------------------------------------------------
//------------------------------------Ensure ENO is TRUE always--------------------------------------------------
ENO := TRUE;
//------------------------------------Ensure ENO is TRUE always--------------------------------------------------
VLT_PROFI_FC_FLEXIBLE
//-------------------------------------------------------------------------------------------------------------
// VLT_PROFI_FC_FLEXIBLE: Rev. V1.12
// Valid for S7-1200 and S7-1500 Type CPU's.
// Block handles communication with a VLT frequency converter. Either Trough PROFINET OR PROFIBUS.
// The FC handles extended needs allowing access to all needed parameters.
// Can be done in HW config of S7, on the Drive LCP or MCT10.
//-------------------------------------------------------------------------------------------------------------
//------------------------------------Standard - Control bits--------------------------------------------------
//Can be used locally in Block.
#AlwaysOff := FALSE;
#AlwaysOn := TRUE;
//------------------------------------Standard - Control bits--------------------------------------------------
//------------------------------------Read data from fieldbus--------------------------------------------------
// Read data from Drive. PPO types 3, 4, 6, 7, 8 Allowed.
// Return value for DPRD and DPWR for PNET Comm. 0=No fault.
#RETVAL1 := DPRD_DAT(LADDR := #ADR, RECORD => #RDRaw_Data); // Read Raw Data
#COMM_ERR := #RETVAL1;
//------------------------------------Read data from fieldbus--------------------------------------------------
//------------------------------------Raw Read data to PCDRead------------------------------------------------------
#PCDREAD.STW.BIT_00_CTRL_RDY := #RDRaw_Data[0].%X0;
#PCDREAD.STW.BIT_01_DRV_RDY := #RDRaw_Data[0].%X1;
#PCDREAD.STW.BIT_02_COAST_RDY := #RDRaw_Data[0].%X2;
#PCDREAD.STW.BIT_03_TRIP := #RDRaw_Data[0].%X3;
#PCDREAD.STW.BIT_04_ERROR := #RDRaw_Data[0].%X4;
#PCDREAD.STW.BIT_05_RESERVED := #RDRaw_Data[0].%X5;
#PCDREAD.STW.BIT_06_TRIPLOCK := #RDRaw_Data[0].%X6;
#PCDREAD.STW.BIT_07_WARNING := #RDRaw_Data[0].%X7;
#PCDREAD.STW.BIT_08_RUNNING_REF := #RDRaw_Data[0].%X8;
#PCDREAD.STW.BIT_09_CTRL_SOURCE := #RDRaw_Data[0].%X9;
#PCDREAD.STW.BIT_10_F_LIMIT_OK := #RDRaw_Data[0].%X10;
#PCDREAD.STW.BIT_11_IN_OPR := #RDRaw_Data[0].%X11;
#PCDREAD.STW.BIT_12_IN_AUTOSTART := #RDRaw_Data[0].%X12;
#PCDREAD.STW.BIT_13_VOLT_MAX := #RDRaw_Data[0].%X13;
#PCDREAD.STW.BIT_14_TORQ_MAX := #RDRaw_Data[0].%X14;
#PCDREAD.STW.BIT_15_TIMER_EXD := #RDRaw_Data[0].%X15;
#PCDREAD.MAV := #RDRaw_Data[1];
#PCDREAD.PCD_02 := #RDRaw_Data[2];
#PCDREAD.PCD_03 := #RDRaw_Data[3];
#PCDREAD.PCD_04 := #RDRaw_Data[4];
#PCDREAD.PCD_05 := #RDRaw_Data[5];
#PCDREAD.PCD_06 := #RDRaw_Data[6];
#PCDREAD.PCD_07 := #RDRaw_Data[7];
#PCDREAD.PCD_08 := #RDRaw_Data[8];
#PCDREAD.PCD_09 := #RDRaw_Data[9];
//------------------------------------Raw read data to PCDRead------------------------------------------------------
//------------------------------------PCDWrite is mapped with Write Raw data--------------------------------------------------
#WRRaw_Data[0].%X0 := #PCDWRITE.CTW.BIT_00_PRESET_REF_1;
#WRRaw_Data[0].%X1 := #PCDWRITE.CTW.BIT_01_PRESET_REF_2;
#WRRaw_Data[0].%X2 := #PCDWRITE.CTW.BIT_02_DC_BRAKE_RAMP;
#WRRaw_Data[0].%X3 := #PCDWRITE.CTW.BIT_03_COAST_INV;
#WRRaw_Data[0].%X4 := #PCDWRITE.CTW.BIT_04_QSTP_RMP;
#WRRaw_Data[0].%X5 := #PCDWRITE.CTW.BIT_05_HLD_RMP;
#WRRaw_Data[0].%X6 := #PCDWRITE.CTW.BIT_06_START;
#WRRaw_Data[0].%X7 := #PCDWRITE.CTW.BIT_07_RESET;
#WRRaw_Data[0].%X8 := #PCDWRITE.CTW.BIT_08_JOG;
#WRRaw_Data[0].%X9 := #PCDWRITE.CTW.BIT_09_RAMP_1_2;
#WRRaw_Data[0].%X10 := #PCDWRITE.CTW.BIT_10_DATA_VALID;
#WRRaw_Data[0].%X11 := #PCDWRITE.CTW.BIT_11_RLY_1_ON;
#WRRaw_Data[0].%X12 := #PCDWRITE.CTW.BIT_12_RLY_2_ON;
#WRRaw_Data[0].%X13 := #PCDWRITE.CTW.BIT_13_SETUP_SEL_1;
#WRRaw_Data[0].%X14 := #PCDWRITE.CTW.BIT_14_SETUP_SEL_2;
#WRRaw_Data[0].%X15 := #PCDWRITE.CTW.BIT_15_REVERSE;
#WRRaw_Data[1] := #PCDWRITE.REF_VALUE;
#WRRaw_Data[2] := #PCDWRITE.PCD_02;
#WRRaw_Data[3] := #PCDWRITE.PCD_03;
#WRRaw_Data[4] := #PCDWRITE.PCD_04;
#WRRaw_Data[5] := #PCDWRITE.PCD_05;
#WRRaw_Data[6] := #PCDWRITE.PCD_06;
#WRRaw_Data[7] := #PCDWRITE.PCD_07;
#WRRaw_Data[8] := #PCDWRITE.PCD_08;
#WRRaw_Data[9] := #PCDWRITE.PCD_09;
//------------------------------------PCDWrite is mapped with Write Raw data--------------------------------------------------
//------------------------------------Send Data------------------------------------------------------------------
IF #RETVAL1 = 0 THEN
#RETVAL1 := DPWR_DAT(LADDR := #ADR, RECORD := #WRRaw_Data); // Write Raw Data
#COMM_ERR := #RETVAL1;
END_IF;
//------------------------------------Send Data------------------------------------------------------------------
//------------------------------------Ensure ENO is TRUE always--------------------------------------------------
ENO := TRUE;
//------------------------------------Ensure ENO is TRUE always--------------------------------------------------
VLT_PROFI_FC_DIAGNOSTICS FB302
//-------------------------------------------------------------------------------------------------------------
// VLT_PROFI_FC_DIAGNOSTICS: Rev. V1.12
// Valid for S7-1200 and S7-1500 Type CPU's.
// Block handles communication with a VLT frequency converter. Either Trough PROFINET OR PROFIBUS.
// Can be done in HW config of S7, on the Drive LCP or MCT10.
//-------------------------------------------------------------------------------------------------------------
#Static_1.AlarmCheckID := #ADDR; //Hardware identifier of the module to Alarm check ID
//RALRM is used to Read manufacture specific alarms
"RALRM_DB"(MODE := #Static_1.AlarmMode, //Mode
F_ID := #Static_1.AlarmCheckID, //Hardware identifier of the module
MLEN := #Static_1.AlarmMaxLength, //Maximum length of the interrupt information to be received in bytes
NEW => #Static_1.AlarmReceived, //New interrupt was received
STATUS => #Static_1.AlarmStatus, //Error code
ID => #Static_1.AlarmFromID, //Hardware identifier of the module from which the interrupt was received
LEN => #Static_1.AlarmLength, //Length of the received interrupt information
TINFO := #Static_1.TI_DiagnosticInterrupt, //Target range for OB start and management information
AINFO := #AINFOManufacture); //Target range for header information and additional interrupt information
// Identify the Profibus or Profinet slave
#SlaveType := #Static_1.TI_DiagnosticInterrupt.slv_prfl; //slv_prfl to slave type
IF #SlaveType = 3 THEN //Profibus slave (Byte#16#0011)
#Profibus_slave := 1;
#Profinet_slave := 0;
END_IF;
IF #SlaveType = 8 THEN //Profinet IO (Byte#16#1000)
#Profibus_slave := 0;
#Profinet_slave := 1;
END_IF;
//Extract error information for PROFINET IO
IF #Profinet_slave AND #Static_1.AlarmReceived AND (#AINFOManufacture.W6_interrupt_type = 16#0001) THEN
IF (#AINFOManufacture.W26_Add_W0_format_ID = 16#7FFF) THEN
#ALARM_1 := #AINFOManufacture.D28_AlarmWord; // Profinet IO Alarm word
#WARNING_1 := #AINFOManufacture.D32_WarnWord; // Profinet IO Warning word
#Static_1.AlarmReceived := 0;
END_IF;
IF (#AINFOManufacture.W26_Add_W0_format_ID = 16#8000) THEN
#CH_ERR_TYP := DWORD_TO_WORD(SHR(IN := (#AINFOManufacture.D32_WarnWord), N := 16)); // Channel Error Type
#Static_1.AlarmReceived := 0;
END_IF;
END_IF;
//Extract error information for PROFIBUS slave
IF #Profibus_slave AND #Static_1.AlarmReceived AND #AINFOManufacture.W2_block_length = 16#0001 THEN
#ProfibusAlarm := #AINFOManufacture.W4_version;
#ProfibusAlarm := SHL(IN := (#ProfibusAlarm), N := 16);
#TempAlarm := #AINFOManufacture.W6_interrupt_type;
#ALARM_1 := #ProfibusAlarm OR #TempAlarm; // Profibus Alarm Word
#Static_1.AlarmReceived := 0;
#ProfibusWarning := #AINFOManufacture.W12_comp_slot_num;
#ProfibusWarning := SHL(IN := (#ProfibusWarning), N := 16);
#TempWarning := #AINFOManufacture.W14_submodule_slot_num;
#WARNING_1 := #ProfibusWarning OR #TempWarning; //Profibus "WARNING" Word
#Static_1.AlarmReceived := 0;
END_IF;
// Clear the PROFINET Alarm/Warning data if alarm is reset
IF #Static_1.AlarmReceived THEN
IF #AINFOManufacture.W6_interrupt_type = 16#000C THEN
#CH_ERR_TYP := 0;
#ALARM_1 := 0;
#WARNING_1 := 0;
#Static_1.AlarmReceived := 0;
END_IF;
END_IF;
// Clear the PROFIBUS Alarm/Warning data if alarm is reset
IF #Static_1.AlarmReceived THEN
IF #AINFOManufacture.W2_block_length = 2 THEN
#CH_ERR_TYP := 0;
#ALARM_1 := 0;
#WARNING_1 := 0;
#Static_1.AlarmReceived := 0;
END_IF;
END_IF;
VLT_PROFI_FC_FLEXIBLE_CTRL FB301
//-------------------------------------------------------------------------------------------------------------
// VLT_PROFI_FC_FLEXIBLE_CTRL: Rev. V1.12
// Valid for S7-1200 and S7-1500 Type CPU's.
// This FB is to be used together with "VLT_PROFI_FC_FLEXIBLE"
// This FB is designed to work with the FCPROFILE on the VLT which is the default setting.
// Block Manages control and status bits' as well as Reference value. The default values on the Input Interface definitions
// are set as if they are not assigned an outside value, it will bring the VLT in a "Ready to Start" State.
//-------------------------------------------------------------------------------------------------------------
//------------------------------------Settings of Controlword--------------------------------------------------
// Prepare all Controlword Bit's to default values so that
// they are in a "ready to start" mode. CTW =043Ch
#PCDWrite.CTW.BIT_00_PRESET_REF_1 := #PRESET_REF_1;
#PCDWrite.CTW.BIT_01_PRESET_REF_2 := #PRESET_REF_2;
#PCDWrite.CTW.BIT_02_DC_BRAKE_RAMP := #DC_BRAKE_RAMP;
#PCDWrite.CTW.BIT_03_COAST_INV := #COAST_INV;
#PCDWrite.CTW.BIT_04_QSTP_RMP := #QSTP_RMP;
#PCDWrite.CTW.BIT_05_HLD_RMP := #HLD_RMP;
#PCDWrite.CTW.BIT_06_START := #START;
#PCDWrite.CTW.BIT_07_RESET := #RESET;
#PCDWrite.CTW.BIT_08_JOG := #JOG;
#PCDWrite.CTW.BIT_09_RAMP_1_2 := #RAMP_1_2;
#PCDWrite.CTW.BIT_10_DATA_VALID := #DATA_VALID;
#PCDWrite.CTW.BIT_11_RLY_1_ON := #RLY_1_ON;
#PCDWrite.CTW.BIT_12_RLY_2_ON := #RLY_2_ON;
#PCDWrite.CTW.BIT_13_SETUP_SEL_1 := #SETUP_SEL_1; // Multi setup in P. 0-10 must be selected.
#PCDWrite.CTW.BIT_14_SETUP_SEL_2 := #SETUP_SEL_2; // Multi setup in P. 0-10 must be selected.
#PCDWrite.CTW.BIT_15_REVERSE := #REVERSE;
//------------------------------------Settings of Controlword---------------------------------------------------
//------------------------------------Set reference speed-------------------------------------------------------
#PCDWrite.REF_VALUE := #REF_VALUE; // Reference speed is a RAW value - 16384 to + 16384.
//------------------------------------Set reference speed-------------------------------------------------------
//------------------------------------Mask out Drive status bit's-----------------------------------------------
// These are those considered to be used most often, there fore put in as "OUTPUT's" on the FB.
#READY := (#PCDRead.STW.BIT_00_CTRL_RDY AND #PCDRead.STW.BIT_01_DRV_RDY AND #PCDRead.STW.BIT_02_COAST_RDY AND #PCDRead.STW.BIT_09_CTRL_SOURCE); // Drive ready to start from Fieldbus
#RUNNING := #PCDRead.STW.BIT_11_IN_OPR; // Drive is started but not necessarily running on reference speed.
#RUN_ON_REF := #PCDRead.STW.BIT_08_RUNNING_REF; // Running on reference
#WARNING := #PCDRead.STW.BIT_07_WARNING; // Warning present
#FAULT := (#PCDRead.STW.BIT_04_ERROR OR #PCDRead.STW.BIT_03_TRIP OR #PCDRead.STW.BIT_06_TRIPLOCK); // Fault present. Trip or Trip lock
//------------------------------------Mask out Drive status bit's-----------------------------------------------
//------------------------------------Extraction of Main actual value--------------------------------------------
#MAV := #PCDRead.MAV; // Main Actual Value(MAV) is read from the Drive as - 16384 to + 16384.
//------------------------------------Extraction of Main actual value--------------------------------------------
//------------------------------------Initialize input's to their default values--------------------------------
// This set's the default values for the input definitions. This ensures that if an input is not configured.
// it will always have it initial default value
#PRESET_REF_1 := FALSE;
#PRESET_REF_2 := FALSE;
#DC_BRAKE_RAMP := TRUE;
#COAST_INV := TRUE;
#QSTP_RMP := TRUE;
#HLD_RMP := TRUE;
#START := FALSE;
#RESET := FALSE;
#JOG := FALSE;
#RAMP_1_2 := FALSE;
#RLY_1_ON := FALSE;
#RLY_2_ON := FALSE;
#SETUP_SEL_1 := FALSE;
#SETUP_SEL_2 := FALSE;
#REVERSE := FALSE;
#DATA_VALID := TRUE;
//------------------------------------Initialize input's to their default values--------------------------------
//------------------------------------Ensure ENO is TRUE always--------------------------------------------------
ENO := TRUE;
//------------------------------------Ensure ENO is TRUE always--------------------------------------------------
VLT_PROFI_FC_PARAM_ACCESS FB300
//-------------------------------------------------------------------------------------------------------------
// VLT_PROFI_FC_PARAM_ACCESS: Rev. V1.12
// Valid for S7-1200 and S7-1500 Type CPU's.
// Block handles communication with a VLT frequency converter. Either Trough PROFINET OR PROFIBUS.
// Acyclic communication with VLT.
// Can be done in HW config of S7, on the Drive LCP or MCT10.
//-------------------------------------------------------------------------------------------------------------
#Static_bool_3 := NOT #RD_WR; // Static bit is NOT of RD_WR
// Initializing the value with Zero
IF (#EXECUTE AND NOT #Static_bool_5) THEN
#DONE := 0;
#BUSY := 0;
#FAULT := 0;
#FALUT_CODE := 0;
#Static_busy := 0;
#Static_done := 0;
#Static_fault := 0;
FILL_BLK(IN := 0,
COUNT := 6,
OUT => #Response_rec.Res_Data[1]); // Read array initializing the value with Zero
END_IF;
//Parameter Read Value Operation Enable
IF (#Static_bool_3) AND (#EXECUTE AND NOT #Static_bool_5) THEN //Read with rising edge command
#Case_sequence_selection := 11; //Case sequence selection
#RD_VALUE := 0; //Read value to zero
#Static_bool_1 := 1; //Start request enable
//Parameter Write Value Operation Enable
ELSIF (#RD_WR) AND (#EXECUTE AND NOT #Static_bool_5) THEN //Write with rising edge command
#Case_sequence_selection := 11; //Case sequence selection
#RD_VALUE := 0; //Read value to zero
#Static_bool_2 := 1; //Start request enable
END_IF;
//Read or Write request parameter values are generally transferred via the header of the RECORD data record
#Request_rec.Req_Header.Request_Ref := B#16#01; //Request reference
#Request_rec.Req_Header.Axis_Number := B#16#00; //Axis number
#Request_rec.Req_Header.No_of_Parameter := B#16#01; //Number of parameter
#Request_rec.Req_ParaAddress.Attribute := B#16#10; //Attribute
#Request_rec.Req_ParaAddress.Num_of_elements := B#16#01; //Number of element
#Request_rec.Req_ParaAddress.Parameter_Num := (#PAR_NO); //Parameter number
#Request_rec.Req_ParaAddress.Subindex := #INDEX; //Sub index
//Read Request parameter values are generally transferred via the header of the RECORD data record
IF #Static_bool_1 THEN
#Request_rec.Req_Header.Request_ID := 16#51; //Read request, 51=Read request, Dword format
END_IF;
// Write Request request parameter values are generally transferred via the header of the RECORD data record
IF #Static_bool_2 THEN
#Request_rec.Req_Header.Request_ID := B#16#52; //Change request, 52=Write request, Dword format
#Request_rec.Req_ParaAddress.Write_Format := B#16#43; //Write format
#Request_rec.Req_ParaAddress.Write_Num_Of_Value := B#16#01; //Write number of value
//Write value
#Request_rec.Req_ParaAddress.Write_Value[4] := WORD_TO_BYTE(DWORD_TO_WORD(#WR_VALUE));
#Request_rec.Req_ParaAddress.Write_Value[3] := WORD_TO_BYTE(DWORD_TO_WORD(SHR(IN := (#WR_VALUE), N := 8)));
#Request_rec.Req_ParaAddress.Write_Value[2] := WORD_TO_BYTE(DWORD_TO_WORD(SHR(IN := (#WR_VALUE), N := 16)));
#Request_rec.Req_ParaAddress.Write_Value[1] := WORD_TO_BYTE(DWORD_TO_WORD(SHR(IN := (#WR_VALUE), N := 24)));
END_IF;
CASE #Case_sequence_selection OF
11: // Statement section case 11
IF (#Static_bool_1 OR #Static_bool_2) THEN
#Static_bool_6 := 1;
#BUSY := 1;
END_IF;
;
IF #Static_bool_6 AND NOT #Static_done THEN //Start WRREC request
#WRREC_Instance(REQ := TRUE, //WRREC Instance
ID := #ADR,
INDEX := 47,
BUSY => #Static_busy,
DONE => #Static_done,
ERROR => #Static_fault,
LEN := 16,
RECORD := #Request_rec,
STATUS => #Static_stored_status);
END_IF;
;
IF #Static_done OR #Static_fault AND NOT #Static_busy THEN //Write request status, done or fault or busy
#Case_sequence_selection := 12; //12 Case sequence selection
END_IF;
;
12: // Statement section case 12
IF #Static_done = 1 THEN //Check parameter write is done
#Case_sequence_selection := 13; //13 Case sequence selection
#DONE := 0;
#BUSY := 1;
#Static_bool_4 := 1;
;
ELSIF #Static_fault = 1 THEN //Check write record is fault
#Case_sequence_selection := 50; //50 Case sequence selection
#FAULT := 1;
#BUSY := 0;
#FALUT_CODE := (#Static_stored_status); //Fault code value
END_IF;
;
13: // Statement section case 13
IF #Static_bool_4 AND (NOT #Static_valid) THEN //Start RDREC response
#RDREC_Instance(REQ := TRUE, //RDREC Instance
ID := #ADR,
INDEX := 47,
MLEN := 10,
BUSY => #Static_busy,
LEN => #Response_Len,
STATUS => #Static_stored_status,
VALID => #Static_valid,
RECORD := #Response_rec);
END_IF;
;
IF #Static_valid = 1 AND #Static_bool_3 THEN //Read response is valid
IF #Response_rec.Res_Data[1] = 16#44 OR #Response_rec.Res_Header.Request_ID = 16#D1 THEN //Check the parameter format
#FAULT := 1;
#DONE := 0;
#BUSY := 0;
#Case_sequence_selection := 60; //Fault State
#RD_VALUE := 0;
;
ELSE
#FAULT := 0;
#DONE := 1;
#BUSY := 0;
#Case_sequence_selection := 14; //Done State
END_IF;
;
ELSIF #Static_busy = 1 THEN //Busy State
#Case_sequence_selection := 13;
#BUSY := 1;
END_IF;
;
IF #Static_valid = 1 AND #RD_WR THEN
IF #Response_rec.Res_Data[1] = 16#44 OR #Response_rec.Res_Header.Request_ID = 16#82 THEN // Statement section IF
#FAULT := 1;
#DONE := 0;
#BUSY := 0;
#Case_sequence_selection := 60; //Fault State
#RD_VALUE := 0;
ELSE
#FAULT := 0;
#DONE := 1;
#BUSY := 0;
#Case_sequence_selection := 15; //Done State
END_IF;
;
ELSIF #Static_busy = 1 THEN //Busy State
#Case_sequence_selection := 13;
#BUSY := 1;
END_IF;
;
14: // Statement section case 14
// Parameter Read done state
#DONE := 1;
#BUSY := 0;
#FALUT_CODE := 16#FF; //If error is not present in the read or write operation and then error code is set as 0xFF. Since 0x00 is valid error code for Unknown Parameter.
// Read value is converted from Word to DWord
#Temp_word_high := SHL(IN := BYTE_TO_WORD(#Response_rec.Res_Data[3]), N := 8);
#Temp_word_low := BYTE_TO_WORD(#Response_rec.Res_Data[4]);
#Temp_word1 := #Temp_word_high XOR #Temp_word_low;
#Temp_word_high := SHL(IN := BYTE_TO_WORD(#Response_rec.Res_Data[5]), N := 8);
#Temp_word_low := BYTE_TO_WORD(#Response_rec.Res_Data[6]);
#Temp_word2 := #Temp_word_high XOR #Temp_word_low;
#Temp_dword_high := SHL(IN := WORD_TO_DWORD(#Temp_word1), N := 16);
#Temp_dword_low := WORD_TO_DWORD(#Temp_word2);
#RD_VALUE := (#Temp_dword_high XOR #Temp_dword_low); //Read Value
;
15: // Statement section case 15
// Parameter Write done state
#DONE := 1;
#BUSY := 0;
#FALUT_CODE := 16#FF; //If error is not present in the read or write operation and then error code is set as 0xFF. Since 0x00 is valid error code for Unknown Parameter.
;
50: // Statement section case 50
// Parameter write Fault state
#FAULT := 1; //Fault status
#DONE := 0;
#BUSY := 0;
#FALUT_CODE := (#Static_stored_status); //Fault code value
;
60: // Statement section case 60
// Parameter Response error state
#FAULT := 1; //Fault status
#DONE := 0;
#BUSY := 0;
#Temp_word_high := SHL(IN := BYTE_TO_WORD(#Response_rec.Res_Data[3]), N := 8);
#Temp_word_low := BYTE_TO_WORD(#Response_rec.Res_Data[4]);
#FALUT_CODE := #Temp_word_high XOR #Temp_word_low; //Fault code moving to stored status
;
END_CASE;
IF NOT #EXECUTE THEN // If execute command is not present then zero value moved to below variables
#Static_bool_1 := 0;
#Static_bool_2 := 0;
#Static_bool_4 := 0;
#Static_bool_6 := 0;
#Static_valid := 0;
END_IF;
;
#Static_bool_5 := #EXECUTE; //Capturing the falling edge of Last value
|