Download Two Way Audio Communications Using the

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Heterodyne wikipedia , lookup

Dynamic range compression wikipedia , lookup

Public address system wikipedia , lookup

Analog-to-digital converter wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Serial digital interface wikipedia , lookup

Transcript
Application Note AN064
AN064
Two Way Audio Communications using the CC2510
By Michael Burns
Keywords
• CC2510
• Two Way Audio
• Frequency Hopping
Introduction
This note describes a two-way audio
communications link between a ‘Master’
and a ‘Slave’, based on the Texas
Instruments CC2510 System-on-Chip Low
Power RF Transceiver. It operates in the
2.4 GHz ISM/SRD band. It has been
optimized for low cost, using a PCB
(Printed Circuit Board) folded dipole
antenna and a minimum of external
components. Several key features of the
CC2510 are employed, including the
internal ADC, the DSM (Delta-SigmaModulator), and (optionally) ulaw
SWRA225
compression/expansion algorithm
implemented in hardware. These features
eliminate the need for an external audio
codec.
While the card described herein is based
on the CC2510 and operates in the 2.4
GHZ band, both the card and the software
can be easily modified for use with a
CC1110 operating in the 433 MHz, 868
MHz, or 915 MHz bands.
Page 1 of 11
Application Note AN064
Figure 1 – Two Way AudioTransceiver
SWRA225
Page 2 of 11
Application Note AN064
Brief Description
The CC2510 can be configured to perform µ-law compression and expansion. Using µ-law
compression, the ADC samples are compressed from 11 to 8 bits, thereby reducing the
required number of bytes in a ‘packet’ and the transmitted data rate, as compared to a
system not using µ-law encoding. However, the SNR (Signal to Noise Ratio) and quality of
the audio will not be as good when compression is used. Software is available for both
compressed (µ-law enabled) and uncompressed (µ-law disabled) modes. The table below
shows parameters with compression both enabled and disabled. In ‘µ-law disabled’ mode two
11 bit ADC samples are packed into two bytes.
Parameter
ADC Samples per Packet
Packet Length (bytes)
RF Data Rate (kbps)
Period Between Packets (msec)
µ-law Enabled
µ-law Disabled
54
61
250
6.75
60
92
300
7.5
Note: Throughout the remaining document, the descriptions given pertain to the ‘ulaw
enabled’ code.
At both the Master and the Slave, audio is sampled at an 8 kHz rate (i.e., every 125 usec),
using the CC2510’s ADC set for a resolution of 11 bits. Every 54 samples (6.75 msec), the
data is transferred to the TX Buffer, and the transmitter enabled. Similarly, a received
sample must be entered into the CC2510s Timer 1. The Master controls system timing: it will
blindly transmit a packet containing the last 54 audio samples every 6.75 msec. Following
each transmission, the Master will listen for a response from the Slave, which should respond
with a packet containing the last 54 audio samples that it has collected. The Slave listens for
a transmission from the Master; should it ‘hear’ the transmission, it will transfer the data
received from the Master into its ‘playback’ buffer and subsequently transmit its ADC
samples back to the Master.
The Slave has two modes: ‘Waiting for Beacon’ and ‘Paired’. In ‘Waiting for Beacon’, the
Slave continuously listens on channel 0 (see ‘Frequency Hopping’, below) for a transmission
from the Master. While in ‘Paired’ mode, the Slave expects to receive a packet of audio data
every 6.75 msec.
The card has been designed for use with a headset that contains both a condenser
microphone and a headphone, such as the Sennheiser PC131.
Detailed Description - Hardware
Refer to the block diagram, Figure 2. The Texas Instruments CC2510 System-on-Chip Low
Power RF Transceiver is used with a half wave dipole antenna etched onto the printed circuit
board. Audio from the microphone is amplified to a maximum peak-to-peak voltage of 3 volts
using one section of a LMV324 operational amplifier. The gain of this amplifier is controlled
by the CC2510 via analogue switches (TSA3157), and can be set to a value of 20, 40, 60, or
80 (20, 26, 32, and 38 dB). After amplification, the audio is filtered by a 6 pole Chebychev
low pass anti-aliasing filter having a cut-off frequency of 3 kHz. This filter connects to the
CC2510’s ADC.
Audio is obtained from the CC2510’s Timer 1, used in Delta-Sigma Modulation (DSM) mode.
The audio output is further filtered using a 6 pole Chebychev low pass filter identical to that
SWRA225
Page 3 of 11
Application Note AN064
used in the audio input path. A TPA122 150 mW Stereo Audio Power Amplifier is used to
drive the headphone.
The card may be powered from either the three AAA batteries attached to the back of the
card or from an external 5 volt DC power source. A TPS73033 Low-Noise, High PSRR, RF
200-mA Low-Dropout Linear Regulator is used to obtain the required 3.3 volts.
Included on the card are five LEDs (Light Emitting Diodes), two push button switches, and a
Reset switch. Currently, the two push buttons are not used. The five LEDs have the following
functions:
Blue: Heartbeat, Flashes twice per second as long as the CC2510 program is running.
Green (D200): Power On
Red: Timeout Error. No data was received from a Slave (Master) or from the Master (Slave).
Orange (Slave only): Waiting to ‘hear’ the Master’s Beacon signal
Green (D106) (Slave only): Paired with a Master
Detailed Description - Software
Due to the time critical nature of streaming audio, the supporting software code used for this
project is application specific; that is, it is not based on any standard protocol.
Figure 3 is a flow chart of the Master’s main program loop. Note that the ‘Frame Ready’ flag
is set by the audio handler, an interrupt driven routine (executed once every 125
microseconds) that both reads ADC samples and places them in an available buffer and
transfers audio samples received from the Slave into the Timer 1 ‘count’ register. ‘Frame
Ready’ is set to True every 54 samples (6.75 msec).
Figure 4 is a flow chart of the Slave’s main program loop. Its timing is based on a ‘Frame
Timer’ (T2). This is a ‘count down’ timer, which is initialized to a value of 229 tics,
corresponding to a period of 6.75 msec, after a packet is received from the Master. Two
variations of a ‘Receive A Packet’ subroutine are used. Subroutine ‘ListenforMaster’ is used
while in ‘waiting for beacon’ mode, and will return immediately after receiving a packet, or
after the specified ‘timeout’ period (27 milliseconds) if no packet is received. Subroutine
‘rfReceivepacket’ is used in ‘paired’ mode, and will return after the specified time period
(1438 usec) if a packet is not received. If, after the specified time period a packet is being
received (SYNC word was detected), the subroutine will not return until the entire packet has
been received.
Frequency Hopping
A set of four channels (frequencies) is used, on a rotating basis (every transmission is on a
different channel). Currently the four channels used are 0, 13, 26, and 39. The base
frequency is set to 2406.0 MHz and the channel spacing to 250 kHz, so channels 0, 13, 26,
and 39 correspond to frequencies of 2406.000, 2409.250, 2412.500, and 2415.750 MHz,
respectively. When first turned on and after 4 consecutive packets have been lost, the Slave
goes into a ‘waiting for beacon’ mode, continuously listening on channel 0 (2406.000 MHz).
Lost Packets\Latency
There are several ways in which a ‘lost packet’ can be handled, including both simple (mute
the audio during the duration of the lost packet) and complex (e.g., interleaving data across
SWRA225
Page 4 of 11
Application Note AN064
three consecutive packets). The idea behind the interleaved data approach is that should a
packet be lost, the missing data can be re-created via interpolation, based on correctly
received samples in other packets.
Experimental results suggest that a simple muting approach is the least audibly objectionable
alternative. If a packet is lost, the audio is simply muted for the duration of the packet.
Interpolation of missing data using any practical algorithm invariably leads to audible ‘clicks’
and ‘pops’. A further advantage of this simple approach is that latency (the time delay
between when audio is sampled by the ADC and when that sample is ‘played back’) is
minimized. For this implementation, latency is 13.5 msec, short enough that it is not audibly
detectable. Note that local audio feedback is provided; e.g., each ADC audio sample is
mixed with a sample received from the external card. This allows a user to hear him of her
self in the headphones as well as the other user.
System Timing\Other Data Rates
Sampling rates other than 8 kHz are possible, within the limitations of the CC2510s
maximum data rate (500 kbps), maximum packet length (255 bytes), and ADC conversion
time.
The ADCs conversion time and, by implication, maximum sample rate is a function of the
selected resolution.
ADC resolution (bits)
7
9
10
12
Conversion Time (usec)
18.4
33.12
62.56
121.44
Maximum Sample Rate (kHz)
54.3
30.2
16.0
8.2
Note: The listed ADC resolutions apply to differential input applications, where the ADC
value represents the voltage difference between the input signal and Vref. For example, with
a Vref of 1.25 volts, ADC values can range from -1.25 to +1.25 volts. For single ended
applications, the ADC value represents the voltage difference between ground and Vref. One
bit of resolution is lost in single ended applications.
The ADC data must be sent in ‘packets’. Every packet contains some fixed overhead,
including a preamble field (4 to 8 bytes, usually 4 bytes as in this application), sync field (2 to
4 bytes, usually 4 bytes as in this application), CRC field (2 bytes), a packet length specifier
(1 byte), and a MAC (Machine) Address (1 byte). In addition, the CC2510 requires 88.4 usec
to transition from the Idle state to either the Receiver On (Rx On) on Transmitter On (Tx On)
state, and 721 usec to calibrate the PLL.
Packet overhead can be minimized by maximizing packet length. However, ‘long’ packets
are more likely to be corrupted during transmission than ‘short’ packets. Additionally, audio
latency and the length of the ‘blank out’ period (if a packet is lost) increase with increasing
packet length. A timing diagram for the Master card is shown below.
SWRA225
Page 5 of 11
Application Note AN064
375
750
1125
1500
1875
2250
2625
3000
3375
3750
4125
4500
4875
5250
5625
6000
6375
TIME
2354 usec
TX ON
2016 usec
TX GDO0
308 usec
2500 usec
RX ON
600 usec
1888 usec
RX GDO0
721 usec
PLL CALIBRATE
Master Timing
Where
Audio samples per packet: 54
Audio Sampling Rate: 8 kHz
Audio data rate: 64 kbps in each direction (voice quality)
Radio data rate: 250 kbps
Packet length (excluding preamble, sync, and CRC fields): 61 bytes
Total packet length (including preamble, sync, and CRC fields): 71 bytes
Idle to TX ON and Idle to RX ON: 89 usec
In the diagram, “TX ON” and “RX ON” include the time required to change the radio from the
IDLE state to the RX or TX ON state. “GDO0” refers to a signal available on pin 34 of the
CC2510 (P1_5). It asserts when the sync word has been sent\received, and de-asserts at the
end of the packet. 1605 usec after enabling the receiver, bit 3 (“SFD”) of the PKTSTATUS
register is checked to see if it is asserted. This bit is set when the SYNC word is found and
reset after a packet is received. If the bit is not set, it is assumed that the expected packet
has been lost and the receiver is shut off.
A timing diagram for the Slave card is shown below.
0
375
750
1125
1500
1875
2250
2625
3000
3375
3750
4125
4500
4875
5250
5625
6000
6375
0
FRAME TIMER
4724 usec
2026 usec
MASTER TX GDO0
SLAVE RX GDO0
4196 usec
SLAVE RX ON
2554 usec
284 usec
2248 usec
SLAVE TX ON
308 usec
1896 usec
SLAVE TX GDO0
Slave Timing
Note that the Frame Timer is reset immediately after a packet is received from the Master, and that
the receiver is turned on approximately 2570 usec before the timer ‘times out’.
Additional Specifications:
Resolution: 9 bits, compressed to 8 bits using ulaw algorithm
Spread spectrum technique: Frequency hopping (4 channels)
Hop rate: 148 hops/sec
SWRA225
Page 6 of 11
Application Note AN064
Modulation: MSK
RF Output Power: 0 dBm (1 mW)
Features:
•
•
•
Frequency Hopping (4 channels)
Automatic Gain Control (Microphone): A software controlled AGC is implemented. The
microphone preamplifier has four discrete gain settings of approximately 10, 20, 40, and
80 (20, 26, 32, and 38 dB), selectable via two control lines. The VGA gain is increased
by 6 dB (2 times) whenever the peak ADC voltage is less than approximately 618
millivolts. The VGA gain is decreased by 6 dB (.5 times) whenever the CC2510s peak
ADC voltage is more than approximately 1440 millivolts.
Manual Volume Control (Speaker): The card uses a Texas Instruments TPA122 Mono
power amplifier. Volume is controlled via a one-turn potentiometer.
Card Layout
In a ‘two way’, full duplex design, the placement of components on the card is critical. The
RF signal from the antenna during transmission can be rectified by the microphone
preamplifier and filter components, producing a noticeable ‘buzz’. To minimize this effect,
the preamplifier, filter, and headphone driver components have been placed as far away as
possible from the antenna and (with the exception of the TPA122 headphone driver and
associated components) on the back side of the card. The CC2510 and its associated
components have been placed on the front side of the card.
Conclusion
This document describes a set of cards and software that demonstrate telephone quality
audio over a 2400 MHz two way, full duplex link, using the CC2510 transceiver.
SWRA225
Page 7 of 11
MICROPHONE
+3.3
Reset
Gain =
10, 20, 40, 80
Programable
Gain Amplifier
LMV324 (1/4)
TS5A3157 (3)
Talk
Spare
+3.3
6 Pole
Chebychev
Low Pass
Filter
fc = 3 KHz
LMV324 (3/4)
RED
Ferrite Bead
ORN
PGA Gain 0
PGA Gain 1
DVDD
26.0 MHz
P1_3
P0_7
P1_1
RF_N
RF_P
DGUARD
DVDD
DVDD
AVDD
AVDD
AVDD
AVDD
P1_0
P1_2
P0_5
P0_6
RESET
P0_4
P2_0
Rbias
P0_0
DCOUPL
Ferrite Bead
BLU
GRN
6 Pole
Chebychev
Low Pass
Filter
fc = 3 KHz
LMV324
Power Jack
(5 Volts)
+1.65
100K
LMV358
+
100K
TPS73033
LDO
Regulator
20K
20K
+3.3
TPA122
CC2510
XOSC_Q1
SWRA225
XOSC_Q2
+3.3
GRN
100K
+
-
+
100K
Headphone
Application Note AN064
Figure 2 – Transceiver Block Diagram
Page 8 of 11
4.5 Volts
(3 AAA CELLS)
Folded Dipole Antenna
(Etched onto Card)
Application Note AN064
Start
Master Main Loop
Initilize I/O and Peripherals
Configure Radio
Allocate DMA Channels for RX and Tx
Initilize Channel Table and index
Set Channel
Increment 'Active Channel' index
Start PLL Calibration
No
Note: The 'audioIn' buffer contains the
Masters ADC samples, to be
transmitted to the Slave. The 'audioOut'
buffer contains ADC samples received
from the Slave, to be 'played back'
using the PWM timer.
FrameReady
= True?
'FrameReady' will be set
by the Timer 1 ISR when
the 'audioIn' buffer is full.
(every 6.75 msec)
Yes
Copy audioIn data into Tx
Buffer
No
Calibration
Complete?
Yes
Send TX Data
Listen for Data from Slave
Time Out Period = 1605 usec
Packet
Received
O.K.?
No
Lite the Red
LED
Mark AudioOut
Buffer
unavailable
Switch audioOut
Buffers
Yes
Mark AudioOut
Buffer
unavailable
Extinguish
the Red LED
Copy data from Rx
buffer into AudioOut
buffer
Mark AudioOut
Buffer
available
Figure 3 – Master Main Program Loop
SWRA225
Page 9 of 11
Application Note AN064
Start
Slave Main Loop
Configure Radio, I/O, and Timers
Reserve DMA Channels for RX and Tx
Initilize Channel Table
Set Wait4Beacon = True
Wait4Beacon =
True?
No
No
Yes
Calibration
Complete?
Extinguish Green ('Paired') LED
Light the Orange ('Waiting') LED
Set Channel to activeTable[0]
Start PLL Calibration
Note: The 'audioIn' buffer contains
the Slaves ADC samples, to be
transmitted to the Master. The
'audioOut' buffer contains ADC
samples received from the Master, to
be 'played back' using the PWM
timer.
Yes
No
No
FrameTimer <
2570 usec?
Calibration
Complete?
Uses Subroutine
'ListenforMaster'
Uses Subroutine
'rfReceivePacket'
Listen for Data from Master
Time Out Period 1438 usec
Yes
Listen for Data from Master
Time Out Period 27 msec
Switch audioOut
Buffers
Packet
Received
O.K.?
No
lostpackets = 0
Waiting4Beacon = True
Packet
Received?
No
This path will also be taken
if a 'Time Out' occurs
No
No
Yes
Lite Green ('Paired') LED
Extinguish the Orange ('Waiting') LED
Wait4beacon = False
Initialize Frame Timer (T2)
Yes
lostpackets >
4?
Frametimer =
0?
Mark AudioOut Buffer
available
lostpackets++
Initialize FrameTimer (T2)
Copy audioIn data into Tx Buffer
Send Packet
Force Idle State
Set 'channel' to next channel
Increment channel index
Start PLL Calibration
Copy RxBuffer into
audioOut Buffer
Lite Red LED
Mark AudioOut Buffer
unavailable
Mark AudioOut Buffer
unavailable
No
Packet
Received
O.K.?
Yes
Extinguish Red LED
lostpackets = 0
Figure 4 – Slave Main Program Loop
SWRA225
Page 10 of 11
Application Note AN064
References
General references
[1]
[2]
[3]
[4]
[5]
[6]
CC2510 Data Sheet (CC2510Fx)
CC2510 Reference Design (http://www.ti.com/litv/zip/swrr035a)
CC2510 Folded Dipole Antenna for CC25xx (swra118)
Simple Audio Loopback Using CC251X (DN402)
TPA122 Data Sheet (TPA122)
TPS73033 Low Noise High PSR RF Low Drop Out Regulator (TPS73033)
Document History
Revision
A
B
Date
18 Sept 2008
14 April 2010
30 June 2010
Description/Changes
Initial release.
Added reference to optional µ-law compression
SWRA225
Page 11 of 11
IMPORTANT NOTICE
Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements,
and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should
obtain the latest relevant information before placing orders and should verify that such information is current and complete. All products are
sold subject to TI’s terms and conditions of sale supplied at the time of order acknowledgment.
TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TI’s standard
warranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where
mandated by government requirements, testing of all parameters of each product is not necessarily performed.
TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products and
applications using TI components. To minimize the risks associated with customer products and applications, customers should provide
adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right,
or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information
published by TI regarding third-party products or services does not constitute a license from TI to use such products or services or a
warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual
property of the third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied
by all associated warranties, conditions, limitations, and notices. Reproduction of this information with alteration is an unfair and deceptive
business practice. TI is not responsible or liable for such altered documentation. Information of third parties may be subject to additional
restrictions.
Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids all
express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is not
responsible or liable for any such statements.
TI products are not authorized for use in safety-critical applications (such as life support) where a failure of the TI product would reasonably
be expected to cause severe personal injury or death, unless officers of the parties have executed an agreement specifically governing
such use. Buyers represent that they have all necessary expertise in the safety and regulatory ramifications of their applications, and
acknowledge and agree that they are solely responsible for all legal, regulatory and safety-related requirements concerning their products
and any use of TI products in such safety-critical applications, notwithstanding any applications-related information or support that may be
provided by TI. Further, Buyers must fully indemnify TI and its representatives against any damages arising out of the use of TI products in
such safety-critical applications.
TI products are neither designed nor intended for use in military/aerospace applications or environments unless the TI products are
specifically designated by TI as military-grade or "enhanced plastic." Only products designated by TI as military-grade meet military
specifications. Buyers acknowledge and agree that any such use of TI products which TI has not designated as military-grade is solely at
the Buyer's risk, and that they are solely responsible for compliance with all legal and regulatory requirements in connection with such use.
TI products are neither designed nor intended for use in automotive applications or environments unless the specific TI products are
designated by TI as compliant with ISO/TS 16949 requirements. Buyers acknowledge and agree that, if they use any non-designated
products in automotive applications, TI will not be responsible for any failure to meet such requirements.
Following are URLs where you can obtain information on other Texas Instruments products and application solutions:
Products
Applications
Amplifiers
amplifier.ti.com
Audio
www.ti.com/audio
Data Converters
dataconverter.ti.com
Automotive
www.ti.com/automotive
DLP® Products
www.dlp.com
Communications and
Telecom
www.ti.com/communications
DSP
dsp.ti.com
Computers and
Peripherals
www.ti.com/computers
Clocks and Timers
www.ti.com/clocks
Consumer Electronics
www.ti.com/consumer-apps
Interface
interface.ti.com
Energy
www.ti.com/energy
Logic
logic.ti.com
Industrial
www.ti.com/industrial
Power Mgmt
power.ti.com
Medical
www.ti.com/medical
Microcontrollers
microcontroller.ti.com
Security
www.ti.com/security
RFID
www.ti-rfid.com
Space, Avionics &
Defense
www.ti.com/space-avionics-defense
RF/IF and ZigBee® Solutions www.ti.com/lprf
Video and Imaging
www.ti.com/video
Wireless
www.ti.com/wireless-apps
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2010, Texas Instruments Incorporated