Arduino microcontroller processing for everyone second edition pdf

Thursday, March 21, 2019 admin Comments(0)

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 _

Language: English, Spanish, Japanese
Country: Honduras
Genre: Technology
Pages: 481
Published (Last): 10.09.2016
ISBN: 906-7-43643-537-6
ePub File Size: 15.84 MB
PDF File Size: 12.63 MB
Distribution: Free* [*Regsitration Required]
Downloads: 39546
Uploaded by: DELL

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.

Online publication date: It is a hardware version of a rain gage indicator. To turn the motor clockwise. If no switches have been depressed in the row. Adapted from [Faulkenberry]. Support your answer.

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.

You might also like: CAO FORM 2016 PDF

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.

Microcontroller edition arduino second for pdf everyone processing

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.

Arduino Micro Controller Processing for Everyone Part II

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.

Everyone pdf edition microcontroller second for arduino processing

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.

Arduino Microcontroller Processing for Everyone! Third Edition

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.

Edition pdf everyone microcontroller for arduino processing second

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. In addition. As a part of the initialization process. As the elevator approaches. Once the falling edge is generated. The elevator motor speed will ramp up gradually from stop to desired speed. If we want. This technique may be used to generate any desired duty cycle.

The features of the timing system are summarized in Figure 7. The timer channels are designated Timer 0. This information may be readily adapted to Timer 1 and Timer 2.

Fast PWM. The clock source for Timer 0 is provided via an external clock source at the T0 pin PD4 of the microcontroller. The information provided on timer channel 0 is readily adapted to the other two channels. The clock source for Timer 0 is selected using the CS0[2: Timer 1 is equipped with the Input Capture feature.

We provide more information on these modes shortly. Space does not permit a complete discussion of the other two timing channels. This clock frequency may be too rapid for many applications. We begin with an overview of the timing system features followed by a detailed discussion of timer channel 0. Each timing channel has the capability to generate pulse width modulated signals. A Timer 0 block diagram is shown in Figure 7. Timer 0 and 2 are 8-bit timers. Timer 1 is a bit timer.

Each timing channel is equipped with a prescaler. Normal -. Clear timer on compare match CTC -. Frequency generation -. Pulse width modulation -. Fast PWM -. Event counter -. Phase correct PWM Timer 2.

Modes of operation: Phase correct PWM Timer 1. The compare signal from the 8-bit comparator is fed to the waveform generators. Output compare -. The waveform generators have a number of inputs to perform different operations with the timer system.

This register is incremented or decremented on each clkT n clock pulse. Atmel timer system overview. Phase correct PWM Figure 7. Input capture. Figure used with permission Atmel. Timer 0 block diagram. The system designer chooses the correct mode for the application at hand. The timer modes of operation are summarized in Figure 7. Timer 0 modes of operation. The CTC mode is used to generate a precision digital waveform such as a periodic signal or a single pulse.

We provide an example of this application in Section 5. Timer 0 registers. Set OC0B on compare match when down counting Figure 7. As discussed earlier in the chapter. When the desired edge occurs. It shares many of the same features of the Timer 0 channel.

The block diagram for Timer 1 is shown in Figure 7. Each register will be discussed in turn. Due to limited space the shared information will not be repeated. Timer 1 block diagram. Figure used with Permission.

Timer 1 registers. Phase Correct 11 PWM. Phase Correct. OC0 disconnected 01 WGM1[3: Clear OC0 on compare match when down counting. Its registers are summarized in Figure 7. TIMER 2 7. The Timer 2 channel block diagram is provided in Figure 7. Timer 2 block diagram. Timer 2 registers. These include: The pulseIn function measures the length of an incoming digital pulse. The pulseIn function returns the length of elapsed time in microseconds as an unsigned long.

The PWM frequency is approximately Hz. Set OC2B on compare match when down counting Figure 7. We will provide examples of using the timer system to generate a prescribed delay. Note how the PWM ramps up from 0 to the desired speed. An analog voltage provided to ADC Channel 3 is used to set the desired duty cycle from 50 to percent.

The microcontroller is set to operate at an internal clock frequency of 1 MHz. A voltage-follower op amp circuit is used as a buffer between the ATmega and the servo motor. Pulse lengths in between these two extremes provide angular displacements between 0 and degrees. A test and interface circuit for a servo motor is provided in Figure 7. A 1 ms pulse provides an angular displacement of 0 degrees while a 2 ms pulse provides a displacement of degrees.

Arduino Microcontroller: Processing for Everyone! Second Edition - Morgan & Claypool books

Most servo motors provide the angular displacement relative to the pulse length of repetitive pulses sent to the motor as shown in Figure 7. The software to support the test and interface circuit is provided below.

For edition everyone processing pdf arduino second microcontroller

Pulse width modulated signals to rotate the servo motor is provided by the ATmega Test and interface circuit for a servo motor. We then took a detailed look at the timer subsystem aboard the ATmega and reviewed the features.

Robert Coughlin. We then investigated the builtin timing features of the Arduino Development Environment. Embedded Microprocessor Systems Design: Embedded Microcontrollers. To turn on the sprinklers of a zone. Given an 8 bit free running counter and the system clock rate of 24 MHz. Program the output compare system of the ATmega to generate a 1 kHz signal with a 10 percent duty cycle.

Describe how one can generate an aperiodic pulse with a pulse width of 2 minutes? Design a microcontroller system to control a sprinkler controller that performs the following tasks. We assume that your microcontroller runs with 10 MHz clock and it has a 16 bit free running counter. The sprinkler controller system controls two different zones by turning sprinklers within each zone on and off.

Describe how you can compute the period of an incoming signal with varying duty cycles. To turn off the sprinklers of the same zone. If we desire to generate periodic signals with periods ranging from nanoseconds to microseconds.

Modify the code of the automated cooling fan example to also display the set threshold temperature. For the automated cooling fan example. To meet this wide audience, the book has been divided into sections to satisfy the need of each reader.

The book contains many software and hardware examples to assist the reader in developing a wide variety of systems. The second edition has been updated with the latest on the Arduino UNO R3 processor, changes to the Arduino Development Environment and several extended examples.

Table of Contents: If you have purchased an Individual Subscription or were provided with a login for access, you may enter your username and password here. Sign in to personalize your visit. New user? Register now. Quick search: This issue This series All series. Steven F. Third Edition This book is about the Arduino microcontroller and the Arduino concept. Access to the content you have requested requires one of the following:.

View Abstract Free Add to favorites Email to a friend.