III - Advanced Project » History » Version 59
COLIN, Tony, 12/16/2015 06:07 PM
1 | 25 | COLIN, Tony | h1. III - Advanced Project. |
---|---|---|---|
2 | 1 | COLIN, Tony | |
3 | 1 | COLIN, Tony | {{>toc}} |
4 | 1 | COLIN, Tony | |
5 | 25 | COLIN, Tony | h2. 1. Adapting project to elementary task. |
6 | 1 | COLIN, Tony | |
7 | 43 | COLIN, Tony | See [[II - Tutorial - Simple project on CubeSat Kit#"3. Creation of a simple MPLAB X IDE project"|Tutorial page]] for project bases. |
8 | 34 | COLIN, Tony | In this part, you will have to modify particular files of the previous folder Test/. |
9 | 1 | COLIN, Tony | |
10 | 26 | COLIN, Tony | h3. 1.1 Integration of C Source files into task(s). |
11 | 25 | COLIN, Tony | |
12 | 27 | COLIN, Tony | * *task_name.c* stating _void task_name (void) { ... }_. |
13 | 26 | COLIN, Tony | Here you can either call the C main function in the task_name function or adapting your main file into one or several tasks (for simultaneity during process). |
14 | 25 | COLIN, Tony | |
15 | 27 | COLIN, Tony | * *task_name.h* stating _extern void task_name (void);_ and other intern functions. |
16 | 25 | COLIN, Tony | |
17 | 26 | COLIN, Tony | h3. 1.2 Definition of your task(s) to be called. |
18 | 25 | COLIN, Tony | |
19 | 28 | COLIN, Tony | * *tasks.h* defining OSTCBP of all predifined tasks i.e. the way of specifying a pointer to a particular Salvo _Task Control Block_. More information is available on Salvo User Manual. |
20 | 25 | COLIN, Tony | |
21 | 27 | COLIN, Tony | * *task_cmd.c* which is a tool provided by Test/ that allows to resume/stop your task(s). |
22 | 32 | COLIN, Tony | !task_cmd.png! |
23 | 25 | COLIN, Tony | |
24 | 28 | COLIN, Tony | * *main.c* i.e. the basic implementation to call your task(s). All statements are essential for Salvo and CSK to work. |
25 | 32 | COLIN, Tony | !main.png! |
26 | 1 | COLIN, Tony | |
27 | 30 | COLIN, Tony | |
28 | 1 | COLIN, Tony | --- |
29 | 1 | COLIN, Tony | |
30 | 25 | COLIN, Tony | h2. 2. Integration of a Reed-Solomon encoder/decoder. |
31 | 1 | COLIN, Tony | |
32 | 25 | COLIN, Tony | A highly convenient implementation of a Reed-Solomon code is available on "RS Code Website":http://rscode.sourceforge.net/ and will be integrated in the following. |
33 | 1 | COLIN, Tony | |
34 | 53 | COLIN, Tony | h3. 2.1 Presentation of Reed-Solomon (n=255,k=239,t=8). |
35 | 28 | COLIN, Tony | |
36 | 29 | COLIN, Tony | This is an implementation of a Reed-Solomon code with 8 bit bytes, and a configurable number of parity bytes. The maximum sequence length (codeword) that can be generated is 255 bytes, including parity bytes. It provides the following C/H - files : |
37 | 29 | COLIN, Tony | (1) *rs.c*, (2) *berlekamp.c*, (3) *crcgen.c*, (4) *ecc.h* and (5) *example.c* |
38 | 29 | COLIN, Tony | |
39 | 29 | COLIN, Tony | The *rs.c* file contains an algorithm to generate the encoder polynomial for any number of bytes of parity, configurable as the _NPAR_ constant in the file *ecc.h*. For this RS code, G(x) = (x-a^1)(x-a^2)(x-a^3)(x-a^4)...(x-a^NPAR) where 'a' is a primitive element of the Galois Field GF(256). |
40 | 29 | COLIN, Tony | *rs.c* contains also a decoder that generates four syndrome bytes, which will be all zero if the message has no errors. |
41 | 29 | COLIN, Tony | The more general error-location algorithm is the Berlekamp-Massey algorithm (implemented in *berlekamp.c*), which will locate up to four errors, by iteratively solving for the error-locator polynomial. |
42 | 29 | COLIN, Tony | |
43 | 28 | COLIN, Tony | More information is available on attachment:rs.doc and attachment:config.doc. |
44 | 1 | COLIN, Tony | |
45 | 25 | COLIN, Tony | h3. 2.2 Task Example. |
46 | 29 | COLIN, Tony | |
47 | 38 | COLIN, Tony | The example of Reed-Solomon code *example.c* can be used to implement our encoder/decoder in a simple task. See [[III - Advanced Project#"1.1 Integration of C Source files into task(s)."|1.1]] and [[III - Advanced Project#"1.2 Definition of your task(s) to be called."|1.2]] for the definition and integration of *task_example.c* |
48 | 1 | COLIN, Tony | |
49 | 38 | COLIN, Tony | * The following message (or information word) is considered at the encoder : |
50 | 38 | COLIN, Tony | !CodingWin3.png! |
51 | 54 | COLIN, Tony | *Message of 86 characters (or bytes)* |
52 | 1 | COLIN, Tony | |
53 | 38 | COLIN, Tony | * Then, errors due to a fictional channel are added to the codeword : |
54 | 38 | COLIN, Tony | !CodingWin2.png! |
55 | 38 | COLIN, Tony | *Code of adding errors* |
56 | 38 | COLIN, Tony | |
57 | 1 | COLIN, Tony | --- |
58 | 25 | COLIN, Tony | |
59 | 17 | COLIN, Tony | h2. 3. Displaying results. |
60 | 32 | COLIN, Tony | |
61 | 1 | COLIN, Tony | h3. 3.1 In simulation. |
62 | 1 | COLIN, Tony | |
63 | 38 | COLIN, Tony | First of all, we want to simulate the behavior of the dsPIC33 and get an output message window in order to watch our results : |
64 | 38 | COLIN, Tony | 1. Right-click on your project > Properties > Chose Simulator as Hardware Tool > Apply |
65 | 38 | COLIN, Tony | 2. Right-click on your project > Properties > Simulator > Chose Uart IO Options > Check Enable Uart1 IO > Apply |
66 | 40 | COLIN, Tony | |
67 | 40 | COLIN, Tony | p=. !UART1.png! |
68 | 17 | COLIN, Tony | *Checking Output UART Window* |
69 | 1 | COLIN, Tony | |
70 | 1 | COLIN, Tony | After building and debugging the program (through Debug Main Project), results are printed in the UART 1 Output window : |
71 | 40 | COLIN, Tony | |
72 | 40 | COLIN, Tony | p=. !CodingWin1_red.png! |
73 | 1 | COLIN, Tony | *Displayed result* |
74 | 40 | COLIN, Tony | |
75 | 38 | COLIN, Tony | It is now possible to see the codeword, the errors and the correction. |
76 | 20 | COLIN, Tony | |
77 | 25 | COLIN, Tony | h3. 3.2 On board. |
78 | 17 | COLIN, Tony | |
79 | 39 | COLIN, Tony | Henceforth, we can switch from the Simulator to ICD3 and connect the development board. It has been necessary to plug in some LEDs on the board to see the evolution of the program without interface and compare it to the previous results. |
80 | 39 | COLIN, Tony | |
81 | 39 | COLIN, Tony | In this part, we are focusing the last byte of the message : |
82 | 35 | COLIN, Tony | |
83 | 17 | COLIN, Tony | |_.- |_.Char |_.Code ASCII |_.Hexadecimal |_. Binary | |
84 | 15 | COLIN, Tony | |_.Codeword |=. 2 |=. 50 |=. 0x32 | 0b00110010 | |
85 | 58 | COLIN, Tony | |_.Error pattern |=. - |=. - |=. 0x01 | 0b00000001 | |
86 | 15 | COLIN, Tony | |_.Erroneous Codeword |=. 3 |=. 51 |=. 0x33 | 0b00110011 | |
87 | 58 | COLIN, Tony | |
88 | 58 | COLIN, Tony | Indeed, we denote the modification of the last character from 2 to 3 i.e. from 0b00110010 to 0b00110011 that can be illustrated by LEDs : 1 -> light, 0 -> no light. |
89 | 35 | COLIN, Tony | |
90 | 56 | COLIN, Tony | A first function _void display_6bits(unsigned char* string, int index)_ has been written in order to light up the six LEDs according to the six most right bits of the binary representation of the character indicated by the _index_ in _string_ (See the end of [[I - Equipment]]). A second function _void reset_leds(void)_ switchs off the LEDs. |
91 | 2 | COLIN, Tony | |
92 | 15 | COLIN, Tony | !LEDs_resized.png! !LEDs_error_resized.png! !LEDs_resized.png! |
93 | 7 | COLIN, Tony | __________________ *a. Codeword : 0bXX110010* ________________________ *b. Erroneous codeword : 0bXX110011* ____________________ *c. Corrected codeword : 0bXX110010* ______________ |
94 | 22 | COLIN, Tony | |
95 | 25 | COLIN, Tony | --- |
96 | 49 | COLIN, Tony | |
97 | 49 | COLIN, Tony | h2. 4. Complete project. |
98 | 49 | COLIN, Tony | |
99 | 59 | COLIN, Tony | This project is available on Files widget. |
100 | 1 | COLIN, Tony | Note that it has been built by including and putting together all necessary Inc/ Src/ and Lib/ needed and described in the Tutorial. Moreover the adapted files of the Reed-Solomon encoding/decoding are available in Reed_Solomon_Code/ |
101 | 53 | COLIN, Tony | |
102 | 55 | COLIN, Tony | p=. !Structure.png! |
103 | 53 | COLIN, Tony | *Tree of folders* |
104 | 49 | COLIN, Tony | |
105 | 49 | COLIN, Tony | Please take care by adding these folders to your project to have the following configurations : |
106 | 49 | COLIN, Tony | |
107 | 49 | COLIN, Tony | p=. !Final_Project.png! |
108 | 49 | COLIN, Tony | *Structure of project* |
109 | 49 | COLIN, Tony | |
110 | 49 | COLIN, Tony | p=. !Final_Project2.png! |
111 | 50 | COLIN, Tony | *Including common directories.* _NB:Take care of the order!_ |
112 | 49 | COLIN, Tony | |
113 | 49 | COLIN, Tony | For more information, visit the Tutorial. |