DIGITAL RADIO With BB-AR1010

DIGITAL RADIO With BB-AR1010
PR31
DIGITAL RADIO
With BB-AR1010
Version 1.0
Sep 2010
Cytron Technologies Sdn. Bhd.
Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by
updates. It is your responsibility to ensure that your application meets with your specifications. No representation or warranty is given and no liability is
assumed by Cytron Technologies Incorporated with respect to the accuracy or use of such information or infringement of patents or other intellectual
property rights arising from such use or otherwise. Use of Cytron Technologies’s products as critical components in life support systems is not
authorized except with express written approval by Cytron Technologies. No licenses are conveyed, implicitly or otherwise, under any intellectual
property rights.
OVERVIEW
FEATURES
This document describes the development of Cytron
Technologies DIY (Do It Yourself) Project PR31. This
project describes the application of AR1010 FM Radio.
Schematic and sample source code is provided. Please
refer to Getting Started section for steps to assemble
the necessary hardware and run the sample program on
PR31.
PIC16F877A
- 8-bit microcontroller with 33 I/O
- operate with 5V supply
- operating speed 20MHz
LCD (2X16 characters)
2X16 characters display
- Operate at 5V
BB-AR1010
- Worldwide FM band support: 76~108Mhz
- Operate at 5V
- Serial control interface for 2-wire and 3-wire
modes
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
1
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
SYSTEM OVERVIEW
LCD display
User
Input
I²C
PIC 16F877A
BB-AR1010
UART
Audio
Output
Computer
GENERAL DESCRIPTION
PR31 is an open source microcontroller DIY project.
This PIC microcontroller based project was designed
for user to understand the application of BB-AR1010.
This project uses I²C to interface with BB-AR1010.
Through this project, users are exposed to one of serial
communication types, I²C. I²C transfer and receive data
through one wire and use another wire to transmit
clock signal. I²C is very useful because it can choose
device to interface among many devices connected to it.
PIC16F877A
This powerful (200 nanosecond instruction execution)
yet easy-to-program (only 35 single word instructions)
CMOS FLASH-based 8-bit microcontroller packs
Microchip's powerful PIC® architecture into an 40- or
44-pin package and is upwards compatible with the
PIC16C5X, PIC12CXXX and PIC16C7X devices.
Features of the device:
•
•
•
•
•
•
•
8 Kbytes of Flash Program Memory
368 bytes of Data Memory (RAM)
256 bytes of EEPROM data memory
8 channels of 10-bit Analog-to-Digital (A/D)
converter
2 capture/compare/PWM functions
MSSP (Master Synchronous Serial Port) can
be configured as either 3-wire Serial
Peripheral Interface(SPI™) or the 2-wire
Inter-Integrated Circuit (I²C™) bus
Universal Asynchronous Receiver Transmitter
(UART).
All of these features make it ideal for more advanced
level A/D applications in automotive, industrial,
appliances and consumer applications.
Figure 1
Figure 1 shows the pin diagram for PIC16F877A. For
more information about the PIC microcontroller, please
refer to the datasheet. The datasheet can be found in
microchip web site at: http://www.microchip.com
BB-AR1010
Figure 2
This board has a 3.3V regulator for easy integration
with 5V parts. There is 5V to 3.3V and vice versa
converter circuit to change voltage level of signals flow
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
2
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
into and out from AR1010. User is recommended to
carefully go through the AR1010 datasheet before
using this product. The AR1010 is a great IC, but its
small, leadless package makes it difficult for the
typical student or hobbyist to use. The device also
operates at 2.7V to 3.6V, which can make interfacing
difficult for microcontrollers operating at 5V. This
carrier board addresses both issues and audio jack plug
is added. All user need to do is connect 31” wire to
ANT footprint, connect Data pin, Clock pin and BusEn
pin to microcontroller. BusMode connect to Gnd (2wire) or 5V (3-wire) according to selected interfacing
mode. Connect an earphone to audio jack plug. Finally
write a program and run with microcontroller.
Interface LCD (2x16 Character) with
PIC16F877A
To use the LCD, user has to solder 16 pin header pin.
LCD used in this project is JHD162A, for other type of
LCD, please refer to its data sheet.
Figure 3
Features:
• Worldwide FM band support: 76~108MHz.
• 5V TTL logic interface as converter circuit is
integrated in the breakout board.
• Integrated Audio jack to transmit audio
signals.
• Additional circuit can be added as all
necessary pins are extended.
• Operating voltage : 5V
• Tuning step:
- 100 kHz (set SPACE = 1)
- 200 kHz (set SPACE = 0)
For more information about BB-AR1010 please refer
to BB-AR1010 user manual. User may download the
user manual from www.cytron.com.my
Figure 4
Figure 3 is a 2x16 character LCD. Figure 4 shows the
connection of LCD to PIC microcontroller.
HARDWARE (excluded add–on gadget)
This project will require following hardware:
a.
b.
c.
d.
e.
f.
1 x PIC16F877A
1 x PR31 Printed Circuit Board (PCB)
1 x LCD (2x16 character)
1 x BB-AR1010
1 x Earphone
Related electronic components
(Please check the hardware)
Please refer to Appendix A for the board layout of
PR31. The board layout is provided free therefore
Cytron Technologies will not be responsible for any
further modification, improvement and notification.
LCD connection pin and function of each pin is shown:
Pin
1
2
Name
VSS
VCC
3
VEE
4
RS
5
R/W
6
E
7
8
9
10
11
12
13
14
15
DB0
DB1
DB2
DB3
DB4
DB5
DB6
DB7
LED+
16
LED-
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
Pin function
Ground
Positive supply
for LCD
Brightness adjust
Select
register,
select instruction
or data register
Select read or
write
Start data read or
write
Data bus pin
Data bus pin
Data bus pin
Data bus pin
Data bus pin
Data bus pin
Data bus pin
Data bus pin
Backlight positive
input
Backlight
negative input
Connection
GND
5V
Connected to a
preset to adjust
brightness
RB4
GND
RB5
RD0
RD1
RD2
RD3
RD4
RD5
RD6
RD7
5V through
10 ohm resistor
GND
3
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
Power Supply for Board
In Circuit Serial Programming (ICSP)
User may choose either AC to DC adaptor (not
included in the DIY project set) or battery (7V to 12V not included in the DIY project set) to power up the
circuit. Higher input voltage will dissipate more heat at
LM7805 voltage regulator. Typical voltage is 12V.
Anyhow, LM7805 will still dissipate some heat at 12V.
There are two type of power connector for the circuit,
DC plug (JP1) and 2510-02 (JP2). Normally AC to DC
adaptor can be plugged to JP1 type connector.
Figure 7
Figure 5
Refer to Figure 5, D1 is use to protect the circuit from
wrong polarity supply. C1 and C3 are used to stabilize
the voltage at input of LM7805 voltage regulator,
while the C2 and C4 are used to stabilize voltage at
output side of the LM7805 voltage supply. Power
indicator LED is green color and as the name state, it is
to indicate power status. R1 is a resistor to protect
power indicator LED from over current.
MCLR, RB6 and RB7 are needed for ICSP purpose.
These pins should be connected to the USB ICSP PIC
Programmer (UIC00A/B) via the 2x5 box header for
loading and reading program from computer. The
programmer (UIC00A/B) is not included in DIY
project set since it can be used for different project set.
User can also choose other type of PIC programmer to
load the program; however, the interface and method to
load program might differ from UIC00A/B. Please
consult the manufacturer of that particular PIC
programmer.
For the instruction of using UIC00A/B, please refer to
its User’s Manual at: www.cytron.com.my
Interface UC00A with PIC16F877A
Push Button as Digital Input
Figure 6
One digital I/O pin (e.g. RB0) is needed for one push
button as input (or interrupt) of PIC microcontroller.
The connections are shown in Figure 6. Capacitor
connect parallel to push button is use for debouncing.
The pins are being pulled up to 5V via a resistor (with
value range 1K-10K) and this configuration will result
to active-low input. When the button is being pressed,
logic low (0) is presented at the input pin; while the
button is not pressed, logic high (1) is presented.
Figure 8
RC6 and RC7 which serve as TX and RX pins in
PIC16F877A are used for UART interface. 5V and
ground is connected to provide power and voltage
reference to the module.
If user wishes to use power from UC00A to supply the
project board please connect JP4. Anyway, it is
advisable to use power supply from adapter to power
the project board by disconnect JP4. UC00A is USB to
UART convertor from Cytron Technologies. It offer
simple and straight forward USB interface between
computer and embedded system with 5V TTL UART.
A cable/connector is needed to interface UC00A to
PR31 and further to PIC Microcontroller UART pin.
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
4
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
User may use this cable/connector for interface with
other devices. Figure 8 shows the connection.
The Function of Component on PCB
Extended Area
1
6
2
5
3
9
4
7
14
Figure 9
12
8
13
10
15
11
There are 24 pins available for prototyping. Users can
add their own circuit to improve this DIY project.
Please refer the description of each pin at PIC16F877A
datasheet and PR31 schematic.
Figure 11
Components:
BB-A1010
1.
2.
3.
4.
5.
6.
7.
8.
Figure10
Pin 7 (5V) and pin 6 (ground) is connected to provide
power to the module. RC3 is I²C clock line and RC4 is
I²C data line. Both lines are use for I²C serial
communication. Pin 3 is BusEn which is use to activate
and deactivate AR1010 while Pin 8 is BusMode which
determine 2-wire mode or 3-wire mode is selected. For
2-wire interface, Pin 3 and Pin 8 is always connected to
Ground. User may ignored pin 4 and 5 as audio jack
already implement in BB-AR1010.Pin 4 and 5 are use
if user wish to add external circuit to amplify the
volume. Pin 9 is connected to antenna. User can choose
to connect antenna on BB-AR1010 or PR31 PCB board.
9.
10.
11.
12.
13.
14.
15.
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
2510-02 connector, (to use 9V/12V battery to
power up the circuit)
AC-DC adaptor socket (to plug power supply
from AC-DC adaptor)
Slide switch (to ON or OFF the circuit)
UIC00A/B box header (connect to UIC00A/B
programmer to load program)
Parallel LCD 2x16 character
LM7805 (voltage regulator, supply 5V for
PIC and other component)
2510-04 connector, (UC00A connector)
Header pin and mini jumper, (optional power
supply from UC00A)
Preset (to adjust LCD backlight)
Reset button (to reset the microcontroller)
Programmable push buttons
BB-AR1010
Audio Jack (to connect with earphone)
Crystal (20MHz)
Extended area
5
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
5.
SOFTWARE:
Flow Chart:
6.
7.
8.
9.
Default radio frequency can be change. User
must first adjust to desire radio frequency by
pressing up or down button. Then press SW1
more than 1 second. The program will replace
the data in EEPROM with the new radio
frequency. The new radio frequency channel
will be listened whenever the channel is select.
If SW2 is press, program will jump to adjust
volume loop. Then press up or down to
instruct microcontroller to change volume
level in AR1010 chip. Press SW1 to return to
main loop.
Number of channel and the radio frequency
are display on LCD.
If UC00A is connect between computer and
PR31, number of channel and radio frequency
are display on monitor too.
The program is running continuously.
Communication with AR1010 using I²C
(2-wire interface)
Flow chart 1
For more information about the software of this DIY
project, please refer to the source code provided. The
explanation of the instruction is provided in the source
code as comments.
For this DIY project, I²C is used to communicate with
BB-AR1010. I²C is also introduced as 2-wire interface
because only 2 signals (SDA and SCL) are use for
communication. SCL is the clock line. It is used to
synchronize all data transfer over the I²C bus. SDA is
the data line which transmits and receives data. The
device initiating data transfer and provide the clock
signal on the bus is called a ‘master’. A device being
addressed by the master is called a ‘slave’. The
advantage of I²C is it can connect with many devices
with SDA bus and SCL bus. Target device is called by
sending device’s address. In this DIY project,
microcontroller act as master while BB-AR1010 act as
slave. Microcontroller calls BB-AR1010 by sending
0x20 through SDA. The explanation below will help
user to understand more about the operation of
AR1010.
The source code is provided free and Cytron
Technologies will not be responsible for any further
modification, improvement or notification.
Basic operation of the source code:
1.
2.
3.
4.
Project name and instruction are display on
LCD.
Condition of SW1 and SW2 is monitor.
If SW1 is pressed, channel 1 will display on
LCD and set radio broadcast channel is heard.
There are six channels for user to select. Each
channel has its default radio broadcast channel
after hex file is load into microcontroller.
To switch channel, press SW1 to send signal
to microcontroller. Channel will switch from
channel 1 to channel 6 then back to channel 1
again.
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
6
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
Write to AR1010:
Read from AR1010:
Start, AR1010_Add+WR
Start, AR1010_Add+WR
AR1010_Reg_add
AR1010_Reg_add
ACK
Ar1010_Add +RD
ACK
BB-AR1010
PIC16F877A
RSEN
ACK
Data<15:8>
BB-AR1010
ACK
PIC16F877A
ACK
ACK
Data<7:0>
Data<15:8>
ACK
ACKDT, ACKEN
Stop
Data<7:0>
Figure 14
N_ACKDT, ACKEN, Stop
Figure 12
Figure 15
Figure 13
Figure 12 and figure 13 show the sequence of I²C to
read AR1010’s registers. Like usual I²C operation,
microcontroller needs to send start condition (SEN=1)
to start the serial communication. AR1010 is called
when master sent 7-bits of AR1010’s address (0b
0010000x) and WR (0) bit out from SDA e.g. = (0b
00100000). AR1010 response to this “calling” by
sending ACK. Microcontroller must write the target
register’s address before read data. Register’s address
is sent to AR1010 and waits for ACK. Read operation
is start by sending a repeated start (RSEN) condition.7bits of AR1010’s address (0b 0010000x) and RD (1)
bit are sent to AR1010 to indicate read operation (0x
00100001). Wait for AR1010 to give respond. Set
RCEN bit to enable microcontroller receive data from
slave. After 1st byte data received completely,
microcontroller need to acknowledge AR1010 by clear
ACKDT (acknowledge) and set ACKEN. As
AR1010’s registers are 16 bits register, microcontroller
needs to receive 2 bytes of data. To receive 2nd byte of
data, set RCEN again because RCEN already reset
after received first byte of data. Then wait for second
byte of data. Set ACKDT (not acknowledge) and
ACKEN after second byte of data received completely.
Finally set PEN to terminate the serial communication.
Figure 14 and figure 15 show the sequence of I²C to
write AR1010, it is simpler. Similar to I²C read,
microcontroller need to send start condition (SEN=1)
to initial I²C communication. To call AR1010,
microcontroller send out 7-bits of AR1010’s address
(0b 0010000x) and WR (0) e.g. = 0b 00100000. A1010
will respond to this “calling” by sending ACK.
Register’s address is send to AR1010 and wait for
ACK. Data will be written to the target register after
master received ACK. Master send 1st byte of data to
AR1010. After receiving ACK, 2nd byte of data is
send until next ACK is received. Finally, send stop bit
(PEN) to terminate the serial communication.
Initialization of AR1010:
1. Disable AR1010 to write the default registers
value. (R0<0>)=0
2. Write all the default register value into
registers (R1-R17)
3. Enable AR1010 by setting (R0<0>)=1
4. Wait STC to set (finished calibration state)
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
7
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
Figure 16 show the respond of AR1010 during
initialization. For more detail description please refer
to source code provided.
Figure 16
Tune AR1010:
1. Set hmute bit
2. Clear TUNE bit
3. Clear SEEK bit
4. Set SPACE
5. Set CHAN
6. Set TUNE bit
7. Wait for STC to set
8. Clear hmute bit
Important notes:
I²C clock speed:
AR1010 can support clock frequency from 0kHz to
400kHz. Clock frequency is determined by set a preset
value to SSPADD. The pre-set value is calculated
using formula below.
SSPADD = (FOSC / (4*clock frequency)) - 1
GETTING STARTED
User can obtain the hardware set for this project (PR31)
either by online purchase at www.cytron.com.my or
walk-in purchase from Cytron Technologies Shop.
1. Once user has the hardware set, component
arrangement and soldering can be started. Please
solder the electronic components one by one
according to overlay label (white color) on PCB
surface. Ensure the component value and polarity is
correctly mounted.
2. To make sure LCD screen and BB-AR1010 are
soldered parallel with PR31 board, user are
encourage to solder first pin and last pin of the row
of pins first.
3. After make sure the LCD screen and BB-AR1010
are parallel, solder the other pins.
Caution: Make sure all the connectors (2510) are
soldered in proper side. Electronic components which
have polarity such as capacitor, diode, PIC, 2N3904,
and LED should be soldered in proper orientation else
it will cause component failure further board failure.
Warning: Before the battery (Power) is plugged in,
make sure the polarity of critical component is
correctly soldered to prevent any explosion. Wrong
polarity of electrolytic capacitor may cause explosion.
Attention:
Remember to solder Antenna (31 inches wire) to BBAR1010 before solder the board to PR31 board.
Guides to Solder Iron Pin
FM Radio Frequency:
RF frequency (kHz) = 690 + CHAN<8:0>
As CHAN can store 9 bit (512-0) data only, it cannot
support FM frequency which range from 760 till 1080.
Therefore the FM frequency need to minus 690 to
make the FM frequency become 9 bit data which can is
compatible with CHAN (9-bit).
1
2
E.g.: FM frequency to be set = 107.6MHz
CHAN = 1076 – 690
= 386
= 0b110000010
3
4
Register in AR1010:
Register 0 – 17 are read and write register
Register below 17 are read only register.
5
6
Figure 17
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
8
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
4. Please download the necessary files from Cytron
Technologies website, www.cytron.com.my. These
include Details Description (this file), sample
source code, schematic and necessary software.
5. The next step is to install MPLAB IDE and HITECC C PRO (operating in Lite mode) into
computer. The MPLAB IDE and HI-TECC C PRO
can be downloaded from www.cytron.com.my .
Please refer MPLAB IDE installation step
document to install the software. The documents
can be used for any version of MPLAB IDE
software.
6. After the installation complete, open the project file
provided using MPLAB IDE. Please refer MPLAB
Open Project document to open the sample program.
7. Plug in power supply for the circuit. User can
choose to use battery or AC to DC adaptor.
8. Build the project and load the hex file into the PIC
microcontroller using USB ICSP PIC Programmer
(UIC00A/B). The programmer is not included in
the hardware set but it can be purchased separately
at Cytron website. (User’s manual is provided at
website).
9. Connect Earphone to audio jack connector.
10. The connection of adapter, UIC00A and earphone
are shown in figure 18.
12V Polarity
Figure 19 (not included in DIY project set)
9V battery connector:
Adapter
Earphone
Figure 20
TEST METHOD
1. Switch ON the power
- Push slide switch to ON side
- Power LED (green) will turn ON
UIC00A
Figure 18
AC to DC adaptor:
User can decide either uses a 9V battery or an AC to
DC adaptor as the power source to the circuit. The
picture and the way to use the adaptor are shown in
Figure 19 and 20.
2. Plug Earphone to Audio Jack.
3. Test channel
- Press SW1 after instruction appear on LCD
- Press SW1 several time to switch channe1
4. Set channel (e.g. : Channel 1)
- Press SW1 until LCD display “Channel 1”.
- Press UP / DOWN to tune FM frequency.
- Press SW1 longer then 1 second to store the
adjusted FM frequency into EEPROM.
- LCD show “Channel 1 is set”.
- Desired FM radio broadcast is set as default
channel.
5. Volume
- Press SW2
- “volume level = 8” displayed on LCD
- Press UP/DOWN to change volume
- Press SW1 to return
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
9
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
6. If all steps mentioned above can be executed, your
project is done successfully. Congratulations!!
Connect to UC00A (optional):
1. Before switch on power supply, connect UC00A to
2510-04 connector (JP4).
2. Please refer UC00A user manual(7.1e to 7.1g) to set
up HyperTerminal.
3. Switch on PR31 and test the program. Words will
display on monitor screen.
Demo:
Figure 23
Press SW1 to select channel.
Figure 21
Turn on the switch. Green LED is lit. Words are shown
on LCD.
Figure 24
Press SW2 to change volume level
Figure 22
Instructions are shown on LCD.
Figure 25
Press UP or DOWN to adjust volume level.
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
10
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
Figure 26
Change default radio frequency by pressing SW1
longer than 1 second.
Figure 29
Display above is shown on monitor after power up
PR31.
Figure 30
Display above is shown after SW1 is pressed
Figure 27
The radio frequency is store in EEPROM. The radio
broadcast channel can be heard whenever the channel 1
is selected.
Using UC00A with PR31:
Figure 31
Volume level is shown on monitor when SW2 is
pressed.
Figure 28
UC00A connector is connect to the connector shown
(JP4)
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
11
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
WARRANTY
No warranty will be provided as this is DIY project.
Thus, user is advice to check the polarity of each
electronic component before soldering it to board
Figure 32
Channel 2 default radio frequency is replaced with new
value after SW1 is pressed more than 1 second.
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
12
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
Appendix A
Table 1: AR1000F register Table
AR1010 can refer the table above. The different is AR1010 do not support RDDS function
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
13
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
Board Layout:
50 ohm
1K
1K
c-cap
104
c-cap
330pF
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
14
ROBOT . HEAD to TOE
PR31 – DIGITAL RADIO
2510-02
Connector
Adapter
LM7805
LCD
1N4007
c-cap
104
Slide switch
330
LED
E-cap
25v100
E-cap
16v10u
2N222
Box
Header
Preset
4 K7
2510-04
Connector
1K
Header
pin
Audio
Jack
BB-AR1010
c-cap
104
20M
Crystal
Antenna
RESET
PIC16F877A
SW1
c-cap
104
SW2
c-cap
104
UP
c-cap
104
DOWN
c-cap
104
* Cytron Technologies reserved the right to replace the component in the list with component of the same functionality
without prior notice.
Prepared by
Cytron Technologies Sdn. Bhd.
19, Jalan Kebudayaan 1A,
Taman Universiti,
81300 Skudai,
Johor, Malaysia.
Tel:
Fax:
+607-521 3178
+607-521 1861
URL: www.cytron.com.my
Email: [email protected]
[email protected]
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
15
Was this manual useful for you? yes no
Thank you for your participation!

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

Download PDF

advertisement