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 #ifdef COMPILE_EXAMPLE1_CODE_MODSERIAL
DimitriGruebel 0:1447d2f773db 2
DimitriGruebel 0:1447d2f773db 3 /*
DimitriGruebel 0:1447d2f773db 4 * To run this test program, link p9 to p10 so the Serial loops
DimitriGruebel 0:1447d2f773db 5 * back and receives characters it sends.
DimitriGruebel 0:1447d2f773db 6 */
DimitriGruebel 0:1447d2f773db 7
DimitriGruebel 0:1447d2f773db 8 #include "mbed.h"
DimitriGruebel 0:1447d2f773db 9 #include "MODSERIAL.h"
DimitriGruebel 0:1447d2f773db 10
DimitriGruebel 0:1447d2f773db 11 DigitalOut led1(LED1);
DimitriGruebel 0:1447d2f773db 12 DigitalOut led2(LED2);
DimitriGruebel 0:1447d2f773db 13 DigitalOut led3(LED3);
DimitriGruebel 0:1447d2f773db 14 DigitalOut led4(LED4);
DimitriGruebel 0:1447d2f773db 15
DimitriGruebel 0:1447d2f773db 16 MODSERIAL pc(USBTX, USBRX);
DimitriGruebel 0:1447d2f773db 17
DimitriGruebel 0:1447d2f773db 18 /*
DimitriGruebel 0:1447d2f773db 19 * As experiement, you can define MODSERIAL as show here and see what
DimitriGruebel 0:1447d2f773db 20 * effects it has on the LEDs.
DimitriGruebel 0:1447d2f773db 21 *
DimitriGruebel 0:1447d2f773db 22 * MODSERIAL uart(TX_PIN, RX_PIN, 512);
DimitriGruebel 0:1447d2f773db 23 * With this, the 512 characters sent can straight into the buffer
DimitriGruebel 0:1447d2f773db 24 * vary quickly. This means LED1 is only on briefly as the TX buffer
DimitriGruebel 0:1447d2f773db 25 * fills.
DimitriGruebel 0:1447d2f773db 26 *
DimitriGruebel 0:1447d2f773db 27 * MODSERIAL uart(TX_PIN, RX_PIN, 32);
DimitriGruebel 0:1447d2f773db 28 * With this, the buffer is smaller than the default 256 bytes and
DimitriGruebel 0:1447d2f773db 29 * therefore LED1 stays on much longer while the system waits for
DimitriGruebel 0:1447d2f773db 30 * room in the TX buffer.
DimitriGruebel 0:1447d2f773db 31 */
DimitriGruebel 0:1447d2f773db 32 MODSERIAL uart(TX_PIN, RX_PIN);
DimitriGruebel 0:1447d2f773db 33
DimitriGruebel 0:1447d2f773db 34 // This function is called when a character goes from the TX buffer
DimitriGruebel 0:1447d2f773db 35 // to the Uart THR FIFO register.
DimitriGruebel 0:1447d2f773db 36 void txCallback(MODSERIAL_IRQ_INFO *q) {
DimitriGruebel 0:1447d2f773db 37 led2 = !led2;
DimitriGruebel 0:1447d2f773db 38 }
DimitriGruebel 0:1447d2f773db 39
DimitriGruebel 0:1447d2f773db 40 // This function is called when TX buffer goes empty
DimitriGruebel 0:1447d2f773db 41 void txEmpty(MODSERIAL_IRQ_INFO *q) {
DimitriGruebel 0:1447d2f773db 42 led2 = 0;
DimitriGruebel 0:1447d2f773db 43 pc.puts(" Done. ");
DimitriGruebel 0:1447d2f773db 44 }
DimitriGruebel 0:1447d2f773db 45
DimitriGruebel 0:1447d2f773db 46 // This function is called when a character goes into the RX buffer.
DimitriGruebel 0:1447d2f773db 47 void rxCallback(MODSERIAL_IRQ_INFO *q) {
DimitriGruebel 0:1447d2f773db 48 led3 = !led3;
DimitriGruebel 0:1447d2f773db 49 pc.putc(uart.getc());
DimitriGruebel 0:1447d2f773db 50 }
DimitriGruebel 0:1447d2f773db 51
DimitriGruebel 0:1447d2f773db 52 int main() {
DimitriGruebel 0:1447d2f773db 53 int c = 'A';
DimitriGruebel 0:1447d2f773db 54
DimitriGruebel 0:1447d2f773db 55 // Ensure the baud rate for the PC "USB" serial is much
DimitriGruebel 0:1447d2f773db 56 // higher than "uart" baud rate below.
DimitriGruebel 0:1447d2f773db 57 pc.baud(PC_BAUD);
DimitriGruebel 0:1447d2f773db 58
DimitriGruebel 0:1447d2f773db 59 // Use a deliberatly slow baud to fill up the TX buffer
DimitriGruebel 0:1447d2f773db 60 uart.baud(1200);
DimitriGruebel 0:1447d2f773db 61
DimitriGruebel 0:1447d2f773db 62 uart.attach(&txCallback, MODSERIAL::TxIrq);
DimitriGruebel 0:1447d2f773db 63 uart.attach(&rxCallback, MODSERIAL::RxIrq);
DimitriGruebel 0:1447d2f773db 64 uart.attach(&txEmpty, MODSERIAL::TxEmpty);
DimitriGruebel 0:1447d2f773db 65
DimitriGruebel 0:1447d2f773db 66 // Loop sending characters. We send 512
DimitriGruebel 0:1447d2f773db 67 // which is twice the default TX/RX buffer size.
DimitriGruebel 0:1447d2f773db 68
DimitriGruebel 0:1447d2f773db 69 led1 = 1; // Show start of sending with LED1.
DimitriGruebel 0:1447d2f773db 70
DimitriGruebel 0:1447d2f773db 71 for (int loop = 0; loop < 512; loop++) {
DimitriGruebel 0:1447d2f773db 72 uart.printf("%c", c);
DimitriGruebel 0:1447d2f773db 73 c++;
DimitriGruebel 0:1447d2f773db 74 if (c > 'Z') c = 'A';
DimitriGruebel 0:1447d2f773db 75 }
DimitriGruebel 0:1447d2f773db 76
DimitriGruebel 0:1447d2f773db 77 led1 = 0; // Show the end of sending by switching off LED1.
DimitriGruebel 0:1447d2f773db 78
DimitriGruebel 0:1447d2f773db 79 // End program. Flash LED4. Notice how LED 2 and 3 continue
DimitriGruebel 0:1447d2f773db 80 // to flash for a short period while the interrupt system
DimitriGruebel 0:1447d2f773db 81 // continues to send the characters left in the TX buffer.
DimitriGruebel 0:1447d2f773db 82
DimitriGruebel 0:1447d2f773db 83 while(1) {
DimitriGruebel 0:1447d2f773db 84 led4 = !led4;
DimitriGruebel 0:1447d2f773db 85 wait(0.25);
DimitriGruebel 0:1447d2f773db 86 }
DimitriGruebel 0:1447d2f773db 87 }
DimitriGruebel 0:1447d2f773db 88
DimitriGruebel 0:1447d2f773db 89 /*
DimitriGruebel 0:1447d2f773db 90 * Notes. Here is the sort of output you can expect on your PC/Mac/Linux host
DimitriGruebel 0:1447d2f773db 91 * machine that is connected to the "pc" USB serial port.
DimitriGruebel 0:1447d2f773db 92 *
DimitriGruebel 0:1447d2f773db 93 * ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUV
DimitriGruebel 0:1447d2f773db 94 * WXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR
DimitriGruebel 0:1447d2f773db 95 * STUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN
DimitriGruebel 0:1447d2f773db 96 * OPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ
DimitriGruebel 0:1447d2f773db 97 * KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF
DimitriGruebel 0:1447d2f773db 98 * GHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB
DimitriGruebel 0:1447d2f773db 99 * CDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQ Done. R
DimitriGruebel 0:1447d2f773db 100 *
DimitriGruebel 0:1447d2f773db 101 * Of interest is that last "R" character after the system has said "Done."
DimitriGruebel 0:1447d2f773db 102 * This comes from the fact that the TxEmpty callback is made when the TX buffer
DimitriGruebel 0:1447d2f773db 103 * becomes empty. MODSERIAL makes use of the fact that the Uarts built into the
DimitriGruebel 0:1447d2f773db 104 * LPC17xx device use a 16 byte FIFO on both RX and TX channels. This means that
DimitriGruebel 0:1447d2f773db 105 * when the TxEmpty callback is made, the TX buffer is empty, but that just means
DimitriGruebel 0:1447d2f773db 106 * the "last few characters" were written to the TX FIFO. So although the TX
DimitriGruebel 0:1447d2f773db 107 * buffer has gone empty, the Uart's transmit system is still sending any remaining
DimitriGruebel 0:1447d2f773db 108 * characters from it's TX FIFO. If you want to be truely sure all the characters
DimitriGruebel 0:1447d2f773db 109 * you have sent have left the Mbed then call txIsBusy(); This function will
DimitriGruebel 0:1447d2f773db 110 * return true if characters are still being sent. If it returns false after
DimitriGruebel 0:1447d2f773db 111 * the Tx buffer is empty then all your characters have been sent.
DimitriGruebel 0:1447d2f773db 112 *
DimitriGruebel 0:1447d2f773db 113 * In a similar way, when characters are received into the RX FIFO, the entire
DimitriGruebel 0:1447d2f773db 114 * FIFO contents is moved to the RX buffer, assuming there is room left in the
DimitriGruebel 0:1447d2f773db 115 * RX buffer. If there is not, any remaining characters are left in the RX FIFO
DimitriGruebel 0:1447d2f773db 116 * and will be moved to the RX buffer on the next interrupt or when the running
DimitriGruebel 0:1447d2f773db 117 * program removes a character(s) from the RX buffer with the getc() method.
DimitriGruebel 0:1447d2f773db 118 */
DimitriGruebel 0:1447d2f773db 119
DimitriGruebel 0:1447d2f773db 120 #endif