diff options
author | Julian T <julian@jtle.dk> | 2020-06-08 11:50:57 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-06-08 11:50:57 +0200 |
commit | d309dc0217fe6e0165f1f425503f4f6112a3914d (patch) | |
tree | c9c371447345e9954bc6587737be7d0d797996bd | |
parent | 6075c41624efa8260344dfd4b0c7fa563f4cfe5e (diff) |
Færdiggjorde embedded. Bestod :-D
-rw-r--r-- | sem4/embedded/eksamnen/M65f1.png | 14 | ||||
-rw-r--r-- | sem4/embedded/eksamnen/M7opg.adoc | 10 | ||||
-rw-r--r-- | sem4/embedded/eksamnen/M8opg.adoc | 1 | ||||
-rw-r--r-- | sem4/embedded/eksamnen/m7cap.sr | bin | 0 -> 562 bytes | |||
-rw-r--r-- | sem4/embedded/eksamnen/notes.adoc | 85 | ||||
-rw-r--r-- | sem4/embedded/m7/m7.ino | 51 |
6 files changed, 158 insertions, 3 deletions
diff --git a/sem4/embedded/eksamnen/M65f1.png b/sem4/embedded/eksamnen/M65f1.png new file mode 100644 index 0000000..2fb34c8 --- /dev/null +++ b/sem4/embedded/eksamnen/M65f1.png @@ -0,0 +1,14 @@ +The name is too long, 260 chars total. +Trying to shorten... +New name is JO_DQiCm48JlUeebTx-2IKWkImyn29rA3wgzJWNwCLg9uhUljIL6nvtvPaQwSh6vrE3LdCAM8iK2duOf0yP2URKpVO5bCDW36DS4NBzvvq910DGzCEKq4xEBhuQ5j5J_tpDffTox6Jvet-pI2G_7cxTxhzpktNNHb9trWCzBQzFuxCpReqVlar7A80oUrZAyfvgGtUkd3ECvXXg6kXs2GV6Nz1kFgpsrMQFCJFeCjhyU. +--2020-06-08 09:21:52-- http://www.plantuml.com/plantuml/png/JO_DQiCm48JlUeebTx-2IKWkImyn29rA3wgzJWNwCLg9uhUljIL6nvtvPaQwSh6vrE3LdCAM8iK2duOf0yP2URKpVO5bCDW36DS4NBzvvq910DGzCEKq4xEBhuQ5j5J_tpDffTox6Jvet-pI2G_7cxTxhzpktNNHb9trWCzBQzFuxCpReqVlar7A80oUrZAyfvgGtUkd3ECvXXg6kXs2GV6Nz1kFgpsrMQFCJFeCjhyUMn8Ih7aIaj7p6kNnLufB3VuF +Resolving www.plantuml.com (www.plantuml.com)... 104.31.70.56, 104.31.71.56, 172.67.211.21, ... +Connecting to www.plantuml.com (www.plantuml.com)|104.31.70.56|:80... connected. +HTTP request sent, awaiting response... 200 OK +Length: unspecified [image/png] +Saving to: ‘JO_DQiCm48JlUeebTx-2IKWkImyn29rA3wgzJWNwCLg9uhUljIL6nvtvPaQwSh6vrE3LdCAM8iK2duOf0yP2URKpVO5bCDW36DS4NBzvvq910DGzCEKq4xEBhuQ5j5J_tpDffTox6Jvet-pI2G_7cxTxhzpktNNHb9trWCzBQzFuxCpReqVlar7A80oUrZAyfvgGtUkd3ECvXXg6kXs2GV6Nz1kFgpsrMQFCJFeCjhyU’ + + 0K .......... .... 1.27M=0.01s + +2020-06-08 09:21:53 (1.27 MB/s) - ‘JO_DQiCm48JlUeebTx-2IKWkImyn29rA3wgzJWNwCLg9uhUljIL6nvtvPaQwSh6vrE3LdCAM8iK2duOf0yP2URKpVO5bCDW36DS4NBzvvq910DGzCEKq4xEBhuQ5j5J_tpDffTox6Jvet-pI2G_7cxTxhzpktNNHb9trWCzBQzFuxCpReqVlar7A80oUrZAyfvgGtUkd3ECvXXg6kXs2GV6Nz1kFgpsrMQFCJFeCjhyU’ saved [15293] + diff --git a/sem4/embedded/eksamnen/M7opg.adoc b/sem4/embedded/eksamnen/M7opg.adoc index 4be491a..f974c6b 100644 --- a/sem4/embedded/eksamnen/M7opg.adoc +++ b/sem4/embedded/eksamnen/M7opg.adoc @@ -47,3 +47,13 @@ Eftersom de begge har en complete tid på 20 vil de altid ende på t=40. Dette er helt fint i begge tilfælde da ingen af dem har deadline inden 40. +=== Opgave 5 + + +Implement the example of ex. 4 in JDN's kernel (krnl) on Arduino. +Measure computation time of task1 with an oscilloscope/logic analyser. +Measure the time between ready and scheduling instant with oscilloscope/logic analyser. +Measure the time between ready and completion instant with oscilloscope/logic analyser. + + +=== Løsning diff --git a/sem4/embedded/eksamnen/M8opg.adoc b/sem4/embedded/eksamnen/M8opg.adoc index 59f8031..c716a41 100644 --- a/sem4/embedded/eksamnen/M8opg.adoc +++ b/sem4/embedded/eksamnen/M8opg.adoc @@ -1,4 +1,5 @@ = Opgaver til gang 8 +:stem: == Opgave 1 diff --git a/sem4/embedded/eksamnen/m7cap.sr b/sem4/embedded/eksamnen/m7cap.sr Binary files differnew file mode 100644 index 0000000..7b22690 --- /dev/null +++ b/sem4/embedded/eksamnen/m7cap.sr diff --git a/sem4/embedded/eksamnen/notes.adoc b/sem4/embedded/eksamnen/notes.adoc index 736c275..a1e682a 100644 --- a/sem4/embedded/eksamnen/notes.adoc +++ b/sem4/embedded/eksamnen/notes.adoc @@ -7,7 +7,8 @@ Show code and explain for 1,4,5,6 (design and impl ISR, time based debouncing, tick routing, limitations) ____ -TODO med arduino. Og debouncer. +Se ../m1/int/int.ino. +Se ../m1/router/router.ino. == Opgave løsning @@ -303,6 +304,86 @@ ____ Exercise 1 in part3 on page295 (Pdf is on moodle) ____ +=== Løsning + +____ +_Evaluate the timing requirements of the system_ +____ + +Det er vigtigt at beskederne mellem sensor og DAC kommer ordenligt igennem. +Derfor er de dele realtime, mens keypad, display og serial er firm-realtime. +Det er ikke soft da det stadig er vigtigt for piloten at det han får at vide er rigtigt +og at hans kommandoer sker hurtigt, men ikke så vigtigt som DAC. + +____ +_Define the major software functions to be carried out by the system as a set of +software subsystems._ +____ + +User interface:: + Handles display and keyboard, and gets information from info subsystem. + This handles IO with the display and takes input from the user via keypad. +Info subsystem:: + Collect information sent from CPU and sends this on serial IO and User interface. + It therefore handles the serial IO terminator. +Processing submodule:: + Receives updates from sensor and adc, processes the data and sends it to DAC and Info system. + Updates to the info system are done non-blocking and because it's only firm + updates are okay to not be sent. + Updates to DAC are blocking and must be done before the deadline. + +____ +_Show all information flow, both between subsystems and to/from IO devices._ +____ + +Har lavet er på plantuml. + +image::M65f1.png[] + +---- +@startuml +component [User Interface] as UI +component [Info subsystem] as IS +component [Processing submodule] as PS + +interface Keypad +interface Display +interface DAC +interface "Serial IO" as SIO +interface ADC +interface CPU + +UI -left- Keypad +UI -right-> Display +IS -up-> UI +UI -down-> PS + +IS -> SIO +PS -right-> IS +ADC -up-> PS +PS -down- CPU +PS -down-> DAC +@enduml +---- + +____ +_How would you design the software if all the code had to be contained within a +single sequential program._ +____ + +Her ville jeg lave en slags tick router og sørre for at alle task kører super hurtigt. +For eksempel skulle user interface måske have mere swithing inde i sig selv. + +____ +_Redesign the software assuming that interrupt-driven activities are allowed._ +____ + +Interrupt giver mulighed for at køre OS og preimetive multitasking. +Jeg vil have hvert subsystem i en task, som så kører med forskellig hastighed. + +Hvis sensor kommer apriodisk ville det nok være smart at have en interrupt dertil, +samt en til keypad. + == H3 module 7 ____ @@ -311,8 +392,6 @@ ____ Se ./M7opg.adoc -TODO lav arduino opgaver. TODO lav måske lidt flere af opgaverne. - === Noter *Scheduling* er når flere opgaver eller jobs skal time shares på en CPU. diff --git a/sem4/embedded/m7/m7.ino b/sem4/embedded/m7/m7.ino new file mode 100644 index 0000000..27b1ea2 --- /dev/null +++ b/sem4/embedded/m7/m7.ino @@ -0,0 +1,51 @@ +#include <krnl.h> +#define STACK 200 + +char stk1[STACK]; +char stk2[STACK]; +struct k_t *tsk1, *tsk2, *sem1, *sem2; + +#define DELAY 100000 +void f1() { + k_set_sem_timer(sem1, 50); + for(;;) { + k_wait(sem1, 0); + PORTD &= ~(1 << 5); + PORTD |= (1 << 4); + k_eat_msec_time(20); + PORTD &= ~(1 << 4); + } +} + +void f2() { + k_set_sem_timer(sem2, 80); + for(;;) { + k_wait(sem2, 0); + PORTD &= ~(1 << 5); + PORTD |= (1 << 3); + k_eat_msec_time(20); + PORTD &= ~(1 << 3); + } +} + +void setup() { + pinMode(13, OUTPUT); + pinMode(3, OUTPUT); + pinMode(4, OUTPUT); + Serial.begin(115200); + Serial.println("Starting"); + + k_init(2, 2, 0); + + sem1 = k_crt_sem(0, 1); + sem2 = k_crt_sem(0, 1); + + tsk1 = k_crt_task(f1, 10, stk1, STACK); + tsk2 = k_crt_task(f2, 10, stk2, STACK); + + k_start(1); +} + +void loop() { + +} |