Reaction Wheel Actuated Satellite Dynamics Test Platform

Dependencies:   mbed

Diploma Thesis in Aerospace Engineering, January 2014

University of Applied Sciences Munich, Faculty 03

Electronics:

  • 1x mbed NXP LPC 1768 Microcontroller
  • 2x XBee S1 Radios + Sparkfun USB Adapter
  • 1x CHR UM6-lt IMU
  • 4x Graupner BEC 8 Motor Controllers
  • 4x ROXXY 2826/09 Brushless Motors
  • 1x Hacker TopFuel LiPo 1300mAh Battery
  • 1x big Selfmade BreakOutBoard to connect all components
  • 1x small BreakOutBoard to connect IMU

Hardware developed with Catia V5R20

Manufactoring Technology: Rapid Prototyping - EOS Formiga P110

Controlled via text based menu with DockLight

__________________

Committer:
DimitriGruebel
Date:
Wed Jul 09 07:35:50 2014 +0000
Revision:
0:1447d2f773db
Dynamics Test Platform

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DimitriGruebel 0:1447d2f773db 1 /*
DimitriGruebel 0:1447d2f773db 2 Copyright (c) 2010 Andy Kirkham
DimitriGruebel 0:1447d2f773db 3
DimitriGruebel 0:1447d2f773db 4 Permission is hereby granted, free of charge, to any person obtaining a copy
DimitriGruebel 0:1447d2f773db 5 of this software and associated documentation files (the "Software"), to deal
DimitriGruebel 0:1447d2f773db 6 in the Software without restriction, including without limitation the rights
DimitriGruebel 0:1447d2f773db 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
DimitriGruebel 0:1447d2f773db 8 copies of the Software, and to permit persons to whom the Software is
DimitriGruebel 0:1447d2f773db 9 furnished to do so, subject to the following conditions:
DimitriGruebel 0:1447d2f773db 10
DimitriGruebel 0:1447d2f773db 11 The above copyright notice and this permission notice shall be included in
DimitriGruebel 0:1447d2f773db 12 all copies or substantial portions of the Software.
DimitriGruebel 0:1447d2f773db 13
DimitriGruebel 0:1447d2f773db 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
DimitriGruebel 0:1447d2f773db 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
DimitriGruebel 0:1447d2f773db 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
DimitriGruebel 0:1447d2f773db 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
DimitriGruebel 0:1447d2f773db 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
DimitriGruebel 0:1447d2f773db 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
DimitriGruebel 0:1447d2f773db 20 THE SOFTWARE.
DimitriGruebel 0:1447d2f773db 21 */
DimitriGruebel 0:1447d2f773db 22
DimitriGruebel 0:1447d2f773db 23 #include "MODSERIAL.h"
DimitriGruebel 0:1447d2f773db 24 #include "MACROS.h"
DimitriGruebel 0:1447d2f773db 25
DimitriGruebel 0:1447d2f773db 26 namespace AjK {
DimitriGruebel 0:1447d2f773db 27
DimitriGruebel 0:1447d2f773db 28 int
DimitriGruebel 0:1447d2f773db 29 MODSERIAL::resizeBuffer(int size, IrqType type, bool memory_check)
DimitriGruebel 0:1447d2f773db 30 {
DimitriGruebel 0:1447d2f773db 31 int rval = Ok;
DimitriGruebel 0:1447d2f773db 32
DimitriGruebel 0:1447d2f773db 33 // If the requested size is the same as the current size there's nothing to do,
DimitriGruebel 0:1447d2f773db 34 // just continue to use the same buffer as it's fine as it is.
DimitriGruebel 0:1447d2f773db 35 if (buffer_size[type] == size) return rval;
DimitriGruebel 0:1447d2f773db 36
DimitriGruebel 0:1447d2f773db 37 // Make sure the ISR cannot use the buffers while we are manipulating them.
DimitriGruebel 0:1447d2f773db 38 disableIrq();
DimitriGruebel 0:1447d2f773db 39
DimitriGruebel 0:1447d2f773db 40 // If the requested buffer size is larger than the current size,
DimitriGruebel 0:1447d2f773db 41 // attempt to create a new buffer and use it.
DimitriGruebel 0:1447d2f773db 42 if (buffer_size[type] < size) {
DimitriGruebel 0:1447d2f773db 43 rval = upSizeBuffer(size, type, memory_check);
DimitriGruebel 0:1447d2f773db 44 }
DimitriGruebel 0:1447d2f773db 45 else if (buffer_size[type] > size) {
DimitriGruebel 0:1447d2f773db 46 rval = downSizeBuffer(size, type, memory_check);
DimitriGruebel 0:1447d2f773db 47 }
DimitriGruebel 0:1447d2f773db 48
DimitriGruebel 0:1447d2f773db 49 // Start the ISR system again with the new buffers.
DimitriGruebel 0:1447d2f773db 50 enableIrq();
DimitriGruebel 0:1447d2f773db 51
DimitriGruebel 0:1447d2f773db 52 return rval;
DimitriGruebel 0:1447d2f773db 53 }
DimitriGruebel 0:1447d2f773db 54
DimitriGruebel 0:1447d2f773db 55 int
DimitriGruebel 0:1447d2f773db 56 MODSERIAL::downSizeBuffer(int size, IrqType type, bool memory_check)
DimitriGruebel 0:1447d2f773db 57 {
DimitriGruebel 0:1447d2f773db 58 if (size >= buffer_count[type]) {
DimitriGruebel 0:1447d2f773db 59 return BufferOversize;
DimitriGruebel 0:1447d2f773db 60 }
DimitriGruebel 0:1447d2f773db 61
DimitriGruebel 0:1447d2f773db 62 char *s = (char *)malloc(size);
DimitriGruebel 0:1447d2f773db 63
DimitriGruebel 0:1447d2f773db 64 if (s == (char *)NULL) {
DimitriGruebel 0:1447d2f773db 65 if (memory_check) {
DimitriGruebel 0:1447d2f773db 66 error("Failed to allocate memory for %s buffer", type == TxIrq ? "TX" : "RX");
DimitriGruebel 0:1447d2f773db 67 }
DimitriGruebel 0:1447d2f773db 68 return NoMemory;
DimitriGruebel 0:1447d2f773db 69 }
DimitriGruebel 0:1447d2f773db 70
DimitriGruebel 0:1447d2f773db 71 int c, new_in = 0;
DimitriGruebel 0:1447d2f773db 72
DimitriGruebel 0:1447d2f773db 73 do {
DimitriGruebel 0:1447d2f773db 74 c = __getc(false);
DimitriGruebel 0:1447d2f773db 75 if (c != -1) s[new_in++] = (char)c;
DimitriGruebel 0:1447d2f773db 76 if (new_in >= size) new_in = 0;
DimitriGruebel 0:1447d2f773db 77 }
DimitriGruebel 0:1447d2f773db 78 while (c != -1);
DimitriGruebel 0:1447d2f773db 79
DimitriGruebel 0:1447d2f773db 80 free((char *)buffer[type]);
DimitriGruebel 0:1447d2f773db 81 buffer[type] = s;
DimitriGruebel 0:1447d2f773db 82 buffer_in[type] = new_in;
DimitriGruebel 0:1447d2f773db 83 buffer_out[type] = 0;
DimitriGruebel 0:1447d2f773db 84 return Ok;
DimitriGruebel 0:1447d2f773db 85 }
DimitriGruebel 0:1447d2f773db 86
DimitriGruebel 0:1447d2f773db 87 int
DimitriGruebel 0:1447d2f773db 88 MODSERIAL::upSizeBuffer(int size, IrqType type, bool memory_check)
DimitriGruebel 0:1447d2f773db 89 {
DimitriGruebel 0:1447d2f773db 90 char *s = (char *)malloc(size);
DimitriGruebel 0:1447d2f773db 91
DimitriGruebel 0:1447d2f773db 92 if (s == (char *)NULL) {
DimitriGruebel 0:1447d2f773db 93 if (memory_check) {
DimitriGruebel 0:1447d2f773db 94 error("Failed to allocate memory for %s buffer", type == TxIrq ? "TX" : "RX");
DimitriGruebel 0:1447d2f773db 95 }
DimitriGruebel 0:1447d2f773db 96 return NoMemory;
DimitriGruebel 0:1447d2f773db 97 }
DimitriGruebel 0:1447d2f773db 98
DimitriGruebel 0:1447d2f773db 99 if (buffer_count[type] == 0) { // Current buffer empty?
DimitriGruebel 0:1447d2f773db 100 free((char *)buffer[type]);
DimitriGruebel 0:1447d2f773db 101 buffer[type] = s;
DimitriGruebel 0:1447d2f773db 102 buffer_in[type] = 0;
DimitriGruebel 0:1447d2f773db 103 buffer_out[type] = 0;
DimitriGruebel 0:1447d2f773db 104 }
DimitriGruebel 0:1447d2f773db 105 else { // Copy the current contents into the new buffer.
DimitriGruebel 0:1447d2f773db 106 int c, new_in = 0;
DimitriGruebel 0:1447d2f773db 107 do {
DimitriGruebel 0:1447d2f773db 108 c = __getc(false);
DimitriGruebel 0:1447d2f773db 109 if (c != -1) s[new_in++] = (char)c;
DimitriGruebel 0:1447d2f773db 110 if (new_in >= size) new_in = 0; // Shouldn't happen, but be sure.
DimitriGruebel 0:1447d2f773db 111 }
DimitriGruebel 0:1447d2f773db 112 while (c != -1);
DimitriGruebel 0:1447d2f773db 113 free((char *)buffer[type]);
DimitriGruebel 0:1447d2f773db 114 buffer[type] = s;
DimitriGruebel 0:1447d2f773db 115 buffer_in[type] = new_in;
DimitriGruebel 0:1447d2f773db 116 buffer_out[type] = 0;
DimitriGruebel 0:1447d2f773db 117 }
DimitriGruebel 0:1447d2f773db 118
DimitriGruebel 0:1447d2f773db 119 buffer_size[type] = size;
DimitriGruebel 0:1447d2f773db 120 return Ok;
DimitriGruebel 0:1447d2f773db 121 }
DimitriGruebel 0:1447d2f773db 122
DimitriGruebel 0:1447d2f773db 123 }; // namespace AjK ends