beckhoff TS3900 — 9 Example

Example All PLC blocks of the TwinCAT PLC SPA library are now available to you. All further implicitly required libraries have been automatically integrated with the TcSPA.lib. 2. Program structure For sun position calculations you should declare an instance of function block FB_SPA [ } 13] and local variables for allocating the required result values. The input parameter for the calculation can be directly assigned to the inputs of the function block. In addition to the sun angles the sunrise and sunset is required as output, which means the advanced functionality is required, which is specified via the enumeration value eSPA_ZA_RTS of type E_SPA_FunctionCode [ } 18] .

The output values of the function block are assigned to your local variables. The program section should now look as follows: PROGRAM MAIN VAR fbSPA : FB_SPA; fSunZenith : LREAL; fSunAzimuth : LREAL; tSunrise : TIME; tSunset : TIME; eErrorCode : E_SPA_ErrorCode; bExecute : BOOL; END_VAR fbSPA.stTime.iYear := 2010; fbSPA.stTime.iMonth := 3; fbSPA.stTime.iDay := 4; fbSPA.stTime.iHour := 14; TS3900 23 Version: 1.1