Cubesat Attitude Determination Control System (ADCS) Testing Apparatus

Total Page:16

File Type:pdf, Size:1020Kb

Cubesat Attitude Determination Control System (ADCS) Testing Apparatus

P16105: CubeSat Attitude Determination Control System (ADCS) Testing Apparatus Presents

Software, Schematics, Wiring, Theory of Operation, and Troubleshooting

Written By: Bradley Conn Requirements

Software: Windows Matlab: Available through RIT MATLAB Support Package for Arduino: Free online Supporting software files: Available on RIT p16105 edge website or on included flash drive -Files: gui.m gui.fig Arduino_init.m MAG_init.m PS_init.m PS_sweep.m relay_toggle.m set_field.m, find_closest.m, read_x_y_z.m, simulate_orbit.m, orbit_field.log,

Hardware: Constructed Helmholtz Coil RS232 cable for communicating PC to Power Supply: Should be with apparatus Male to Male RS232 cable adapter: Should be with apparatus Electrical box with relay board and Arduino Uno: Should be with apparatus Arduino Nano with mini usb cable: Should be with apparatus Sparkfun HMC5883L Triple Axis Magnetometer: Should be connected to Arduino Nano

NOTE: The HMC5883L magnetometer is very bad. A better one would do wonders for the apparatus.

Setup: Please see provided construction manual for apparatus setup. The construction manual can be found on the p16105 website or on the provided flash drive. The wiring section of the construction manual has been copied onto the next page for simplicity. In addition to connecting the wires to the coil pairs several extra wires must be connected as well. An overview of all of the communication can be seen in the image below. Please note that the Arduino Nano and Magnetometer are only required for initial calibration and can be removed afterwards. Wiring

Included should be an electrical box with many banana plug terminals. Each of the ends of the wires are labeled. Five of the terminals go to the power supply, and the rest get connected to the coils. The five that connect to the power supply are +6V, -6V, +25V, COM, and -25V. They get connected to the equivalent outputs of the power supply as shown in the image below.

The remaining wires get connected to the coils. The coils have reciprocating female banana plug terminals for the connection. Both the electrical box wires and the coil wires are labeled as well. The wires should be connected to matching labels. For example, the wire SMALL 1B should be connected to the wire SMALL 1B as seen in the image below. Each of the male banana plugs should match with a female banana plug of the same color.

The full list of electrical box to coil wires: SMALL 1A <= SMALL 1A SMALL 1B <= SMALL 1B SMALL 2A <= SMALL 2A SMALL 2B <= SMALL 2B MEDIUM 1A <= MEDIUM 1A MEDIUM 1B <= MEDIUM 1B MEDIUM 2A <= MEDIUM 2A MEDIUM 2B <= MEDIUM 2B LARGE 1A <= LARGE 1A LARGE 1B <= LARGE 1B LARGE 2A <= LARGE 2A LARGE 2B <= LARGE 2B

A schematic of a single coil pair has been added for a better understanding of the wiring setup.

In addition to this wiring, the rs232 cable must be connected from the power supply to the computer using a rs232 to usb cable as well as an rs232 male to male adapter cable provided. Additionally, the usb cable extruding from the electronics box needs to be attached to the computer. Lastly, if calibration is needed, a mini usb cable is required to connect the Arduino Nano to the computer. Attached to the Arduino Nano should be the sparkfun magnetometer. This communicated over a 4 cable I2C interface. This connection should be permanent but see the next section if fixing is required.

Permanent Connections

In addition to the usual setup, there are permanent connections that may become disconnected over time for various reasons. The first and most probably is the disconnection between the Arduino nano and the sparkfun magnetometer. This connection contains 4 wires. A +3.3V, Ground, Data, and Clock. The ground wire connects the magnetometer “GND” pin to a “GND” pin on the Arduino Nano.The +3.3V wire connects the magnetometer “VCC” pin to the Arduino “3V3” pin. The data wire connects the magnetometer “SDA” pin to the Arduino Nano “A4” pin. The clock wire connects the magnetometer “SCL” pin to the Arduino Nano “A5” pin.

Magnetometer pins Arduino Nano pins GND GND VCC 3V3 SDA A4 SCL A5 Inside the electrical box there is an Arduino Uno which also contains connections that should be permanent. For this connection, there is a power and ground line, and 6 additional io pins. The IO pins control individual relays. The connections can be seen in the table below.

Relay Board Arduino Uno VCC 5V GND GND IN1 2 IN2 3 IN3 4 IN4 5 IN7 6 IN8 7 Software

Brief Overview:

The software should completely handle all operations of the apparatus. It controls the power supply and arduinos automatically which controls the magnetic field. A GUI has been provided to handle operating the apparatus. To run the gui open gui.m and click the green triangle run button. An image of the GUI can be seen below. There are three buttons which initialize the power supply and two arduinos. There is a reset button which clears the previous initializations. Then there are four functionality buttons.

The first button Map Voltage to Magnetic Field turns on one coil at a time and sweeps through voltages and records the magnetic fields as they change. This is not required every time if the apparatus has not been moved since the last mapping, but it always a good idea. The magnetometer will need to be placed in the middle of the cage in the proper orientation (see in depth section) for this function.

The Set Magnetic Field Value button takes in an an x value, y value, and z value in gauss (range about +-4 Gauss), and produces the magnetic field entered. The logged files from the mapping function are used to determine the power supply outputs required to create that field. The Simulate Magnetic Field through Orbit button takes in a file of field points and an interval between points (in seconds) and produces the magnetic field of all these points.

The Read Magnetic Field Values button reads the field from the connected magnetometer. The values are NOT displayed on the GUI, but are on the regular matlab console.

In Depth:

The first thing to note about the software is that it is not foolproof. If you try to break it it will break easily. If you follow the appropriate steps everything should work fine. All errors will print back on the regular Matlab terminal. When in doubt, check connections, unplug and replug the devices, restart matlab, or restart your computer.

The object initializations accomplished using the Initialize buttons are required first. Without these, the mapping button, setting magnetic field button, simulation button, and reading magnetic field button will not work. These buttons create objects to communicate with the power supply, and arduinos. The COM ports are entered to the left. To check a COM port of a device check the device manager.

The button labeled Initialize Power Supply takes a COM port input, and opens a serial connection to the power supply. The USB to RS232 adapter must be plugged into the computer to get an appropriate COM port. To see a list of COM ports check the device manager. The button labeled Initialize Arduino (Box) takes a COM port input, and initializes an Arduino Uno object. This is required to control the relay board. The board is put in place to change the direction of current, and thus magnetic field, so the full range can be created. Six relays are used, one for each coil pair. The Arduino must be plugged in to get a COM port. Sometimes Matlab may need to update the code on the Arduino before it can interact with it. This should only take around 30 seconds. To see a list of COM ports check the device manager.

The button labeled Initialize Arduino (Magnetometer) will initialize the Arduino Nano as well as the magnetometer connected to the Nano. If the magnetometer is not attached or is attached incorrectly it will not initialize properly. This Arduino is only required if using the Map function or Reda Magnetic Field Values function.

The button labeled Reset will delete all the initialized device objects.

The button Map Voltage to Magnetic Field is the most difficult to understand. This function turns off all coils, and turns on one power supply output, which turns on one coil pair. The output sweeps from 0 volts to 6 volts in small increments, and records the magnetic field at each step. The values are recorded to a file, one file per coil pair. Then later, when a specific field is desired these recorded values are looked at to find the appropriate voltage which maps to that magnetic field. This sweeping is done twice for each coil pair. One time with the relays off, and the second time with the relays on, changing the direction of the current, and thus the magnetic field. The relays are controlled from the Arduino in the electronics box. For this function, the magnetometer needs to be placed in the middle of the cage with the proper orientation. The orientation of the magnetometer should match the one written on the top piece of the cage. There are arrows for each axis written on both the magnetometer, and the cage. It should be oriented in such a way that the Y axis arrow is pointing to the center of the largest coil pair, the X axis arrow is pointing to the middle of the medium coil axis pair, and the z axis is pointing vertically, to the center of the smallest coil pair. It is important that the magnetometer be aligned as perpendicular as possible. The voltage to magnetic field does not have to be remapped if the cage has not moved.

The button labeled Set Magnetic Field Value will take three inputs from the GUI and set the magnetic field in the cage to the values entered. It does this by looking up (from the previously generated lookup table) the voltage for each axis which maps to those field points desired. Then it will automatically set the voltage to the desired value which creates the field entered.

The button Simulate Magnetic Field Through Orbit takes a filename including the extension (example orbit_field.log) which has a set of field points, and an interval in seconds which determines how fast to go through these points. Under the hood, the function opens and reads the magnetic field values, then loops through and uses the same function as the Set Magnetic Field Value button until all the field values have been set. The last button, Read Magnetic Field Value, reads the values on the magnetometer and prints them to the matlab console. This function relies on the magnetometer being initialized for its use. It reads the values through the Arduino Nano and converts them to the appropriate Gauss in matlab. It is very helpful for testing purposes.

To edit the GUI use the ‘guide’ command at the matlab console. To see an example of running this apparatus from the command line look at test_all.m in the possibly useful scripts folder. Alternatively, take a look at the gui.m file for the functions called by the GUI.

Troubleshooting

We have found some issues pop up from time to time. Some common issues and solutions are listed below.

Arduino Uno “loses connection”

This one has popped up annoyingly here and there. I have found changing the USB cable to a better (shorter) cable has usually fixed this issue. Some other things to try are hitting the ‘reset’ button on the GUI and reinitializing the Arduino Uno, unplug and replug the device, try a different usb port, restart matlab, or restart your computer. Maybe a different arduino would fix the issue.

Errors initializing the devices

Make sure they have not already been initialized. If you hit initialize twice without resetting it will give you an error. Make sure you reset before trying to initialize again. Make sure you have the correct port numbers. This can be looked up in the Device Manager

Functions giving errors

Make sure the devices are initialized. Make sure the you are providing a text file (.txt, .log, etc.) with the extension included in the name for the ‘simulate orbit’ button (example: orbit_field.log)

Recommended publications