An Introduction to Microcontrollers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone my name is Tim and I am the host of solid state workshop and today I'm going to try to give you a brief introduction to microcontrollers and hopefully by the end of this video you'll have a good enough understanding of microcontrollers to get started with microcontrollers and to you know be interested in working with them and they're really quite amazing and fascinating little little devices so let's try to figure out exactly what they do and why we need them so of course probably the first thing we need to figure out is what on earth is a microcontroller and coincidentally I have a slide here to tell you exactly that and a microcontroller in pretty much the most basic form that I could formulate is an integrated circuit also known as a chip that is programmed by a human being to do a specific task and if you want an even more simple definition of a microcontroller a microcontroller is essentially a mini computer so think of your desktop or your laptop or your tablet and any of those and think of a microcontroller as the entire package of your computer but just on a miniature scale and that's essentially a microcontroller now maybe that just confused you more but hopefully by the end of this video you won't be confused and if you are let me know and I'll try to help you out before we get into the more scientific stuff let's try to just think about where we find microcontrollers and hopefully that will give you a good perspective as to the importance of them so while the humble refrigerator blu-ray player home theater TV microwave camcorders cameras printers telephones practically everywhere they're hidden and all these all these appliances and devices and we don't even know that they're in there but you know you name an electronic gadget and there's a very good chance that there's a microcontroller inside there so uh they're very unsuspecting you know and they're super important so it's kind of an interesting mix they're everywhere that's yeah that's what I said before okay I think for us to have a better understanding of microcontrollers we should examine the history a little bit so I'm just going to try to give you a brief history of the microcontroller and I want to give you a giant description because I want to give you the history of electronics and it's in itself here so let's just get into it back in the 30s and the 40s in the 50s we had computers consisting of vacuum tubes and vacuum tubes worked yeah but you only really saw them in big military or government computers or someone who's extremely rich or something or had the money to have one reason being is because they were pain in the butt they produced a ton of heat consumed a ton of electricity were very unreliable and of course that meant big maintenance costs and it was just a mess they worked yes but it was a mess so luckily in the late 40s we had the development of the transistor which is monumental because pretty much every electronics device that exists today is based off the transistor doubt it we'd have nothing really nothing none of the electronics that we have today would exist so the transistor was like the vacuum tube but it did everything the vacuum did vacuum tube did and more in a smaller package at a cheaper cost took less power and produced less heat for the same operation that a vacuum tube would do and then in the 60s we crammed a lot of transistors into a single chip and/or not a lot but at least a couple of transistors onto a single chip so what this meant is that we got more transistors in a small amount of space and so that improved density that meant that we could build more powerful computers in a smaller space than previously before and then in the 70s we had the advancements of the microprocessors and microcontrollers which well the microprocessor was developed by Intel and then shortly thereafter the microcontroller was developed by Texas Instruments and the first microcontroller ever is the TMS 1000 and I'm going to tell you if I just confused you I said I just had two different words there I said microprocessor and then I said microcontroller and don't be confused the microprocessor and microcontroller are different and we'll look at that right now so as I just said there's a difference between a microprocessor and a microcontroller neither are better than the other so don't first get that out of your head they're just two different beasts they're different the micro micro processor does one thing in the microcontroller does the other thing does another thing so let's let's look at that because most likely you've heard of the term processor before but you might not have heard of microcontroller so let's think let's look at this first things first a micro processor is used in general computing what do I mean by general computing well in your laptop or your tablet or your desktop those are general computational machines because you can practically do anything on a computer just think about it you can watch this video you can edit a picture you can play games you can write a word document you can send an email so many things you can do on a computer and a microcontroller on the other hand does one thing it's not as versatile so that's why you see them in appliances and in specialized devices like as I mentioned before maybe in a microwave how many things can you do want to microwave can you play a game on your microwave no can you write a letter on your microwave no right so that's where you'd use a micro controller where it's just constantly doing one thing speed muckle processors because they have just a giant giant slate of activities that it has to be able to do they have to be extremely powerful they have to be extremely extremely pet extremely fast that's why when you get a processor like in your computer it's rated in gigahertz one gigahertz 2 gigahertz three gigahertz that's very fast but a microcontroller on the other hand doesn't have to be fast doesn't need all that power just do something simple like like as I said to run a microwave doesn't need that it's just it'd be wasteful to have something like that microprocessor requires many external parts because a microprocessor only processes data it does not store data it has no memory you know you can't put programs onto a microprocessor because the only thing it does is all it does is it does like math that's it nothing else it's not very smart it's pretty stupid microprocessor alone is very dump it doesn't know anything because all it does is crunch numbers a microcontroller on the other hand has a lot of stuff built into it it has memory it has ways to communicate with the external world it has everything pretty much set up for it to work as a standalone device and that's the beauty of a microcontroller a microcontroller can be used pretty much alone it doesn't need external part because it's all internal to it microprocessor yes it's very fast as I said but in order for it to work you need external parts you need to add the memory to a microprocessor you need to add a storage and waste interface with the outside world because it's pretty dumb cost microprocessors are expensive because they're ridiculously complicated and they require some really really high tech processes manufacturing processes to create them because they're really all over well at least today are really bleeding edge and that's why they're expensive though there are cheap process processors out there the ones that we encounter today are 50 60 70 80 100 200 dollars apiece so they're pretty they're pretty expensive microcontrollers on the other hand are internally a little more simple though they have more functionalities like they have more peripherals and stuff built into them there they're less complicated for the most part some are really complicated of course there's exceptions to everything but that's why they're a little cheaper um you know energy use processors again are really powerful they take tons of energy well tons comparing it to the microcontroller which just sips energy at least most of them this is a this is just a general statement about microcontrollers and micro processors now vendors who makes them and you're probably familiar with people who make micro processors you have Intel and AMD and erm arm if you're familiar with these you might be you might have seen them you know on your computer box it might say Intel Inside or AMD or whatever microcontrollers on the other hand you might not have ever heard of these companies in your life like what's an atmel or an ST or a microchip or Texas Instruments you've probably heard of but you didn't know that they made microcontrollers did you or maybe you did I don't know maybe you're really smart and maybe you shouldn't be watching this video because you're a genius I don't know but why why do we not know any of these brands here like why don't I get to choose the microcontroller I want and the reason is because the electrical engineer is going to say okay this is the best microcontroller for the task and it's better for him just to pick the best one instead of giving you the option because if he gave you the option well you don't really know any better the engineer is the one who knows the exact application how it's going to be used so that's why you don't really get to choose that so just as a quick quick recap microprocessor is just say this green box alone that's it but you got to add all these things to it look at all these things we have to add I mean it's useless unless you add all these things to it and the microprocessor again is just just this green box here that's it just this none else that's it control or on the other hand plop it puts all those things under the hood under one hood under one package the micro pop the micro control micro controller put all of these things I'm going to call them things because I don't want to describe all them right now but all these really useful things and package them together for you which makes it easier to use and cheaper and more effective in general so let's think about what the basic principles of operation of a microcontroller are and we really haven't talked about really how microcontrollers work at all we've described a lot of of what we really haven't we haven't really talked about how or why much so this is we're going to start getting into some more actual engineering stuff here so microcontrollers are used in specific applications they don't need to be powerful because the applications they are used in don't really require a lot of power or a lot of storage or a lot of memory or whatever and something we haven't talked about is that a microcontroller needs to be programmed by a human being to be useful but controllers just don't know what you want to do with them because they can be used in so many different applications as we've talked about but in order for it to be used you need to program it a human being needs to be needs to know how to program it and of course we only has to know how to know how to do it anyway but a microcontroller is only as useful as the code written for it so I have a little example here if you wanted to turn on a red light when a temperature reached a certain point the programmer would have to know if plus would have to explicitly specify how that would happen through his code so really all I'm trying to say is that again microcontrollers don't know what you want them to do you have to tell them and you have to program them so as we just talked about programming this is the general sequence that you have to follow to program your microcontroller so you're going to write code for the microcontroller on a computer in something called an integrated development environment which is a PC program or Mac program or Linux program or whatever program you want whenever you want to use and this code is written in a high-level programming language generally like C or basic or lower-level languages like assembly and then the integrated development environment kind of proofreads your code for you and says ok you forgot a semicolon here you forgot this here forgot this here and then you had to make that correction but note a compiler or integrative element environment is not going to like write your code for you it's just going to give you kind of like punctuation punctuation errors that's all it's really going to tell you it's not going to say this is a better way to write this because it really has no idea what you're trying to write but it's really gonna say you know like you forgot a period you forgot a capitalized this letter or something like that and then what I was trying to say is that then the IDE or compiler compiles this of pseudo English kind of code written it's it's a it's a human code and then it translates this human code into binary code which the microcontroller can execute because the words that we write in a program don't meet anything to a microcontroller microcontroller likes ones and zeros that's it and then we use a programmer which is a piece of hardware not a person not a human being and we use a programmer to transfer the code from the PC to the microcontroller and the most common type programmer that we use is something called an in circuit serial program are also known as an IC SP and here's the basic kind of flowchart here we have a computer you write all your code on that computer and then you use a programmer and then you send it to your your project to your application board here and as you can see on the board here is the microcontroller and then we can program that and we can keep programming that we can program that as many times until we get it right essentially and then once you do all these steps and you got everything right boom it works presto complete yeah that was corny okay now again I've talked about a lot of what and you might kind of understand how it works but now that if you really think about it you probably don't understand exactly how it works how does a microcontroller interface with the real world and as you can see here I have something up on the screen that says the analog to digital converter scary right well there's a lot of built-in functions as I told you in a microcontroller which is why it's so widely used and so useful because it has all these functionalities that are built right into it and one of the most important things that a microcontroller has built right into it something call and analog to digital converter and this is usually just called an ADC so this might confuse you or it might not confuse you I don't know but uh let's try to think about this so just about every modern microcontroller contains an ADC or multiple ADC some of them have several and an ADC s job as I've as you might be able to just see is to convert an analog voltage to a digital value a digital representation of that voltage that it can store so these digital representations can be analyzed in the code you write for the microcontroller you can log these these values in memory and you can practically use it any way you'd like and that's why why analog digital converters are just so useful because it's so versatile everything microcontrollers are just very versatile chips and that's as I've said reiterating you could probably use a microcontroller for practically any project you'd like ever think of ever this is how an analog to digital converter basically works so you're going to have a signal say we have a sine wave right boom sine wave right now we want to be able to convert we want to be able to store this sine wave in our microcontroller we want to take a picture of it we want to take a snapshot of it so what the microcontroller does is it takes samples of this wave at very precise intervals microcontrollers as we as we said work at a certain frequency a clock frequency so it has a built-in clock so it can it can take measurements of this wave at very precise intervals so what does that mean well here I'll give you a little demonstration so let's let's hook up our ADC to this sine wave and let's see what would happen boom boom boom boom boom boom boom boom boom boom boom right so this is essentially how the ADC is working at every point here here or here or here or here or here or whatever it takes a sample of the waveform so at this point at this point here it might say it'll it'll find the value of negative 2 or something and then here it'll take a value of negative 1 and then here will be positive 1 positive 2 positive 2 and 1/2 or something like that at very very precise intervals so in between these sample points here here and here between these sample points it might be a microsecond or a nanosecond or a very very small amount of time these things work incredibly fast so what this means is that let's get rid of the actual signal and then we can piece it together like this like this like this like this and then let's get rid of those sampling lines and that is how essentially the microcontroller is interpreting that waveform of course it doesn't look perfect at all but I did that so that you could kind of get the point usually it will not usually depends on the application but you use an analog to digital converter that would be appropriate for the waveform you're using so you might understand that'll make sense later but essentially that's what's happening there it's taking a sample at individual points and then it'll store those values or you could do whatever you want with those values and you can make stuff happen so here's an example of where an analog to digital converter could be used and I'm going to be using the example of a digital thermometer and how can we use an ADC to measure temperature of the real world and it's really quite simple here so there's a couple concepts that you should know or else this little discussion here will make little or no sense the first thing you should know is Ohm's law second thing you should know is what a voltage divider is and the third thing you should know is what a ptc is which is a positive temperature coefficient resistor if you don't know what those are I don't really want to explain it right now because I feel like I do a bad job so it'd be probably more beneficial if you just look those up and stop and look those up right now oh and if you do know them I'll try to go forward and explain to you how an ADC can be used to measure temperature so let's look at our PTC specifications the PTT specifications are telling us that at 25 degree Celsius the PTC has a resistance of 100 ohms and then if we increase temperature by one degree Celsius our resistance will increase by 1 ohm so we can deduce from that that at 26 degrees Celsius we have 101 ohms and that 24 degrees Celsius will have 99 ohm so it works both ways so now we're going to throw the peak throw the PTC into this circuit over here which is known as a voltage divider and we'll measure the voltage across at PTC and the voltage across that PTC will be directly proportional to the temperature in the atmosphere or whatever measuring the temperature of so that is awesome and we also have a couple key facts over here in our PTC specifications so knowing this we can write some code that can convert the voltage measured across the PTC here to a temperature now another thing a lot of microcontrollers have 10 bit Dax so I'm going to be using an example of a 10 bit DAC here and you can look that up also but essentially what you should know is that a voltage can be represented well a voltage really you can only input a voltage to a microcontroller or less than whatever it's specified maximum voltages so you can't apply it that was in volts to the ADC input or also blow it up most of them are either 0 to 5 or 0 to 3 point 3 or 0 to 1 point 2 or something like that but most microcontrollers that you probably will encounter will have an input range of 0 to 5 volts so say so an ADC will represent a voltage between 0 and 5 as a number between 0 and 24 so and 1024 rather so in this code here we'll have we're going to be using that the voltage is what we're using these numbers which are representative of the voltages that we measured so according to our specifications at according to a number between 0 and 1024 the voltage that is equivalent to that should be read out at 25 degrees Celsius is 512 because assuming this other resistor is a hundred ohms and this one is 100 ohms the voltage across the PTC would be 2.5 volts or half of 5 volts and 512 is is half of 1024 so that's the voltage that would be read at 25 degrees Celsius and we're going to use this as a ratio we're going to use this in a ratio so we're going to then have to of course input the ADC we're going to import the ADC and we're going to use that command there and then what we're going to do is we're going to take the measured voltage from the ADC and put it over 512 and that will give us the ratio of the ADC voltage to the ratio to note to the voltage of that should be measured at 25 degrees Celsius and then that ratio we can measure we can multiply it by 25 to give us our temperature and you can study that for a second but that's basically how we could do it and there's of course probably a variety of ways to do that but you don't really need to know how that works as much as that it will work and then it's possible and that anything is possible with a microcontroller so I'm sorry if I didn't make a whole lot of sense right there I tried my best though but just understand that you could practically do anything with a microcontroller and an ADC so let's move on from this drum roll please yes you guessed it there's also an accompanying digital to analog converter just as there is an ADC there's also a DAC and these are usually called Dax because it's easier to say DAC and DAC I guess I don't know but a DAC or DAC does the exact opposite function of an ADC we know that an ADC takes an ad along voltage and turns it into a digital value so therefore a DAC must take a digital value and convert it into an adult-like voltage and I have written here that it converts into a pseudo analog voltage while it can definitely create like regular flat voltages if you want to create like a waveform it's going to have those steps in it that we saw in a previous slide it'll have that stepping effect however a lot of times it's quick enough to change those steps to create those little steps that you can't ever tell the difference you can't even tell the difference between a real analog voltage and one of these pseudo analog voltages created by a DAC and we can use a DAC for a variety of things enormous amount of things actually one such thing is to synthesize or create a waveform we can create an audio signal from a microcontroller pretty awesome it's not even that difficult these days maybe back in the day it was a little more tricky but today we can we can plug and play almost put some quick code in there and we have an audio generator and that is the beauty of the digital to analog converter so let's go over a few applications and let's try to understand how the microcontroller is working in these applications we're almost near the end of this video so just bear with me okay one of the one thing that I mentioned before is that they that you find microcontrollers in appliances so this board you see here this circuit board here is from a washing machine and right there in that aren't circle is the microcontroller and essentially this microcontroller is interfacing with all those all these buttons here these are all buttons and buttons here and all sorts of stuff like that to make the microcontroller to make the washing machine work so if you were to hit this start button here the microcontroller would it would go to the microcontroller and the microcontroller would say okay the start button has been pushed so let's flip on a relay to start the big AC motor and the drum will go wish-a-wish it will show wish' and your clothes are clean magic right and this next one this board you see here is from a car more specifically a Buick Regal not that it matters really but microcontrollers have a lot of applications and cars in auto automobiles for example this board here can be used to handle something from dashboard controls like heat and cooling and fans and all that kind of stuff or can be used for more complicated things like timing the ignition system or you know spraying when to spray gas and the cylinders and that kind of stuff so my controllers can do all these things from a really basic task like before like a washing machine to something more complicated like this another a pretty pretty popular or at least a lot of people tend to think of microcontrollers as being used in robots so here we have our friend Wally and the microcontroller definitely do have a big presence in robots in robotics and for example Wally here might have proximity sensors in his eyes here at a proximity sensor is going to tell you how close you are to an object nearby so the microcontroller again maybe now using its analog to digital converter reads the value from the sensor and it knows how far away it is from something and then it will know how to react should it change its course of direction should it try to do something shouldn't do something whatever so that is really how microcontrollers can actually be you and pretty much the last thing I have to talk about today is microcontroller packaging now packages means the shape that the microcontroller takes because microcontrollers come in all sorts of shapes and sizes there's not one single type of microcontroller there's many many types of microcontrollers and here are some of the most common types we have a dual inline package and this is pretty much the oldest form factor for a microcontroller or for any chip for that matter doesn't have to be a digital chip these are through-hole parts which means that holes are drilled in the circuit board and these legs here go through the board and yeah that works there these are definitely still used today they're cheap and they're effective a lot of times you don't need a ton of power and these kind of chips are appropriate and then we also have something called a small outline IC or a so Ike these are surface mount chips which means that they are soldered directly onto the top of a board there's no holes drilled they're just soldered right on we have a quad flat package which means that we have these pins or these leads on four sides of the chip which means you have greater density more output or input abilities in a smaller amount of space these are used in more demanding applications not demanding but you know where you need more functionality and the latest and greatest is something called a ball grid array which means you can put tons and tons of power into a very small package because on the underside of this little black chip here we have tada each one of those little balls is a pin and then put an output pin just like just like these pins here or just like these pins here or these pins there except now look how close they are to each other look how many of them there and if you've been reading these little descriptions here we notice that we have eight pins on this one 18 pins on this one 32 pins on this one and a hundred pins on this one and here's our pin density here so how many pins per square millimeter and on this one we see we have point 15 so we have point 23 as when we have point 65 on this one we have almost three pins per millimeter squared so what does that mean that means that we that we get more amount of input and output you know smaller amount of space and this is the advance here these packages here are much more expensive than these packages here these packages but sometimes you need it so these are the different options we have now it just has a quick quick little side note this is how big our BGA packages scale size boom that is a match stick a standard match stick that is how big that microcontroller is so some of them get really quite tiny and it has a hundred pins on it rather ridiculous I'd say but so last slide I have here is how can I get started because one of the biggest things the biggest inhibitors is that we don't know how to get started and probably the easiest way to get started is to look around the internet and see how other people got started but uh you can you can buy something called a development board for microcontroller that essentially gets you off on the right foot you don't really have to think about much you can focus on learning how to use microcontroller without driving yourself mad so a really popular microcontroller development board is the Arduino which has an microcontroller on it here but it also incorporates a lot of other things like a way to communicate with USB with a computer that's a USP chip there we also have a power supply here and we have all the pins on the microcontroller right here on these pin headers which allow us to interface very easily with it we don't need solder we don't need any special board we can do it by plugging and plugging in wires to these little headers here makes it really easy there's also other boards this is a pic microchip pic 16 X floor board and as you can see this one has has an LCD screen on it it has more of these expansion headers and buttons and probably potentiometers and all sorts of stuff on there that puts it all the right place for you so you can find which one you like the best there's a lot of different development boards out there but that's probably what you want to get started with microcontrollers and it's really a lot of fun you can do a lot of things and you'll keep finding things to do with microcontrollers they're really quite amazing and I definitely recommend getting started with microcontrollers so very very much for watching I love to hear your feedback um this is my first video I've ever done on youtube so I really want to see what you have to say about it and if you liked it or not thank you very much if you liked it please thumbs it up so I know and if you didn't like it thumbs it down if it was really that bad and if you want more you can subscribe to make sure that you get updates on when I upload a video so thanks a lot and have a great day
Info
Channel: Solid State Workshop
Views: 461,285
Rating: undefined out of 5
Keywords: MCU, Arduino, What is a Microcontroller?, DAC, ADC, Analog to Digital Converter, Atmel, Microchip, MSP430, Electronics, Beginners Guide, Subject (programming), Programming, PICKIT, IDE, Intel, AMD, Solid State Workshop, History of Microcontrollers, Learning Microcontrollers, Microcontroller Basics, Microcontroller Projects, Using microcontrollers
Id: CmvUY4S0UbI
Channel Id: undefined
Length: 40min 59sec (2459 seconds)
Published: Sat Jan 19 2013
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.