Você está na página 1de 9

Embedded Software Architectures

The architectures are driven by the need for response time.


Round-Robin (or superloop). Round-Robin with interrupts Non-preemptive Real-Time Operating System Preemptive Real-Time Operating System

Round-Robin (or superloop) A main loop checks each of the I/O devices and services each in a prescribed order.
void main() { init(); while(1) { task1(); task2(); ... } }

Example A digital multimeter which checks the position of a switch, reads a value from a proble, performs an ADC conversion and then displays the result on an LCD is such an example. Advantage Works well when there are few I/O devices, no lengthy processing, and no tight response requirements. Disadvantage If any device has a response time which is less than the time required to get around the superloop. If any of the tasks requires length processing. Modification made to meet requirements results in a fragile architecture. Round-Robin with interrupts A main loop checks each of the I/O devices and services each in a prescribed order. Interrupts are used to deal with the time constrained I/O devices.
int8 data_for_device_A; void main() { init(); while(1) { task1(); task2(); ... if (global_flag_A) taskA(); } } void ISR_deviceA() {

service_A(data_for_device_A); set(global_flag_A); }

Example 36 position rotary encoder which selects which function to perform on a DS1302 real time clock. Assume that it takes 100mS to read the time from the DS1302. We assume that we want to be able to monitor the rotary encoder when it is turned slower than 1 rotation per second. This means that we must examine the rotary encoder at least 36 clicks/sec * 4 detents / click = 144 detents / sec or 7mS / detent. Thus, we need to put either the DS1302 or the rotart encoder onto an interrupt so that we can perform both tasks. Advantage Simple. Disadvantage Open to problems associated with shared data. All the tasks in main operate with the same priority. For example, a laser printer spends lots of time calculating where to put the tiny dots of ink. Main would then get "stuck" working on this task at the exclusion of all the other tasks. Moving the other tasks into ISRs is a solution, but then a low priority interrupt might take to long to service. In addition, if there were a pair of time consuming tasks then one of them would always have to wait for the other. Interrupt Background We will be entering into the real time operating system portion of the course. In order to start our exploration of real time operating systems we should have some context of interrupts. We can do this by examining the fiollowing questions.

How does the MCU know where to find the ISR? Can the MCU interrupt in the middle of an instruction? If 2 interrupts occur at the same time which interrupt is serviced first? Can an interrupt interrupt another ISR? What happen to an interrupt if interrupts are disabled? What happen if interrupts are disabled and not reenabled? What happens if I disable/enable interrupts and their are already disabled/enabled?

Shared Data Problem As soon as we use interrupts to share information between an ISR and main we can create problems. The foundation for these problems arises from the fact that we don't want the ISR to perform all the work. Generally, we use the ISR to manipulate some I/O device and pass all the work of actually processing the information from the sensor to main.

The problems that can arise from sharing data between an ISR and main are shown in the following code snippet. In this example we are to monitor the temperature from two sensors and set off an alarm if these are different (we are to assume that this condition indicates that there is a problem with the sensors that someone needs to know about). Figure 4.4 So where is the error? Well it arises out of a sequsnce of events. 1. The temperature is changing. 2. We have just finished executing the "iTemp0..." line in main 3. The interrupt occurs and updates both values of iTemp[] The alarm will sound even though there was no real error. Even worse this error will not be repeatiable. This is a instance of a so-called Heisenbug. How about trying the following fix? Figure 4.5 Well this really doesn;t work either. So how to we solve this problem. Well go the source. The interrupt is the real culprit, if it occurs when we are making the comparition then we can get a problem. The solution will consist of making a "critical section" around the comparison, not allowing interrupts to occur. Figure 4.7 These are logical errors caused when independent programs are allowed to read and write the same variable. In order to refresh your memory, lets look at the following example, Figure 4.9 from the text. In this example, a hardware interrupt triggers the
UpdateTime once every second. The SecSinceMidnight function is called by a user program to determine the number of seconds since midnight. Can you see where the shared data bug resides? The bug occurs if an interrupt occurs while the "return" statement of the SecSinceModnight is being executed. Since we know that this C statement translates into several lines of assembly language, changing the values of iHr, iMin, and iSec when some of them have already been used can create incorrect values being generated by this function. An interesting follow-up question is, "how wrong can this function be?"
Before Interrupt 3 59 59 After Interrupt 4 00 00 Value used by SecSinceMidnight 3 00 00

iHr iMin iSec

Interrupt Latency
If we enable and disable interrupts to solve the problems associated with the shared data problem then we will increase the interrupts latency; the time delay between the occurrence of an

interrupting event and its being serviced. In some cases you will need to calculate the latency, so how can you do this? You need to know 4 things. 1. The longest period of time that the interrupt is disabled. 2. The length of time required to service interrupts at a higher priority level. 3. The time required to enter an ISR. This is MCU book-keeping required to save the state of the MCU so that its not perturbed by the ISR. 4. How long if takes the ISR to set itself up and then "service" the interrupting event. Lets look at an example 1. You have to disable interrupts for 125uS for your task code to use a pair of temperature variables it shares with the interrupt routine that reads the temperatures from the hardware and writes them into the variables. 2. You have to disable interrupts for 250uS for your task code to get the tie variables from variables it shares with the interrupt routine that responds to the timer interrupt. 3. It takes 10uS for the MSU to switch contexts. 4. You must complete a response within 625uS when you get a special signal (an interrupt) from another processor in your system; the inter-processor interrupt routine takes 300uS to complete. This solution assumes that the interprocessor communication is given the highest priority and there are no other interrupts with that interrupt priority. Always work these types of problems assuming a worst-case scenerio from the current state of the MCU to the resolution of the interrupt. That is assume that we have just entered the portion of the foreground code which disables the intterputs. Interrupts are disabled for 250uS, it takes 10uS to switch to the interprocess ISR, and interprocess communications require 300uS. Thus it takes 560uS to service this requires, well within the 625uS requirement. What if we assumed that all the interrupts were of the same priority?

Non-blocking Solutions to the Shared Data Problem

Tentang Apollo Guidance Computer


Posted on December 7, 2012 by yusniaalfisyahrin
Salah satu prestasi paling menonjol dari abad ke-20 adalah pendaratan manusia di bulan pada 20 Juli 1969. Penggunaan teknologi komputasi untuk sampai ke sana sering disinggung, tetapi jenis hardware dan software apakah yang diperlukan?

Sejumlah besar daya komputasi dalam bentuk mainframe dan minicomputer melakukan misi penting-perencanaan perhitungan di tanah sebelum, selama, dan setelah perjalanan. Yang kurang terkenal adalah kisah kotak 70-lb sirkuit terpadu dan panel kontrol terpasang secara real-time guidance dan kontrol dan yang berfungsi sebagai penghubung untuk para astronot turun ke permukaan bulan. Perakit di Raytheon gedung pengujian modul AGC (Apollo Guidance Computer).

Apollo Guidance Computer (AGC) dibangun oleh Raytheon dan digunakan sekitar 4000 sirkuit terpadu diskrit dari Semi konduktor Fairchild. Hampir satu dekade pembangunan proyek, AGC dimulai sebagai sebuah proyek penelitian di Lab Instrumentasi MIT di Cambridge, Massachusetts. Laboratorium adalah rumah bagi para ahli terkemuka di dunia dalam bimbingan dan kontrol, di mana Polaris dan program rudal bimbingan Poseidon dikembangkan. Namun, sampai Apollo, semua perhitungan untuk persamaan gerak dalam sistem ini dilakukan oleh komputer analog. Pada April 1961, NASA kontrak dengan MIT untuk mempelajari kelayakan dari suatu sistem kontrol digital untuk program Apollo.

Pada saat itu, sirkuit terpadu yang sederhana (mungkin sebuah gerbang AND atau dua per chip) dan yang sangat mahal Texas Instruments, misalnya, menjual IC tersebut kepada militer untuk sekitar masing-masing $1000. Seperti begitu banyak proyek, belakang mengungkapkan kompleksitas tidak dihargai pada saat itu. Eldon Hall, desainer utama dari AGC, mencatat bahwa jika mereka tahu apa yang mereka pelajari nanti, atau memiliki satu set lengkap spesifikasi telah tersedia mereka mungkin akan menyimpulkan bahwa tidak ada solusi dengan teknologi awal tahun enam puluhan.

Meskipun demikian, tim bekerja pada persyaratan perhitungan misi umum (disimulasikan pada mainframe dan mini) pada saat yang sama sebagai pengembangan IC mengakibatkan dramatis (bahkan kemudian) perbaikan dalam biaya, fungsi, dan kehandalan. Pada tahun 1964, ketika Philco-Ford terpilih untuk memasok IC, harga telah turun menjadi $25 perbuah. Rope Core Memory AGC menggunakan bentuk unik dari Read Only Memory (ROM) yang dikenal sebagai Rope Core Memory untuk menyimpan program operasi. Teknologi ini merupakan turunan dari memori inti magnetik tetapi bekerja dengan cara yang sedikit berbeda: bukan magnetizing inti individu searah jarum jam atau berlawanan arah jarum jam untuk menyimpan 1 atau 0, Rope Core Memory diperlakukan masing-masing inti sebagai inti transformator dalam matriks kabel diskrit. Kabel berjalan melalui inti menyimpan 1, mereka melewati

inti mewakili 0. Interaksi dengan AGC adalah melalui DSKY (Display Keyboard), atau disebut diskey, di mana astronot menggunakan benda + sintaks verba. Kata benda dan kata kerja yang dimasukkan menggunakan tabel lookup yang silang kata tertentu dengan nilai numerik. Sebuah entri khas sehingga mungkin: DISPLAY + VELOCITY atau LOAD + ANGLE. Sistem berjalan eksekutif yang ditangani (biasanya) sekitar 40 proses konkuren dan membolehkan adanyan gangguan dari berbagai sistem sensor serta inputan astronot. Hal itu mampu digagalkan dengan baik, dimana selama keturunan lunar sebagai subsistem radar mulai mengirim data terlalu banyak untuk itu. Hal itu juga cukup kuat untuk menangani serangan petir saat Apollo 12 berada di landasan peluncuran sesaat sebelum lepas landas.

Datangnya pengembangan Perangkat Lunak Rekayasa Perangkat Lunak berlangsung pada sebuah komputer mini Honeywell 1.800 yang berjalan pada sepersepuluh kecepatan real-time dari AGC. Seperti di setiap modul pada AGC adalah ditaruh, yaitu, dicelupkan ke dalam senyawa epoxy tahan air untuk melindungi dalam ruang, ada tekanan besar pada tim perangkat lunak untuk secara khusus didedikasikan untuk bebas dari kesalahan pembangunan. Sayangnya, ada beberapa prosedur untuk memastikan konsistensi dan tim software MIT sedang belajar baik dari coding dan aspek perangkat lunak manajemen proyek pada pekerjaan. Ko nsep Rekayasa Perangkat Lunak, diciptakan pada tahun 1968-baik ke program-berusaha untuk menerapkan konsep rekayasa hardware untuk coding. Secara khusus, konsep siklus hidup perangkat lunak (definisi, desain, coding, pengujian, pemeliharaan) hanya muncul sebagai paradigma di NASA untuk memproduksi perangkat lunak keandalan tinggi yang diharapkan dalam suatu sistem di mana kehidupan manusia sedang dipertaruhkan. Bahkan saat Apollo 11 awak-Armstrong, Aldrin, dan Collins-duduk di landasan peluncuran, dokumentasi hanya ada pada daftar program AGC tersendiri.

Tentang Apollo Guidance Computer Apollo Guidance Computer (AGC) adalah sebuah komputer digital yang diproduksi untuk program Apollo yang dipasang onboard pada setiap Apollo Command Module (CM) dan Lunar Module (LM). AGC mendukung perhitungan dan antarmuka elektronik untuk bimbingan, navigasi, dan kontrol dari pesawat ruang angkasa. AGC memiliki word length sebesar 16-bit, dengan 15 bit data dan satu bit paritas. Sebagian besar perangkat lunak pada AGC disimpan dalam read only memory (ROM) khusus yang dikenal sebagai cope rope memory yang dibentuk oleh tenun kabel melalui core magnet, meskipun sejumlah kecil baca-tulis core memory disediakan.

Astronot dikomunikasikan dengan AGC menggunakan tampilan numerik dan tombol yang disebut DSKY (Display Keyboard). AGC dan antarmuka pengguna DSKY yang dikembangkan pada awal 1960-an untuk program Apollo oleh Laboratorium Instrumentasi MIT. AGC penting untuk menjadi salah satu sirkuit terintegrasi berbasis komputer yang pertama.

Operasi

Setiap penerbangan ke Bulan (dengan pengecualian dari Apollo 8, yang tidak mengambil Lunar Modul pada misi orbit lunar-nya) memiliki dua AGC, masing-masing dalam Command Modul (CM) dan Lunar Module (LM). AGC diCommand Modul berada di pusat bimbingan bahwa pesawat ruang angkasa dan sistem navigasi (G & C). AGC di Modul Lunar dijalankan pada Apollo PGNCS (Primary Guidance, Navigation and Control System), atau disingkatpings.

Setiap misi lunar memiliki dua komputer tambahan, yang pertama yaitu Launch Vehicle Digital Computer (LVDC) pada Saturnus V penguat instrumentasi cincin, yang kedua adalah Abort Guidance System (AGS) dari Lunar Module, yang akan digunakan dalam hal kegagalan LM PGNCS. AGS dapat digunakan untuk lepas landas dari Bulan, dan bertemu dengan Command Module, tetapi tidak termasuk saat mendarat.

Desain dari Apollo Guidance Computer AGC dirancang di Laboratorium Instrumentasi MIT di bawah pengawasan Charles Stark Draper, dengan desain hardware yang dipimpin oleh Eldon C. Hall. Awal karya arsitektur berasal dari JH Laning Jr, Albert Hopkins, Ramon Alonso, dan Hugh Blair-Smith. Hardware penerbangan itu dibuat oleh Raytheon, yang Herb Thaler juga di tim arsitektur.

Komputer penerbangan Apollo merupakan komputer pertama yang menggunakan sirkuit terpadu (IC) . Sementara Blok I versi yang digunakan 4.100 IC, masing-masing berisi satu 3-masukan gerbang NOR , Blok II nanti (yang digunakan dalam penerbangan berawak) versi digunakan IC 2.800, masing-masing dengan dua masukan 3-NOR gerbang. IC, dari Fairchild Semi konduktor, yang dilaksanakan dengan menggunakan resistor-transistor logika (RTL) dalam paket datar. Mereka terhubung melalui bungkus kawat, dan kabel itu kemudian tertanam di plastikepoxy. Penggunaan satu jenis IC (yang NOR3 ganda) di seluruh AGC menghindari masalah yang mendera lain desain IC komputer awal, Minuteman II guidance computer, yang menggunakan campuran dioda-transistor logika dan gerbang logika dioda.

Komputer tersebut memiliki 2.048 words magnetic core memory yang dapat dihapus dan 36 kilowords dari readonly core rope memory. Keduanya memiliki waktu siklus 11,72 mikro-detik. Word length dari memori sebesar 16 bit: 15 bit data dan 1 aneh- bit paritas . CPU - internal 16-bit format word adalah 14 bit data, 1 overflow bit, dan 1 bit tanda. Antarmuka dari DSKY User interface ke AGC adalah DSKY, berdiri untuk display dan keyboard yang biasanya disebut dengan dis-key. Antarmuka ini memiliki sebuah array dari lampu indikator, menampilkan numerik dan keyboard kalkulator. Perintah yang dimasukkan adalah numerik, sebagai dua-digit angka: Verb, dan Noun. Verb menggambarkan jenis tindakan yang akan dilakukan dan Noun ditentukan mana data yang dipengaruhi oleh tindakan ditentukan oleh perintah Verb.

Pada tahun 2009, DSKY yang dijual dalam lelang publik yang diselenggarakan oleh Heritage Auctions sebesar $ 50.788.

Software Apollo Guidance Computer AGC software ditulis dalam bahasa assembly AGC dan disimpan di rope memory. Ada sistem operasi real-time sederhana yang terdiri dari Exec, penjadwalan pekerjaan batch sistem yang bisa bekerja hingga delapan pekerjaan pada waktu menggunakan multi-tasking kooperatif (tiap pekerjaan harus menyerahkan kontrol kembali ke Exec secara berkala kemudian diperiksa apakah ada pekerjaan yang menunggu dengan prioritas yang lebih tinggi). Ada juga komponen interrupt-driven yang disebut daftar tunggu yang bisa menjadwalkan beberapa tugas time-driven. Tugasnya berupa jalur eksekusi pendek yang bisa menjadwal ulang untuk re-eksekusi pada daftar tunggu, atau bisa memulai operasi lagi dengan memulai pekerjaan dengan Exec tersebut.

AGC juga memiliki interpreter perangkat lunak yang canggih, yang dikembangkan oleh MIT, yang menerapkan mesin virtual dengan lebih kompleks dan mampu melakukan pseudo-instruction dari AGC asli. Instruksi ini disederhanakan oleh program navigasi. Rata-rata pseudo-instruction yang dibutuhkan sekitar 24 ms untuk mengeksekusi. Assembler dan kontrol versi sistem, bernama YUL ditegakkan transisi yang tepat antara kode asli dan diinterpretasikan.

Satu set interrupt-driven rutinitas user interface yang disebut Pinball menyediakan keyboard dan jasa tampilan untuk pekerjaan dan tugas-tugas berjalan pada AGC. Satu set banyak diakses pengguna secara rutin yang diberikan untuk membiarkan operator (astronot) menampilkan isi dari lokasi memori berbagai oktal atau desimal dalam kelompok 1, 2, atau 3 register pada suatu waktu rutinitas monitor yang disediakan sehingga operator bisa melakukan tugas secara berkala dan menampilkan kembali isi dari lokasi memori tertentu. Pekerjaan apat dimulai. Secara berkala Pinball melakukan setara dengan shell UNIX.

Sebagian besar perangkat lunak pada read-only rope memory tidak bisa diubah dalam operasi, tetapi beberapa bagian penting dari perangkat lunak yang disimpan dalam standar rea d-write magnetic core memory dan bisa ditimpa oleh astronot menggunakan antarmuka DSKY, seperti yang dilakukan pada Apollo 14 .

Aplikasi di Luar Apollo AGC membentuk dasar dari sebuah percobaan sistem fly-by-wire yang terinstal menjadi Crusader F-8 untuk menunjukkan kepraktisan komputer driven FBW. AGC yang digunakan dalam tahap pertama program tersebut diganti dengan komputer lain pada fase kedua, dan penelitian yang dilakukan pada program ini menyebabkan perkembangan sistem fly-by-wire untuk Space Shuttle. AGC juga memimpin, meskipun tidak langsung, untuk sistem fly-by-wire untuk generasi pejuang yang sedang dikembangkan pada saat itu. AGC juga digunakan untuk Angkatan Laut Amerika Serikat, Deep Submergence Rescue Vehicle.

Você também pode gostar