Installing the Simulator

The package includes two folders:

Extract the “Simulator” folder to any location you wish. There is no further installation process required, you may now start the simulator and experiment with it.

To see the code for a simple controller that doesn't quite follow the satellite, check “Example_Design_P_Controller.cs”. To see a better, more complex controller with detailed explanations in action, load up “Example_Design_PID_Controller.cs” on the designer tab, set the sampling time to 20 milliseconds and start the simulation.

To start implementing your own controller, you can either modify a copy of the example controllers or click the new file button to get a bare-bones template to begin with.


Developing on the Arduino IDE

All projects in the Arduino IDE need to consist of a single folder, containing the main source file with the same name as the folder and .ino as its extension. All additional source files go into the folder and are automatically opened and compiled by the IDE.

The Arduino IDE has a “Verify” button which compiles your code, but doesn't upload it to the board. Use this to check your code for errors. To upload your code to the board, first make sure that you select the board's COM port from the “Serial Port” option in the “Tools” menu. Then click the “Upload” button to compile and send the code. The boad will start executing the code immediately after the upload process. I also recommend that you fiddle with the IDE to familiarize with it and see all the tools is offers you.

A simple controller that doesn't perform well can be found in the “Example_Arduino_P_Controller” folder. A better controller with detailed explanation is located at “Example_Arduino_PID_Controller” folder. Just double-click the .ino file in the folder to open the project in the Arduino IDE.

The easiest way to get your controller project going is to create a copy of the “Example_Arduino_PID_Barebones” folder in the simulator package. This contains an example source and two additional files to help you communicate with the simulator.

To run the simulation using a controller implemented on an Arduino board; upload the project onto the board, verify your simulator settings, click “Start”, then press the reset button on the Arduino. The board firmware waits about 1 second before starting execution of your code, so just be patient.

If you ever rename an Arduino the project, don't forget to rename both the folder and the .ino file to the same name.


Simulator Screens

Main

Main Screen

This screen contains a 3-dimensional representation of the antenna, and the simulation can be managed from here. Certain basic settings are also available on this screen.

  1. 3D display area. Click and drag within this area to adjust antenna azimuth and elevation. This only works when the simulation is stopped.
  2. Satellite position and strength of received signal.
  3. Antenna position and tracking error, i.e. difference between satellite and antenna positions.
  4. Current simulation time.
  5. Wind speed and direction.
  6. Start and end time overrides for the simulation. These can be adjusted to perform the simulation for a specific time interval, in order to observe the controller behavior during that time. Regardless of the end time, the simulation always stops when the satellite “sets”, i.e. goes below the horizon.
  7. Wind speed adjustment. The two ends of the trackbar correspond to a wind speed of 0 km/h and 108 km/h. Adjustments made here do not reflect immediately on the simulation, but take a few seconds as the wind gradually changes speed. Keep in mind that the maximum speed allowed here is extreme; and an actual antenna of this size would be blown away by such a wind force unless shielded in an enclosure (in which case, wind is no longer a disturbance).
  8. Simulation mode. “Position Control” mode involves sending torque commands to the motors to control the dynamic system model in an attempt to track the satellite position with minimum error. This is the mode required by the assignment. In “Signal Tracking”, no dynamic model is involved and the antenna looks directly at the angles sent by the controller. This latter mode, the satellite position reported to the controller is off by a certain amount from the actual satellite position, and an algorithm needs to be developed to find the correct position and maximize signal strength.
  9. Antenna axes to be controlled. Selecting either axis makes the other one perfectly track the satellite, requiring the controller to send commands only for the selected axis. This allows development and optimization of controllers for both axes separately. Selecting “Both” requires both axes to be controlled, which is the default requirement.
  10. Controller selection. Select “Board” to control the antenna using a connected development board. Select “Design Tab” to control the antenna using the controller implemented on the Design screen.
  11. This toggles a hemisphere-shaped grid on the 3D visualization, approximately showing the antenna position with a green dot and the satellite with a red one, giving an idea of where they are.
  12. This toggles the recording of plant states and various parameters into a text file on the hard drive. The file path can be changed from the Settings screen.
  13. The simulation can be started or stopped using these buttons.

Settings

Settings Screen

Many settings regarding the software and the simulation can be adjusted here. These settings, along with those on the main screen, are saved in the file “Settings.xml” in the same folder as the simulator executable. This file can be deleted to revert the simulator to default settings.

  1. Serial communication settings. The values here should match those appearing on the operating system and configured in the controller software.
  2. Simulation sampling time. This value should be equal to that in the controller design.
  3. Data logging interval. The largest value that this can be set is half the sampling time.
  4. Log file name. The files are saved in the same folder as the simulator executable.
  5. Delimiter character placed between the data columns in the log file. This can be changed to ensure compatibility when importing the data into other programs for analysis.
  6. Decimal separator for data values in the log file. This can be changed to ensure compatibility when importing the data into other programs for analysis. For instance, Matlab always uses period for decimals, while Microsoft Excel obeys the system language settings.
  7. States recorded in the log file. Check or uncheck the boxes to include or exclude desired states.
  8. Satellite trajectory parameters. These simplified parameters affect the satellite trajectory.
  9. Adjustable antenna parameters. Backlash amount in gears of both axes can be adjusted here.
  10. Fixed antenna parameters. The values here are provided just for the sake of being quickly accessible.

View

View Screen

This screen contains simple graphs for observing the satellite and antenna positions, torques on both axes and signal strength. Double-clicking a graph shows up a small window for adjusting a number of display settings regarding that graph.

Design

Design Screen

This screen allows the implementation of a controller algorithm in C# programming language. (Additional languages may be supported in the future.) A simple text editor provides syntax highlighting. However, no auto-complete features currently exist. If a file was open when exiting the simulator, it will be loaded the next time the simulator is launched.

  1. File controls. Creating a new file yields a template instead of a blank document.
  2. Compile the controller but don't start the simulation. This makes it easier to check for errors within the code. Compiling does not save the currently loaded file.
  3. Compile the controller and start the simulation. This also switches the view to the main screen and sets the controller selection to “Design Tab”. Compiling does not save the currently loaded file.
  4. Text editor.
  5. List of errors generated during controller compilation. Double-clicking an error in this list will take you to the line where that error occurs.

Console

Console Screen

The console shows text sent from the controller using the WriteConsole() function.

  1. Text display area.
  2. Save the currently displayed text to a file on the hard drive.
  3. Clear the displayed text.
  4. Checking this clears the displayed text automatically every time the simulation is started.

Function Reference

int16 ReadRegister(unsigned int8 id)
Available in: Arduino, CCS C, Designer
Description: Returns the value contained in register numbered id from the simulator. id can be from 0 to 25.

void WriteRegister(unsigned int8 id, int16 value)
Available in: Arduino, CCS C, Designer
Description: Writes value into register numbered id in the simulator. id can be from 0 to 25.

void WriteConsole(string text, parameters ...)
Available in: Arduino, CCS C, Designer
Description: Formats text with provided parameter values (if given) and prints the resulting string the the simulator console. In Arduino and CCS C, text should utilize the printf() format specifiers. In designer, text is a composite format string.
Note: Not all printf() format specifiers may be supported on Arduino and CCS C. The specifier %f for floating point numbers is not supported on Arduino as of Arduino IDE v1.0.5. Instead, use %ld.%ld and encapsulate the relevant parameter in fto2ld() macro. See Arduino example in package.

void AutologField(string fieldName)
Available in: Designer
Description: Registers the field named fieldName in the controller class for auto-logging to the log file at every time step. This function should be called only once per field to be registered, inside Initialize() method of the controller class.

void LogVariable(object variable)
Available in: Designer
Description: Writes the value of variable to the log file at the end of the current time step. This function should be only called inside the TimerISR() method of the controller class.