This book is about the Arduino microcontroller and the Arduino concept. The visionary Arduino team of Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca. newly developed or emerging material in digital circuits and systems design and analysis. Arduino Microcontroller: Processing for Everyone! Second Edition. This book is about the Arduino microcontroller and the Arduino concept. The third edition has been updated with the latest on these two processing boards.
|Language:||English, Spanish, German|
|Distribution:||Free* [*Sign up for free]|
This book is about the Arduino microcontroller and the Arduino concept. .. the processor to complete 20 million instructions per second (MIPS) when . continuous loop to gather data and issue outputs to steer the robot through the maze. There seemed to be a huge sense of community with everyone the Arduino that it has since been updated to this second edition with improvements . microcontroller designed to make the process of using electronics in. Download as PDF, TXT or read online from Scribd Arduino Microcontroller Processing for Everyone! .. We also discuss the Arduino Development Environment built-in features that allow generation of an output analog If we only had a single bit. while the encoded sampled value for the second sample is _
If you are a seller for this product, would you like to suggest updates through seller support? Read more Read less. Customers who viewed this item also viewed. Page 1 of 1 Start over Page 1 of 1.
Arduino Microcontroller Processing for Everyone! Synthesis Lectures on Digital Circuits and Systems. Product details Series: English ISBN Tell the Publisher! I'd like to read this book on Kindle Don't have a Kindle? Share your thoughts with other customers. Write a customer review. Top Reviews Most recent Top Reviews. There was a problem filtering reviews right now. Please try again later.
Paperback Verified download. Covers Uno and Mega boards. Not just a book of examples but how to write code. See the review. site Giveaway allows you to run promotional giveaways in order to create buzz, reward your audience, and attract new followers and customers. Learn more about site Giveaway. This item: Arduino Microcontroller Processing for Everyone!: Set up a giveaway. There's a problem loading this menu right now. Learn more about site Prime. Get fast, free shipping with site Prime.
Back to top. Get to Know Us. Quantization and Encoding. Threshold Detector. Art piece illumination system — Revisited. Buzzers 8. Flight Simulator Panel. Fine Art Lighting System. Automated Fan Cooling System. Chapter 2 provides an introduction to programming for the novice programmer. These chapters are intended for engineering students and practicing engineers. Chapter 1 provides a review of the Arduino concept.
There approach was to openly share details of microcontroller-based hardware design platforms to stimulate the sharing of ideas and innovation. It also serves as a good review for the seasoned developer. Preface This book is about the Arduino microcontroller and the Arduino concept. Chapters 1 through 2 are intended for novice microcontroller users. It provides a systematic.
Chapter 3 provides an introduction to embedded system design processes. Chapter 2 also introduces the Arduino Development Environment and how to program sketches. This book is written for a number of audiences. Chapters 4 through 8 provide detailed engineering information on the ATmega microcontroller and advanced interfacing techniques. In I would like to dedicate this book to my close friend and writing partner Dr.
May Steve Barrett. Daniel suggested that we might write a book together on microcontrollers. He also provided permission to include portions of background information on the Atmel line of AVR microcontrollers in this book from several of our previous projects. I know that we will do many more together. To you good friend I dedicate this book. I would like to thank Massimo Banzi of the Arduino design team for his support and encouragement in writing the book.
Atmel Incorporated. I would also like to thank Sparkfun Electronics of Boulder. Daniel Pack. Daniel is a good father.
I would like to thank my wife and best friend of many years. After reading this chapter. Most microcontrollers are equipped with an ADC subsystem. An ADC system performs this task while a digital to analog converter DAC performs the conversion in the opposite direction. DACs must be added as an external peripheral device to the controller. Since the information from the natural world.
We will discuss both types of converters in this chapter. In this chapter. Each digital system has a number of bits it uses as the basic unit to represent data. Engineers who work for telephone companies must deal with such issues. A byte is eight bits. Harry Nyquist from Bell Laboratory studied the sampling process and derived a criterion that determines the minimum sampling rate for any continuous analog signals. In the example above. Now that we understand the sampling process. A nibble is made up of four bits put together.
For example. For further study on the Nyquist sampling rate. Sampling is important since when we want to represent an analog signal in a digital system. We present three important processes associated with the ADC: We conclude our discussion of the analog-to-digital converter with several illustrative code examples. Throughout the chapter. When we sample a signal.
In essence. We also discuss the Arduino Development Environment built-in features that allow generation of an output analog signal via pulse width modulation PWM techniques. A bit is the most basic unit where single binary information. Any analog signal value in between the range had to be mapped either as level 0 or level 1. You can represent four different levels. If we add one more bit.
Suppose you have two bits. When a signal is sampled. Suppose you have a single bit to represent an incoming signal. Similar discussion can lead us to conclude that given n bits.
The voltage signals are then conditioned to map their range with the input range of a digital system. How about What happens when the available number of bits is 8?
How many different quantization levels are available now? What if you have three bits? You now can represent eight different levels: Figure 5.
In Figure 5. Note the amount of quantization error introduced for both samples. As a result of the encoding process. Now imagine what happens as we increase the number of bits available for the quantization levels.
Consider the two sampled signals shown in Figure 5. Think of it as follows. The quantization of a sampled signal is how the signal is represented as one of the quantization levels. In many digital systems. Once a sampled signal is quantized. The quantization levels are determined by the eight bits and each sampled signal is quantized as one of quantization levels. You only have two different numbers. If we only had a single bit. You may say that you can distinguish only low from high.
When you had two bits. The quantization error is inversely proportional to the number of bits used to quantize the signal. Suppose again we are using eight bits to quantize a sampled analog signal. Suppose again we have a range of 5 volts and one bit to represent an analog signal. In fact. Suppose you have 20 bits for quantization levels.
Suppose you now have four bits to represent quantization levels. You can imagine how your TV screen will look if you only had only two levels to represent each pixel. The resolution now becomes 1. In general. Resolution is a measure used to quantize an analog signal.
The resolution in this case is 2. As the number grows. The number of bits used for the quantization is directly proportional to the resolution of a system.
The maximum error. The resolution now becomes 4. It has to do with the cost involved. If all customers are making out of town calls. For such reasons. Toward this end. The unit used for the measurement is Decibel dB. Dynamic range. A camera. Depending on the purpose. The mouse. We just saw that the more bits we use for the quantization levels. You will need some major computing power to meet the requirement for processing and storage of the data.
In particular. Before the ADC process takes place. If the conversion is from physical to electrical. The dynamic range is a measure used to describe the signal to noise ratio. The answer will be The greater the dB number. For each individual phone conversation. Why not use the maximum number of bits current technologies can offer for all digital systems.
Speakers and electrical motors are also output transducers. A poorly designed interface could result in improper embedded system operation or failure. The box with constant K maps the output range of the input transducer to the input range of the converter. The objective of the transducer interface circuit is to scale and shift the electrical signal range to map the output of the input transducer to the input range of the analog-to-digital converter which is typically 0 to 5 VDC.
Note that the scale factor maps the output range of the input transducer as Interface techniques are discussed in detail in Chapter 8. Once the range has been mapped. The second portion of the circuit shifts the range by 2. The computer screen and the printer for your computer are output transducers. The signal conditioning circuitry is called the transducer interface.
The scalar multiplier maps the magnitudes of the two ranges and the bias voltage is used to align two limits. The range of the sensor voltage output is mapped to the analog-to-digital converter input voltage range. A block diagram of the signal conditioning for an analog-to-digital converter. It is important to carefully design the interface between transducers and the microcontroller to insure proper operation. We thus have two equations and two unknowns to solve for K and B.
This voltage occurs when the minimum physical variable Xmin is presented to the input transducer. A photodiode is a semiconductor device that provides an output current corresponding to the light impinging on its active surface. In this section. This voltage occurs when the maximum physical variable Xmax is presented to the input transducer. The variable V1min represents the minimum output voltage from the input transducer.
This voltage must be scaled by the scalar multiplier K and then have a DC offset bias voltage B added to produce voltage V2min to the input of the ADC converter. Going through this design process yields a required value of gain K and DC bias B.
Due to the large value of Avol. Op amps are typically used in a closed loop. Op amps are also used in a wide variety of other applications including analog computing. We do not have the space to investigate all of these related applications. When an op amp saturates. The two inputs are labeled Vp. Vn saturation -Vcc Figure 5. The interested reader is referred to the References section at the end of the chapter for pointers to some excellent texts on this topic.
This will clip the output. The op amp is an active device requires power supplies equipped with two inputs. The output of the op amp is determined by taking the difference between Vp and Vn and multiplying the difference by the open loop gain Avol of the op amp which is typically a large value much greater than An ideal operational does not exist in the real world. Adapted from [Faulkenberry]. In the previous section. Since this stage also introduces a minus sign to the result. As an example.
For a review of other converter techniques. The two-stage op amp circuitry provided in Figure 5. Rf Node equation at Vn: This same analysis technique may be applied to all of the circuits in Figure 5. Programming and Interfacing. In the second stage. The advantage of this technique is that the conversion time is uniform for any input. The successive-approximation technique uses a digital-to-analog converter. It has the following features [Atmel]: Based on the result of the comparison.
The process continues until decisions are made for all available bits. The ADC is equipped with a single successive-approximation converter. The ADC system may be run at a slower clock frequency than the main microcontroller clock source.
Only a single ADC channel may be converted at a given time. Successive-approximation ADC. It requires 13 analog-to-digital clock cycles to perform an ADC conversion.
The input of the ADC is equipped with an six input.
It must be emphasized that the ADC system has many advanced capabilities that we do not discuss here. These bits may be set to the following values: The analog input voltage for conversion must be between 0 and Vcc volts.
We will discuss each register in turn [Atmel]. The key features and registers of the ADC system previously discussed are included in the diagram. These two registers provide 16 bits for the bit result. This may be accomplished using the following C instruction: The analog input for conversion is selected using the MUX[3: The six analog input channels are provided at ADC[5: Our goal is to review the basic ADC conversion features of this powerful system.
The left edge of the diagram provides the external microcontroller pins to gain access to the ADC. The REFS[1: If this is not the case. We have already discussed many of the register setting already. Figure used with permission of Atmel. Internal 1. The ADC is turned on by setting this bit to a logic one. Setting this bit to logic one initiates an ADC. This bit sets to logic one when the ADC is complete.
The ADIF bit is reset by writing a logic one to this bit. The ADC clock is derived from dividing down the main microcontroller clock. The ADPS[2: The format for the analogRead function is: Recall that we introduced the use of this function in the Application section at the end of Chapter 3. The analogRead function was used to read the analog output values from the three IR sensors on the Blinky A robot.
In this particular example, the ADC prescalar is set to 8 the main microcontroller clock was operating at 10 MHz. The function then enters a while loop waiting for the ADIF bit to set indicating the conversion is complete. After conversion the ADIF bit is reset by writing a logic one to it.
The desired channel for conversion is passed in as an unsigned character variable. In this example, we construct a rain gage type level display using small light emitting diodes. The rain gage indicator consists of a panel of eight light emitting diodes. The gage may be constructed from individual diodes or from an LED bar containing eight elements. Whichever style is chosen, the interface requirements between the processor and the LEDs are the same. The requirement for this project is to use the analog-to-digital converter to illuminate up to eight LEDs based on the input voltage.
A 10k trimmer potentiometer is connected to the ADC channel to vary the input voltage. Then a solution employing the ATmega programmed in C is provided. We describe the operation of the LED interface circuit in Chapter 8. The sketch to implement the project requirements is provided below. In this example, the loop function senses the voltage from the 10K trimmer potentiometer and illuminates a series of LEDs corresponding to the sensed voltage levels.
ADC with rain gage level indicator. In this example. The algorithm for the project was written by Anthony Tony Kunkel. This prevents the display from looking as a series of LEDs that are always illuminated.
PD0 3 TXD1. PC6 2 RXD1. The result is returned as a right justified. Recall in Chapter 1. A threshold level is applied to one input of the op amp.. This serves as a comparison reference for the signal applied to the other input. When the input signal is greater than the set threshold value. That is. It is a hardware version of a rain gage indicator. If a single-sided op amp is used in the circuit e. A bank of threshold detectors may be used to construct a multi-channel threshold detector as shown in Figure 5.
In Chapter 1. The two inputs are constantly compared to one another. When the input signal falls below the threshold the op amp will saturate at a voltage slightly greater than —Vcc. One-bit ADC threshold detector. A summation method to convert a digital signal into a quantized analog signal. With the summation method of digital-to-analog conversion. Human voice is converted to a digital signal. The most commonly used technique to convert digital signals to analog signals is the summation method shown in Figure 5.
A simple example of such a conversion occurs in digital audio processing. The process to convert digital signals to analog signals is completed by a digital-to-analog converter. For each bit. Comparators are used to clean up incoming signals and the resulting values are multiplied by a scalar multiplier and the results are added to generate the output signal. Reference Figure 5. This signal. Once all bits for the signal have been processed.
It has a wide range of features packed into a pin chip including [Texas Instrument]: The form of the analogWrite command is the following: The Blinky A control sketch provided in Chapter 3 used the analogWrite command to issue drive signals to the robot motors to navigate the robot through the maze.
The analogWrite function is used to issue a proportional signal. The LEDs could be mounted in front of or behind the painting as the artist desired. The analogRead function is used to obtain the signal from the IR sensor. The painting was to be illuminated via high intensity white LEDs. A circuit diagram of the system is provided in Figure 5.
The Load line is pulsed low to update the DAC. As can be seen in the timing diagram. We also wanted to adjust the intensity of the lighting based on how the close viewer was to the art piece. The Arduino Development Environment sketch to sense how away the viewer is and issue a proportional intensity control signal to illuminate the LED is provided below. We equipped the lighting system with an IR sensor to detect the presence of someone viewing the piece.
The function to transmit data to the DAC is left as an assignment for the reader at the end of the chapter. Adapted from [Texas Instrument]. Eight channel DAC. IR sensor interface. We also presented the quantization errors and the data rate associated with the ADC process.
We then presented the successive-approximation converter. The dynamic range of an analog-to-digital converter. We then reviewed the operation. Second Edition. McGraw-Hill Book Company. Discrete-time Signal Processing. Academic Press. Microcontroller Theory and Applications: HC12 and S Cambridge University Press.
New York. Introduction to Biomedical Engineering. Upper Saddle River. McGraw-Hill Companies. Fourth Edition. Atmel Corporation. Electrical Signals and Systems. Texas Instruments. Prentice Hall. The Analysis and Design of Linear Circuits. Morgan and Claypool Publishers. The Art of Electronics. San Jose. New Jersey CA New Jersey. Horowitz and W. Susan Blanchard. Stout and M. Design a circuit to convert the resistance change to a voltage change Hint: A photodiode provides a current proportional to the light impinging on its active area.
If 12 bits are used to quantize a sampled signal. Given the 12 V input range of an analog-to-digital converter and the desired resolution of 0. Find the sampling rate. If an analog signal is converted by an analog-to-digital converter to a binary representation and then back to an analog voltage using a DAC. Given a sinusoid with Hz frequency. What will be the resolution of such a system if the input range of the analog-to-digital converter is 10V? Investigate the analog-to-digital converters in your audio system.
Does the time to convert an analog input signal to a digital representation vary in a successiveapproximation converter relative to the magnitude of the input signal? These tasks.
To process such events. The interrupt system onboard a microcontroller allows it to respond to higher priority events. Once the ISR is complete. We provide several examples on how to program an interrupt in C and also using the built-in features of the Arduino Development Environment.
When an interrupt event occurs. Appropriate responses to these events may be planned. The interrupt service routine will then commence. Microcontroller Interrupt Response. The interrupts are listed in descending order of priority. The remaining interrupt sources are internal to the ATmega When an interrupt occurs. As you can see. The ATmega interrupt sources are shown in Figure 6. Execution of. It also turns off the interrupt system to prevent further interrupts while one is in progress.
This is accomplished with the assembly language instruction SEI. We provide both an externally generated interrupt event and also one generated from within the microcontroller. The number that follows the ISR name corresponds to the interrupt vector number in Figure 6. The ISR is then written like any other function.
For each type of interrupt. It is important that the ISR name used in the pragma instruction identically matches the name of the ISR in the function body. Since the compiler knows the function is an ISR. In the next two examples that follow. For the C examples. Program control then reverts back to the main program. Other compilers have similar features.
INTFx flag sets when corresponding interrupt occurs. External Interrupt Control Register. Figure 6. This function links the interrupt to the appropriate interrupt service routine. These are the four functions: This function disables interrupts. LOW level on pin. The attachInterrupt interrupt. This function enables interrupts. The Arduino Duemilanove processing board is equipped with two external interrupts: To illustrate the use of these built-in Arduino Development Environment features.
In the example that follows. The resonator frequency is further divided by using the clock select bits CS[2: If activated. We discuss the ATmega timer system in detail in the next chapter. The function stays within a while loop until the desired number of interrupts has occurred.
To create a precision delay. The function requires an unsigned integer parameter value indicating how many 6. When CS[2: If a different source frequency is used. These vector names are provided in the right column of Figure 6. The Arduino Duemilanove is clocked with a 16 MHz crystal. In the following sketch. To tie the interrupt event to the correct interrupt service routine. How is this possible with a single processor? Normal processing accomplished by the microcontroller is called foreground processing.
It processes instructions in a fetchdecode-execute sequence as determined by the program and its response to external events.
To keep track of clock time in seconds. The ticks are counted in reference to clock time variables and may. Once the door is in motion. This may be accomplished using interrupts. An interrupt may be used to periodically break into foreground processing. In many cases. The microcontroller responds to user input status in the foreground while monitoring safety related status in the background using interrupts.
Interrupt used for background processing. This is also a useful technique for generating very long delays in a microcontroller. The timing functions in the previous example assumed a time base of 10 MHz. The ATmega on the bottom serves as the positional encoder. Since the actual encoder is not available for evaluation. Encoder data format. The actual encoder is new technology and production models are not available for evaluation. The encoder provides bit resolution.
The current position is converted to an analog signal via the DAC. You have been asked to evaluate a new positional encoder technology.
The position data is sent serially at Baud as two sequential bytes as shown in Figure 6. The pushbutton at PD2 provides a debounced input to open a simulated door and increment the positional encoder. In the following example. The position data is sent serially at Baud as two sequential bytes. The pushbutton at PD3 provides a debounced input to close a simulated door and decrement the positional encoder.
The microcontroller is equipped with two pushbuttons at PD2 and PD3. The transmitted and received signals may be compared at the respective DAC outputs.
PC6 2 RXD. PD0 3 TXD. April Steven Barrett. We also discussed how to program an interrupt for proper operation and provided representative samples for an external interrupt and an internal interrupt. What are the concerns when using multiple interrupts in a given application? What is the advantage of using interrupts over polling techniques?
The pin should go logic high three weeks from now. Describe the built-in interrupt features available with the Arduino Development Environment. Explain in detail. Adapt the 24 hour timer example to generate an active high logic pulse on a microcontroller pin of your choice for three seconds. What is the purpose of an interrupt? A 10 MHz ceramic resonator is not available. Describe the interrupt features available with the ATmega What is the accuracy of the timer? How can it be improved?
How much time can background processing relative to foreground processing be implemented? What is the interrupt priority? How is it determined? In the text. We begin with a review of timing related terminology. Timer 0. We then provide an overview of the general operation of a timing system followed by the timing system features aboard the ATmega Timer 1. In a simple application. In a more involved application. We then review the built-in timing functions of the Arduino Development Environment and conclude the chapter with a variety of examples.
We call this signal periodic with period T. The unit of frequency is the Hertz or cycles per second. To control the direction and sometimes the speed of a motor.
Both periods and frequencies of signals are often used to specify timing constraints of microcontroller-based systems. For a timer system. The constraint then forces the design team that monitors the slippage to program their monitoring system to check a slippage at a rate of 50 Hz.
The job of a free running counter is to. If an event occurs with a rate of 1 Hz. The pulse shown in b is on for only 25 percent of the same period as the signal in a and off for 75 percent of the period. The periodic pulse signal shown in Figure 7. To measure the frequency of a periodic signal. A good example is the use of a periodic pulse to control a servo motor.
To provide for a wider range of frequency selections an external time source may be used. The RC internal time base is selected using programmable fuse bits. All other timer related units reference the contents of the free running counter to perform input and output time related activities: As previously mentioned.
The Arduino Duemilanove processing board is equipped with a 16 MHz crystal oscillator time base. Two signals with the same period but different duty cycles. The external time sources. The ATmega may be clocked internally using a user-selectable resistor capacitor RC time base or it may be clocked externally. The system designer chooses the time base frequency and clock source device appropriate for the application at hand.
Since we already know how long it takes for the system to increment by one. You can also use the timer input system to measure the pulse width of an aperiodic signal. We can use such ability to measure the period of an incoming signal. The checking process is executed at each clock cycle and when a match occurs. In such situations. The second overall goal of the timer system is to generate signals to control external devices.
Now consider Figure 7. We can use these values to easily compute the pulse width of 0. Using such capability. The timer input system then uses the clock values to compute frequencies. Suppose your microcontroller is clocked by a 2 MHz signal and the system clock uses a bit free running counter. For output timer functions. For such a system. Suppose an external device connected to the microcontroller requires a pulse signal to turn itself on.
Such components rely on a free running counter to capture external event times. The pulse width of the signal in the number of counter value is The simple answer is that we can not do so directly. A programmer must use the system clock values and derive the absolute time values. Suppose the particular pulse the external device needs is 2 millisecond wide. From the examples we discussed above. A diagram of a timer output system. To calculate the total elapsed time of an event. When a counter rolls over from its maximum value back to zero.
Our calculations do not take into account time increments lasting longer than the rollover time of the counter. Elapsed time may be calculated using: The equation. Logic high. The rollover events may be counted to correctly determine the overall elapsed time of an event. To reduce power consumption a microcontroller usually does not turn on all of its functional systems after reset until they are needed. Once the timer is turned on and the clock rate is selected.
Use of the timer input and output systems of a microcontroller. Figure 7. The captured signal is subsequently used to compute the input signal frequency. This step is done using a special input timer port.
The signal on top is fed into a timer input port. The signal on the bottom is generated using the timer output system. In addition to a separate timer module. The signal is used to control an external device. To convert to seconds the number of clock ticks are multiplied by the period of the clock source of the free running counter.
Using the hardware and functional units discussed in the previous sections. If we assume that the timer clock runs at 10 MHz. A programmer then needs to record the newly acquired captured time represented in the form of a free running counter value again.
Suppose we want to count the number of logic state changes of an incoming signal for a given period of time. To use interrupt systems. Such situation introduces the second method: The period of the signal can now be computed by computing the time difference between the two captured event times. In this application. The next step is to program the input event to capture. For both techniques. In our current example. Most microcontroller manufacturers have developed built-in interrupt systems with their timer input modules.
If the polling technique is used. If we turn on a DC motor and provide the required voltage. Suppose that the external device requires a pulse which is 2 milliseconds wide to be activated. As was mentioned in Section 5. In this subsection and the next one. For the particular example in Figure 7. If the interrupt technique is used. Suppose we turn the motor on and off rapidly.
As shown in. By changing the duty cycle. The timing signal is arbitrary but the application will show that a timer output system can generate any desired time related signals permitted under the timer clock speed limit of the microcontroller.
Suppose in this application. To generate the desired pulse. The motor at some point can not react fast enough to the changes of the voltage values and will run at the speed proportional to the average time the motor was turned on.
Similar to the use of the timer input system. As was the case with the input timer system module. To generate the signal shown in Figure 7. The underlying concept is as follows. Once the rising edge is generated.