Square Thoughts

an engineering student's blog

MOSFETs as Current Drivers

A few weeks back, in one of my projects, what I required was to drive 8 RGB LEDs using the minimum number of pins on a 8bit AVR ATTiny micro-controller. Laying put the schematic was easy, as I knew what I had to do. I was aware I had to employ methods for current sinking and sourcing to make the LEDs glow.  The conventional method would have been use of PNP and NPN transistors with lots and lots of resistors at their bases and use them as switches so that the least amount of current reaches the micro-controller pins. However, due to size limitations of my PCB, I could not use that many resistors.

Using MOSFETs was the other option as their gate current is negligible. I had read on the internet about current sourcing using P Channel MOSFETs. No one talked about current sinking using MOSFETs as such. So trivially accepting that if a P Channel sources current, an N channel would sink it. This is right to some extent but wouldn’t work if some conditions are overlooked. That prime condition being threshold voltage of the NMOS and PMOS. PMOS have higher threshold voltages compared to NMOS and hence cannot be ignored. For those who don’t know what threshold voltage, it is the minimum voltage between the the gate and source of the transistor required for switching operations. Threshold voltage for the NMOS I was using was 2V(NDS355AN) and for the PMOS was -2.5V(NDS356AP).

So getting my concepts straight about using MOSFETs as switches, I started building a daughter board for driving a single LED using a PMOS and NMOS. The schematic for which is given at the bottom of this post. It failed. Not because I had got my concepts wrong, rather I had soldered it wrong or the transistor was faulty.

The next time with immense help from my professor and guide, I was successful. We were successful.

This design concept is not just limited to driving LEDs. It can sink and source high value currents of over 2 amperes and send current in micro-amperes to the controller(current flow into the controller would be higher when using BJTs). It can be used to drive motors, LCD displays etc.

Some points to be remembered:-

  1. Use a supply of 5V or more for switching states. 3.3V would work, but may pose a serious problem in the presences of voltages being developed across any stray resistances which would make it very hard to debug.
  2. Use a current limiter resistor between the transistors, always.
  3. A high on the gate of the NMOS, turns on the transistor and vice versa.
  4. A low on the gate of the PMOS, turns on the transistor and vice versa.
  5. Last, as FETs can be depicted in several ways, recheck your connections before applying any voltages.
Components I used:-
  1. NDS355AN N-Channel Logic Level Enhancements FET.(perfect when using logic levels of 5V)
  2. NDS356AP P-Channel Logic Level Enhancements FET.(perfect when using logic levels of 5V)
  3. 3MM LED.
  4. 220ohm current limiting resistor.

Matrix Baby!

It’s been eight days since my Arduino arrived and I have not been able to take my hands off it. It’s simply brilliant!

I wanted to use extra electronic components other than the Arduino alone, which I have been doing so far, so I settled to design a 8×8 LED matrix using shift registers and lot and lots of transistors.

I am using two 74HC595 Serial In Parallel Out Shift Registers for the rows and columns and software multiplexing through them to create amazing LED patters. I am using 8 PNP transistors for current sources and 8 NPN transistors for current sinking.

The matrix is constructed in a manner such that LEDs in a single row have a common anode and in a single column have a common cathode. The PNP transistors are connected to the anode side and the NPN at the cathode.

But the best part, I am only using 6 I/O pins on the Arduino to control a matrix fo 64 LEDs which when connected individually would require 128 pins. So the technique is really useful and can be extended to drive bigger displays as well.

The matrix can be used as a text display, to scroll text, display sequential patterns, the possibilities are countless.

I have a made a simple animation on the matrix which you can see in the video below. I intend to use the display as an email notifier/RSS feed display in my room, but that would require some more thought process.

Let us Count

Salut!

So I have been playing around with the Arduino for a while and believe me, you will be mind struck by the amazing capabilities of this little device.

A LED is a very versatile electronic component, it can act as an actuator, a sensor and you all know, how lovely they look when lit up.

This time, I am experimenting with  a 4 Digit 7 Segment Display, which I got hold of from an old microwave oven display panel. What’s with the fancy name? Well, it is a grid of 4×7 LEDs arranged in a manner so as to form digits. But this doesn’t mean it has 4x7x2 leads, absolutely WRONG! It only has 4+7 leads and the multiplexing is done through software on the Arduino. However, one could use external multiplexers/shift registers, I just didn’t feel the need for the same.

I have made this small, basic but useful counter using the 4 Digit 7 Segment display which counts up to 9999 and then resets back to 0000. Again, this project just under estimates the capabilities of the Arduino, though very good for learning. The counter speed can be varied in the software and the brightness can be controlled by varying the current limiting resistors.

NOTE:- I am shuffling through each LED one by one with a frequency of 10,000 Hertz or a time period of 10 microseconds due to which the duty cycle is considerably reduced. To maintain optimum brightness I have chosen a resistance value of 100 ohms.

Check out the video below to see how this counter works.

PS:- One should aim to use the least possbile I/O pins on the Arduino making room for further enhancements. So I would be working out the counter using shift register in the next weblog.

Arduino 101

I have been waiting for this small dose of magic for over a month now. I am talking about my Arduino, the open source hardware prototyping platform for hobbyists, yes, I call myself a hobbyist rather than a to-be engineer.

It is small piece of hardware weighing about 50 grams and 3×2.5 inch size. It has everything you will ever need to design micro controller based projects. Offering 18 total I/O pins, 6 PWM pins and 6 Analog I/O pins it can be adapted well to almost all one’s requirements. To know more click here.

I got hold of my first Arduino today.

Before getting onto anything big on the Arduino, I decided to start with the basics as it was the first time I am using the hardware.

I made a simple, very simple in fact, LED Sequencer. It is the most basic thing you can do with the Arduino. I am basically controlling five LEDs over the five Digital I/O pins and sequencing them. Check out the video below.

I will be posting a weblog of all my experiences with the Arduino over the next couple of months.

Sorry for the abrupt tick at 00:10 when the light goes off. Stupid Clap Switches.

A Stranger

This may not interest all, but something unusual happened yesterday. I met a person: dark complexioned, 5feet 6inch tall, having two beautiful children and a gorgeous looking wife, I met a stranger!

To tell you more about this, let me recapitulate an incident which happened with me two months back.

It was 26th of February, 2010 and I was headed to Vasant Kunj via bus route 764 with my friends Prashant Mital and Abhinav Yadav. We took the bus from NSIT bus stand (Dwarka) and occupied the last row seats of the bus. We talked about our colleges, our falling grades, girls and alcohol. After about ten minutes, there was some commotion in the bus. A completely drunk person boarded the bus and came to sit with us. He was talking to himself in an angry tone and murmuring words which only he could understand. After continuing all this for sometime, he realized we were sitting next to him and giving him more-than-needed attention. So, he started talking to us.

Kahan se ho bhai?

None of us bothered to reply, mistaking him for talking to himself again. He repeated his question.

Arrey kahan se ho tum log?

We still didn’t care. Replying to his question would mean we were to get ready to answer some of the most weird questions we had ever answered.

Mai bass thoda sa out hoon, zyaada nahi piya maine. Tum toh mere bhai jaise ho, kabhi koi problem ho toh turant phone kar dena.

He was getting way too friendly.

Ek kaam karo, tum mera number likh lo, call karna mujhe.

I took out my phone, and entered the number he gave me thinking he may stop bothering us after that.

98101******

Likh liya?

I nodded to his question.

Yeh number toh aajkal bandh hai, doosra likh lo.

What the fuck? He just made a fool out of me. I took down the other number he gave me. Typing it on my phone and deleting it at that very instant without him knowing. I thought at least now he would stop.

Tumne mujhse naam toh poocha nahi, phir jab phone karoge toh kya bologe? Phone toh mera bhai uthayega.

I didn’t have the answer to his question. I preferred to keep quiet.

Mera naam “kishan” hai. Tumhaara kya hai? Mai ghar jaake apne mobile mei save kar loonga.

I didn’t want to tell my name to a stranger. So I just made up a name, and told him that my name was “Ravi”.

Ab toh humein ek doosre ka naam pata hai, ab toh hum dost hai. Ek dost hi doosre dost ki maddad karta hai, koi bhi problem ho toh mera number ghuma dena. Tum mujhe zaroor call karna.

He continued speaking for the next 15 minutes. We didn’t care, we just ignored him. and he got down from the bus at Palam. We just took him to be a drunkard and didn’t think of him ever after that incident. He was totally out of our mind.

It was totally normal on our part to ignore everything he said. How many of us are there who actually listen to drunk people? None of us.

And yesterday, April 26th, 2010 at 1630 hours, I met that person again. This time in the Delhi Metro. I boarded the train from the Dwarka Mor station. I took the unreserved seat next to the ladies seat. And there he was, a person whose face was at first difficult to recall but then I could totally remember him. He was staring at me. I tried to avoid him and started looking the other way round. He came up to me and took the the seat next to mine.

Bhaiyya pehchaana?

Definitely I had recognized him, but I refused.

Hum mille the! 764 mei, uss din mai thoda tull tha. Aaj bilkul theek hoon. Aapne mujhe call hi nahi kiya?

Shit! He remembered that I was to call him. So I at once showed that I was happy to meet him.

Agar uss din maine kuch galat bola tha, toh mujhe maaf karna. Zindagi badhi dhokebaaz hai, bahut kuch hua tha mere saath uss din.

Trying to act a little concerned, I asked him what happened that day?

Humaari naukri chali gayi thi. Hum par chori ka jhoota ilzhaam lagaya gaya tha. Bina naukri ke hum apne biwi baccho ki kaise dekhbaal karte. Yeh ameer log kabhi nahi samjhte ek gareeb ko. Hum badhe pareshaan the. Ghar jaane ki himmat nahi tha. In sab ke beech thodi daru chadha li thi. Koi chahiye tha baat karne ke liye, ek bhai jaisa insaan, jo humein samajhta.

And….. I felt like hitting myself on the face, jumping out of the moving train and die. Why did I ignore him? He just wanted someone to talk. A few lines of condolence would have helped him. My heart felt heavy. He introduced me to his family of three, his two children and his wife. The innocence on their faces and an agreement with what all they had, just made me feel awful. He had got his job back and earned five thousand a month now. We talked a little more and then he got down at Janakpuri East. He de-boarded the train asking me to call him at least once. I gave him an assurance that I would, but deep inside I knew I can’t call him even if I want to, I never stored his number.

So moral of the story is, never mistake a drunk person with a thief or douche bag. All of them have a story to tell. If you ever come across a drunk person who starts talking to you, spare out some time and listen to what he has to say. Don’t just ignore them. Someday, you might change someone’s life.

Post Navigation