Your SlideShare is downloading. ×
Mini Project- Microprocessor Control Of A Radio Receiver
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Mini Project- Microprocessor Control Of A Radio Receiver

19,529
views

Published on

The following resources come from the 2009/10 BEng (Hons) in Digital Communications & Electronics (course number 2ELE0064) from the University of Hertfordshire. All the mini projects are designed as …

The following resources come from the 2009/10 BEng (Hons) in Digital Communications & Electronics (course number 2ELE0064) from the University of Hertfordshire. All the mini projects are designed as level two modules of the undergraduate programmes.

The objectives of this module are to control the following functions of a radio receiver for a communication system
• Digital control of a PLL frequency synthesised local oscillator
• Digital control of a varicap-tuned RF amplifier stage
Using ‘C’, students will write software to allow an embedded microprocessor or microcontroller to control various functions of a radio receiver including programming a frequency synthesised local oscillator and track tuning of a varicap tuned RF amplifier stage.

Published in: Education, Technology, Business

1 Comment
5 Likes
Statistics
Notes
  • 635104
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
19,529
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
451
Comments
1
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Mini Project: Microprocessor Control of a Radio Receiver Author: University of Hertfordshire Date created: Date revised: 2009 Abstract The following resources come from the 2009/10 BEng (Hons) in Digital Communications & Electronics (course number 2ELE0064) from the University of Hertfordshire. All the mini projects are designed as level two modules of the undergraduate programmes. The objectives of this module are to control the following functions of a radio receiver for a communication system • Digital control of a PLL frequency synthesised local oscillator • Digital control of a varicap-tuned RF amplifier stage Using ‘C’, students will write software to allow an embedded microprocessor or microcontroller to control various functions of a radio receiver including programming a frequency synthesised local oscillator and track tuning of a varicap tuned RF amplifier stage Contents Section 1. Project Introduction..........................................................................................................................2 Section 2. Project Specification........................................................................................................................3 Section 3. Project Day 1 Brief...........................................................................................................................5 Section 4. Project Day 2 Brief...........................................................................................................................7 Section 5. Downloading mikroC Compiler and Example Progs........................................................................8 Section 6. Project Preparation..........................................................................................................................9 1. Radio Receivers.........................................................................................................................................12 2. Oscillators...................................................................................................................................................12 3. Frequency Synthesisers.............................................................................................................................16 4. PIC Microcontrollers...................................................................................................................................20 Appendix A.....................................................................................................................................................21 Credits............................................................................................................................................................22 In addition to the resources found below there are supporting documents which should be used in combination with this resource. Please see: Mini Projects - Introductory presentation. Mini Projects - E-Log. Mini Projects - Staff & Student Guide. Mini Projects - Standard Grading Criteria. Mini Projects - Reflection. © University of Hertfordshire 2009 This work is licensed under a Creative Commons Attribution 2.0 License.
  • 2. Mini Project- Microprocessor Control of a Radio Receiver Section 1. Project Introduction Cohort: DCE2 [B.Eng] Project Title: Microprocessor control of a radio receiver Project Objectives: (technical, specific to this project) Control the following functions of a radio receiver for a communication system • Digital control of a PLL frequency synthesised local oscillator • Digital control of a varicap-tuned RF amplifier stage Project Summary: Using ‘C’, students will write software to allow an embedded microprocessor or microcontroller to control various functions of a radio receiver including programming a frequency synthesised local oscillator and track tuning of a varicap tuned RF amplifier stage. Introductory Lecture (2hrs) Content: • General Project area: control of a radio receiver • Architecture of a superhet receiver at block diagram level • PLL frequency synthesiser control • Receiver control interface hardware. • Fundamental Electromagnetic Compatibility (EMC) issues involved in using an embedded microprocessor in a radio receiver. Preparation Session (3hrs): Laboratory session, familiarisation with microprocessor/microcontroller system, programming environment and hardware interface to radio receiver. Page 2 of 22
  • 3. Mini Project- Microprocessor Control of a Radio Receiver Section 2. Project Specification 1. Learning Outcomes assessed (as taken from the DMD) All Learning Outcomes specified in the Definitive Module Documentation are assessed as part of this miniproject, the specific Learning Outcomes are: Knowledge and Understanding • identify and enhance knowledge gained from other studies in areas relevant to the project topic selected. Skills and Attributes • use relevant measurement instruments to analyse a defined electronic engineering problem relevant to communication systems. • synthesise a solution to a defined electronic engineering problem relevant to communication systems. • take, and analyse appropriately, test results from that solution. • carry out a simple critical evaluation of the results taken 2. Project Title: Microprocessor control of a radio receiver 3. Project Objectives: (technical, specific to this project) Control the following functions of a radio receiver for a communication system • Analogue control of RF amplifier stage varicap tuning • Digital control of a PLL frequency synthesised local oscillator 4. Project Summary: (50 words max) Using ‘C’, students will write software to allow an embedded microprocessor or microcontroller to control various functions of a radio receiver including track tuning of RF amplifier stages and programming a frequency synthesised local oscillator. 5. Introductory Lecture (2hrs) Content: • General Project area: control of a radio receiver • Architecture of a superhet receiver at block diagram level • Receiver control interface hardware. • PLL frequency synthesiser control • Fundamental Electromagnetic Compatibility (EMC) issues involved in using an embedded microprocessor in a radio receiver. 6. Preparation Session (3hrs): Laboratory session, familiarisation with microprocessor/microcontroller system, programming environment and hardware interface to radio receiver. 7. Day 1 Expected Outcomes for the day: To have designed at block diagram level a radio receiver controlled by a microcontroller. To have written programs to control a frequency synthesiser for tuning a radio receiver. Assessment criteria: Block diagram of superhet radio receiver with control by microcontroller Program to control a PLL frequency synthesiser, set a fixed frequency and display the frequency on the LCD Key Tasks: • Draw a block diagram showing how available modules can be connected together to form a superhet radio receiver controlled by a microcontroller that can control a PLL frequency synthesiser and can track-tune a varicap tuned RF amplifier stage via a D/A converter or PWM.. • Program a PLL frequency synthesiser to generate the required local oscillator frequencies to receive signals on a specified fixed frequency and display that frequency in megahertz on the LCD. 8. Day 2 Page 3 of 22
  • 4. Mini Project- Microprocessor Control of a Radio Receiver Expected Outcomes for the day: To have written a program for a microcontroller to control the tuning of a superhet radio receiver that uses pre-built modules. To have written a program that allows a user to control the receiver tuning using up and down buttons and saves the current frequency in non-volatile memory. Assessment criteria: Demonstrate and document a program to allow the user to step the receiver frequency up and down using push buttons, display the frequency on an LCD, calculate the required L.O. frequency and program the PLL synthesiser. Demonstrate and document a program to save the current frequency in non-volatile memory so that the microcontroller tunes the receiver to the same frequency after the power is turned off and on again. Evaluation of fundamental Electromagnetic Compatibility (EMC) issues involved in using an embedded microprocessor and PLL frequency synthesiser in a radio receiver Key Tasks: • Write a program to allow the user to step the receiver frequency up and down in the range 88.0 - 136.0 MHz using push buttons, display the frequency on an LCD in MHz with one decimal point, calculate the required L.O. frequency and program the PLL synthesiser. • Write a program to save the current frequency in non-volatile memory. 9. Facilitator Guidance (key ideas to draw out from students): Day 1: Programming a PLL frequency synthesiser and displaying the RF frequency on an alphanumeric LCD Day 2: Programming a user interface for a radio receiver to allow the user to step the frequency up and down. 10. Required Resources: Laboratory Facilities and Teaching Support. Laboratory Resources: Day 1: Microprocessor or microcontroller board with keypad or switches, LCD and D/A converter or capability for PWM output. Software development environment including 'C' compiler. Superhet radio receiver modules (1 complete set of receiver per group of students). Day 2: As Day 1 Teaching Resources: • Preparatory Session; tutorial exercises. Day 1; briefing pack containing instructions for the day Page 4 of 22
  • 5. Mini Project- Microprocessor Control of a Radio Receiver Section 3. Project Day 1 Brief Expected Outcomes for the day: To have designed at block diagram level a radio receiver controlled by a microcontroller. To have written programs to control a frequency synthesiser for tuning a radio receiver. Assessment criteria: Block diagram of superhet radio receiver with control by microcontroller Program to control a PLL frequency synthesiser, set a fixed frequency and display the frequency on the LCD Key Tasks: • Draw a block diagram showing how available modules can be connected together to form a superhet radio receiver controlled by a microcontroller that can control a PLL frequency synthesiser and can track-tune a varicap tuned RF amplifier stage via a D/A converter or PWM.. • Program a PLL frequency synthesiser to generate the required local oscillator frequencies to receive signals on a specified fixed frequency and display that frequency in megahertz on the LCD. Further information 1. Block diagram Your block diagram should show a superhet receiver that is capable of receiving signals from 88 MHz - 136 MHz with FM or AM detection. It should use modules that are already available in the laboratory or which can be constructed. The receiver should be frequency synthesised with control of tuning by a microcontroller. The microcontroller should also be capable of track-tuning a varicap-tuned RF stage via a PWM port output. 2. Program functions Your program should be able to control the Freescale (Motorola) MC145170-2 PLL frequency synthesiser IC via its SPI serial data interface, controlled by port lines on the EasyPIC5 board. Your program should perform the following functions: • When the program starts, it should tune the PLL frequency synthesiser to so that it generates a local oscillator (L.O.) frequency to receive a signal on 100.0 MHz. Note that the I.F. used is 10.7 MHz and the L.O. should operate above the R.F. frequency. The PLL synthesiser should be programmed for a reference frequency/step size of 50 kHz to allow for a possible future enhancement to provide fine-tuning in 50 kHz steps. You will need to calculate suitable values for the 'N' and 'R' counters in the synthesiser. You will also need to write a program to set the required control bits in the 'C' register using an 8 bit write to the SPI bus of the frequency synthesiser, load the 'N' value using a 16 bit write to the SPI bus and load the 'R' value using a 24 bit write. • In order to assist with testing, a PC is available with the Motorola PLLGEN program to allow PLL registers to be loaded, in order to verify that the correct 'N' and 'R' values have been calculated. • The current RF frequency (not the LO frequency) should be displayed on the LCD in units of megahertz, with one decimal place, e.g.100.0 MHz 3. Hardware interface information Extracts from the data sheet for the MC145170-2 data sheet have already been provided to show the block diagram and the functions of the various registers on the chip. The connections between the PIC microcontroller port pins and the PLL frequency synthesiser pins are as follows: Port pin on PIC 16F877A SPI bus pin on MC145170-2 RC3 CLK RC4 Din RC5 ENB- The SPI bus timing for the MC145170-2 is shown on the MC145170-2 data sheet. When your program starts, you should initialise Port 3 of the microcontroller so that all the port bits are set as Page 5 of 22
  • 6. Mini Project- Microprocessor Control of a Radio Receiver outputs. You should also set RC5 (ENB-) high and RC3 (CLK) low. The state of RC4 (Din) does not matter at this stage. You should write a function that could be called mwire_shift_out that shifts data into the 8, 16 or 24 bit data registers in the MC145170-2 with the most significant bit (MSB) being sent first. Your function should take two arguments, serial_data the data to be shifted as an unsigned long integer (32 bits) and num_bits the number of bits to send, as an unsigned short (num_bits will be 8, 16 or 24 for this synthesiser). The function prototype could be as follows: void mwire_shift_out (unsigned long serial_data, unsigned short num_bits) You will need to write to individual bits RC3, RC4 and RC5. To find out how to do this, see mikroC Help > microC Specifics > Accessing individual bits You can use the direct member selector (.) with a variable, followed by one of pre-defined identifiers F0, F1, … , F7, with F7 being the most significant bit. This is specific to the mikroC compiler and it therefore makes the program 'non-portable' to other 'C' compilers and processors but it is simpler than the more portable alternative of using bit fields. For example, to set port pin RC5 to zero, you can write: PORTC.F5 = 0; A more elegant programming style is to replace F5 with a more meaningful identifier (name) such as LE. This makes your program more readable. You can include the following statement at the start of your program: #define CLK F3 #define DATA F4 #define LE F5 Note that F0 .. F7 are pre-defined in the mikroC compiler. The above #define statements allow you to control the LE bit as follows: PORTC.LE = 0; Another thing that you will need to do is a logical shift left or right. For example, the following statement shifts the variable a left by one bit: a = a << 1; Another thing that you will need to do is to test the state of a bit in a variable using a bitwise logical AND or bitwise logical OR instructions with a mask, which can be expressed as a hexadecimal constant prefixed 0x. For example, the following IF statement returns TRUE if the least significant bit of the variable a is a logic 1 if (a & 0x01) { } Test your mwire_shift_out function by calling it with constant data, then single-step it with the debugger and observe the LEDs on ports RC3, RC4 and RC5. If it works, you should then write functions that load the 'N' and 'R' registers by calling mwire_shift_out. Then you can connect it to the PLL synthesiser and see if you load the 'C', 'R' and 'N' registers and generate the required LO frequency. You will also need to load the 'C' register with 0xe3 when the PLL synthesiser is initialised to set the required control bits. This only needs to be done once however. You are advised to use unsigned integers not floating point numbers to store frequencies in your program. You will need to work out a way of displaying the number in decimal on the LCD with a decimal point in the appropriate place. Page 6 of 22
  • 7. Mini Project- Microprocessor Control of a Radio Receiver Section 4. Project Day 2 Brief Expected Outcomes for the day: To have written a program for a microcontroller to control the tuning of a superhet radio receiver that uses pre-built modules. To have written a program that allows a user to control the receiver tuning using up and down buttons and saves the current frequency in non-volatile memory. Assessment criteria: Demonstrate and document a program to allow the user to step the receiver frequency up and down using push buttons, display the frequency on an LCD, calculate the required L.O. frequency and program the PLL synthesiser. Demonstrate and document a program to save the current frequency in non-volatile memory so that the microcontroller tunes the receiver to the same frequency after the power is turned off and on again. Evaluation of fundamental Electromagnetic Compatibility (EMC) issues involved in using an embedded microprocessor and PLL frequency synthesiser in a radio receiver Key Tasks: • Write a program to allow the user to step the receiver frequency up and down in the range 88.0 - 136.0 MHz using push buttons, display the frequency on an LCD in MHz with one decimal point, calculate the required L.O. frequency and program the PLL synthesiser. • Write a program to save the current frequency in non-volatile memory. Further information Program function Your program should be able to control the Freescale (Motorola) MC145170-2 PLL frequency synthesiser IC via its SPI serial data interface, controlled by port lines on the EasyPIC5 board. You should already have a program that you wrote on Day 1 that can tune the PLL frequency synthesiser to so that it generates a local oscillator (L.O.) frequency to receive a signal on a 100.0 MHz and displays the frequency in megahertz on the LCD. You should further develop your program from Day 1 so that it can perform the following functions: • The current RF frequency (not the LO frequency) should be displayed on the LCD in MHz with one decimal place and the user should be able to step the frequency up and down in steps of 100 kHz by pressing buttons that apply a Logic '1' to the RA0 and RA1 or RE0 and RE1 ports respectively. • The current frequency should be saved in non-volatile memory so that when the receiver is switched off and on again, it will tune to the last frequency that was set before it was switched off. Note that like all EEPROM and Flash memory, the EEPROM data memory on the PIC microcontroller chip has a limited number of write cycles. You should therefore write data to EEPROM only when the user changes the frequency and you should only write the data once. Page 7 of 22
  • 8. Mini Project- Microprocessor Control of a Radio Receiver Section 5. Downloading mikroC Compiler and Example Progs The EasyPIC5 boards that we use for this Mini Project are made by Mikroelectronika of Belgrade, Croatia.http://www.mikroe.com/ You can download a free demo version of the mikroC Compiler and some manuals from: http://www.mikroe.com/en/compilers/mikroc/pic/download.htm The demo version of the compiler is limited to 2k words program size but it includes all functions including a software simulator for debugging programs without a target hardware board. You can download mikroC example programs and manuals for the EasyPIC5 board from: http://www.mikroe.com/en/tools/easypic5/ Note that the mikroC example programs on the EasyPIC5 web page are only those that are specific to the EasyPIC5. There are more example programs for the EasyPIC4 and most of these (but not all) also work for the EasyPIC5. Installing mikroC should install the EasyPIC4 examples but you will need to add the EasyPIC5 examples manually. Page 8 of 22
  • 9. Mini Project- Microprocessor Control of a Radio Receiver Section 6. Project Preparation Laboratory session, familiarisation with mikroC compiler/debugger and EasyPIC5 development board 1. Checking switch and jumper settings for EasyPIC5 board. Jumper J6 (Supply Select) should be set to USB and the on-board power supply switch should be set to OFF. SW1, SW7, SW8 & SW9 - all OFF SW2, SW3, SW4, SW5 & SW6 all ON J17 set to Vcc Plug USB cable into PC USB2 port and to EasyPIC5 connector CN2 at the back left of the board (not CN4). Set on-board power supply switch to ON 2. Creating a new project Go to Start (All) Programs > Mikroelectronika > mikroC > mikroC First, you may wish to change the screen colours in the Editor window. Go to Tools > Options > Scheme and change Zedar to mikreDream. Before starting a new project, select File > Close All to close any project that has opened. To create a new project, select Project > New Project Give your project a name such as DCEminiproject3 then browse for the folder where you would like the project to be stored. Type a description in the Description box. For the device, select PIC16F877A and set the clock frequency to 008.000000 (8 MHz). Click Default then OK. You should see an editor window with the project name at the top, e.g. DCEminiproject3 This is a 'C' source file called DCEminiproject3.c mikroC also creates a project file called DCEminiproject3.ppc which stores various project settings. You can open other 'C' source files or text files by using File > Open and these will appear as extra 'tabs' in the editor window. You can copy and paste code from other files into your C source file but note that opening other files does NOT add them to the project and you should not need to add any extra files to the project. Shrink the Code Explorer window vertically and enlarge the Project Setup window until you can see the Build Type and Debugger settings. Set Build Type to ICD Debug and set Debugger to mikroICD Debugger. 3. Opening an existing project After you have saved your project and closed it, the next time you run mikroC, select Project > Open Project, then select the .ppc file (NOT the .c file). 4. Compiling and linking a project Select Build Type - ICD Debug if you want to use In-Circuit Debugging or Release to run without degugging. Select Project > Build then check for any error messages or warnings in the Messages box at the bottom of the screen. 5. Downloading code to the target processor and debugging Page 9 of 22
  • 10. Mini Project- Microprocessor Control of a Radio Receiver Be sure that you have rebuilt the project after the most recent changes. Select Tools > mE Programmer (F11). The linked object file will be downloaded into the Flash program memory of the PIC via the USB interface. If you selected Build Type - Release, your program will run automatically after downloading has completed. If you selected Build Type - ICD Debug, you can debug the program that has been loaded into the target processor. Run > Start Debugger (F9) A 'Watch' window appears where you can set a 'watch' on a variable to show its value. Then you have the following debug options • You can single-step the program using: • Step into • Step over • Step out Step Into steps into a function. You do not normally want to step into library functions so you can use Step Over instead. Step Out gets you out of a function back to the calling program. • Run/Pause Debugger F6 When the program is running, there is a bar at the bottom of the watch window that shows the status 'Idle' or 'Running' and it turns yellow when the program is running. You can also set breakpoints and run to breakpoint or run to the cursor position To finish debugging, select: Run > Stop Debugger When your program is working, go to Project Setup and change the Build Type to Release, rebuild the project and download it to the target processor. 6. Programming exercises (a) Write a progam that outputs your name to the LCD (More than 8 characters, maximum 16 characters) You will need to adapt an example program for the 16F877 for EasyPIC5 board (not EasyPIC4). Note that the 16 character by 1 line LM020 type LCD that is used for this project is actually organised as 2 lines of 8 characters side-by-side so to write to the right hand half of the LCD, it is necessary to write to line 2. (b) Write a program that uses a count variable of type unsigned short (0 to 255) and displays the value to the LCD. Before you can display a number on the LCD, you need to convert the number to a string. To find out how to do this, see Help > Help > mikroC Libraries > Conversion Library. Consider carefully which conversion to use. The initial value of the count variable should be 127 but it should be possible to increase the value of the count by pressing button RE0 and to decrease it by pressing button RE1. Note that Port B lines RB0 - RB6 are reserved for the LCD and should not be used for any other type of I/O. You can adapt a button example program from the 16F877 examples for EasyPIC4. (c) Modify your program so that the value of the count variable also controls the duty cycle of a PWM signal that is output on port pin RC2, so that the brightness of the RC2 LED can be controlled using the UP and DOWN buttons RE1 and RE0. You can adapt a PWM example program from the 16F877 examples for EasyPIC4. Check Port C pin RC2 with the oscilloscope. Observe and record the frequency and the effect of setting the variable to 63 and 127 using the up and down buttons. (d) Modify your program so that it writes the value of the count variable to EEPROM non-volatile data memory but only when the value of count has changed (due to the limited number of write cycles of the EEPROM data memory). When your program starts, it should load the initial value of count from EEPROM instead of using a fixed value. Test your program by showing that after a power interruption, it reads the Page 10 of 22
  • 11. Mini Project- Microprocessor Control of a Radio Receiver previously stored value from EEPROM. You will need to refer to the mikroC EEPROM library functions in the Help file. Page 11 of 22
  • 12. Mini Project- Microprocessor Control of a Radio Receiver 1. Radio Receivers For this mini project, an FM broadcast receiver with frequency synthesiser will be controlled by a microcontroller. Details of radio receiver architecture are covered in DCE Mini Project 2 but for the purposes of Mini Project 3, the following points are significant. A superhet radio receiver has a local oscillator (L.O.) that can operate above or below the received (RF) frequency (usually above). The difference between the L.O. and R.F. frequencies is equal to the Intermediate Frequency (I.F.) which is fixed. The frequency of he L.O. is variable and tuning the L.O. tunes the receiver. The RF amplifier stage includes a bandpass filter and in some receivers (including FM broadcast receivers), the tuning of the RF stage is variable. 1.1 An FM Broadcast Band Radio Receiver The block diagram of an FM broadcast band receiver covering 88 - 108 MHz is shown below: • A typical IF is 10.7 MHz and an I.F. bandwidth of approx. 256 kHz is required for FM stereo broadcasting. • An FM IF amplifier is designed to 'clip' or 'limit' in order to remove unwanted amplitude variations and impulsive interference from the received signal (unlike an AM receiver where clipping or limiting must be avoided as it causes severe distortion). • The L.O. can be controlled by a PLL frequency synthesiser and a frequency synthesiser normally requires a microcontroller to control it. • Natural and man-made atmospheric noise levels are lower on the VHF band than on the MF band so a VHF receiver has a sensitive and low noise RF amplifier stage. • The tuning of the RF stage is variable and is normally controlled by varicap diodes. The above type of receiver is called a 'tracking superhet' and the RF tuning and the L.O. tuning need to 'track' each other. This means that the frequency difference is constant and is equal to the I.F. (10.7 MHz in this case). The RF tuning voltage could be controlled by the same microcontroller that controls the L.O. frequency synthesiser. • Many receivers can receive more than one band (e.g. MF AM and VHF/FM or dual band mobile phones). Switching between bands can be controlled by a microcontroller. 2. Oscillators Oscillators form the heart of most RF applications and are required to generate carriers in a transmitter or as local oscillators (L.O.) in a receiver. RF oscillators that give a sufficiently stable output frequency with adequate spectral purity are of fundamental importance in RF systems. Frequency stability is a particularly important requirement for oscillators in radio communications. If oscillator frequencies are not sufficiently stable, the frequency of a transmitter may drift out off its design Page 12 of 22
  • 13. Mini Project- Microprocessor Control of a Radio Receiver frequency, so that it is no longer in the centre of the receiver's passband. In severe cases, a drifting transmitter would cause interference to users of adjacent frequencies. In the case of a receiver, the effect of oscillator drift would be that the passband of the receiver would no longer be centred on the wanted signal from the transmitter, leading to signal distortion, loss of sensitivity and possible interference due to receiving unwanted signals on adjacent frequencies. 2.1 General Principles of Sinusoidal Oscillators Most oscillators are amplifiers with feedback applied via a frequency dependent feedback network like this; FEEDBACK NETWORK For sinusoidal oscillation a frequency (fo) must exist where the following conditions are satisfied so that oscillation can take place. These are called the Barkhausen Criteria; Condition (a); THE LOOP GAIN IS UNITY β ( fo) A( fo) = 1 Condition (b); ZERO LOOP PHASE SHIFT φ ( fo) + α ( fo) = 0 (or a multiple of 360°) Or in Cartesian form (a) and (b) together can be written as; Condition 1; LOOP GAIN IS UNITY AND PURELY REAL β ( fo) A( fo) = 1 + j 0 If the above conditions are only met at a certain frequency f0 then this will be the frequency of oscillation. 2.1.1 Feedback Network Response (β) There are many configurations that can be used to meet conditions 1 and 2; RC phase shift networks and resonant LC circuits are common examples. We will concentrate on LC resonant types as they are used routinely at RF where the required values of inductance tend to be smaller. RC types are used mainly at audio frequencies since inductors at these frequencies would need to be large. The feedback network has the following generic topology and is made up of purely reactive elements X1,X2 and X3. It must include two different types of reactive element, e.g. 2L & C or 2C & L X3 OUT X1 X2 IN • A Colpitts oscillator is one which has two capacitive elements and one inductive • A Hartley oscillator is one which has two inductive elements and one capacitive 2.2 A Practical Hartley Oscillator Design a fixed frequency oscillator to operate at 10MHz into a low impedance load; Page 13 of 22
  • 14. Mini Project- Microprocessor Control of a Radio Receiver R2 680.0 V1 12.0 C3 220.0n C1 22.0p C2 220.0n T1 2N4416 L3 3.13u R1 150.0k OUTPUT L2 7.3u C2 is a DC block, R1 biases the gate of the FET, R2 and C3 decouple the amplifier to prevent self oscillation. 2.3 A Practical Colpitts Oscillator for VHF Design a fixed frequency oscillator to operate at 100MHz into a low impedance load; R2 100.0 V1 12.0 C4 1.0n L1 61.8n C1 1.0n T1 2N4416 C3 82.0p R1 100.0k OUTPUT C2 82.0p C5 22.0n RFC1 1.0m R3 330.0 Notes: 1) C1 is a DC block, R1 and R3 bias the FET, R2,C2 decouple the drain of the FET at RF, RFC1 has a low impedance at DC to permit R3 to bias the FET whilst presenting a high impedance at RF (i.e. the output signal amplitude is not reduced by R3) 2) Could be made variable frequency by inserting a variable capacitor in series with L1 to ground. Limited tuning range though. 3) L1 could be 5 turns, 15mm long with 7 mm diameter air cored, wire wound coil (67.5nH) 4) L1 resonates with C2 and C3 in series at f0 2.4 An oscillator using the SA612 The SA602/612 double balanced mixer manufactured by NXP (formerly Philips) contains an NPN transistor that can be used as an oscillator. How can this be done? Page 14 of 22
  • 15. Mini Project- Microprocessor Control of a Radio Receiver 2.5 Stabilised Oscillators 2.5.1 Frequency stability A very important characteristic of an oscillator for RF applications is good frequency stability, both long term (variations in frequency due to changes in temperature, etc.) and short term, (phase noise). The frequency stability of an oscillator may be expressed in parts per Million (ppm) and is defined as follows:  Change in frequency  Frequency stability in ppm. =    × 10 6   Operating frequency  For example, if an oscillator operates at a frequency of 10 MHz and its frequency changes by 100 Hz (for example due to a temperature change), the frequency stability is 10 ppm There is a practical limit to the frequency stability that can be achieved using an L-C oscillator. One way of stabilising an oscillator is to effectively replace part of the tuned circuit with a suitable resonator with a very high 'Q' factor. This can be either be a quartz crystal, a ceramic resonator or a surface acoustic wave (SAW) device. All of these involve some form of electro-mechanical vibration at a very well-defined frequency and can be incorporated into some of the oscillator circuits seen so far with little modification. 2.5.2 Quartz crystals A quartz crystal can be used as the resonator in an RF oscillator and achieves much better stability than is possible with an L-C oscillator. A quartz crystal exhibits the piezo-electric effect and has a very high "Q" mechanical resonance due to a bulk acoustic wave (as opposed to a Surface Acoustic Wave - SAW). This permits excellent frequency stability but crystals must be manufactured for a specific fixed frequency which can only be adjusted by a very small amount, e.g: +/-50 to100 ppm. Hence a 10MHz crystal can only be 'pulled' by about +/-1 kHz max. A quartz crystal has the following equivalent circuit at the fundamental frequency: C1 L1 R1 C2 Examples of typical values for a 7MHz crystal are: C1=12.2 fF, C2=2pF, R1=19Ω, L1=42.5mH. Calculating Q=XL/R shows that the 'Q' factor is about 100,000 In the electrical equivalent circuit shown above, C2 is the shunt capacitance of the crystal holder and electrodes while C1 is the motional capacitance and L1 is the motional inductance. C1 and L1 are not Page 15 of 22
  • 16. Mini Project- Microprocessor Control of a Radio Receiver true electrical capacitors and inductors but are due to the bulk acoustic wave resonance in the crystal and the piezo-electric effect. Manufacture of a fundamental mode crystal above about 20 MHz is difficult in practice because the slice of quartz is very thin and fragile. For higher frequencies, a crystal oscillator can be used to provide the reference frequency of a frequency synthesiser. 2.5.3 Crystal Stabilised Oscillators 2.5.3.1 Pierce Oscillator This is a specific form of crystal Colpitts oscillator where an inverting amplifier is used. By making one of the capacitors adjustable, it is possible to make a small adjustment to the frequency (e.g. +/- 100 ppm). This may be used to 'fine tune' a crystal oscillator to its required operating frequency. The amplifier can be a CMOS inverter biased into its linear region with a high value feedback resistor (e.g. 10 MΩ). This is often used in digital circuits to produce stable clock oscillator signal. 3. Frequency Synthesisers Radio communications systems have a requirement for a source or sources that can generate a wide range of frequencies with a high degree of stability. This requirement can be satisfied by a tuneable oscillator, these are only stable over relatively narrow bandwidths and so need many switched ranges to cover any significant spread of frequencies. A better solution is to use some form of frequency synthesiser to cover the entire spread with a minimum of range switching. 3.1 Switched Crystal Bank This is the most basic method of obtaining a number of output frequencies, and is not really synthesis in itself since a separate quartz crystal is required for every output frequency. Simply, one of a number of crystals is switched by a matrix to give the required output frequency Fo. Fo Osc 'n' control lines MATRIX fN f1 f0 CRYSTAL BANK This design requires N crystals (f0,f1,f2,f3.....fN) Clearly this is not a very satisfactory method if many channels are required. For a transceiver, each channel generally requires two crystals, one for the transmit carrier frequency and one for the receive LO frequency. In the past, this technique was used in Private Mobile Radio (PMR) equipment for up to 5 or 10 channels but has been superseded by PLL frequency synthesisers. Page 16 of 22
  • 17. Mini Project- Microprocessor Control of a Radio Receiver 3.2 Coherent Indirect Synthesis In this case the output is derived by applying feedback to the system. The result is a low cost and compact frequency synthesiser that uses only a small number of reference sources, typically one. Control is via a programmable divider (1/N) in the loop where the resolution is set by a fixed divider (1/R), together these are selected to give the required bandwidth and resolution. The main disadvantages are slow acquisition times and the difficulty of maintaining loop stability over a wide range of frequencies. 3.2.1 Simple Phase Locked Loop (PLL) Frequency Synthesis fin 1/R PD LPF VCO fo 1/N f The above loop will be locked when fin/R = fo/N in other words fo = Nδ f where δ f = in the programmable R divider has its divisor (N) set to force the VCO to run at the required output frequency and the resolution is determined by fin and R. PLL frequency synthesisers are widely used in most modern radio receivers and transmitters that can operate on more than one frequency. Even for fixed-frequency applications, a PLL synthesiser may be used if the operating frequency is too high for a crystal and the frequency stability of a SAW resonator is insufficient. A PLL frequency synthesiser allows a wide range of frequencies to be generated, each with the long-term frequency stability equal to that of the reference frequency which is derived from a crystal oscillator. The VCO is normally a varicap-tuned L-C oscillator but the frequency stability of the VCO on its own would not be adequate when free-running (i.e. not locked). When the VCO is used in a PLL frequency synthesiser, it is phase-locked to a crystal oscillator. Nevertheless, the phase noise performance of a PLL synthesised oscillator depends on the reference frequency, loop filter characteristics and the 'Q' of the L-C tuned circuit in the VCO. A key design issue in a PLL frequency synthesiser is the choice of reference frequency. The output frequency can be changed in discrete steps equal to the reference frequency, e.g. a 12.5 kHz step may be used for VHF/UHF mobile radio systems. If a smaller step size is required, a lower reference frequency is required but this has several undesirable effects: • Narrower loop filter bandwidth (lower loop filter cut-off frequency) results in increased time to achieve lock after changing frequency. • Increased level of sidebands at +/- at the reference frequency which can only be partially offset by narrowing loop filter bandwidth. • Narrower loop filter bandwidth results in increased VCO phase noise. Another issues is that for UHF operation, it is difficult to make a fully programmable 'Divide by N' counter that can be clocked at frequencies of 1 GHz or more. A fixed pre-scaler (high speed divider) with a ratio such as ÷10 or ÷16 can be made to clock at 2.7 GHz or more and can be used between the VCO and the 'Divide-by- N' counter. The disadvantage of using a fixed pre-scaler is that for a given step size, a lower reference frequency is required, e.g. if a 25 kHz step is required, the use of a ÷10 pre-scaler requires the use of a reference frequency of 2.5 kHz, which is undesirably low. For some applications such as an HF communications receiver or transceiver, continuously variable frequency is required and a very small frequency step is required (e.g. 1 Hz or 10 Hz). As it is not practical to use such a low reference frequency in a single-loop PLL synthesiser, a complex multi-loop PLL with multiple mixers was used in the past. More recent designs use a hybrid PLL/DDS design with the DDS 'filling in' the steps of the PLL. Page 17 of 22
  • 18. Mini Project- Microprocessor Control of a Radio Receiver 3.2.2 A typical PLL frequency synthesiser device The MC145170-2 from Freescale Semiconductor (formerly Motorola) is an example of a PLL frequency synthesiser chip that will be used in this mini project. A block diagram of the frequency synthesiser IC with the VCO and LPF is shown below. For full details of the frequency synthesiser chip, please se the MC145170-2 data sheet, Ref [1]. For further details of the schematic diagram of the frequency synthesiser IC with the VCO and LPF, please see Appendix A. MC145170-2 PLL synthesiser I.C. Low Pass Voltage- Reference Reference Reference Phase Filter/ Controlled crystal oscillator divider Detector Integrator Oscillator 1/R PD LPF VCO fin fref Output frequency fo CLK 1/N Din Control ENB logic Programmable Micro- "Divide-by-N" controller counter interface Fig 3.2.2A. A block diagram of the frequency synthesiser IC with the VCO and LPF The ‘N’ and ‘R’ counters in the frequency synthesiser are programmable via a 3-wire serial interface using the CLOCK, Din and ENB pins. This requires a microcontroller to load the required values into the registers. The microcontroller can also be used to calculate the required value of N from the required frequency. The 'R' counter is a 15 bit counter that can be set to divide by any ratio between 5 and 32767. It divides the input frequency down to the reference frequency. In this case, an input frequency of 4 MHz or 10 MHz may be used. For FM broadcast reception, a reference frequency and therefore a step size of 100 kHz or less is desirable (50 kHz or 25 kHz may be used to allow 'fine tuning). For other frequency bands, a smaller step size is be required, e.g. 9 kHz or 5 kHz for AM on MF or HF. Nevertheless, the choice of step size may be limited due to the limited length of the 'N' or 'R' counter. The 'N' counter is a 16 bit counter that can be set to divide by any ratio between 40 and 65535. The 'N' and 'R' counter division ratios are loaded by writing serial data into the synthesiser chip via a 3-wire serial interface. • Writing data serially with 15 or 24 clock cycles causes the data to be written to the 'R' register. • Writing data serially with 16 clock cycles causes the data to be written to the 'N' register. • Writing data serially with 8 clock cycles causes the data to be written to the 'C' register. The 'C' register contains various control bits for functions such as the polarity of the phase detector. You do not need to work out what value to write to the 'C' register as this is a constant value that will be given to you. Nevertheless, you must write the correct value into the 'C' register otherwise the synthesiser will not lock. The microcontroller needs to do some bit manipulation in order to format the 'N' and 'R' values into a 16 bit or 24 bit data word that can be written to the frequency synthesiser. A timing diagram for the 'N' counter access is shown below. The 'R' counter timing is similar but with a different number of clock cycles. See the MC145170-2 data sheet for further details (Ref [1]. Page 18 of 22
  • 19. Mini Project- Microprocessor Control of a Radio Receiver Fig 3.2.2B. Timing diagram for the 'N' counter access using 16 clock cycles 3.3 The PLL synthesiser board A PLL synthesiser board is provided that includes an MC145170-2 PLL synthesiser with a Voltage Controlled Oscillator (VCO), loop filter and lock detection indicator. Further details are given in Appendix A. The synthesiser board has a switch that can set the VCO to 'Free Run' or 'Lock'. • The VCO 'Free Run' setting is an 'open loop' setting that allows the VCO frequency to be adjusted by a tuning voltage potentiometer so that maximum and minimum frequencies of the VCO can be tested and the voltage versus frequency characteristic can be plotted. Nevertheless, frequency stability is poor in the 'Free Run' setting and the frequency cannot be controlled digitally by the microcontroller. • The VCO 'Lock' setting is a 'closed loop' setting where the VCO frequency is controlled by the PLL synthesiser chip. The registers in the frequency synthesiser must be programmed with suitable values to give the required VCO frequency. • There is also an 'Out of Lock' indicator LED on the board which shows if the loop; is out of lock. This is an error condition that can occur if the PLL synthesiser has not been programmed correctly or is programmed to generate a frequency that is outside the tuning range of the VCO. 3.4 Controlling a radio receiver using a microcontroller Port lines on the microcontroller can be used for band switching, i.e. to select different receivers or parts of receivers for different frequency bands. A microcontroller can also be used for tuning a varicap-tuned RF amplifier in a superhet receiver. This needs to be 'track tuned' so that the difference between the RF amplifier tuned frequency and the local oscillator frequency is always equal to the I.F. This is called a 'tracking superhet' receiver and the tracking can be digitally controlled via a look-up table stored in non-volatile memory in the microcontroller. An analogue output from a microcontroller could be via a Digital to Analogue Converter (DAC) but many low cost microcontrollers including the PIC 16F877A do not have a DAC. Instead, they have low cost Pulse Width Modulation (PWM) outputs that can be used to generate an analogue voltage via a low-pass filter. A PWM output with LPF is suitable for generating analogue voltages that do not need to change rapidly. Page 19 of 22
  • 20. Mini Project- Microprocessor Control of a Radio Receiver 4. PIC Microcontrollers For this mini project, a Microchip PIC microcontroller is used. This is a popular range of microcontrollers for low-cost embedded applications. It is not necessary to learn the instruction set of the PIC processor as a 'C' language compiler is available. It is not necessary to understand the architecture of the PIC processor in detail as most of the special functions are handled by library functions. The PIC 16F877A microcontroller will be used. A block diagram is shown below. Further information can be found in the PIC 16F877A data sheet, Ref. [2]. The PIC 16F877A is in a 40 pin DIL package with a CPU, 8k 14-bit words of electrically reprogrammable Flash program store, 368 bytes of RAM, 256 bytes of non-volatile EEPROM data memory and 33 I/O port lines. Port A is a 6-bit port, Ports B, C and D are each 8-bit ports and Port E is a 3-bit port. Each port line can be programmed to operate as an input or an output pin. Some port pins have alternative functions, for example for serial communications, counter/timer, A/D converter, etc. There is no D/A converter on chip but a low cost way to perform a D/A function is to use a Pulse Width Modulation (PWM) output and a simple low pass filter. The internal non-volatile EEPROM data memory can be used for storage of data that is retained when the power is switched off. Examples of possible uses of the EEPROM in this mini project would be storing preset stations for a radio receiver or storing calibration data for track-tuning a varicap-tuned RF amplifier in a frequency-synthesised superhet receiver. The development board used for this mini project is called an EasyPIC5, made by MikroElectronika. All the port lines of the microcontroller are connected to LEDs to indicate the state and also to push-button switches. All port lines are also available externally although Port B lines RB0 - RB6 are reserved for the LCD on this board so they cannot be used for other purposes. Some of the EasyPIC5 boards have a PIC 16F877A chip and some have a PIC16F887 chip. There are some differences in the way the port pins are used and there is a slight difference in the program code required to initialise the device. References [1] Freescale Semiconductor MC145170-2 data sheet (available on StudyNet) [2] Microchip PIC16F877A data sheet (available on StudyNet) Page 20 of 22
  • 21. Mini Project- Microprocessor Control of a Radio Receiver Appendix A Fig A.1. Schematic diagram of the frequency synthesiser IC with the VCO and LPF U1 is an SA612 double balanced mixer I.C. The oscillator in the SA612 is used as a Voltage Controlled Oscillator (VCO) that is tuned by a fixed inductor that can be plugged into the circuit board and a varicap diode. The output of the VCO is buffered by an N-Channel JFET amplifier before being fed into the frequency synthesiser IC, U2. The frequency synthesiser IC, U2 has a 4 MHz crystal as the reference oscillator. The phase detector output D0 (pin 6) is fed to a passive low-pass filter and then to the VCO. This arrangement only permits a limited tuning range and an active filter/integrator with an operational amplifier running on +12 volts would give a wider tuning range. The Lock Detect (LD) output of U2 drives an Out-of-lock LED via a PNP BJT. When the LED is lit brightly or is flashing, it indicates that the PLL is not locked. This may be caused by the registers in the synthesiser being programmed for a frequency that the VCO cannot reach. The LE, Data and CLK pins of U2 are connected to a connector where a microcontroller can be plugged in. The microcontroller can then be used to load the registers in U2. A PLL/free-run switch is provided for testing purposes. When the switch is switched to the 'Free run' position, the VCO frequency is controlled by the open-loop tuning control. This allows the tuning range of the VCO to be tested. When the switch is set to the 'PLL' position, the VCO is controlled by the frequency synthesiser IC U2 and the synthesiser should be able to lock if the registers in U2 have been programmed to suitable values. Page 21 of 22
  • 22. Mini Project- Microprocessor Control of a Radio Receiver Credits This resource was created by the University of Hertfordshire and released as an open educational resource through the Open Engineering Resources project of the HE Academy Engineering Subject Centre. The Open Engineering Resources project was funded by HEFCE and part of the JISC/HE Academy UKOER programme. © University of Hertfordshire 2009 This work is licensed under a Creative Commons Attribution 2.0 License. The name of the University of Hertfordshire, UH and the UH logo are the name and registered marks of the University of Hertfordshire. To the fullest extent permitted by law the University of Hertfordshire reserves all its rights in its name and marks which may not be used except with its written permission. The JISC logo is licensed under the terms of the Creative Commons Attribution-Non-Commercial-No Derivative Works 2.0 UK: England & Wales Licence. All reproductions must comply with the terms of that licence. The HEA logo is owned by the Higher Education Academy Limited may be freely distributed and copied for educational purposes only, provided that appropriate acknowledgement is given to the Higher Education Academy as the copyright holder and original publisher. Page 22 of 22