Microcontroller

Nope, not that MCU.

So by MCU, I mean(uh..uh?) The microcontroller unit.

A microcontroller is a small and low-cost microcomputer, which is designed to perform the specific tasks of embedded systems like displaying microwave information, receiving remote signals, etc.

The general microcontroller consists of theprocessor, the memory (RAM,ROM,EPROM),Serial ports, peripherals (timers,counters), etc.

Where can you find them?

They are almost everywhere, from simple devices like washing machines, traffic lights, microwave ovens to highly sophisticated satellite systems. A 1999 BMW 7-series has 65 microcontrollers. Although the microcontrollers in PCs are the most visible, they account for just 6% of the microcontroller market.

Microcontrollers are used in applications requiring repetitive operations such as running the traffic light at an intersection. In traffic lights, the microcontroller's sole function is to turn lights on and off at predetermined times.

Another example is a microwave oven. Let's examine how a microcontroller functions while cooking a bag of popcorn in a microwave oven.

You open the door and put the bag of popcorn inside. You close the door and push the button labeled "Popcorn." A few minutes later, a tone announces the popcorn is done. What happened behind the scenes?

When you opened the door, the microcontroller sensed the door switch, turned on the light, and disabled the magnetron. The microcontroller continually scans the keyboard. When you pushed the "Popcorn" button, the microcontroller confirmed that the door was closed and began to count timing pulses, started the motor for the turntable, set the power level of the magnetron, and controlled the display. When the timer reaches zero, the microcontroller shuts down the magnetron, stops the turntable, and signals you.

Controller board of a washing machine which controls the time of motor rotation, speed, buzzer control, 8-segment display control, etc. The board has a microcontrollerST7LITE49M.

Components of a microcontroller

  • CPU - It is the processing unit of any computer. It is the “brains” of the microcontroller. It is what fetches the instructions from the code memory and executes the instructions that it fetches.
  • RAM - The data RAM (Random Access Memory) is the data space that is used for temporarily storing constant and variable values that are used by the microcontroller during normal program execution.
  • EEPROM - The on-chip EEPROM memory (Electrically Erasable Programmable Read-Only Memory) on a microcontroller is like a microcontroller’s hard drive. It has two partitions. One partition is reserved for the storage of the program code i.e program memory while the other partition is reserved for permanent storage of data i.e data memory, used by the chip during normal program execution.
  • I/O ports - These are the ports that are used to provide binary data to the microcontroller and to fetch processed binary data from the microcontroller. They provide a channel to communicate with the microcontroller.
  • Timers and counters - Counters are simply used to generate a count in electronics such as 1,2,3,4. You also must know timers from the description where the 555 timer IC is described. In similar ways, microcontrollers are embedded with such components that act as timers and counters inside the microcontroller to perform time and count related tasks.
  • Oscillators - An oscillator embed in a microcontroller is used to provide a clock to the microprocessor of a microcontroller. In a microprocessor, every instruction is executed in synchronization with the clock. To achieve high clock speeds, an external oscillator can be used with a microcontroller.
  • A/D Converters(Analog to Digital Converters and Digital to Analog Convertors) - Any microprocessor needs data to be in digital form i.e data has to be in a binary state to be processed. In microcontrollers, the CPU too requires digital data to work on but the input provided by devices is analog signals of voltage. So data needs to be converted into digital signals so analog to digital converters is present in a microcontroller to aid the processing.

After data gets processed according to the instructions, the processed data in digital form is again needed to be converted into analog signals as most of the output devices need analog signals to show output. So, a digital to analog converter is also embedded inside a microcontroller for this purpose. Remember, there are external converters also available.

Classification of MCUs

Microcontrollers are classified into various categories based on memory, architecture, bits, and instruction sets. Following is the list of their types −

  1. On the basis of the number of bits

    Based on the number of bits microcontroller can process in one clock cycle, the microcontroller is further classified into three categories:

    • 8-bit microcontroller − Microcontrollers that process 8-bit of information in one clock cycle. This type of microcontroller is used to execute arithmetic and logical operations like addition, subtraction, multiplication division, etc. For example, Intel 8031 and 8051 are 8 bits microcontrollers.
    • 16-bit microcontroller − Microcontrollers that process 16-bit of information in one clock cycle. This type of microcontroller is used to perform arithmetic and logical operations where higher accuracy and performance are required. For example, Intel 8096 is a 16-bit microcontroller.
    • 32-bit microcontroller − Microcontrollers that process 32-bit of information in one clock cycle. This type of microcontroller is generally used in automatically controlled appliances like automatic operational machines, medical appliances, etc.
  2. On basis of Memory

    Based on the memory configuration, the microcontroller is further divided into two categories:

    • External memory microcontroller − This type of microcontroller is designed in such a way that it does not have a program memory on the chip. Hence, it is named an external memory microcontroller. For example, Intel 8031 microcontroller.
    • Embedded memory microcontroller − This type of microcontroller is designed in such a way that the microcontroller has all programs and data memory, counters, and timers interrupt, I/O ports are embedded on the chip. For example, Intel 8051 microcontroller.
    • On basis of Memory Architecture

      Based on the memory architecture on which microcontroller is created, they can be classified into two categories:

      • Based on Von Neumann Memory Architecture -

        These Microcontrollers have common memory for storage of data as well as programs.

      • Based on Harvard Memory Architecture -

        These Microcontrollers have separate memory units (and separatebuses.) for storage of data as well as programs.

Some of the examples of microcontrollers are ATmega328, ATtiny85, ESP8266, etc.

You’ll see the use of some of the microcontrollers mentioned above in the blog of Development boards.

Applications of Microcontrollers

Microcontrollers are used for specified tasks where the tasks are predefined. They are used in different devices such as −

  1. Light sensing and controlling devices like LED.
  2. Temperature sensing and controlling devices like microwave oven, chimneys.
  3. Fire detection and safety devices like a Fire alarm.
  4. Measuring devices like multimeters.

Difference between Microprocessor and Microcontrollers

What is the need for Microcontrollers if we already had Microprocessors or vice versa A simple difference chart will surely clarify all such doubts.

Development boards

Hello everyone! Here we are with another fascinating topic for you to learn - Development Boards, more specifically, Arduino Uno

What is a Development Board?

A development board is a printed circuit board with circuitry and hardware designed to facilitate experimentation with a certain microcontroller. Some everyday development boards are- Arduino Boards like Uno, Nano, Mega, and many more non-arduino boards like ESP32.

Why do we need development boards?

Imagine you have a microcontroller, and you wish to do some cool projects, say a maze solver bot or a burglar alarm. Now, every time you would have to set up the elementary circuit on a breadboard, and you know that some of the electric circuits would be the same each time, like power circuits. That makes it redundant and frustrating. Imagine a PCB containing all this basic circuitry. That’s the reason why we use a Development Board.

Regarding Arduino boards:

Arduino boards are the pivotal components for thousands of ongoing projects in the field of robotics. With Arduino boards, you can convert input, like light, temperature, etc., from the sensors and govern an output, like activating an arm, a motor, or even sending information online.

This is done by sending a set of instructions to the Arduino board using Arduino Programming Language, using Arduino Integrated Development Environment (ArduinoIDE). The language can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it is based. Similarly, you can add AVR-C code directly into your Arduino programs if you want to.

Wondering what exactly is an Arduino and what’s with this new term AVR? Hold on! Let’s see what they mean.

Arduino is an open-source hardware and software company which helps us build exciting electronics projects with easy-to-use hardware and software. All Arduino boards have one thing in common - a MICROCONTROLLER. The microcontroller is a comp...but you know what a microcontroller is?

AVR is a microcontroller family developed by Atmel. Some of the examples are the ATmega series, ATtiny, ATxmega.

Some sample projects that you could do using Arduino as brain include building aburglar alarm,line follower bot,obstacle avoiding robot,temperature monitoring systems,RC car, or evenhome automation.. or, you could also make some 'useless machines' like the one shown inthisvideo.

Now you know how interesting and important it is to learn about Arduino. As per requirements, Arduino CC manufactures many boards, (you can see them here: Arduino - Products).

Why are we studying Arduino boards, and why are they so popular?

Arduino development boards are so popular because of their simple IDE, straightforward code, and lots of Open-source libraries. But this is not it. Arduino Hardware is also Open-source, which means several other companies make Arduino compatible boards programmable with Arduino IDE. Some of the common arduino boards are Arduino Nano, Arduino Uno, Arduino Mega, etc

In this tutorial, we will study an everyday Arduino board - Arduino Uno. We will also do some simulations on Arduino Uno but let’s go through the hardware part first.

This is how an Arduino Uno looks like.

Some numbers have been marked on the image corresponding to components on the board. Let’s know about these components in detail

  1. An Arduino Uno board can be powered using a USB cable from your computer. All you need to do is connect the wire to the USB connection. It helps to upload the sketch to the Arduino Uno board. Sometimes it is used to send serial data to Arduino Uno too.
  2. The Arduino Uno board can also be powered using an AC-to-DC adapter or a battery. The power source can be connected by plugging in a 2.1mm center-positive plug into the power jack of the board.
  3. It is a voltage regulator.
  4. Crystal Oscillator: The crystal oscillator helps Arduino Uno in dealing with time issues. How does Arduino Uno calculate time? The crystal oscillator is what helps here. Its frequency is 16,000,000 Hertz or 16 MHz.
  5. You can reset your Arduino Uno board, i.e., start your program from the beginning. You can reset the UNO board in two ways. First, by using the reset button (15) on the board. Second, you can connect an external reset button to the Arduino Uno pin labeled RESET(5).
  6. It supplies 3.3V output once the board is powered up.
  7. It supplies 5V output once the board is powered up
  8. There are several GND pins on the Arduino Uno, any of which can be used to ground your circuit.
  9. This pin also powers up the Arduino Uno board. Arduino Uno can operate on an external supply from 6 to 20 volts. If supplied with less than 7V, the 5V pin may supply less than five volts, and the board may become unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.
  10. The Arduino Uno board has six analog input pins A0 through A5.
  11. It is a microcontroller IC. The main IC on the Arduino is slightly different from board to board but is usually from the ATmega line of IC’s from the ATMEL company. Arduino Uno uses ATmega328P.
  12. This LED should light up when you plug your Arduino Uno into a power source to indicate that your board is powered up correctly. If this light does not turn on, then there is something wrong with the connection.
  13. On the board, you will see two labels: TX (transmit) and RX (receive). They appear in two places on the Arduino Uno board. First, at the digital pins 0 and 1, indicate the pins responsible for serial communication. Second, the TX and RX led (13). The TX led flashes with different speeds while sending the serial data. The speed of flashing depends on the baud rate used by the board. RX flashes during the receiving process.
  14. The Arduino Uno board has 14 digital I/O pins (of which 6 provide PWM (Pulse Width Modulation) output. These pins can be configured to work as input digital pins to read logic values (0 or 1) or as digital output pins to drive different modules like LEDs, relays, etc. The pins labeled “~” can be used to generate PWM.

What is PWM?

Pulse Width Modulation is a method of reducing the average power delivered by an electrical signal, by effectively chopping it up into discrete parts. The term duty cycle describes the proportion of 'on' time to the regular interval or 'period' of time; a low duty cycle corresponds to low power, because the power is off for most of the time. Duty cycle is expressed in percent, 100% being fully on. When a digital signal is on half of the time and off the other half of the time, the digital signal has a duty cycle of 50% and resembles a "square" wave.

That was pretty much all about the Uno board. But it's not over yet. In the next blog, we will do some simulations on an Arduino Uno board online on tinkercad. Till then, complete the given assignment.

Assignment Questions (mail them to puneet@zine.co.in):

  1. What is flash memory? What is the size of flash memory for Arduino Uno?
  2. What is the baud rate mentioned in the blog?

Programming Arduino Uno

Hello there! In the previous blog, we introduced you to Arduino. Now, it is time to try your hand at programming.

Generally, we code in Arduino IDE, compile it and upload it to the Arduino. And the Arduino mostly behaves as expected. Simple? The programming language we use for programming the Arduino devices is Arduino Programming Language. But this is nothing to be scared of, it is just a framework built on top of C++, which means most syntax is the same.

But there are quite a few differences too. One of the main differences is that unlike C++, it doesn’t have a main() function, but it does require two main functions: setup() and loop(). A program written in Arduino Programming Language is called Sketch.

Now let’s start programming our Arduino board. If you’ve been following the blogs so far, you must know what we are going to use for simulation.

  1. Go to tinkercad tinkercad and create a new personal account. You can sign in with google for your ease.
  2. You will see a screen like this after completing the signup process.

    Select Circuits from the left panel and then create new circuit.

  3. Next, you should see a blank screen with some components listed on the right side. Search for Arduino Uno R3, LED, and a resistor and drag them on the blank screen one by one.
  4. Make connections like the ones shown below and click on the Start Simulation button on the top right.
  5. Wow! The led is blinking. Note that not only the LED which we connected to the Arduino but the LED on the board is also blinking.

But you didn’t program it to do so. How did it happen? Let’s figure that out. First, Stop Simulation. Click on that little code button near the Start Simulation button. Open the Blocks menu and click on Text. You should see this:

This is the default program that is causing the led to blink.

Let’s try to understand how this program is doing so.

void setup()

void setup() { pinMode(13, OUTPUT); }

void loop() {

digitalWrite(13, HIGH);

delay(1000); // Wait for 1000 millisecond(s)

digitalWrite(13, LOW);

delay(1000); // Wait for 1000 millisecond(s) }

The first thing is you can see two functions: setup() and loop().

setup(): This function is called at the very beginning and only once, when the program starts, and when the Arduino is shut down and restarted. So, for example, if you wanted something to be done only once, you will include those tasks in the setup.

loop(): This function is repeatedly called while the program is running, this function governs the regular functioning of the Arduino board. So, if you want a task to be done repeatedly by an Arduino board then those tasks must reside in a loop().

Line 3: pinMode(13, OUTPUT);

This sets pin 13 on the Arduino board as an output pin.

Lines 8, 10: digitalWrite(13, HIGH); and digitalWrite(13, LOW);

These lines are used to set pin 13 high and low respectively.

Lines 9, 12: delay(1000);

These lines are giving a delay of 1000 milliseconds between setting pin HIGH and LOW.

As the loop() is called repeatedly, the led starts blinking.

Isn’t it amazing? Congratulations! You learned the “Hello World” of Arduino today. For more information on Arduino programming language you can refer to the following link:

https://flaviocopes.com/arduino-programming-language/#:~:text=The%20Arduino%20Programming%20Language%20is,Programming%20Language%20is%20called%20sketch.

Now it's the time for you to do a small assignment (Submission through Google form):

  1. Why is the led on the Arduino Uno Board blinking?
  2. What will happen if we remove “delay(1000)” from the last line in the above program? Why do you think it is happening?
  3. What is the extension of a sketch?
  4. Redraw the circuit shown below.

    Write a program such that the led lights up when the push button is pressed and turns off when we release the push button. Submit the code below.

  5. Simulate the hypothetical circuit you studied in circuits [link to BEE circuits blog] blog on tinkercad and share the link.

Sensors

Aight! It is time to learn about sensors now. Let’s cut to the chase!

What is a sensor?

Any device that measures physical input from its environment and converts it into data that can be interpreted by us or a machine.

Let’s make it simpler with the example of an eye.

The eye is a sensor of sight for us and the electronic counterpart of it is a camera. Both gather visual information from the surrounding environment and convert it into data that can be interpreted by their respective data processing units, i.e., brain for us and microcontroller or microprocessor for machines.

Fact: The average resolution of a human eye is approximated to be 576 megapixels (you can refer thisvideo) meanwhile the highest resolution camera devices ever created has a resolution of 108 megapixel created byXiomi) andSamsung).

Now, we know what are sensors, but why do we need sensors in robotics?

To answer this question, let’s take an example- You want your device to function according to the light, say a light follower bot. So, the bot you built must act to detect where the light is. As the intensity of light falling on the bot increases, then it can be concluded that the distance between the light source and bot is decreasing (assuming that light source emits at constant power). But how will you give the intensity of light as input to the microcontroller directly as the visual data can’t be directly interpreted by a microcontroller? We need an intermediate to bridge this gap.

There exists a need to convert light intensity into signals to feed them into our ICs or a microcontroller so the data can be interpreted and output can be obtained. We need a device that can sense the intensity of light in the surroundings and provide that information in the form of electrical signals to make a robot that acts on the intensity of light. Sensors, come to the rescue. Just like you have your senses to interact with the surroundings, such as

  1. Eyes for visual input (discussed above)
  2. Ears for auditory inputs
  3. Tongue for the sense of taste (or sense of pH indirectly)
  4. Skin for the sense of touch, change in temperature, etc
  5. Nose for the sense of smell

Similarly, fields of electronics also have several sensors so that the ICs and microcontrollers can interact with their surroundings. Although most of the sensors provide output in the form of electrical signals, some sensors provide data in some other form too.

For example, a thermometer is a sensor or a temperature sensor that senses the temperature and provides data in the form of visual information. In our case, we are going to use an LDR(sensor) to detect the intensity of light which in return feeds that data into our device to process further.

In a nutshell, sensors are the devices that detect the alteration in electrical or physical, or other quantities and provide the compatible data to the devices you are using to process the information. For a robot utilizing electronic circuitry or system to perform any useful task or function, it needs to be able to communicate with the “real world” whether this is by reading an input signal from an “ON/OFF” switch or by activating some form of the output device to illuminate a single light.

Now, we’ve mentioned some sensors. We need you to think which electronic sensors are associated directly with our sense organs and how. This is an assignment to help you understand the relation between sensors in humans and machines.

In the next blog, we’ll learn about how to choose sensors. We’ll also classify a wide range of sensors on different bases, and how they work.

Till then, try to think about more sensors that provide the data but not in the form of electric signals.

Robotics &
Research
Group

GROUP

Home

Team

Alumni

PROJECTS

Achievements

Projects

Contribute

ACTIVITIES

Workshops

Blogs

Gallery


COPYRIGHT 2023, ZINE
zine.nitj@gmail.com

Get it on Google Play