III - Advanced Project » History » Version 36
Version 35 (COLIN, Tony, 12/14/2015 10:52 AM) → Version 36/59 (COLIN, Tony, 12/14/2015 10:59 AM)
h1. III - Advanced Project.
{{>toc}}
h2. 1. Adapting project to elementary task.
See [[Wiki#"3. Creation of a simple MPLAB X IDE project"|Tutorial page]] for project bases.
In this part, you will have to modify particular files of the previous folder Test/.
h3. 1.1 Integration of C Source files into task(s).
* *task_name.c* stating _void task_name (void) { ... }_.
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).
* *task_name.h* stating _extern void task_name (void);_ and other intern functions.
h3. 1.2 Definition of your task(s) to be called.
* *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.
* *task_cmd.c* which is a tool provided by Test/ that allows to resume/stop your task(s).
!task_cmd.png!
* *main.c* i.e. the basic implementation to call your task(s). All statements are essential for Salvo and CSK to work.
!main.png!
---
h2. 2. Integration of a Reed-Solomon encoder/decoder.
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.
h3. 2.1 Presentation of Reed-Solomon.
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 :
(1) *rs.c*, (2) *berlekamp.c*, (3) *crcgen.c*, (4) *ecc.h* and (5) *example.c*
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).
*rs.c* contains also a decoder that generates four syndrome bytes, which will be all zero if the message has no errors.
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.
More information is available on attachment:rs.doc and attachment:config.doc.
h3. 2.2 Task Example.
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*
---
h2. 3. Displaying results.
h3. 3.1 In simulation.
!CodingWin3.png!
*Message of 87 characters*
!CodingWin2.png!
*Code of adding errors*
!UART1.png!
*Checking Output UART Window*
!CodingWin1.png!
*Displayed result*
h3. 3.2 On board.
In this part, we are focusing the last byte of the message.
|_.- |_.Char |_.Code ASCII |_.Hexadecimal |_. Binary |
|_.Codeword |=. 2 |=. 50 |=. 0x32 | 0b00110010 |
|_.Erroneous Codeword |=. 3 |=. 51 |=. 0x33 | 0b00110011 |
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 most right six bits of the binary representation of the character indicated by the _index_ in _string_. A second function _void reset_leds(void)_ switchs off the LEDs.
!LEDs_resized.png! !LEDs_error_resized.png! !LEDs_resized.png!
__________________ *a. Codeword : 0bXX110010* ________________________ *b. Erroneous codeword : 0bXX110011* ____________________ *c. Corrected codeword : 0bXX110010* ______________
---
h2. 4. Measurement of encoding/decoding time.
POSIX requires that CLOCKS_PER_SEC equals 1000000 independent of the actual resolution.
!Clock1.png!
*1000 ticks per milliseconds*
!Clock2.png!
*Time measurement of data encoding*
!Clock3.png!
*Printing clock data*
p=. !Time_RS_resized.PNG!
*Chart of Reed Solomon time measurement*
{{>toc}}
h2. 1. Adapting project to elementary task.
See [[Wiki#"3. Creation of a simple MPLAB X IDE project"|Tutorial page]] for project bases.
In this part, you will have to modify particular files of the previous folder Test/.
h3. 1.1 Integration of C Source files into task(s).
* *task_name.c* stating _void task_name (void) { ... }_.
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).
* *task_name.h* stating _extern void task_name (void);_ and other intern functions.
h3. 1.2 Definition of your task(s) to be called.
* *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.
* *task_cmd.c* which is a tool provided by Test/ that allows to resume/stop your task(s).
!task_cmd.png!
* *main.c* i.e. the basic implementation to call your task(s). All statements are essential for Salvo and CSK to work.
!main.png!
---
h2. 2. Integration of a Reed-Solomon encoder/decoder.
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.
h3. 2.1 Presentation of Reed-Solomon.
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 :
(1) *rs.c*, (2) *berlekamp.c*, (3) *crcgen.c*, (4) *ecc.h* and (5) *example.c*
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).
*rs.c* contains also a decoder that generates four syndrome bytes, which will be all zero if the message has no errors.
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.
More information is available on attachment:rs.doc and attachment:config.doc.
h3. 2.2 Task Example.
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*
---
h2. 3. Displaying results.
h3. 3.1 In simulation.
!CodingWin3.png!
*Message of 87 characters*
!CodingWin2.png!
*Code of adding errors*
!UART1.png!
*Checking Output UART Window*
!CodingWin1.png!
*Displayed result*
h3. 3.2 On board.
In this part, we are focusing the last byte of the message.
|_.- |_.Char |_.Code ASCII |_.Hexadecimal |_. Binary |
|_.Codeword |=. 2 |=. 50 |=. 0x32 | 0b00110010 |
|_.Erroneous Codeword |=. 3 |=. 51 |=. 0x33 | 0b00110011 |
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 most right six bits of the binary representation of the character indicated by the _index_ in _string_. A second function _void reset_leds(void)_ switchs off the LEDs.
!LEDs_resized.png! !LEDs_error_resized.png! !LEDs_resized.png!
__________________ *a. Codeword : 0bXX110010* ________________________ *b. Erroneous codeword : 0bXX110011* ____________________ *c. Corrected codeword : 0bXX110010* ______________
---
h2. 4. Measurement of encoding/decoding time.
POSIX requires that CLOCKS_PER_SEC equals 1000000 independent of the actual resolution.
!Clock1.png!
*1000 ticks per milliseconds*
!Clock2.png!
*Time measurement of data encoding*
!Clock3.png!
*Printing clock data*
p=. !Time_RS_resized.PNG!
*Chart of Reed Solomon time measurement*