﻿<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
  <GVL Name="CT" Id="{53ee3538-8ad9-066b-1876-e48ae65e9a16}">
    <Declaration><![CDATA[{attribute 'qualified_only'}
VAR_GLOBAL
	
	// test code
	udpHandlerFast					: UDP_handler_fast;			// debug data to logging PC		
	UDPdataCollection				: UDP_dataCollection;		// read PLC variables and build string
	//speedPID						: PID;	
	torquePID						: PID;	
	timekeeping						: Time_keeping;				// produce pulses and triggers for testing
	houseKeeping					: CT_housekeeping ;
	
	
	processData						: Process_data; 						// Struct for for logging to laptop
	speedCommand					: LREAL ;  			// produced by PID regulator, Drum RPM
	torqueCommand					: LREAL ;  			// produced by PID regulator, Motor Nm 
	isIndoors						: BOOL ; 			// should crane slow down?
	isSensorsOK 					: BOOL ; 			// Check loadcell and trolley position
	trolleyPos						: LREAL ;			// 0-1 ( 1 is fully out)
	potmeterAdjustmentValue			: LREAL ;				// in CT, the potmeter can add or subtract to the target tension
	
	// global timekeeping stuff
	seconds							: ULINT ;
	msec							: ULINT ;
	s_1_pulse						: BOOL;				// single pulse every second
	s_10_pulse						: BOOL;				// single pulse every 10 seconds
	s_20_pulse						: BOOL;				// single pulse every 20 seconds
	s_1_toggle						: BOOL;				// 1 sec on/off
	s_10_toggle						: BOOL;				// 10 sec on/off
	s_20_toggle						: BOOL;				// 20 sec on/off
	
	
END_VAR

// configuration values - When finished, this should be copied and use the 'proper' userwinch config. 
VAR_GLOBAL PERSISTENT
	_TargetTension_kg 				: LREAL 	:= 500;				//kg	(setpoint)
	_PIDactive						: BOOL 		:= TRUE;	// turn on to override 'regular' CT
	_selectedPIDtype 				: UINT 		:= 1;		// 0= off,  1 = torque mode, 2 = Torque step simulation 3 = tension step simulation 
	_motorNominalTorque_Nm			: LREAL		:= 420.0 ;	// Nm
	_kN_Speed_limit_factor			: LREAL 	:= 50;		// Nm per drum RPM - speed correction factor
	_torquePIDconfig				: PID_config;	
 	_VFD_drum_RPM_limit				: LREAL 	:= -15.0 ;	// constant VFD drum RPM in CT mode. Negative is Haul in
	_TrolleyIndoorThreshold			: LREAL 	:=  0.5 ;	// 1= fully out
	_simTorqueLowValue				: LREAL 	:=  0.02 ;	// 0-1 = 0-100%
	_simTorqueHighValue 			: LREAL  	:=  0.05 ;	// 0-1 = 0-100%
	_PIDindoorReductionFactor		: LREAL 	:= 	0.5	;	// Not used
	_indoorMinTorqueLimit_Nm		: LREAL		:= -100 ;	// Nm - used in indoor mode Pay oot
	_indoorMaxTorqueLimit_Nm		: LREAL		:= 	100 ;	// Nm - used in indoor mode Haul in
	_outdoorMinTorqueLimit_Nm		: LREAL		:= -165 ;	// Nm - used outside Pay out 
	_outdoorMaxTorqueLimit_Nm		: LREAL		:= 	165 ;	// Nm - used outside Haul in
	_TorqueModePIDspeedLimitHaul	: LREAL 	:=  20.0 ;	// max drum RPM in CT mode. positive number
	_TorqueModePIDspeedLimitPay		: LREAL 	:=  20.0 ;	// max drum RPM in CT mode. positive number
	_SpeedRampRate					: LREAL		:=  4 ;		// Drum RPM per second when entering CT mode 
	_simTensionLowValue				: LREAL 	:=  500 ;	// Step change test (Kg)
	_simTensionHighValue 			: LREAL  	:=  650 ;	// Step change test (Kg)
		
	
END_VAR
]]></Declaration>
  </GVL>
</TcPlcObject>