Beginning Embedded Electronics - 1

Not rated 29,201

Circuit Image

This series of lectures is designed for individuals with a basic understanding of electronics, such as sophomores in Electrical and Computer Engineering, to explore the field of Embedded Electronics. It is assumed that the reader has a fundamental knowledge of electricity and has interacted with electrical components. The content is presented in a straightforward manner, encouraging readers to take their time. The goal is to motivate seasoned Electrical Engineering students to engage in practical applications, such as connecting an LED. There is an acknowledgment that mistakes are part of the learning process. The tutorials were originally created using the ATmega8 microcontroller, but the ATmega328 is now available. Although the images may depict the ATmega8, all relevant information for the ATmega328 will be provided in subsequent sections. The text provides a brief overview of logic gates, specifically the OR gate, which takes two inputs to control an output. Readers may recognize a DIP (Dual In-line Package) containing multiple OR gates, which requires power and ground connections for operation. By altering the inputs, the output can be modified. Microcontrollers function similarly to OR gates, with inputs and outputs, but they also execute code. For example, by monitoring the states of two pins (A and B), one can control an output pin (C). This ability to program microcontrollers allows for various applications, as they are used in everyday electronics like microwaves, TV remotes, and vehicles. Modern microcontrollers utilize flash memory, allowing code to be rewritten multiple times, unlike older one-time programmable versions. Microcontrollers are distinct from traditional computers, as they require less power, boot up quickly, and are inexpensive. The discussion returns to the OR gate IC, which has multiple pins dedicated to inputs and outputs. The basic function of microcontroller pins is GPIO (General Purpose Input/Output), allowing for flexible configuration. Each input pin can be monitored and acted upon, exemplified by a simple code that toggles a pin every two seconds, illustrating the fundamental concepts of microcontroller programming.

Microcontrollers are integral to contemporary electronic systems, serving as the backbone of numerous applications. The ATmega328 microcontroller, for example, is a popular choice for hobbyists and professionals alike due to its balance of performance, ease of use, and affordability. It features 32KB of flash memory, 2KB of SRAM, and 1KB of EEPROM, which provides ample storage for complex applications while allowing for easy modification of the code.

The GPIO pins of the ATmega328 can be configured for various functions, including digital input, digital output, analog input via its built-in ADC (Analog to Digital Converter), and PWM (Pulse Width Modulation) output. This versatility enables the microcontroller to interface with a wide array of sensors, actuators, and communication modules, making it suitable for projects ranging from simple LED blinking to complex robotics and IoT (Internet of Things) applications.

Programming the ATmega328 typically involves using the Arduino IDE, which simplifies the coding process through a user-friendly interface and a rich library of pre-written functions. This allows users to focus on the logic of their applications rather than the intricacies of the hardware. The ability to upload code via USB or serial connections further enhances accessibility for users at all skill levels.

In practice, a basic project could involve connecting an LED to one of the GPIO pins. By writing a simple program to toggle the pin state, the LED will blink on and off at a specified interval. This foundational exercise not only demonstrates the microcontroller's capabilities but also serves as an introduction to more advanced concepts such as interrupt handling and sensor integration.

Overall, the exploration of embedded electronics through microcontrollers like the ATmega328 provides a pathway for individuals to develop practical skills in electronics and programming, fostering innovation and creativity in the field.This is a series of lectures written for those with mild electronics background (aka Sophomore in Electrical and Computer Engineering) to learn about the wild world of Embedded Electronics. I assume only that you know what electricity is and that you`ve touched an electrical component. Everything else is spelled out as much as possible. There is q uite a lot here so take your time! It is also my intention to get book-hardened EE`s students to put down the calculator and to plug in an LED. Remember, if it smokes, at least you learned what not to do next time! Sorry for the confusion. When these tutorials were written and photographed, we used the ATmega8. We now carry the newer ATmega328. You will find all ATmega328 information in the following pages, but the pictures will show an ATmega8.

You may know what an OR gate is. An OR gate is a logic gate that takes two inputs and controls an output. You may have played with these types of gates, even possibly a DIP packaged OR gate with 4 OR gates built into it. This DIP package required a power pin and a ground pin. Electricity flowed through the IC and allowed it to operate. You may not be sure how the IC was built, but you understand that if you change the inputs, the output changes.

You can do this by tying the inputs to either power (also known as VCC) or ground (GND). You probably played with one of the DIP ICs in a breadboard. If any of this is completely alien to you, don`t fret! We`ll try to ease you into it. A microcontroller is the same as an OR gate. You have some inputs, you have outputs. The crazy thing is that a micro runs code. Machine code to be specific. For instance, with a little bit of work, you can monitor the input of two pins A and B. And based on those inputs, you can control an output pin C. So to replicate an OR gate: It`s C code! You can code up all sorts of different applications, compile code, load it onto a micro, power the micro, and the code runs. Very simple! Microcontrollers are used in all the electronics you take for granted such as your microwave, TV remote, cell phone, mouse, printer, there`s over 150 microcontrollers embedded into new cars!

There`s one waiting for you to depress the brakes (BRAKES = 1) and for the tires to lock up (LOCK_UP = 1). When this happens, the micro releases the brakes, and you have ABS (anti-lock brake system). In the old days, microcontrollers were OTP or one-time-programmable meaning you could only program the micro once, test the code, and if your code didn`t work, you threw it out and tried again.

Now micros are `flash` based meaning they have flash memory built inside that allows their code to be written and rewritten thousands of times. I`ve been programming micros for years and always burn out the microcontroller far before I hit the limit of flash programming cycles.

Flash micros are different than computers and RAM. Computers require tons of power and components to get up and running. Computers run HOT. Computers take forever and a day to boot. Micros are on and running code within milliseconds and if they`re warm enough you can feel heat coming off of them, something is very wrong and you`ve probably blown the micro. Oh - and micros cost about $2. Now back to that OR gate IC. It had a bunch of pins, all dedicated to being either inputs or outputs of the various built-in OR gates (4 gates in one package = 8 inputs, 4 outputs, 2 power/gnd pins).

14 pins of fun. Now with a micro, the most basic pin function is GPIO - general purpose input/output. These GPIO pins can be configured as an input or an output. Very cool. Each input pin can be monitored and acted upon. Example: Guess what that code does It toggles a pin high/low every 2 seconds. Fancy right This is the `Hello World` of the microcontroller world. It seems trivial, but by god when you`ve been trying to get a micro up and running after 5 hours of tearing your hair out and you see that LED bli 🔗 External reference