21 Nisan 2013 Pazar

Otomatik Kapatma Devresi

Bu yazı, linkteki makalenin Türkçe'ye çevrimidir. Bu yazı ile SPST anahtar barındıran cihazların otomatik açma-kapama işlemlerini yapacak basit bir devre anlatılmaktadır.


Bu yazıda anlatılan devre yerine bir mikrokontrolör devresi koyarak, anahtarları takip etmek ve uygun cihazı kapatmak da mümkündür, ancak burada hedeflenen, cihaz kapatıldığı anda mikrokontrolörün kendi gücü dahil olmak üzere tüm elektriği kesmesidir.


Devrenin temelinde zamanlayıcı olarak kullanılan bir AVR Tiny yer almaktadır. Bu zamanlayıcı, bir portu tetikleyecek ve belirlenen zaman geçtikten sonra da kapatacaktır.  Bu portun bacağı (pin) bir PNP transistörün baz (base) bacağına; PNP transistörün kaynak (collector/source) bacağı da NPN bir transistörün baz bacağına bağlanmıştır. NPN transistörün savak (emitter/drain) bacağı, anahtara ve bataryanın negatif kutbuna bağlanmıştır. Kaynak bacağı, zamanlayıcı devresinin (AVR Tiny) GND’sine bağlanacak ve aynı zamanda asıl devrenin gücünü de besleyecektir. Son olarak (asıl devre ve zamanlayıcı devresi ile) PNP’nin savak bacağı bataryanın pozitif kutbuna, 1K direnç üzerinden bağlanacaktır. Bu direnç, transistörlerin akımını sınırlandıracak ve aynı zamanda NPN’in doğrusal olmayan alanda (non-linear/switching region) çalışmasını sağlayacaktır.


Anahtar kapatıldığında devreyi başlatmak için PNP transistörün baz bacağı ile NPN transistörün savak bacağı arasına 1nF’lık bir kapasitör bağlanmıştır. Güç döngüye sokulduğunda devrenin hızlı olarak yeniden başlaması için 15pF’lık bir kapasitör, PNP transistörün baz ve savak bacakları arasına bağlanmıştır.






Kaynak-savak bağlantısı boyunca NPN üzerinde oluşan gerilim düşümü yaklaşık olarak 200mV’tur. Bu düşüm, asıl devreyi, eğer çok düşük bir empedans yük değilse, etkilemez.









Burada kullanılan mikrokontrolör AVR tiny85’tir, ancak bir kaç baytlık kod hafızası olan herhangi bir mikrokontrolör de kullanılabilir (tiny5 gibi). Kod oldukça basittir; çıkış port bacağı X’i düşük (low) konuma getir, zamanlayıcı dolduğunda ise port bacağını giriş (input) yap (HiZ). Kesmeler (interrupts), uyku modu (sleep mode) ve  gözcü saat kaynağı (watchdog clock source) gücü en düşük seviyede tutmak için kullanılmaktadır. C ile yazıldığında bile kod toplamda yalnızca 200 baytlık yer kaplamaktadır ki Assembly kullanıldığı taktirde bu boyut daha da düşük olacaktır.


AVR Kaynak Kodu
AVR HEX Kodu


NOT: Bu yazının aslı, gerekli kaynak kodlar ve diğer kısımlar şu linkte bulunabilir:

18 Ocak 2013 Cuma

Murphy'nin Teknoloji Yasaları


Internette sağdan soldan topladığım Murphy yasalarının teknoloji üzerine olanları. İleriki günlerde Türkçe'ye çevrilmişini de yazmaya çalışacağım.

  • Logic is a systematic method of coming to the wrong conclusion with confidence.
  • Whenever a system becomes completely defined, some damn fool discovers something which either abolishes the system or expands it beyond recognition.
  • Technology is dominated by those who manage what they do not understand.
  • If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization.
  • The opulence of the front office decor varies inversely with the fundamental solvency of the firm.
  • The attention span of a computer is only as long as it electrical cord.
  • An expert is one who knows more and more about less and less until he knows absolutely everything about nothing.
  • Tell a man there are 300 billion stars in the universe and he'll believe you. Tell him a bench has wet paint on it and he'll have to touch to be sure. 
  • Great discoveries are made by mistake.
  • Always draw your curves, then plot your reading.
  • Nothing ever gets built on schedule or within budget.
  • All's well that ends.
  • A meeting is an event at which the minutes are kept and the hours are lost.
  • The first myth of management is that it exists.
  • A failure will not appear till a unit has passed final inspection.
  • New systems generate new problems.
  • We don't know one millionth of one percent about anything.
  • Any sufficiently advanced technology is indistinguishable from magic.
  • A computer makes as many mistakes in two seconds as 20 men working 20 years make.
  • Nothing motivates a man more than to see his boss putting in an honest day's work.
  • Some people manage by the book, even though they don't know who wrote the book or even what book.
  • The primary function of the design engineer is to make things difficult for the fabricator and impossible for the serviceman.
  • To spot the expert, pick the one who predicts the job will take the longest and cost the most.
  • After all is said and done, a hell of a lot more is said than done.
  • Any circuit design must contain at least one part which is obsolete, two parts which are unobtainable and three parts which are still under development.
  • A complex system that works is invariably found to have evolved from a simple system that works.
  • If mathematically you end up with the incorrect answer, try multiplying by the page number.
  • Computers are unreliable, but humans are even more unreliable. Any system which depends on human reliability is unreliable.
  • Give all orders verbally. Never write anything down that might go into a "Pearl Harbor File."
  • Under the most rigorously controlled conditions of pressure, temperature, volume, humidity, and other variables the organism will do as it damn well pleases.
  • If you can't understand it, it is intuitively obvious.
  • The more cordial the buyer's secretary, the greater the odds that the competition already has the order.
  • In designing any type of construction, no overall dimension can be totaled correctly after 4:30 p.m. on Friday. The correct total will become self-evident at 8:15 a.m. on Monday.
  • Fill what's empty. Empty what's full. And scratch where it itches.
  • All things are possible except skiing through a revolving door.
  • The only perfect science is hind-sight.
  • If an experiment works, something has gone wrong.
  • When all else fails, read the instructions.
  • If there is a possibility of several things going wrong the one that will cause the most damage will be the one to go wrong.
  • Everything that goes up are not always must come down.
  • Any instrument when dropped will roll into the least accessible corner.
  • Any simple theory will be worded in the most complicated way.
  • Build a system that even a fool can use and only a fool will want to use it.
  • The degree of technical competence is inversely proportional to the level of management.
  • A difficult task will be halted near completion by one tiny, previously insignificant detail.
  • There is never time to do it right, but always time to do it over.
  • The remaining work to finish in order to reach your goal increases as the deadline approaches.
  • If there is ever the possibility of several things to go wrong, the one that will cause the most damage will be the one to go wrong.
  • If something breaks, and it stops you from doing something, it will be fixed when: you no longer need it, you are in the middle of something else, or you don't want it to be fixed, because you really don't want to do what you were supposed to do
  • Each profession talks to itself in it's own language, apparently there is no Rosetta Stone.
  • The more urgent the need for a decision to be made, less apparent become the identity of the decision maker.
  • It is never wise to let a piece of electronic equipment know that you are in a hurry.
  • Don't fix something that ain't broke, 'cause you'll break it and you still can't fix it
  • You can never tell which way the train went by looking at the track; but you can tell only by the splatter of the blood stains.
  • Dobie's Dogma: If you are not thoroughly confused, you have not been thoroughly informed.
  • A screw will never fit a nut.
  • Standard parts are not.
  • When working on a motor vehicle engine, any tool dropped will land directly under the center of the engine.
  • Never trust modern technology. Trust it only when it is old technology.
  • The bolt that is in the most awkward place will always be the one with the tightest thread.
  • The most ominous phrase in science: "_Uh_-oh . . ."
  • The 2nd worst thing you can hear the tech say is "Oops!" The worst thing you can hear the tech say is "oh s**t!"
  • Any example of hardware/software can be made fool-proof. It cannot, however, be made damn-fool-proof.
  • The Rossemblat Graphic Insult Theory: When any technological change is made, we have a graphic insult curve. No mater how high the insult curve climb, the important thing is how long it goes.
  • Bahaman's Law: For any given software, the moment you read software reviews and manage to master it, a new version of that software appears. Yakko's addition: The new version always manages to change the one feature you need most.
  • In today's fast-moving tech environment, it is a requirement that we forget more than we learn.
  • It is simple to make something complex, and complex to make it simple.
  • Measurements will be quoted in the least practical unit.
  • In electronics repair the part with the highest failure rate will always be located in the least accessible area of the equipment.
  • Multi-million pound technology is worthless in the hands of morons.
  • The rule of Protection: If you install a 50 cents fuse to protect a 100$ component, the 100$ component will blow to protect the 50 cents fuse.
  • Karl Imhoff was a German engineer who developed sewage treatment systems in the early 1900's. His biggest contribution was the Imhoff Tank, which allows sewage to settle. The Imhoff Law relates to bosses everywhere. The law goes as follows: The largest chunks always rise to the top.
  • An expert will always state the obvious.
  • The boss is always right. If the boss is wrong, refer back to the rule.
  • On a cruise ship, the one, most important part you don't have in stock always breaks on a Friday evening, just when you left harbor and the next time you will be in harbor is a Sunday or Christmas eve.
  • The chance a copy machine will brake down is proportional to the importance of the material that needs to be copied and inversely proportional to the amount of time till the material will be needed.
  • Maintenance department neglect customer's complains till it starts installations in customer's new projects.
  • Murphy's Law on HVAC systems: An HVAC (Heating Ventilating and Air Conditioning) engineering firm, will invariably lease office space in a building with a lousy HVAC system, and all the engineers can do is shiver or sweat and moan about it, and say how they would fix it if the building owner actually gave a damn.
  • The probability any machine breaks down increases with the importance of expected visit.
  • If it works in theory, it won't work in practice. if it works in practice it won't work in theory.
  • Research Law: No matter how clever and complete your research is, there is always someone who knows more.
  • Somers' Law of Repair: No part ever fails where you can reach it, or where there is enough light to see how to replace it.
  • Any tool dropped will fall where it can cause the most damage.
  • Any wire cut to length will be too short.
  • Equivalent replacement parts aren't.
  • When you finally update to a new technology, is when everyone stop supporting it.
  • Interchangeable parts aren't.
  • The proposed size of any project is inversely proportional to the size the project will eventually become. Any project that can consume more resources before reaching it's final state will do so, and this will happen faster than you think, and also, the investors will not be happy.
  • The less intelligent the idea, and the person stating it, the more likely it will be funded.
  • A man with one watch is certain about time. A man with two watches isn't.
  • The more knowledge you gained, the less certain you are of it..
  • If you think you understand science (or computers or women), you're clearly not an expert.
  • Technicians are the only ones that don't trust technology.
  • All impossible failures, will happen at the test site, and all impossible failures will happen on the clients desktop.
  • The more you want to contact someone over an instant messenger is inversely proportional to the chances that they will be on-line.
  • The more important your email is, the worse your email client will screw it up.
  • The degree to which a device will function is directly proportional to the number of times it has been bashed and inversely to its cost.
  • A device having an indestructible component or is user serviceable is deemed unsafe until it's replaced by an expensive, unobtainable, inefficient component which needs constant servicing.
  • Assaf's Laws of Replacement Parts: A failed 25 part cannot be replaced by a new 25 cents part, but by a sub-assembly whose cost is equal to or greater than that of the device in need of the part. The cost and availability of a replacement part are in inverse proportion to the cost of the whole system: a $1500 device will fail because of the burnout of a 25 cents capacitor. But the 25 cents capacitor is either; no longer manufactured, manufactured only by a company in Outer Mongolia with an 18-month backlog, available only as part of a $1450 sub-assembly.
  • All things mechanical/electrical will catastrophically fail after the guarantee has expired, unless an extended guarantee has been purchased.
  • The Harvard Principle: Under the most rigorously controlled conditions of temperature, humidity, pressure, etc., the organism will do as it damn well pleases.
  • First Law of Linear Equations:
  • Given any system n linear equations, there will be n+1 unknowns.
  • The disappearance of a nagging error in a system is explicable only in terms of  insignificant contribution of the source to that system.
  • The repairman will have never seen a model quite like yours before.
  • Law of Repairmen: The repairman fixes your machine to break down the next day and charges for a new machine.
  • While technology progresses at the speed of light it's implementation is filtered through the speed of bureaucracy.
  • In theory there is no difference between theory and practice, but in practice there is.
  • Stationary engineering law never underestimate incompetency.

8 Ağustos 2012 Çarşamba

MOSFET'lerin Bağlanma Şekilleri

Bu yazı ile N-Kanal MOSFET'lerin (Metal-Oxide-Semiconductor Field-Effect Transistor) bağlantı uçlarının bir hidrolik sisteme (musluk-batarya) benzetimi ile kolay anlaşılmasının sağlanması hedeflenmiştir.

En basit kullanım yeri ile MOSFET'leri açıklamak gerekirse; bir mikrokontrolör (microcontroller) ile sarmal bobin (solenoid), röle (relay), motor ve/veya yüksek akım-gerilim gerektiren herhangi bir elemanın doğrudan kontrolü söz konusu değildir. Bu gibi durumlar için, düşük akım-gerilim ile açılıp, yüksek akım-gerilim kontrolüne izin verecek bir devre elemanına ihtiyaç vardır. İşte bu devre elemanı da MOSFET'tir*. N-Kanal ve P-Kanal olmak üzere iki çeşit MOSFET vardır. Bu yazıda N-Kanal MOSFET üzerinden anlatım yapacağım En basit haliyle ele alırsak, MOSFET'in hidrolik eşdeğeri bir musluk-batarya sistemidir (Şekil-1). "Geçit (gate)", suyun açılmasını sağlayan vana görevi görür, yani MOSFET'te akım geçişini kontrol eden bacaktır. "Kaynak (source)", ana boru sistemine bağlanan kısımdır, yani MOSFET'te kontrol edilecek akımın giriş bacağıdır. "Savak (drain)" ise lavabonun gideridir, yani MOSFET'te kontrol edilen akımın çıkış bacağıdır.
Şekil-1: MOSFET-Hidrolik eşdeğeri.
MOSFET'in nasıl çalıştığını daha detaylı olarak anlatmak adına Şekil-2'de Eagle CAD ile çizilmiş basit bir MOSFET ile LED açma-kapama devresi yer almaktadır**. Bu devrede S1 anlık basma butonudur, ancak gerçek dünyada bu bir mikrokontrolör ile değiştirilecektir. R2, LED için bir akım sınırlama direncidir (Eğer pozitif besleme gerilimi +5V ise, standart LED için bu değer 330 Ohm olur. Diğer besleme gerilimi değerleri için Ohm kanunu ile direnç değeri bulunabilir.). MOSFET'in geçit bacağında bir sığa (capacitance) oluşacağından, bu bacak toprağa bir aşağı-çekim (pulldown) direnci ile bağlanmıştır. Eğer geçit eşiği +5V ise, 10KOhm'luk bir 
Şekil-2: Eagle CAD-MOSFET devresi.
direnç iş görecektir.  Bazı MOSFET'lerde yerleşik olarak koruma diyotu bulunmaktadır. Bu diyot özellikle motor kontrolü gibi ters elektro-motor kuvveti (back EMF) oluşturan durumlarda ters akımdan dolayı oluşacak problemleri önler. Bu sebeple kullanılan MOSFET'in özelliklerine bakarak eğer yerleşik koruma diyotu yoksa, devrede diyot kullanmak gerekir.

Bir MOSFET, yanması durumunda ya tamamen açık hale ya da kapalı hale gelecektir. Bu durumda hata kontrolü yaparken MOSFET üzerinde bir multimetre ile ölçüm yaparak herhangi iki bacak arasında çok küçük ya da sonsuz direnç olup olmadığına bakmak yeterli olacaktır.









*MOSFETlerin diğer transistörlere göre farklılıkları veya özellikleri ile bilgiyi bu yazıda vermeyeceğim zira bunun için ilerleyen zamanlarda ayrıca bir yazı düzenlemeyi düşünüyorum.
**Gerçek dünyada LED açıp-kapamak için MOSFET kullanmaya ihtiyaç duyulmayacaktır. MOSFET daha çok motor gibi yüksek akım-gerilim gerektiren elemanların açılıp-kapanması için kullanılmaktadır. MOSFET'in geçitine "PWM (Pulse-Width Modulation)" verilerek motorun hızı kontrol edilebilir. Böyle bir durumda %100 görev döngüsü (duty cycle) ile motor tam hızla, %50 görev döngüsü ile yarım hızla dönecektir.

Bu yazının daha detaylı hali Steven JOHAL'ın sitesinde bulunabilir.