Simulink / STK Solar Energy


Requirements and Setup
This example shows how satellite power system designed in Simulink can be integrated with STK for testing and analysis of that system.  An STK scenario is used to generate inputs to the Simulink power model by determining sunlight exposure, experiment times, and downlink times.  A level-2 s-function block is used to host the STK application.  When the Simulink model is run, an STK scenario will be built that includes a satellite, an area target to be imaged (experiment), and a ground station for downlink (communications).  As Simulink executes the model through time, it will query STK for updates on the state of the satellite.  STK will return 1 or 0 for these three states, In Sunlight, Conducting Experiment (access to area target), Conducting Downlink (link budget with ground station where BER < 1e-8).  These values will feed into the power model to determine the current state of the battery.
Instructions for use
  • Open MATLAB and browse to the SolarEnergy directory
    • It is important that the current directory in MATLAB contains all the files in the SolarEnergy directory, or it will not find the s-function necessary for the simulation.
  • Open SolarEnergy.slx in Simulink
  • Run the Simulation
  • Open the PowerLevel output scope block.  Notice the change in battery power over time due to depletion from normal system operations, experiments, and communications.
User-added image
Additional notes
The s-function block relies on the stk_level2_mfile.m function to interact with the STK scenario.  The STK scenario is started and built with the code that can be found in InitFcn_TestCode.m.  This code is then copied into the s-function’s InitFcn callback (right click on the s-function block, select Properties, and then Callbacks tab). 
Download File