Software » History » Version 2
Version 1 (PRIETO, Matías, 03/22/2015 03:13 AM) → Version 2/44 (PRIETO, Matías, 03/22/2015 03:17 AM)
h1. Software Design
{{>toc}}
System behavior is controlled by the MCU integrated in the motherboard, which communicates with other subsystems through the Cubesat Kit Bus. The MCU is programmed in C language based on the RTOS Salvos. Therefore, the stack implementation is programmed under these constraints.
Figure below presents the final implemented communication stack of the system as part of the communication chain design.
p=. !{width:40%}cubesat_stack.png!
_Communication stack._
h2. Concepts
h3. NMEA sentences
h3. Manchester encoding
h2. Overall program description
The Salvo OS is a multitask operative system, based on the definition of multiple tasks. Each task is implemented inside an infinite loop.
The system main program is composed by two tasks. One in charge of L2+L1, controlling the physical layer and the other one in charge of acquiring plus filtering data from the GPS module, and formatting it (L4). In addition, a specific function is in charge of mapping the native ASCII messages coming from L4, into Baudot alphabet (L3) to be sent to L2+L1.
h3. Tasks, functions and main data structures description
Task and functions definition:
* _task_gps_update()_
* _task_rtty_phy()_
* _baud_coding()_
* _baudTranslate()_
* _inc_pointer()_
Data buffers definition:
* _asciiCharBuf[RTTY_BUFFER_SIZE]_
* _rtty_buffer[2*RTTY_BUFFER_SIZE]_
Main system flags:
* _rts_flag_
* _cod_flag_
h3. Program workflow
Data coming from GPS is retrieved from the USART CSK_0 register. Since data is continuously sent character by character at a rate of 1 NMEA sentence per second, the _task_gps_update()_ have to filter the incoming characters waiting the right sequence which represents the start of a valid NMEA sentence. Then, characters must be stored in a buffer up to receive the end of sentence indicator character. The string stored in the ASCII buffer (_asciiCharBuf_) is the message that has be then sent to lower layers, representing the information held by the beacon. Optionally, an additional fixed messaged can be added to this buffer.
Once beacon message is defined, the task call the function _baud_coding()_, which maps the stored chars in the ASCII buffer to the Baudot alphabet. Finally, the output (the message in Baudot format) is stored in another buffer (_rtty_buffer_). This function, is supported by the function _baudTranslate()_, which is called for each character to perform a search and translation of symbols using a look-up table.
Once data in the Baudot buffer is ready, a ready to send flag (_rts_flag_) is set to indicate the task which manage L2-L1 that there is data available ready to be sent.
_task_rtty_phy()_ is in charge of controlling lower layers and generate the output signal (at _IO.0_) which controls the 2-FSK transmitter. This task runs continuously and has the highest priority.
Since a clock is required to generate the output signal, the task uses the OS timer. This timer is set to one tick per millisecond, this is 1000 ticks per second. Since baudrate is 125, the bit period $T_b$ is 8 msec and the task uses 8 OS ticks per bit.
Each bit period $T_b$, the task performs an iteration and retrieves the bit to be sent at L3. Then it implements Manchester by setting the output signal (at _IO.0_) at 0 (or 1) during $T_b/2$ and then switching to 1 (or 0) during other $T_b/2$.
{{>toc}}
System behavior is controlled by the MCU integrated in the motherboard, which communicates with other subsystems through the Cubesat Kit Bus. The MCU is programmed in C language based on the RTOS Salvos. Therefore, the stack implementation is programmed under these constraints.
Figure below presents the final implemented communication stack of the system as part of the communication chain design.
p=. !{width:40%}cubesat_stack.png!
_Communication stack._
h2. Concepts
h3. NMEA sentences
h3. Manchester encoding
h2. Overall program description
The Salvo OS is a multitask operative system, based on the definition of multiple tasks. Each task is implemented inside an infinite loop.
The system main program is composed by two tasks. One in charge of L2+L1, controlling the physical layer and the other one in charge of acquiring plus filtering data from the GPS module, and formatting it (L4). In addition, a specific function is in charge of mapping the native ASCII messages coming from L4, into Baudot alphabet (L3) to be sent to L2+L1.
h3. Tasks, functions and main data structures description
Task and functions definition:
* _task_gps_update()_
* _task_rtty_phy()_
* _baud_coding()_
* _baudTranslate()_
* _inc_pointer()_
Data buffers definition:
* _asciiCharBuf[RTTY_BUFFER_SIZE]_
* _rtty_buffer[2*RTTY_BUFFER_SIZE]_
Main system flags:
* _rts_flag_
* _cod_flag_
h3. Program workflow
Data coming from GPS is retrieved from the USART CSK_0 register. Since data is continuously sent character by character at a rate of 1 NMEA sentence per second, the _task_gps_update()_ have to filter the incoming characters waiting the right sequence which represents the start of a valid NMEA sentence. Then, characters must be stored in a buffer up to receive the end of sentence indicator character. The string stored in the ASCII buffer (_asciiCharBuf_) is the message that has be then sent to lower layers, representing the information held by the beacon. Optionally, an additional fixed messaged can be added to this buffer.
Once beacon message is defined, the task call the function _baud_coding()_, which maps the stored chars in the ASCII buffer to the Baudot alphabet. Finally, the output (the message in Baudot format) is stored in another buffer (_rtty_buffer_). This function, is supported by the function _baudTranslate()_, which is called for each character to perform a search and translation of symbols using a look-up table.
Once data in the Baudot buffer is ready, a ready to send flag (_rts_flag_) is set to indicate the task which manage L2-L1 that there is data available ready to be sent.
_task_rtty_phy()_ is in charge of controlling lower layers and generate the output signal (at _IO.0_) which controls the 2-FSK transmitter. This task runs continuously and has the highest priority.
Since a clock is required to generate the output signal, the task uses the OS timer. This timer is set to one tick per millisecond, this is 1000 ticks per second. Since baudrate is 125, the bit period $T_b$ is 8 msec and the task uses 8 OS ticks per bit.
Each bit period $T_b$, the task performs an iteration and retrieves the bit to be sent at L3. Then it implements Manchester by setting the output signal (at _IO.0_) at 0 (or 1) during $T_b/2$ and then switching to 1 (or 0) during other $T_b/2$.