Software developpement » History » Version 8

BASTIDE, Paul, 03/23/2016 11:21 AM

1 1 BASTIDE, Paul
h1. Software developpement
2 1 BASTIDE, Paul
3 3 BASTIDE, Paul
The software we are proposing is a variation of the software proposed in the [[Sputnik strikes back:| Sputnik strikes back]] project, software desgin. 
4 1 BASTIDE, Paul
As them, we are going to retriev on a sensor data, tranform it in a more appropriate format so as to send it by the RF transmitter.
5 1 BASTIDE, Paul
6 1 BASTIDE, Paul
h2. General principle
7 1 BASTIDE, Paul
8 1 BASTIDE, Paul
p. We are developping for an RTOS, a real time operating system. As presented in the generalities //LINK HERE, this kind of software runs on a task driven event basis. That is to say we are creating tasks inside infinite loop (so that they keep running) and a scheduler will be operating the shift between the tasks. 
9 5 BASTIDE, Paul
10 7 BASTIDE, Paul
p. In order for the tasks to release or take the processing power they need, the system rune a priority basis : tasks with higher priority, when they need to process, interrupts tsks with lower priorities ta take control. These high priorities tasks need to release the control in order for the lower priority tasks to be able to run.  This is done by what we call a "context switch" functionality present in the scheduler, and notably in the _"OS_Delay()"_ function that enables the tasks to wait and release the prcessing power to another task.
11 5 BASTIDE, Paul
12 1 BASTIDE, Paul
p. In order to set the timing between the tasks, we will implementflags, which will serve to determine when some functionalities will be accessed in the tasks. These flags have to be set by other tasks to manage the workflow between tasks.
13 1 BASTIDE, Paul
14 1 BASTIDE, Paul
h2. Software definition
15 1 BASTIDE, Paul
16 4 BASTIDE, Paul
h3. Tasks definition
17 4 BASTIDE, Paul
18 4 BASTIDE, Paul
p. We are going to define the following tasks and function :
19 7 BASTIDE, Paul
* _task_temp_phys()_: this task is the main one, is used to send to the RF transmitter the bits.
20 7 BASTIDE, Paul
* _sensor_get_update()_ : task used to retrieve from the ADC the voltage value and fill the buffer with the temperature
21 7 BASTIDE, Paul
* _init_ADC()_: used in sensor_update to initialize the ADC registers
22 7 BASTIDE, Paul
* _bin_volt()_: used to convert the results from the ADC to a temperature
23 7 BASTIDE, Paul
* _celcius_coding()_ : used to convert the temperarture over a 7-bits word.
24 4 BASTIDE, Paul
25 4 BASTIDE, Paul
p. We created the following buffer to conserve the data
26 7 BASTIDE, Paul
* _bitCharBuf_: contains the 7-bits word we are planning to send
27 4 BASTIDE, Paul
28 4 BASTIDE, Paul
p. We are using the following flags :
29 7 BASTIDE, Paul
* _rts_flag_ : Ready To Send flag, allow the main task to know when data is ready to be sent.
30 7 BASTIDE, Paul
* _cod_flag_ : Flag used to tell the update function that all the data has been sent and it can now retrieve the data
31 1 BASTIDE, Paul
32 1 BASTIDE, Paul
h3. Sequence of events
33 1 BASTIDE, Paul
34 1 BASTIDE, Paul
p. We are retrieving data from the thermocouple thanks to the _sensor_get_update()_. As the sensor is intern, we can set our own frequency in the retrieving of the data. We are supposing that the dynamic of the temperature we want to measure is slow, that's why we are going to scan on wire at a time and not simultaneoulsy.
35 6 BASTIDE, Paul
36 8 BASTIDE, Paul
p. Once the two analog inputs have been scanned, we are using _bin_voltage()_ function to convert the ADC output value to a voltage, and then map the voltage difference to a negative or positive temperature thanks to known tables associated to the thermocouple.
37 1 BASTIDE, Paul
38 8 BASTIDE, Paul
p. When the temperature value has been identified, we are translating it to a 7-bit word by using the _celcius_coding()_ function.
39 8 BASTIDE, Paul
The format chosen for the 7-bits word is the following "0bsdddddd" where:
40 8 BASTIDE, Paul
* s contains the sign of the temperature, "1" being positive and "0" bieng negative
41 8 BASTIDE, Paul
* "dddddd" : contains the absolute value of the temperature. As the range of temperature we are considereing  was determined as [-20 : +40] in the lab conditions, we can code it on 6 bits (2<notextile></notextile>^6^ = 64).
42 6 BASTIDE, Paul
When the word is ready, we are setting the _rts_flag_ so that the main tasks knows data is ready to be sent.
43 6 BASTIDE, Paul
44 7 BASTIDE, Paul
p. once the _task_temp_phy()_ "sees" that the _rts_flag_ has been set, it takes over and begins to transmit to the lower level (RF transmitter). It transmit to th RF transmitter by setting the I/O output port wired to the RF to high when a "1" has to be transmitted and to low when a "0" has to be transmitted.
45 7 BASTIDE, Paul
As a Manchester encoding has been selected to comply with the bit rate of the RF transmitter (see [[Sptunik strikes back:]]), we are sendding for half a bit period a "1" if the bit transmitted is "1", and "0" on the second half period. The reverse is done when the bit to be transmitted is a "0".
46 7 BASTIDE, Paul
47 7 BASTIDE, Paul
p. Once a bit has been trasnmitted, we increase a _bitpointer_ value, refering to the index in the word to be transmitted, and we send the next bit. This continue until all the bits have been transmitted. finally, the task set the _rts_flag_ to "0" to signify the temperature has been sent, set the _cod_flag_ to "1" to ask for new data, and go back to an idle state