[Overview] [Example Task] [Libraries] [ File Template] [Submitting] [References]
This is a brief document describing the general development of software algorithms for the IONF program. It outlines proper coding procedures, usage of the supplied libraries and documentation and code file templates.
To better understand how the algorithms work with the spacecraft software, and outline of the overall software architecture is show below.
There are multiple tasks that each run simultaneously onboard the spacecraft computer. These are split between Periodic Tasks, which are subsystem operations that run at a fixed frequency, Periodic Update Tasks, which run at a fixed frequency, but only update global variables, and Aperiodic Tasks, which only run when requested to by another task. All inter-task communication is handled through message queues and global variables. However, this is transparent to the algorithm developer.
The subsystem developer will need to only develop a list of operations to perform based on a requested action (ie change mode, send message, etc.) and then the actual algorithms of those operations. The main method of inter-task communication for subsystems are the global variables that are accessed through function calls.

refer to the IONF Software Documentation Set for all the architecture and function definitions.
The code below is an example of what the Attitude Control task will look like. This task will operate after the specified update time, or when a message is put into it's queue. The first if block is handling these messages, such as a statechange shown in the example. In this case, the attitude control task changes its update time (probably to be slower, since it won't actually be controlling). Other operations could include changing gains, turning on and off devices, and so on.
The else block is entered during a normal update. The mode is checked to determine the appropriate operating procedures. For this example, the nominal state checks the attitude, angular velocity, and desired attitude (a global variable that is set by another task). The variables for these data values must be initialized and are passed by reference. Also notice that there is a set of defined classes, such as CQuaternion that encapsulates a defintion of a double[4] array. Use these defined variable typs as appropriate. The control function is then called, passing in the appropriate data values. The example also demonstrates how to check the retcode variable in the case of an error, and the block that will handle this error. For this error, a message is created, its source and destination specified, and sent out through the message queue.
int AttControl()
{
/* Create and initialize variables */
STATUS retcode;
IONF_Message gotMsgATTCONTROL;
IONF_Message sendMsgATTCONTROL;
IONF_Time wakeTimeATTCONTROL;
IONF_Time updateTimeATTCONTROL;
updateTimeATTCONTROL = ATTCONTROL_INITIAL_UPDATE_TIME;
wakeTimeATTCONTROL = IONF_GetCurrentTime() + updateTimeATTCONTROL;
while (1)
{
retcode = IONF_GetMessage(IONF_MSGQ_ATTCONTROL, &gotMsgATTCONTROL, wakeTimeATTCONTROL - IONF_GetCurrentTime());
if (ERROR != retcode)
{ /* Received a message before periodic update */
switch (gotMsgATTCONTROL.Header.msg_type)
{
case IONF_MSG_STATECHANGE:
switch (gotMsgATTCONTROL.StateChange.NewState)
{
case IONF_STATE_SAFE:
updateTimeATTCONTROL = ATTCONTROL_SAFE_UPDATE_TIME;
break;
case IONF_STATE_NOMINAL:
updateTimeATTCONTROL = ATTCONTROL_NOMINAL_UPDATE_TIME;
break;
}
break;
/* etc. */
}
}
else
{ /* Regular Update */
CMode CurrentMode = IONF_STATE_SAFE;
retcode = CDH_GetMode(CurrentMode);
if (CurrentMode == IONF_STATE_NOMINAL)
{
/* If current mode is nominal, perform normal attitude control maneuvers */
IONF_Quaternion CurrentAttitude;
IONF_Quaternion DesiredAttitude;
double[3] AngularVelocity;
retcode = ADCS_GetAttitude(CurrentAttitude);
retcode = ADCS_GetAngularVelocity(AngularVelocity);
retcode = ADCS_GetDesiredAttitude(DesiredAttitude);
retcode = ADCS_ControlAttitude(CurrentAttitude, AngularVelocity, DesiredAttitude);
if(retcode == ERROR_ADCS_CONTROL_FAILURE)
{ /* Detected a system failure, request safe mode */
sendMsgATTCONTROL.Header.msg_type = IONF_MSG_STATECHANGE;
sendMsgATTCONTROL.Header.msg_src = IONF_MSGQ_ATTCONTROL;
sendMsgATTCONTROL.Header.msg_dest = IONF_MSGQ_MODEMGR;
sendMsgATTCONTROL.StateChange.NewState = IONF_STATE_SAFE;
/* Send message through task manager */
IONF_SendMessage(&sendMsgATTCONTROL, NO_WAIT, MSG_PRI_NORMAL);
break;
}
}
wakeTimeATTCONTROL += updateTimeATTCONTROL;
}
}
/* getting here would be bad */
}
We will be using the Matrix TCL Lite library for out matrix interfaces.
Listed below is the template for all software files. The Filename: and Purpose: lines need to be completed, as well as Inputs: and Outputs: for all functions in the file. Just define any specifics of the inputs and outputs that would be necessary to use the function (size, units, etc.)
DO NOT CHANGE THE LINES WRAPPED WITH $...$
/*****************************************************************************
* Filename:
* $Date: 2001/10/30 22:02:58 $
* $Author: berry $
* $Revision: 1.2 $
*
* Purpose :
*****************************************************************************/
/*****************************************************************************
* Function Name:
* Purpose :
*
* Inputs :
* Outputs :
******************************************************************************/
/*****************************************************************************
* $Log: subsystem_programming.htm,v $
* Revision 1.2 2001/10/30 22:02:58 berry
* Corrected link to architectrure drawing.
*
* Revision 1.1 2001/07/13 17:26:49 ajturner
* Document outlining programming information for subsystem developers
*
*
******************************************************************************/
To submit new or updated files, email them to your software team (ie. Hokiesat_Software@vt.edu). These will then be submitted to the CVS repository. If you would like access to the CVS repository to get new files, email Matt Berry to request a username and password. Then go to www.cvshome.org and download the cvs software.