©2019 Robotics for COMPLETE Beginners

07

Transistors

 

Welcome to one of your most important lessons yet.  Transistors.

It has been argued that the introduction of the transistor has allowed modern day computing and microchips to come into existence.  It's a bold claim but a solid argument as every computer chip has millions if not billions of tiny transistors inside them. So many, operating so fast, that the chips heat up so much that you have to install a heat sink with a fan or water cooling system just to start the computer!

Transistors are hard to understand at first but luckily I have spent alot of time thinking about it already for you.

Transistors are gates. Gates for the flow of electricity. That is all you need to know for now.


However, HOW they work is complicated and not even completely understood yet.

Here are some transistors:

Here is the basic schematic a transistor:

Now there are many kinds of transistors with differing symbols and operation, like flavors at a Baskin Robbins Ice Cream shop, but we will only focus on the NPN Metal Oxide Field Effect Transistor, or n type MOSFET, that is all you need for now, trust me.  The reason being it operates best with our 5v AVR microcontroller we will use.

Here it is in all its glory.

As an N-channel MOSFET, Guess what N stands for?

That's right, negative. You little genius, you.

There are 3 parts: Source (power source), Drain (where the electricity is going to, your target), and Gate (this is connected to a pin on your microcontroller that you send out electricity from to the transistor, it opens the gate inside the transistor).

 

Are you still with me? You sure? Read that over a few times. Draw it out with crayon..Do it. DO IT NOW!

...The Source is mostly negatively charged.  Another way to think is it is less positive.

The Drain is relatively positive.

The Gate for our N-type MOSFET is mostly negative. Just a little bit of voltage sent from our AVR chip to the pin connected to the gate unleashes a waterfall of current from the Source to the Gate.  Just imagine the Gate pushing down onto the Drain and Source, making the connection.  This isn't really what is happening but it will save you alot of headache.

 

Like I said, scientists are still figuring this one out so no need to worry about what is happening in there.

 

It just works and its good enough to get started!

So what do we use this for?

We can use it as a switch.  For example, we can connect our motor to a diode to protect it, and connect a capacitor to that and then connect the capacitor to the gate of the N-type MOSFET.  We can then connect the Gate to the AVR chip.

 

FOCUS!

 

In our code, which I will teach you later, we can set up Pulse Width Modulation, PWM, which basically sends positive voltage to the Gate and we can control the duration that voltage is on that pin.

So if we want to slowly rev up the motor, we just write code to lengthen the time the pin is turned on with each beat in the music.

Ok, here is how you can understand PWM easily. First we need to set the frequency.

 

How often the beat in our music happens.

 

Start slapping your desk...I'm not kidding.

Slap the desk very slowly. Now each time you slap the desk say "boom".  Each time you say "boom", say it just a little bit longer.

 

Like this: *slap* Boom, *slap* Booom, *slap* Boooom, *slap* Boooooom, *slap* Booooooom, etc.

 

This turns on the motor for longer periods each time the code loops through itself until the code reaches the maximum of constantly on.  This is just a crude example but will help you prepare your mind for motors and understand how we can use this type of transistor.

Pop Quiz

1. What can we use transistors to do?

2. How does an N-Type MOSFET work?

3. What is the schematic for an N-Type MOSFET?

4. What effects does a a few batteries connected in parellel have?

5.  Explain PWM.

Get my favorite books on programming AVR chips I use.

Equip yourself with the most dependable, no hassle, quality usb programmer I use daily.

Make sure you have a basic kit. Arduino is fine, it contains the removable AVR 328p chip we will use.

 

I started with something very similar.

Summary

WHEW!

CONGRATULATIONS!

You made it through one of the most difficult and crucial lessons on your journey!

It wasn't so bad right? It only took me a YEAR to understand and you just got it in a few minutes.  I even taught you the basics of pulse width modulation which also took me a year to fully understand. 

 

You're a wizard Harry.

That's why I'm here.

Like I always suggest, take a walk, take a nap, make a smoothie, eat some goddamn cake!

Feel good about yourself because right now, you are smarter, better and more attractive than most people on this planet.

You're on FIRE!