0% found this document useful (0 votes)
24 views41 pages

Unit 3 Aurdino 1

The document discusses analog and serial communication methods for embedded systems including pulse width modulation, RS232, I2C, SPI and interfacing with sensors. It provides details on analog communication, applications, advantages of FM over AM, and using PWM on Arduino boards.

Uploaded by

Ashish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views41 pages

Unit 3 Aurdino 1

The document discusses analog and serial communication methods for embedded systems including pulse width modulation, RS232, I2C, SPI and interfacing with sensors. It provides details on analog communication, applications, advantages of FM over AM, and using PWM on Arduino boards.

Uploaded by

Ashish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

EMBEDDED SYSTEM

DESIGN USING ARDUINO


18ECO108J

UNIT III

Prepared by R.Manohari (AP- Dept of ECE) 1


Contents
• Analog and Serial Communication
• Introduction to Analog Communication
• Pulse Width Modulation
• RS232
• I2C
• SPI Protocol
• Interfacing with Sensors

2
Communication system
• The communication system consists of three basic components.
ØTransmitter
ØChannel
Ø Receiver
• Transmitter is the equipment which converts physical message, such as sound, words,
pictures etc., into corresponding electrical signal.
• Receiver is equipment which converts electrical signal back to the physical message
• Channel may be either transmission line or free space, which provides transmission path
between transmitter and receiver.

3
4
Introduction to Analog Communication -
Applications
• Broadcasting
• Which involves the use of a single powerful transmitter and numerous receivers that are
relatively inexpensive to build
• point-to-point communications
• In which the communication process takes place over a link between a single transmitter
and a single receiver.

5
Cont…
• Radio
• Broadcasting
• AM and FM radio
• The voices are transmitted from broadcasting stations that operate in our neighborhood
• Television
• Transmits visual images and voice
• Point-to-point communication
• Satellite communication
• Built around a satellite in geostationary orbit, relies on line-of-sight radio propagation for the
operation of an uplink and a downlink

6
Cont…
• An analog communication system is a • When transmitting high-quality audio, FM
communication system where the information gives an enhanced post-detection signal-to-
signal sent from point A to point B can only be noise ratio, at the expense of greater
described as an analog signal. An example of bandwidth.
this is Monica speaking to Carl over the
telephone. • Even for narrow band FM, which doesn’t
have post-detection signal-to-noise
• A digital communication system is a enhancement, its noise performance is better
communication system where the information than that of AM, because a limiting IF
signal sent from A to B can be fully described amplifier can be used to reduce the noise.
as a digital signal.
• AM, being a linear modulation process,
• For short-range analog communication— requires linear amplifiers after modulation in
wireless microphones, wireless earphones, the transmitter, which are less efficient than
auditive assistance devices—FM is almost the class C amplifiers used for FM.
exclusively used.
• Higher power conversion efficiency gives FM
an advantage in battery-operated equipment.

7
Analog Communication
• An analog communication system, roughly
speaking, looks like what is drawn in Figure
• You can see that the information
signal x(t) comes in and is mapped by
a modulator into a new signal s(t) ready to be
sent over the channel.
• And that is all that happens at the transmitter
side–no source coder, no channel coding.
• At the receiver side, the signal that arrives from
the channel is picked up, and it goes through
a demodulator, which returns it to a best guess
of the original information signal.
• That's i–no channel decoder, no source decoder.
• The SNR is used to measure the performance of
the Analog communication systems.

8
Introduction to analog communication in
Arduino
• Arduino gives analog output in range of 0 to 255.
• Technically the output is digital but in the form of PWM, but it seems
to be analog.
• Arduino Boards have 6 PWM(Analog Pins) these are PIN No.
3,5,6,9,10,11.

9
Pulse Width Modulation
• Each of the timer/counter peripherals has at least two PWM channels associated with it. The
Arduino software automatically configures all of the available timers for hardware PWM duty at
the beginning of every sketch.
• Using the Arduino-supplied analogWrite() function, the hardware PWM channels can be easily
programmed with any value between 0 (completely off) and 255 (completely on).
• Anything in between produces a variable duty-cycle pulse stream at approximately 490Hz.
• The Arduino software treats all the PWM channels the same, limiting them to eight-bit resolution
and hardwiring them to a relatively slow frequency.
• It’s not hard to reprogram any of the available PWM channels and reconfigure them to your liking.
The only trick is choosing among the many operational modes and setting the parameters
accordingly.
• Listing 7-5 is a short experiment you can try, which illustrates the simplicity of the Arduino’s
analogWrite() function and the use of PWM.

10
PWM-1
• Compile and upload this sketch to either an Arduino
Uno or an Arduino Mega 2560.
• Nothing happens. To make something happen, all you
have to is connect D11 to D13 using a short length of
wire or a small-value resistor.
• On the Arduino Mega 2560, you can use D13 instead
of D11 and the sketch works without the help of the
extra wire.
• This is because the Arduino Mega 2560 has 14 PWM
outputs, which happen to include D13—the one that
is already connected to the LED.
• Using the Arduino Uno, however, you have only six
PWM outputs, and D13 is not one of them.
• That’s OK—you can still connect one of the proper
• Note that you don’t have to explicitly set the direction bit PWM outputs (D11 is the closest, so that’s what you
use) to D13 and light up the LED, as long as D13 itself
for the output pin when using the Arduino’s analogWrite() isn’t programmed to be an output.
function. It takes care of this for you. • Without the wire, using analogWrite() on a non-PWM
• If you don’t use the analogWrite() function, and you set up pin produces 1 for values 128 and above and 0 for
the PWM outputs yourself, you need to remember to values less than 128.
configure the proper pin as an output, either using the
pinMode() function or setting the bits in DDRx appropriately. 11
PWM Tricks
• You can eliminate the jumper
wire in the previous exercise
and replace it with a bit of
software trickery, based on
pin-change interrupts. See
Listing 7-6.
• Listing 7-6. Transferring the
PWM Output to a Different
Pin Using Pin-Change
Interrupts

12
PWM Tricks cont…
• Nothing changes in the loop() function. The value of the pwm • When the output pin is a logical 1, the bitRead()
variable is used to write an analog value to the PWM output pin, macro returns a value of true, so the LED is turned
using the analogWrite() function. on.
• Then the pwm variable is incremented. • When it returns a false value—that is, zero,
indicating the pin is in a logical low state—the LED
• When it gets to its maximum value (255 for a byte, which is the is turned off.
same thing as an unsigned char), it rolls over to its minimum value,
which is 0. • The conditional statement could be more explicitly
written as
• The setup() function now contains the initialization code to enable
PCINT3, which corresponds with the digital pin 11 used by the if(bitRead(PINB, 3) == 1) ...
analogWrite() function.
• This is yet another example of the possible
• Because PCINT3 is contained in the first bank of pin-change compactness possible in the C language.
interrupts, you write an interrupt handler for the PCINT0_vect
signal. • Remove the jumper wire from your Arduino Uno,
compile and upload the sketch, and observe what
• The interrupt handler checks the state of the port pin, using the happens.
bitRead() macro. Notice that no explicit comparison is done in this
conditional statement. • If all goes well, the LED should be ramping up in
brightness over the period of approximately 2.56
• The bitRead() macro returns either 1 or 0, depending on the state seconds and then starting over again.
of the bit being examined. In the C programming language,
conditional statements are evaluated as either true (non-zero) or
false (zero).

13
More PWM Trickery • Table 7-4. Timer/Counter PWM Pins on the Arduino Uno

• The PWM hardware can generate its own


interrupts.
• In the previous example sketch, the PWM signal
was present on two pins at once.
• This is a neat trick and can come in handy when
you need to duplicate a relatively slow signal on
multiple pins, for example, using the hardware
USART to transmit on several different lines at once.
• Let’s use the PWM interrupt for overflow to
increment the PWM duty cycle for you.
• You continue to use one of the Arduino Uno’s • Working backward through Table 7-4, you see that
Arduino PWM pin 11 is connected to
PWM-capable pins, D11. Timer/Counter 2’s OC2A output.
• You saw from the previous sketch that this pin is • Each of the timer/counters on the ATmega328 has
also referred to as PB3 (Port B, bit 3). two PWM channels associated with it, referred to
as A and B.
• To get even closer to the bare metal, you need to • When configured for PWM usage, the internal
know the timer/counter with which this PWM counter is continuously compared with the values
output is associated. stored in the two Output Compare Registers,
OCRxA and OCRxB.
• Table 7-4 lists the timer/counters, their PWM • Several options exist for what to do when the
outputs, and both the AVR names and Arduino values line up properly. 14
names for the Arduino Uno.
More PWM Trickery cont…• Listing 7-7. Reassigning PWM Outputs
• For your second PWM to Any Output Pins, Using Interrupts
experiment, you configure
Timer/Counter 2 for normal
counter mode and enable both
the Compare Match A interrupt
and Overflow interrupt.
• When the counter overflows, the
count starts over at zero.
• At this point, you want to turn
on the LED.
• When the compare match event
takes place, you want to turn off
the LED.
• To do so, you define two
interrupt service routines. See
Listing 7-7.

15
More PWM Trickery cont…
• Table 7-5. Timer Clock Select bits
• The setup() function looks pretty for Timer/Counter 2
familiar, configuring the LED output
pin and the timer/counter
peripheral.
• Timer/Counter 2 has a slightly
different set of available clock
prescalers; see Table 7-5.
• You also enable two distinct
interrupts associated with
Timer/Counter 2, the Match
Compare A and Overflow
interrupts, by setting the
appropriate bits (OCIE2A and
TOIE2) in the Timer/Counter 2
Interrupt Mask Register, TIMSK2.

16
More PWM Trickery cont…
• The loop() function slowly adjusts the PWM duty cycle • In the overflow interrupt handler, the zero
upward by continuously writing to the PWM hardware output scenario is tested by the shortened
using the analogWrite() function. conditional if(pwm), which returns true as
long as the value of pwm isn’t zero; otherwise
• You could save 538 bytes of program memory by not it returns false and the rest of the statement
using the analogWrite() function and writing directly to isn’t executed.
the compare register, OCR2A.
• The compare match interrupt, on the other
• There is a bit of finesse going on in the interrupt service hand, only clears the output if the PWM value
routines. is less than full scale (255).
• You could have simply turned on the LED in the overflow • Let’s try one more variation of the PWM
interrupt (where the counter has just restarted from zero) reassignment experiment.
and turned it off again at the compare match interrupt.
This mostly works. • This time, you move all the functionality that
is presently in the loop() function—that is, the
• It fails at the endpoints, 0 and 255. This is because the ramping up of the PWM output value— into
simplistic approach to PWM (turn on at zero, turn off at the overflow interrupt handler.
compare match) fails to consider that you may not want
to turn on the output (for example, when the output is • Why? Because the overflow interrupt handler
zero) or that you may not ever want to turn off the is being invoked on a regular basis, every time
output (for example, when the output is full-scale).
the counter overflows from 255 back to 0.
• This happens on a fixed, periodic basis.

17
More PWM Trickery cont…
• This means the counter is being clocked at
16,000,000Hz ÷ 128 = 125KHz. After every 256
clocks, the counter overflows. This occurs at
• Either delete or comment-out all the code in roughly 488Hz.
the loop() function.
• This is when the overflow interrupt occurs. In the
• Now update the overflow handler as follows: interrupt handler, the PWM value (pwm) is
incremented by one, which correspondingly
adjusts the PWM duty cycle when it’s written to
the Output Compare Register A for Timer/Counter
2, OCR2A.
• Because this value, too, overflows when it gets to
255 (or after every 256 interrupts, if you want to
• Compile and upload the sketch. You should look at it like that), this results in an apparent
see the same old thing, just a little faster. Why blinking frequency of ~488Hz ÷ 256 = ~1.9Hz, or
faster? about twice a second. This can be adjusted in large
steps by changing the prescaler value of the timer.
• Let’s calculate the update frequency. The
system clock remains at 16MHz. • What’s interesting about this approach is that the
• The prescaler you selected for Timer/Counter loop() function is now doing absolutely nothing.
2 was divided by 128 by writing a 5 to the • All the action is happening behind the scenes in
control register, TCCR2B.
the interrupt handlers. 18
Analog and Serial Communication
• Serial communications provide an easy and flexible • Here are some Arduino serial communications
way for Arduino board to interact with computer and functions.
other devices.
Serial.begin(speed)
• Arduino serial communications is simple to use.
This function sets the serial communications speed. It
• The Arduino programming environment has a has one parameter, speed, which is usually set to 9600.
feature, called the serial monitor, which is
specifically for viewing the serial data Serial.read()
communication. This function receives data from the serial port.
• To activate it: Serial.write(val)
Go to toolbar This function sends data via the serial port. The
parameter val can be a single variable, a string or an
array.
Click on Serial monitor option
Serial.printIn(val, format)
Select the baud rate specified the This functions prints val to the Arduino IDE serial
Serial.begin() function. monitor using some specific format.

19
Analog and Serial Communication

• Is serial communication analog or digital?


• Not all audio and video signals are analog. Standardized signals like
HDMI for video (and audio) and MIDI, I2S, or AC'97 for audio are all
digitally transmitted.
• Most communication between integrated circuits is digital.
• ... Serial peripheral interface (SPI) uses many digital signals to
transmit data between devices.
• Interfaces like serial, I2C, and SPI all transmit data via a coded
sequence of square waves.

20
Serial Communication
• Embedded electronics is all about interlinking circuits (processors or
other integrated circuits) to create a symbiotic system.
• In order for those individual circuits to swap their information, they
must share a common communication protocol.
• Hundreds of communication protocols have been defined to achieve
this data exchange, and, in general, each can be separated into one of
two categories: parallel or serial.

21
Parallel vs. Serial
• Parallel interfaces transfer
multiple bits at the same time.
• They usually require buses of
data - transmitting across eight,
sixteen, or more wires.
• Data is transferred in huge,
crashing waves of 1's and 0's.’
• An 8-bit data bus, controlled by a
clock, transmitting a byte every
clock pulse. 9 wires are used.

22
Parallel vs. Serial
• Serial interfaces stream
their data, one single bit
at a time.
• These interfaces can
operate on as little as
one wire, usually never
more than four.
• Example of a serial
interface, transmitting
one bit every clock pulse.
Just 2 wires required!

23
Parallel vs. Serial
• Parallel communication certainly has its benefits. It's fast,
straightforward, and relatively easy to implement.
• But it requires many more input/output (I/O) lines.
• If you've ever had to move a project from a basic Arduino Uno to
a Mega, you know that the I/O lines on a microprocessor can be
precious and few.
• So, we often opt for serial communication, sacrificing potential speed
for pin real estate.

24
Serial Communication
• There are 2 types: • Asynchronous means that data is
• Synchronous transferred without support from an
• Asynchronous external clock signal.
• A synchronous serial interface • This transmission method is perfect
always pairs its data line(s) with a for minimizing the required wires and
clock signal, so all devices on a I/O pins, but it does mean we need to
synchronous serial bus share a put some extra effort into reliably
common clock. transferring and receiving data.
• This makes for a more
straightforward, often faster serial • It is so common, in fact, that when
transfer, but it also requires at least most folks say “serial” they’re talking
one extra wire between about this protocol.
communicating devices.
• Examples of synchronous interfaces
include SPI, and I2C.

25
Rules of Serial
• The asynchronous serial protocol has a number of built-in rules -
mechanisms that help ensure robust and error-free data transfers.
• These mechanisms, which we get for eschewing the external clock signal,
are:
Data bits,
Synchronization bits,
Parity bits, and
Baud rate.
• Through the variety of these signalling mechanisms, you'll find that there's
no one way to send data serially.
• The protocol is highly configurable.
• The critical part is making sure that both devices on a serial bus are
configured to use the exact same protocols.

26
Serial Communication
• Baud Rate: The baud rate specifies how fast data is sent over a serial line. One of the more common baud
rates, is 9600 bps. Other "standard" baud are 1200, 2400, 4800, 19200, 38400, 57600, and 115200.
• Framing the data: Each block (usually a byte) of data transmitted is actually sent in a packet or frame of bits.
Frames are created by appending synchronization and parity bits to our data.

• data is transferred least-significant bit (lsb) first.

27
Wiring and Hardware

• A serial bus consists of just two


wires - one for sending data and
another for receiving. As such,
serial devices should have two
serial pins: the receiver, RX, and
the transmitter, TX.

28
RS232
• The most famous serial port in the Arduino world is the Universal
Synchronous/Asynchronous Receiver/Transmitter (USART) peripheral, which
sends or receives data over a single wire asynchronously (one wire for each data
direction, plus a ground reference connection) at a predetermined rate.
• Other useful serial peripherals include the two wire interface (a.k.a. TWI or I2C)
and the serial peripheral interface (SPI), both of which use a separate clock and
data line to communicate with other devices. Ethernet is another serial
peripheral that can easily be added to the basic Arduino circuit using a special
shield.
• Unfortunately, there is no standard PC serial port that can work directly and
reliably with the Atmel AVR chips used with most Arduinos. A buffer or level-
shifter circuit is needed, at minimum, to allow the 0–5V signals of the AVR to talk
properly to the most common PC serial port standard, RS-232.
• The modern alternative, the USB standard, is generally thought to be too complex,
when fully realized, to be accommodated by a simple microcontroller like the AVR.
Effective solutions to both interfacing challenges have emerged, and you look at
them in a little detail here.

29
RS-232 Interface
• The oldest Arduino prototypes, and some
modern reproductions, provided a level-
shifter circuit to convert the RS-232
voltage levels to the appropriate 0–5V
levels used by the Arduino.
• This circuit was built of discrete
components and is shown in Figure 4-5.

The RS-232 to TTL level-shifter circuit from the original Arduino


30 serial
RS-232 Interface cont…
• This circuit bears a striking resemblance
to the RS-232 interface used in both the
original AVR ISP device programmer as
well as the example programmer
described in Atmel’s AVR application note
AVR910, “In-System Programming.”
• A more robust interface circuit can be
built using a dedicated RS-232 adapter
chip and some capacitors.
• The Maxim IC MAX232 chip contains a
built-in charge-pump circuit to generate
the required RS-232 voltage levels and all
the level-translation circuitry needed,
while providing much higher isolation
levels and protection.
• This circuit was never used by the
Arduino Team but was picked up by
several versions of the Freeduino project,
including the MaxSerial from
Fundamental Logic. See Figure 4-6.

31
RS-232 Interface
• This circuit also introduces the use of the RS-232 handshaking signal Data Terminal Ready (DTR) to
be used to remotely reset the microcontroller (the auto-reset feature), which in turns invokes the
bootloader firmware.
• Previous hardware required you to manually reset the Arduino board before starting the sketch-
upload process.
• Although the Arduino documentation indicates that the RX and TX lines (D0 and D1, respectively)
can be used as normal I/O lines if serial communication isn’t needed in your application, this isn’t
entirely true.
• The TX line (D1) can be used as either an input or an output but will continue to wiggle the TX
circuitry of the serial port, which may or may not cause problems on the other end.
• The RX signal (D0), however, remains connected to the receiver circuitry and must be physically
disconnected before it can be used as either an input or an output.
• There is no convenient way to do this on most Arduino boards.
• The options are to either remove components or cut traces, either one of which will render the
Arduino unprogrammable via the bootloader.
• Later Arduino boards replace the RS-232 with a USB port.

32
RS232
• One possible solution is to translate those low voltages
into higher voltages so they carry farther. • Anything in this range qualifies as a mark,
according to the RS-232 specification. Similarly, a
• This is the idea behind the RS-232 standard. A high space is translated from a Low logic level to a
voltage on the TTL-level TX or RX pins of your Arduino positive voltage in the range of +3V to +15V.
measures in the range of 3V–5V and is called a mark • Most PCs and RS-232-to-TTL adapters work with
condition. voltages between ±5V and ±10V, typically.
• A space is a low voltage, something closer to ground or • Some PCs fudge a bit and accept 0V and 5V signals,
but they’re still of opposite polarity from the TTL-
0V. The TX line stays in the mark condition while idle level serial signals on your Arduino.
and then squirts out a carefully timed series of marks
and spaces to signify a data transmission. • Voltages above 6V can permanently damage the
AVR chip on your Arduino. Always use an RS-232-
• After the transmission is complete, the TX line returns to-TTL adapter when interfacing with RS-232
signals.
to the mark condition.
• Converting RS-232 levels to TTL levels isn’t hard.
• Forcing the data line to a space condition and holding it You can do this with a transistor, a diode, and two
longer than normal for a legal data transmission is resistors.
called a break condition and is sometimes used to get • Because one of those resistors is acting as a pullup
the attention of the other end of the line when other on the received signal, it can be replaced by the
handshaking methods have failed or aren’t available. built-in pullup resistor available on the AVR’s I/O
line, bringing the component count down to a
• Once translated to RS-232 levels, a mark condition, manageable three. See Figure 12-6.
instead of being a High logic level, is now a negative
voltage in the range of -3V to -15V, and possibly as low
33
as -25V.
RS232 (1) • Looking at the circuit schematic in Figure 12-6, you see
the RS-232 input going straight into R1, a 10KΩ resistor.
• The purpose of R1 is to limit the amount of current
flowing to the base of Q1. Yes, in theory, it should be a
mild-mannered RS-232 signal, always between the
mandated voltage of ±15V.
• But it may not be. This is by far the most common point
of failure in any electronic circuit: the connection to the
Outside World.
• All kinds of terrible things are lurking out there, waiting
to zap your tender creation. Static electricity, being
plugged in backward, being plugged into the wrong
device—these are just a few of the possible scenarios.
• You don’t need to go crazy adding protection circuitry
to every node in your invention.
• You do need to know where to look for the most
An RS-232-to-TTL receiver circuit. This circuit limits the commonly occurring failure points when things start
acting strangely. The connections to the Outside World
voltage swing of the incoming signal to TTL levels (0–5V)
are the usual suspects and a good place to start.
and provides the necessary logical inversion. 34
RS232 (2) • D1 can be any small rectifier diode, such
as the 1N4148 or 1N914.
• The collector of Q1 is connected through
a pullup resistor to VCC.
• Diode D1 also offers some protection for Q1 by keeping
the base from going too negative with respect to the • This keeps it at a logic High level until the
emitter. transistor starts to conduct.
• Bipolar junction transistors (actually, most • When the input voltage of the RS-232
semiconductors) have a failure mode called reverse input goes high (a space condition), this
voltage breakdown. causes a small amount of current to flow
through R1 and into the base of Q1.
• Even a beefy small-signal transistor like the PN2222A,
which was used to drive loads up to 1.0A back when you • Q1 becomes forward biased enough to
were blinking LEDs, has a teeny-tiny emitter-base
begin to conduct current from its
breakdown voltage (BV(BR)EBO) of only 6.0V.
collector to its emitter.
• This causes the voltage on the collector to
• That means if the base becomes more negative than the drop to very close (but not all the way) to
emitter by as little as 6.0V, the transistor fails. ground.
• You prevent this particular failure by keeping the voltage • This produces a logic Low level on the
at the base within a volt or so of ground, by clamping the output pin.
base to ground via the diode, D1.

35
RS232 (3) • Listing 12-2. Example Sketch to Test an RS-232-to-TTL
• When the input voltage of the RS-232 signal is ground Adapter Circuit
or negative, very little or no current flows through R1,
Q1 remains unbiased, and the output remains High.
• This is the mark condition, indicating that the data line
is either idle or disconnected.
• The transistor effectively inverts the logic level of the
incoming signal, which is exactly what you need it to
do.
• It also attenuates (reduces the amplitude of) the signal
in the process, assuming that VCC is lower than the
incoming RS-232 signal, which it most likely is.
• Listing 12-2 shows a short example sketch for an
Arduino Mega 2560.
• One of the extra serial port inputs (RX3) is tied to the
output of the circuit in Figure 12-4. An RS-232 signal is
attached from a PC, and serial data is transmitted from
the PC through its serial port to the RS-232-to-TTL
adapter circuit and then received on the Arduino
Mega 2560.
• The received data is then sent back to the PC via the
Serial Monitor in the Arduino software.

36
RS232 (4)
• Note that using the built-in pullup resistor
works up to 115,200 baud but only for very
short distances. For longer distances or
higher communication rates, please use a
real pullup resistor of 10KΩ or so.
• This decreases the rise-time on the TTL
signal coming from the adapter circuit.
Resistors are cheap.
• Converting from TTL to RS-232 levels is a
little more complicated. You can use a circuit
similar to the one presented in Figure 12-7.
• It steals the negative voltage required to
comply with the RS-232 standard from the
incoming TXD signal and stores it in C1.

37
RS232 (5)
• A circuit very similar to the one in Figure 12-7
was used on the original AVRISP from Atmel,
which used an RS-232 port for communication
with the PC.
• The more recent AVRISP mkII (ah, Roman
numerals) uses the more recent USB-type
connection.
• If your eyeballs are starting to cross from
looking at this schematic, have no fear.
There’s a chip for that. It was originally
designed and manufactured by Maxim IC
(www.maxim-ic.com) and called the MAX232.
• Several other manufacturers also produce a
similar part today.
• It’s much better in almost every way when
compared with the circuit in Figure 12-7. Have
a look at the schematic in Figure right side.

The MAX232 chip makes RS-232 interfaces simpler and more


38
reliable, while only requiring a single 5V supply.
RS232 (6)
• The MAX232 does several things. It • C2 is used in the inverter circuit. C3 and
contains a pair of RS-232-to-TTL receivers C4 are the filter capacitors for these ±10V
and a pair of TTL-to-RS-232 transmitters. supplies.
• It also contains a voltage doubler and a • C5 decouples the input power supply,
voltage inverter. reducing the electrical noise generated by
• The doubler converts the 5V input voltage the internal oscillators.
to ~10V. The inverter takes the ~10V and • For the original MAX232 device, C1–C4
converts it to -10V. should be 1.0μF capacitors.
• This ±10V supply is then used to drive the • For the improved MAX232A, the
RS-232 transmitters. capacitors can be much smaller, only
• The MAX232 also offers 15KV of isolation, 0.1μF.
protecting your sensitive circuits from the • The MAX233 incorporates the capacitors
harsh world. C1–C4 internally.
• The capacitors surrounding the chip are • Many variations are available with
required. C1 is used in the voltage- different numbers of transmitters and
doubler circuit. receivers.

39
References:
• https://learn.sparkfun.com/tutorials/serial-communication
• D.Dale.Wheat, “Arduino Intrnals”, TIA Publication, 5th edition, 2011.
• https://www.sciencedirect.com/topics/engineering/analog-
communication
• https://ecedmans.files.wordpress.com/2014/03/analog-
communication-prabhakar-kapula.pdf
• https://howtomechatronics.com/tutorials/arduino/how-i2c-
communication-works-and-how-to-use-it-with-arduino/
• https://www.circuitbasics.com/how-to-set-up-i2c-communication-
for-arduino/

40
• https://www.circuitbasics.com/basics-of-the-spi-communication-
protocol/
• https://maker.pro/arduino/tutorial/how-to-control-leds-with-arduino-
ir-sensor-and-remote

41

You might also like