217

Click here to load reader

BTEC HNC - Engineering Project - All

Embed Size (px)

DESCRIPTION

This assignment has been uploaded for REFERENCE ONLY, direct copying will only be a short term benefit!

Citation preview

Page 1: BTEC HNC - Engineering Project - All

AllEngineering Project

By Brendan Burr

Page 2: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Table of Contents

TABLE OF CONTENTS - 2 -

SUMMARY - 7 -

INTRODUCTION - 7 -

TASK 1 - 8 -

Initial Specification:- - 8 -Performance Requirements:- - 8 -Working Environment:- - 8 -Maintenance:- - 8 -Costs:- - 8 -Quantity:- - 8 -Aesthetics / Ergonomics:- - 8 -Size/Weight:- - 8 -Safety:- - 8 -

Design Parameters:- - 9 -

Mind Map of Ideas:- - 13 -

Internet Research:- - 13 -

Conceptual Design 1:- - 14 -

Conceptual Design 2:- - 15 -

Conceptual Design 3:- - 16 -

Project Plan:- - 16 -

TASK 2 - 17 -

Decision Matrix:- - 17 -

TASK 3 - 18 -

Chosen Solution:- - 18 -

TASK 4 - 19 -

Compliance Table Against the Original Specification:- - 19 -

Design the review procedures for the project:- - 23 -

2

Page 3: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Continuity Tests:- - 23 -Voltage Tests:- - 23 -Menu Selection Test Procedure:- - 23 -Audio Test Procedure:- - 23 -Bode Plot Test:- - 24 -

Results of the review procedures for the project:- - 24 -Continuity Tests:- - 24 -Voltage Tests:- - 24 -Menu Selection:- - 25 -Audio Test Procedure:- - 26 -Bode Plot Test:- - 27 -

DETAILED DESCRIPTION OF THE FINAL DESIGN - 28 -

EVALUATION - 44 -

CONCLUSION - 48 -

BIBLIOGRAPHY - 49 -

Books - 49 -

Catalogues - 49 -

Software - 49 -

Websites - 49 -

APPENDIX I - 50 -

Project Plan - 50 -

APPENDIX II - 51 -

Menu Selection Test Procedure - 51 -

MENU SELECTION TEST PROCEDURE - 52 -

APPENDIX III - 64 -

Audio Test Procedure - 64 -

AUDIO TEST PROCEDURE - 65 -

APPENDIX IV - 69 -

Emulated Menu Selection Test - 69 -

3

Page 4: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

APPENDIX V - 85 -

Emulated & Real Bode Plots - 85 -

BASS POT SET AT 0% - 86 -

BASS POT SET AT 13% - 87 -

BASS POT SET AT 25% - 88 -

BASS POT SET AT 38% - 89 -

BASS POT SET AT 50% - 90 -

BASS POT SET AT 63% - 91 -

BASS POT SET AT 75% - 92 -

BASS POT SET AT 88% - 93 -

BASS POT SET AT 100% - 94 -

TREBLE POT SET AT 0% - 95 -

TREBLE POT SET AT 13% - 96 -

TREBLE POT SET AT 25% - 97 -

TREBLE POT SET AT 38% - 98 -

TREBLE POT SET AT 50% - 99 -

TREBLE POT SET AT 63% - 100 -

TREBLE POT SET AT 75% - 101 -

TREBLE POT SET AT 88% - 102 -

TREBLE POT SET AT 100% - 103 -

APPENDIX VI - 104 -

Audio Selector Wiring & Stripboard Diagrams - 104 -

APPENDIX VII - 105 -

4

Page 5: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Case CAD Rendering - 105 -

APPENDIX VIII - 106 -

Test Images - 106 -

PROTOTYPE BOARDS - 107 -

CONTROL AND VOLTAGE CIRCUITS - 108 -

CHANNEL 1 BOARD - 109 -

PUSH BUTTONS - 110 -

DISPLAY & INPUT/OUTPUT MOUNTINGS - 111 -

INPUT/OUTPUT PORTS - 112 -

PUSH BUTTONS & DISPLAY - 113 -

COMPLETE UNIT - 114 -

SPLASH SCREEN - 115 -

FIRST SCREEN - 116 -

CHANNEL SELECT MENU - 117 -

CHANNEL 1 MENU - 118 -

INVERTED CURSOR - 119 -

CHANNEL 1 LED - 120 -

CHANNEL 2 LED - 121 -

APPENDIX IX - 122 -

Full Costing Breakdown - 122 -

APPENDIX X - 123 -

Completed Software Code - 123 -

APPENDIX XI - 139 -

5

Page 6: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Manufacturers Datasheets - 139 -

APPENDIX XII - 140 -

Internet Research - 140 -

APPENDIX XIII - 141 -

Presentation - 141 -

6

Page 7: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

SummaryThe aim of this report is to identify a design problem and detail the methods undertaken to find a solution to that problem.Initially, generation of ideas and conceptual designs will help provide blocks of solution, which can then be implemented into a final design once inclusion has been justified.The en result of the conceptual design stage has resulted in the most in depth circuit I have personally ever build, at the same time as teaching me the foundations of a language in programming.Using knowledge gained from the past three and a half years, as well as programming tuition in my workplace, I was able to succeed in designing, emulating, building and testing some of my best work to date.

IntroductionThe reasoning behind the development of this project is to help provide a solution to a problem which results from a user unfriendly task. The approach is to remove the need of having to aimlessly remove and reconnect a transmitter, synchronised to a pair of wireless headphones, from multiple audio devices.This approach will allow the user to switch between multiple audio devices, from a single unit, at the press of a button. This will enable the user to have more control and order to the methods of listening to multiple devices without having to rearrange the connections and wiring, using up valuable listening time.The final device should be one where the audio devices come to it rather than the transmitter having to be relocated to the audio devices.

7

Page 8: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Task 1

Initial Specification:-

Performance Requirements:-

Operate at 9 Volts DC. Have a minimum cable reach of:

o 3 meters for power supplyo 6 meters for audio leads

The device should monitor all inputs and automatically send the signal to the output, without any interference from the other inputs.

The selected channel should be visible to the user. The device should use 3.5mm Stereo Jacks as the Input and

Output connectors, to keep conformity with standard audio equipment.

There should be a manual selector switch to select the following:-

o Automatic (connecting the PIC)o Individual Channels

There should be a minimum of 4 Inputs. There should be a minimum of 2 Outputs. There should be an On/Off switch.

Working Environment:-

The device should be able to operate internally at a temperature range of +5 to +40 deg C.

Maintenance:-

The device should only need to be kept clean to ensure life longevity.

Costs:-

The device should cost no more than £30.00.

Quantity:-

This product is going to be a one off.

Aesthetics / Ergonomics:-

Polymer or Metallic body shell. User friendly insertion / removal of headphone jacks.

Size/Weight:-

Maximum weight of 1KG. (excluding the power supply) Maximum size 150 x 150 x 100mm.

Safety:-

Complies with all relevant Standards and Regulations.

8

Page 9: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Design Parameters:-

Requirement ParameterOperate at 9V DC

Materials This will have an implication on circuit components.

Cost May be cheaper to get lower voltage components and

power supply.Cable Reach Function

Audio devices will have to be less than 6 meters away from the device.

Device needs to be less than 3 meters away from the Power Supply.

Cost The longer the cable the greater the cost. For this

reason there may have to be shorter cables with the ability of an extension. This, however, would increase the amount of Stereo Jacks required and therefore increasing the cost.

Monitor Inputs Manufacture There will need to be a parameter to prevent cross

feeding the signals, as there is a likelihood of scrambled noises if there are two or more sources.

There will need to be a default input if there are two or more signals being received.

Display Materials LCD displays are relatively inexpensive with

programming relatively simple. LED’s could be used as an indicator to which channel

is in use.

Manufacture LCD would be slightly more difficult to program and

install.

Performance LCD would make the unit look more professional but

not increase performance.

9

Page 10: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Stereo Jacks

Cost Standard connector so it will be cheap.

Aesthetics Clean finish making the device look professional.

Safety User friendly, preventing injury.

Performance Fits the majority of standard audio devices.

Layout Enough room will have to be left for inputs, to prevent

fouling of connectors.Selector Switch

Layout Switch will have to be in a user friendly place, so that

ease of switching is available.

Materials Basic selector switch can be used, as there is no special

requirement requested.

Function It should only select one channel at a time, to prevent

corrupting the programming.

Cost Can be relatively cheap as the switch is a common

component.

Aesthetics The switch will need to match the style of the rest of the

device.

10

Page 11: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Inputs/Outputs Cost The more inputs/outputs the greater the cost.

Layout The more inputs/outputs the more cramped the

layout will become. The more inputs/outputs the more complicated the

circuit and program will become.

Performance With more inputs/outputs there is a better chance of

the device meeting the key objective which is to prevent the need of messing with wires when an new device is to be listened to.

Aesthetics Too many inputs/outputs will compromise the

aestheticsOn/Off Switch Layout

Should be next to the power supply input, to prevent confusion.

Materials / Cost A simple cheap switch will be required.

Operating Temperature

Materials Any components which may overheat will need heat

sinks.

Manufacture / Layout The body of a metallic casing could be used as a

heat sink.Maintenance Materials

Sealable container for the circuit, to prevent debris contaminating the circuit.

Quantity Performance Can be unique and exactly to customer

requirements, rather than based on market research.

Cost Materials / Performance May have an implication if the parts required come

to more than £30.00 then a compromise in performance may be necessary.

Aesthetics The device may appear cheap and unprofessional if

cheap plastics and components are used for the device.

11

Page 12: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Aesthetics / Ergonomics (Type of case)

Safety If a metallic case is used then correct grounding

will be necessary to prevent any static build up affecting the circuit components.

Friendly insertion for inputs/outputs

Manufacture / Function There needs to be a solid housing of the stereo

jacks to meet this requirement.Safety Legal Implications / Performance

Only designed for UK usage.Weight Materials / Layout

Limit materials required by getting a suitable circuit and device layout.

Cost Limiting materials will save on weight, but

getting lighter components may increase the cost required to produce the circuit.

Maximum Size Layout Layout will become more important with smaller

devices.

Fabrication Will become more difficult with smaller devices.

Cost / Materials Smaller packages may require smaller (more

expensive) components.

12

Page 13: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Mind Map of Ideas:-

It can be seen in this mind map that a PIC 18F4550 Microcontroller will provide a much more complex circuit than the standard 16F84A. This extra potential would mean that more could be included, such as a Treble, Bass and Volume control of the input signals. A user interface could be introduced to enable greater clarity, which is listed in my specification.

Internet Research:-

I carried out some basic internet research to get a general understanding of some aspects best suited for the design. This can be found in Appendix xii, at the back of this report.

13

Page 14: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Conceptual Design 1:-

For the first conceptual design I have followed the design specification, however kept the design as simple as possible.The design includes four inputs into a PIC16F84A Microcontroller. This chip will then control a set of analogue switches which will allow individual stereo signals through.Written into the code of the PIC Microcontroller will be an automatic control program which would sense the detection of a signal at the input and then close the necessary analogue switch. This would then allow the stereo signal to be received by the output, which in my case is a transmitter for a pair of wireless headphones, however on the diagram below the output is simulated by the oscilloscope.Also in the code for the PIC Microcontroller would be an output to a BCD chip, allowing for the use of a seven segment display. The display would allow for the user to see which channel was being sent to the output, corresponding to the original specification.

14

Page 15: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Conceptual Design 2:-

For the second conceptual design I have introduced an LCD Display. This requires a lot more pins on the PIC16F84A Microcontroller, and as a result I have had to limit the amount of stereo inputs to three. Although this doesn’t follow the specification entirely (with the request of a minimum of four inputs), I feel that the clarity which can be delivered by the introduction of the more advanced display will overrule the deficit of one input.Much of the second conceptual design is the same as the first design, with analogue switches controlling the flow of stereo signals to the output.If I were to use this design as my final one then I would probably get a smaller display than the 20x4 size, as I only really need to display the channel number.

15

Page 16: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Conceptual Design 3:-

I have kept the introduction of the LCD in the third design, the 20x4 line LCD will allow much more information onto the screen than the seven segment display.I have also introduced a new PIC18F4550 Microcontroller, as this will give me the extra availability of five ports, compared to two on the 16F84A Microcontroller. The introduction to a greater number of ports allows me, as the designer, to include extra features to the project. An area I am looking to explore is the possibility of a user interface on the chip, rather than overcomplicating the program I will have to write, I will simply get the user to select the channel through Up, Down, Enter and Back Buttons.There is also the introduction of relays rather than analogue switches, as research has suggested that stereo signals could be impaired by the analogue switches, and that for greater sound clarity, relays may be the best option. (Note: I would also need to include transistors to energise the coils of the relays)

Project Plan:-

A detailed Project Plan for implementing the solution can be found under Appendix i at the back of this report.

16

Page 17: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Task 2

Decision Matrix:-

i:- Specification Conformity. I need to ensure that the design solution conforms to the design specification. I will analyse each solution to see if it is suitable and if so then by how much.

ii:- Design Complexity. I have to ensure that the design is not going to be too complex for me to achieve within the time frame. Complex circuits will be rated depending on how many sections are introduced, for example an input, process and output has three sections, introducing a display will increase that to four.

iii:- Cost. With a greater level of complexity there is a chance that the cost will increase. Although I have specified that a maximum of £30 is to be spent on the project, I am willing to exceed it if there are significant benefits in other sections.

iv:- Future Development Potential. This will help me determine which design has the most potential to be developed on easily in the future. If ideas will require a complete re-design to implement a new feature then it will be marked with a lower score than ideas which can have new features implemented easily.

v:- Clarity. If I feel that one design will provide greater clarity for the user, over another design then I will increase the rating. The whole point of this project is to make the ease of using the wireless headphones better. If the device itself is difficult to use then the whole project is pointless.

vi:- Feasibility. This criteria partners Circuit Complexity, in that a circuit which is too difficult is also likely to be unfeasible to produce. If there are components required in the solution which may have a long lead time to acquire, I will reduce the rating for the solution.

vii:- Education. This criteria I feel is important, as the project should teach me something and test my current understanding as well as knowledge about electronics I am yet to learn. The theory is that the more complex a circuit is, the more likely it is I will require a more advanced knowledge base to understand and manipulate if fully.

viii:- Value For Money. The most suitable design will be one that meets the specification requirements, at the cheapest cost. An outweighing factor will lay with the Education criteria, as the cost of programming lessons is substantial and the availability of receiving them for free could be regarded as value for money.

ix:- Personal Preference. I like a bit of a challenge, and therefore it is likely that I will prefer to produce a circuit which is just outside of my current level of understanding to enable me to learn a little bit.

17

Page 18: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

All criteria are rated 1 to 5, with 5 being the best score and 1 being the worst.Design Solution

Selection Criteria 1 2 3i 5 2 3ii 4 3 2Iii 5 3 3iv 2 4 5v 3 3 5vi 5 4 3vii 2 3 5viii 5 3 4ix 1 3 5

Total 32 28 35

Task 3

Chosen Solution:-

My chosen solution is Design Solution 3. It ranked top of the decision matrix mainly because of its potential to introduce extra parameters to the project. I may be able to introduce a few digital potentiometers to control the Volume and maybe even the Treble and Bass, if I can find a suitable circuit to implement into my design, as I feel that designing my own would be too difficult. This would increase the complexity of the project quite significantly, however it will be necessary for me to weigh up whether it is suitable within the time frame. I believe I have been left with the design which is most suitable for what I want to personally achieve as well as a design which will challenge me but still be achievable within the time frame.I am planning to utilise as much time as I can during the programming lessons at work, as this will enable me to not only progress with project but also within the Microprocessors Unit at college. I have actually already started the lessons on most Friday afternoons, and am undergoing basic programming in “C” language which is something we have already touched upon in class. I have so far initialised ports and made LED’s walk forwards and backwards as well as count in Binary, which is identical to what we have done at college.The chosen design also allows me to add further hardware to the circuit relatively easily as there will be spare ports on the programmable integrated circuit chip. The software can then be written to use this additional hardware, or switch it off if not required.I will have to look into the correct approach required to control the Relays, as I am not sure that the PIC is able to control the Relays in the way I have exampled in the diagram above.I can now have a user interface in the design, which will give the foundation for better functionality and clarity to the user. This would also make implementing more hardware into the circuit much easier as there is somewhere for the hardware to be controlled.

18

Page 19: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Task 4

Compliance Table Against the Original Specification:-

Performance Requirements:-Operate at 9 Volts DC:- The final design has been produced with a 9V DC supply, with an integrated 5V regulator to power the PIC, Display and hold high various pins for the push buttons. There is also a +9V chip which draws 5V DC and converts it to a steady +9V supply, so that the op-amp chips can be powered appropriately. Another single op-amp and potentiometer has been integrated to allow for a 2.5 Volt reference, to bias the signal input above the 0V line, allowing the potentiometers to work effectively.

Have a minimum cable reach of:3 meters for power supply:- The Power Supply which has been

purchase only has a cable reach of 1.7m, so does not meet this specification, however in hindsight this isn’t a necessary spec to meet and I shouldn’t have included it.

6 meters for audio leads:- I have purchased four 7m long stereo extension leads which have 3.5mm plugs on either end. This allows the unit to be connected to audio devices which are practically anywhere in a normal sized room.

The device should monitor all inputs and automatically send the signal to the output, without any interference from the other inputs:- The final design does not monitor the inputs, however it does send the signal to the output without any interference from the other channels, this is confirmed after testing.The new parameter which replaces the monitoring of the inputs is the user interface, allowing the user to easily select individual channels, removing the need for complex coding by automatically sensing.The software switches channel one on immediately, so the primary audio device can be heard as soon as power is supplied to the device.

The selected channel should be visible to the user:- The user will have the option of selecting various channels, upon entering the channel through the channel menu, the relay coil will energise and the audio signal can then be heard for the new channel. All other channels will then switch off to ensure that there is minimal interference.The final design also utilises the I2C Bus, which is used to control the four relays, using the four remaining pins four LED indicators have been implemented. This allows a visual indication of the channel being sent to the output, as requested in the specification.

19

Page 20: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

The device should use 3.5mm Stereo Jacks as the Input and Output connectors, to keep conformity with standard audio equipment:- I have managed to implement the standard 3.5mm TRS (Tip, Ring, Sleeve) connector, enabling the user to connect most types of audio equipment into the device. This meets the specification precisely.

There should be a manual selector switch to select the following:Automatic (connecting the PIC):- As explained above, there is no

automatic sensing by the PIC, so this criteria could also not be met.

Individual Channels:- The individual channels can be selected and switched using 5V relays, although the selection is not automatic, the switching is, as it happens autonomously as soon as the user enters that specific channel from the channel menu.

There should be a minimum of 4 Inputs:- The specification has been met in the design stages. The design allows for a maximum of four inputs to be integrated into the hardware, however multiple reasons led me to only integrate one channel in house and an auxiliary second channel.Firstly there was a lack of space in the box which it had been designed for. I hadn’t taken into account the amount of depth the Display was going to take, as it was mounted approximately 10-15 mm away from the case surface as well as the connector on the bottom as well taking a further 10-15 mm. This meant that there was not enough space to integrate a second channel within the case. This was rectified slightly by adding an auxiliary channel which was taken from one of my prototype boards. I then needed to allow enough cable length to provide external power and communications from the boards inside the case, to the board outside the case.Secondly, it was surprising how long it took to manufacture an individual channel board. It would take easily a full day to complete one channel board, so unfortunately it didn’t seem feasible to create three more identical boards, otherwise the manufacturing process of only the hardware would have taken over 60 man hours.

There should be a minimum of 2 Outputs:- It became clear to me for no obvious reason, that implementing two outputs hanging off of one source would cause the sound to be halved. This would mean that there would need to be an amplifier circuit at the output which would only amplify when there were two outputs. It is something which could be implemented into the design at a later stage, however for this final design, I have decided to only use one output to reduce the complexity.My initial reason for specifying a requirement for two outputs was because I often find myself wanting to have personal audio shared between more than one person. Without introducing a speaker, I would need two independent audio outputs, unless I use a standalone splitter, but this will take me back to the same problem.

20

Page 21: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

There should be an On/Off switch:- This is a criteria which I could have easily implemented into the final design, but for some reason have failed to. A simple rocker switch would have sufficed in opening the circuit preventing current flow to the circuit boards. When I came to order the parts, I simply forgot to order it because it has not been included on the final design. The only benefit of this is so the DC PSU could be hard wired into the unit, however I have integrated a PSU connecter so that it can be switched on/off as necessary with ease, through plugging and unplugging the device.

Working Environment:-The device should be able to operate internally at a temperature range of +5 to +40 deg C:- The device has components which cannot operate much outside of these parameters. The 5V Regulator has to supply the entire circuit with current, so a heat sink has been introduced to dissipate heat away from the component.I do not have the facilities available to me to be able to test the circuit in a temperature range +40oC, however I cannot see any reason to suggest the components would fail at this temperature. The Datasheets for the PIC18F4550, PCF8574 and the MCP42XX Chips states that the operating temperatures are between -40oC to +85oC, which is well within this boundary.

Maintenance:-The device should only need to be kept clean to ensure life longevity:- The sealed nature of the final design, enables this specification to be fulfilled. Unfortunately my final design required an auxiliary channel to be situated outside the box, allowing channels one and two to be operational. This means that if the second channel is disconnected then there will be bare wires coming out of the device which could easily lead to a short. This means that the connections will need to be stowed when not in use, requiring some maintaining.

Costs:-The device should cost no more than £30.00:- This is something that was completely overlooked. My naivety at the start of the project was one of the factors which led such an inaccuracy in the estimated cost and therefore the specified maximum cost. Another factor was the expansion of the design compared to my initial concept, this I feel would have been around that mark. The LCD alone cost more than the entire project budget at £40.00, I feel this is a comment which highlights the inaccuracies.Included in the expansion was the entire Volume and Tone control circuit which wasn’t detailed with much depth in the initial concepts. The design required the inclusion of digital potentiometers, multiple op-amps, which needed their own supply of +9V, as well as a 2.5V reference, not including extra cable, strip-board and discreet and passive components, all of which add cost.My Parts list, found in Appendix ix, has calculated two total costs. The first cost is the price of the project considering it as a one-off unit. So this means where there is a minimum order of 50, but I only need 1, then 50 is the price summed. The total order cost comes to £323.07, so is almost eleven times the amount initially estimated. This is high compared to the total cost per unit

21

Page 22: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

at £222.38, which takes into account only the parts required, but it is still almost seven and a half times greater than the amount initially estimated.

Quantity:-This product is going to be a one off:- This is a spec which is true for the final design, however realistically a prototype was worked on throughout the design phase, so there have actually been numerous circuits produced.

Aesthetics / Ergonomics:-Polymer or Metallic body shell:- The case used was made from ABS plastic, so meets this specification. In hindsight I would have integrated a metal case so that the heat from components could be dissipated through the case rather than an internal heat-sink.

User friendly insertion / removal of headphone jacks:- I located all of the ports into the case on a single board located at the back of the case. This allows the user to easily connect and disconnect leads, whilst maintaining a generally cable free device.The mounting of the jacks is very sturdy, allowing the user to insert and remove the input and output peripherals with ease.

Size/Weight:-Maximum weight of 1KG. (excluding the power supply):- even including my power supply, the whole device does not weigh 1KG. This only includes one channel though, so the more channels included the greater the weight, and it is likely that the overall device with all four channels would exceed 1KG.

Maximum size 150 x 150 x 100mm:- My device with only one channel can be mounted into a box of 150 x 120 x 60mm. If I included the other channels then I would definitely need a deeper box, however at the same time I would likely redesign the whole project on PCB, rather than strip-board. This in itself would allow me to miniaturise the circuit as surface mount technology can be introduced, so the entire circuit may fit in the same box.

Safety:-Complies with all relevant Standards and Regulations:- I used the following Standards and Regulations when designing and building my project:

1. Health and Safety at Work Act 1974 (When testing my project at work)2. BS 7671 “Requirements for Electrical Installations” (When ensuring the

wiring inside the case was adequate)3. BS EN ISO 9453:2006 “Soft solder alloys, Chemical compositions and

forms standard” (When soldering)4. EN11491-1 (Anti-Static) (When handling sensitive components)5. Control Of Substances Hazardous to Health (When disposing of waste

clippings and soldering)6. BS 3939 “Electrical Symbols” (When creating the wiring diagrams)

22

Page 23: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Design the review procedures for the project:-

Continuity Tests:-

During the manufacturing of the hardware, it will be crucial for every single connection to be joined to all the correct places, without having any shorting across tracks.A procedure has not been written detailing the connections as I am planning on using my wiring diagrams to ensure everything is connected in the correct places.

Voltage Tests:-

Once the Continuity Testing has been completed, when manufacturing, power can be supplied to the circuit. It is planned to test the voltage regulating circuitry primarily in order, as follows:

1. 9V DV Input from Mains Adapter.2. Installation on 5V Regulating Circuit.3. Test for 5V Regulation up to 5V Rail and all connected IC Pins.4. Installation of NMS0509C Chip.5. Test for + 9V Supplies from NMS0509C Chip, up to the Voltage Rails

and all connected IC Pins.6. Installation of Op-Amp Reference Voltage Circuit.7. Test for 2.5V Reference up to 2V5 Ref Rail and all connected IC Pins.

The 2.5V Reference is required to bias the input waveform above the 0V line. Without it the tone control circuit would not operate correctly, so it is critical this value is achieved.

Menu Selection Test Procedure:-

I have created a test schedule which tests all of the parameters required to confirm the correct functionality of the software code loaded in the PIC and displayed on the LCD. This can be found under Appendix ii at the back of this report. During the manufacturing process this will help ensure the necessary outcome is achieved precisely.

Audio Test Procedure:-

The Audio Test Procedure, which can be found under Appendix iii at the back of this report, helps ensure that further specifications are met. It will not be suitable to have any noise at the output, as this will not benefit the user in any way. Instead it is will be necessary to have a clear and undisturbed output which could mistake the user in thinking they are connected directly to the selected audio device.There is also the requirement, within this test schedule, to check that the I2C part of the circuit is functioning correctly. A simple test of changing Channels and visually testing the Channel LED, will confirm/disaffirm this. If this Test Procedure passes then the device can be regarded as complete.

23

Page 24: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bode Plot Test:-

Once the device has been confirmed as functioning correctly, I will then need to measure the actual Gain and Attenuation at the various frequencies. During the design stages I will also need to produce the predicted results through emulation of the Op-Amp Tone Control Circuit. This will give me a suitable guideline of what to expect, and also confirm/disaffirm the results I am getting from the real circuit are true to the emulation.

Results of the review procedures for the project:-

Continuity Tests:-

After wiring up the circuit on the stripboard, I used the wiring diagrams to help ensure that all of the tracks were broken in the correct places and that only the necessary connections were made between pins.During the Audio Test, below, I found that there was substantial noise coming from the output. This was not acceptable so I had to redo the Continuity Test to ensure I hadn’t missed anything. It turns out that I had missed a track break between the left input and an output of the right Op-Amp circuit, simply by breaking the track the circuit was fixed.I was very pleased that this was the only error, as I had taken my time and wired the circuit correctly first time to ensure I wouldn’t spend multiple hours looking for almost invisible problems.

Voltage Tests:-

I carried out the Voltage Tests in the order as described above. It was critical that I did it in this order as the sections were daisy chained together. The 9V DC input supplied the 5V Regulator, which supplied the IC’s and the + 9V converter, which supplied the Op-Amps, which produces the 2.5V Reference. So if the first one is incorrect then it is likely that the rest will be too.The following is a table of the four voltage levels referenced to ground.

Required Measured+ 5 V + 4.95 V+ 9 V + 9.46 V- 9 V - 9.47 V

+ 2.5 V + 2.49 V

The 5V Regulator is providing an adequate voltage to all points required on the board, such as the IC’s. This level is within tolerance of what is required for the components to operate correctly.The + 9V supplies are slightly on the high/low side, however the two Op-Amp Chips selected for use are very versatile and will work perfectly fine at this voltage level.The 2.5V Reference was very easy to get accurate, as I was able to vary the 10K Pot to suit. By connecting a Voltmeter across the output and ground I could easily set the necessary 2.5V value. I then painted across the dial and the body of the Pot with some nail varnish, to ensure it remains in place.

24

Page 25: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Menu Selection:-

I used Proteus’ ISIS ECAD package significantly during the design and build of this project. The main benefit of this package over others such as MultiSim 10 is the fact that the parts library is incredibly extensive. This attribute allows parts which are available to the user to be implemented into the design, allowing the designer to choose precisely the type of component they want to use, for example power ratings and tolerances on resistors, as well as component layout/size for PCB design.Another key feature when using ISIS was the fact that you can test in real time. This was a massive benefit to me whilst I was writing the code for the project. Because I was learning as I went, I could change a piece of code, test it and then change it again, all within about five minutes. If I had to flash the code onto the PIC and physically test it every time then it would take me easily twice as long.There are also other key features such as visual representation of logic levels on pins. This helps during the design process to better understand and process any errors which may arise, i.e. the ports may not be initialised properly to allow individual pins to be used for inputs or outputs.

I carried out two tests, the first being the emulations, which can be found in Appendix iv Emulated Menu Selection Test, at the back of this report. These Print-screens detail the setup of the emulated test. Pages 1-6 demonstrate all of the code working to the necessary level, as stated in the test schedule. The Glyphs are displayed in the correct positions and there can be varied using the up and down buttons when the selection cursor has been inverted.Pages 7-15 then demonstrate that the SPI control code is working. There is a 1V Amplitude @ 1 KHz, sine-wave injected into Pin A of the Potentiometer. The output (i.e. the wiper) is connected to the Oscilloscope, with Pin B connected to Ground.The idea behind the test is to ensure the amplitude of a known input is successfully manipulated by pre-determined steps, through the control of the digital pot.As you can see from the results, there is a clear increase with a direct relationship between the bars indicated on the LCD and the amplitude of the waveform shown on the Oscilloscope.What isn’t demonstrated in this appendix is the fact that another channel can be manipulated, with control being possibly through the successful implementation of the Chip Select pins.

This circuit design was then transferred to two Prototype Boards for the second test, to simulate a single full channel in operation. An image of the Final Prototype can seen on Page 1 of the Test Images found in Appendix viii, at the back of this report. This test was successful, however did not test the full circuit as there was only one channel, and I couldn’t see if the switching between channels was working correctly.

25

Page 26: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

I then developed the Final Project onto Stripboard as there was not enough time left to get a full PCB Design and have it manufactured and fabricated in time for the Presentation.The Stripboard can be seen on Pages 2-5 of the Test Images found in Appendix viii, at the back of this report.Unfortunately there was not enough space in the Case to house a second channel board, so I had to have an auxiliary loom out to the modified Prototype Board Channel. This enabled me to now test the switching.

The Menu Selection Test actually starts with the final product on Pages 9-13, where the menus are successfully navigated and work as is required in the test schedule.

On Pages 14-15 I have demonstrated the test of the switching between the two channel LED’s. This all works perfectly well.

Audio Test Procedure:-

The audio testing was the most significant thing, as the whole circuit needed to ensure the required input was being received at the output. I primarily needed to ensure I was receiving the correct input but I also needed to check that the Volume and Tone control circuits were being controlled in the same fashion as was being displayed on the screen.It was during this test that I noticed I had actually wired the digital potentiometers the wrong way around, so the Bass became Volume and the Volume became Bass. This was easily rectified, as the information through the SPI bus needed to be ordered so that the last chip is sent the first piece of information, this would allow the next piece of information loaded to push through the first piece to the second chip and then finally the third information set is loaded. All that needed doing was the code needed rearranging so that the Bass settings are loaded first rather than the Volume.Note:- The above piece of code can be found in the “UpdateSPI” Subroutine beginning on line 706 of the “main.c” code, found in Appendix x Completed Software Code, at the back of this report.I did notice that the Treble gain and attenuation didn’t have much effect on the audio signal, this would have been because the gain and attenuation didn’t happen until too high a frequency to be audible. To change this in future designs I would need to test various component values so that I can bring the frequency range down to a more audible level. More information can be found on this under the Bode Plot Test, below.

26

Page 27: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bode Plot Test:-

With the Emulated Volume Control successful in the Menu Selection Test above, I needed to test the Tone Control Circuit. This meant building an equivalent circuit to the one I was going to use, but with manual potentiometers, rather that digital ones. This enables me to measure the Attenuation or Gain levels with the pots in the pre-determined step positions.The Emulated Bode Plots can be found under Appendix v at the back of this report.As can be seen by the Emulated Bode Plots on Pages 1-9, there are suitable changes in Bass Attenuation and Gain. This is also audible as explained in the Audio Test Procedure. The surprising result was that there is a staggering + 15dB’s of Gain which is similar to other professional audio devices.On Pages 10-18, the Bode Plots for the Treble Attenuation and Gain can be found. Again there is a clear trend with the levels being around + 14 dB’s of Gain.

I then connected my real circuit to a Bode Plotter, which injects a frequency into one end of the circuit and then measures the response at the output.The Real Circuit Bode Plot can be found under Appendix v at the back of this report.I was only able to have six plots on one graph, so simulated the Bass and Treble Potentiometers at 0%, 50% and 100%, giving me the bowtie effect which is common in audio circuits. The results also corresponded to the results expected from the research gathered when finding this Tone Control Circuit online.It is possible to see a correlation between my emulated plots and the real thing. There are slight differences in the levels of Gain and Attenuation between the two, however they are still relatively close.

27

Page 28: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Detailed Description of the Final DesignBefore beginning the description of the Final Design, attention should be paid to the following three appendices, to familiarise the reader to the finished product.

1. Appendix vi – Audio Selector Wiring Diagrams2. Appendix vii – Case CAD Rendering3. Appendix viii – Test Images

My design involves the use of multiple parameters to suit the initial criteria. Due to the availability of programming lessons at my work place, I was able to utilise a number of aspects from the chosen microprocessor.With the preliminary intention of using a PIC 16F84A I switched to the PIC 18F4550, due to the extra availability of ports. This PIC also proved more suitable as the programming lessons were based around this chip so the set up parameters were already in place, i.e. the ports had been initialised to suit my intentions etc, this is shown between lines 24-62 of the “main.c” code, found in Appendix x Completed Software Code, at the back of this report. The only requirement on me in terms of configuration was to set the ports to the required inputs/outputs which was similar to what we have covered in the Microprocessors unit at college. This can be found on lines 91-99 in the same Appendix.

Initially the user interface was going to be really basic with a channel menu controlled by a couple of push to make buttons. Within two weeks the design had changed slightly to integrate four push buttons which control the up, down, enter and back functions as well as a push button to reset the microcontroller.The implementation of the four user function buttons changed during the construction as there was a requirement for RB1 on Pin 34 of the chip to be used for its Serial Clock function, this caused me to change the location of the connections going into Port B and also lead to me having to change the code respectively so that the software monitored the correct pins. Within the code I had firstly written code that meant I had to change the pin names around thirty times, this lead me to integrate an equate so that if in the future I needed to change the pins again all I would need to do to the code is change the equate once and the rest of the code would follow. This can be found on lines 26-29 of the “config.h” code, found in Appendix x.Pins 35, 36, 37 and 38 on the microprocessor were finally used for the push buttons. These pins were held high through a 10K resistor, then by pressing the push button the pin would go low, the function of the resistor is to prevent a short when pressing the push button. The code will then check for the pin to go low, at which point the button is being pressed. An inhibit while loop was initially used to stall the program from executing the relevant code more than once, ensuring that when the push button was pressed once the code would only execute once. This while loop was replaced with a do while loop to ensure the code was as clear as possible for the final product. An example of this can be found on lines 237-246 of the “main.c” code found in Appendix x.

28

Page 29: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Here the code tests the buttons (subroutine found on lines 267-309) to see if they have been pressed. The update variable within the code is used as a write prevention method to help reduce noise, through unnecessary writing/compiling. Only when a button has been pressed will the update variable be true, and therefore only during that instance will the code compile the next sequence, otherwise it will skip that “if statement”.If a button has been pressed the MenuCursor subroutine will run, housed inside the “if statement”. This can be found on lines 311-380 in Appendix x. Here the start and end positions of the cursor are loaded into the subroutine. In this example there will be four lines for the cursor to navigate on, comparing that to line 499, where only three lines will house the cursor.Within the MenuCursor subroutine a value loaded during the TestButtons subroutine will determine the course of action. If the Up Button was pressed then the value of a variable called Cursor will decrement by one. If the Down Button was pressed then the value of the variable Cursor will increment by one.There are two loop around parameters included here, found on lines 330-331 and 337-338, where if the value of cursor is less than the start value, it will then equal the end value or if the value of cursor is more than the end value, it will equal the start value. This allows the Up or Down Buttons to be pressed continuously and the Screen Cursor will simple cycle around the options rather than get lost in an ever increasing/decreasing variable number. It actually prevents the code from becoming corrupt as you cannot get negative integers.This value of the Cursor variable is then evaluated in a switch statement. Depending on the value loaded within Cursor there will be a different message written to the display, this can be found on lines 348-376.With each cycle of this, there will be an evaluation of the Enter Button (found on line 245). As long as the Enter Button has not been pressed then the cycle will continue with checking the buttons and manipulating the on screen cursor.

The push buttons were placed on Port B to keep Port A free as this was not set up for digital inputs, only analogue.

The oscillator circuit was a copy taken from another design and simply used two capacitors, a resistor and a crystal. This was then fed into pins 13 and 14 on the microprocessor to provide an external clock source of 20MHz.

Port D was utilised for 20 x 4 Liquid Crystal Display as this used six of the eight pins available. Fortunately I was able to simulate a screen with the same specification as the real device, which meant the code I wrote did not have to be edited before loading it onto the real device.Using the MPLAB C18 C COMPILER LIBRARIES Document Pages 79 and 81, I was able to write a small subroutine, found on lines 248-265 in Appendix x. This meant that whenever I wanted to write something to the LCD all I had to do was detail the position on the display (a list of all the positions can be found in the LCD Datasheet [Appendix xi]) separate with a comma and then write a maximum of twenty characters within two hyphens. An example of this can be found on line 186 of the “main.c” code.

29

Page 30: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Port C utilises the SPI (Serial Peripheral Interface) function so that the digital potentiometers could be controlled. The digital potentiometers used could not be simulated correctly as they did not have a Data Out pin, which was required to daisy-chain multiple chips together, so the only time I could test that they were working was with the real end product. The chips ordered housed two digital pots, which were to function as the two lines used in stereo for the right and left ears. The datasheet of the chips calls for an indication in the code of the address of the chip and which potentiometer is to be changed (Command Byte), detailed on page 18 of the digital pot chips found in Appendix xi. This can be found on line 727 of the “main.c” code, where Potentiometer 0 is written to, compared to line 736 where Potentiometer 1 is written to.I need the wiper on both of the pots for the right and left to be the same, so the value loaded was identical for each i.e. the Values of the code on lines 728-732 is the same as that on lines 737-741. The value of the first two pots are loaded into the first chip, then when a second value is loaded in the first values are pushed into the second chip, then when the third values are loaded in the values in chips 1 and 2 are pushed into 2 and 3. Because of this it was necessary to determine which chips would output which setting, I settled on the first chip to output the Volume setting, the second chip would output the Treble setting and the third chip would output the Bass. This meant that the SPI Bus would have to be updated in the reverse order to allow for the data push each time new data is loaded, as exampled above. Therefore I would need to update the Bass, then the Treble and finally the Volume in the code to ensure that the correct values were loaded into the correct potentiometer wipers. This information was extracted from the datasheet for the MCP42010 Chip, as there are clear examples for the setup. This gave me a general layout required to make full use of both potentiometers.I could have loaded the Command Byte with the value of 0x13 instead of the two values I have used 0x11 and 0x12. There would have been no difference in the outcome at this stage, however with the method I have used, I could very easily implement another option (along with the Volume, Treble and Bass) which would control the Balance. This would simply load one earpiece with one value and the other earpiece with a different value, when loading the volume pots.

30

Page 31: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

I did need to calculate the values necessary to make a gradual stepping sequence. To do this I needed to work out 256 divided by 9, to the nearest whole number, which was 31. This gave me a range of 0-248.

Digital Potentiometer Values:

Potentiometer Percentage (%) Bit Number Resistance (Ohms)100 248 087.5 217 1,25075 186 2,500

62.5 155 3,75050 124 5,000

37.5 93 6,25025 62 7,500

12.5 31 8,7500 0 10,000

Volume:When the Pot is at 0% the Wiper is effectively directly connected to PB (connected to the 2V5 reference), meaning there is 10,000 Ohms resistance, limiting the amplitude on signal coming in (Volume). As the Bit Number increases so does the Pot percentage, which turn varies the wiper to a closer position to PA (connected to the input signal), this has the effect of reducing the resistance level between the input and the output of the Pot. For example, when the Bit Number equals 124, the Pot is set at 50%, which means there is a resistance of 5K Ohms between the input and the output, this represents a direct relationship between the amplitude of the waveform and the pot percentage. When there is 100% on the Pot, the waveform is 100% amplitude, and when there is 37.5% on the Pot, the waveform is 37.5%.

This is in fact a linear relationship between the Pot and the waveform. Our ears actually hear in a logarithmic form, so the lower end of the spectrum on the volume would not appear to change much and then at the higher end of the spectrum the volume would increase substantially on the final few steps. I didn’t have time to integrate a logarithmic potentiometer into the circuit, as this would require new steps to replace the ones calculated in the above table, as well as additional cost to an already expensive project. Instead I integrated a resistor which was 15% the value of the 10K Pot, of 1K5, this was connected to the wiper and the 2V5 reference connected to PB. The effect this had on the volume was sufficient enough to make an audible difference in the steps of the volume settings, whilst maintaining the simplicity of the original coding. Emulated representation of this data can be witnessed in Appendix iv.

There is a similar relationship between the Bass and the Treble Potentiometers, in terms of values loaded and resistance levels, however their function is different. This is explained in greater depth during the Volume and Tone Control Circuit description.

31

Page 32: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

The switching of the channels on and off worked through the use of 5V DC relays, this way the signal should be undisturbed by noise from the switching. Unfortunately there were not enough outputs left to allow for the relay implementation so I had to make use of the second data bus, the I2C. Using a single pin on the PIC you are able to get an extra eight outputs, so because I only need four I have decided to provide a visual indication of channel in use with an LED as well as the screen. This LED can be located next to the channel inputs so it can be clear which device is selected at the output. There was obviously the need to introduce power transistors to allow for a direct supply of 5V DC, with switching being controlled by the PCF8574 I2C Chip. The code required for this was very easy to write compared to the rest of the code. Quite simply the first channel will be latched on, as a default, until another channel is entered, this allows for a constant audio source to the user until they select their desired channel. The code for this can be found on lines 413-433 of the “main.c” code found in Appendix x. The hex values are relating to the pins on the I2C chip being controlled. I wanted to only sync the LED’s, but power the Relay Transistor Base Pins. So for Channel 1 I would need 1110 (i.e. E in hex) for the LED on Pin 9 and 0001 (i.e. 1 in hex) for the Relay on Pin 4, hence the 0xE1 on line 416 of the “main.c” code. These pin numbers relate to the wiring diagrams found in Appendix vi.

The Volume and Tone Control circuit was based on a circuit taken from an online source (reference 2 in the Bibliography). This needed a few adjustments to fit into my existing circuitry, however working with a work colleague, Dave Bethell, we managed to adjust the circuit to include the two digital pots as the treble and bass control pots. This allowed direct digital control of the tone, through the two digital pots in the treble and bass MCP42010 Chips, with the volume MCP42010 Chip controlling the input to the tone circuit. Analysis was performed on the circuit to ensure the desired results were being delivered, ensuring accuracy at the output. This is explained in detail in the Testing stages earlier in this report.

The audio inputs are through four 3.5mm Stereo Sockets. This allows the signals for both the right and the left input to be edited through the digital potentiometers and the tone control circuit, before being delivered to the output through each of the channel relays.Five of the 3.5mm Stereo Sockets were mounted onto a small piece of stripboard, which allowed all of the ground pins to be connected together, with the right and left tracks being broken in the appropriate places to prevent crosstalk between channels. Wires were then soldered to the board to allow communication between the Input/Output board and the two implemented channel boards.Also on this board is the LED’s which indicate the Channel in use, the workings of which are described above.

32

Page 33: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Noise prevention was a factor in my circuit design and in the code. To begin with my code was written with while loops which meant the code would constantly loop until a push button was pressed, for example. During these loops I would write to the screen, but because in was in a loop the text would be written again and again until the loop was ended. I used a variable which was called “update”, by only running the loop when the update variable equalled 1 (or was true). This meant the noise created from constantly writing to the display would be significantly reduced as it would now only happen once. Initially the variable would equal false and then when the user has pressed a button the variable would be loaded with one, which would in turn execute the code and therefore change the display once. At the end of the loop the update variable will be loaded with a false value again so that the loop isn’t executed more than once.

I used a 9V at 2 Amps (18 Watt) Dc Power Supply Unit which allows the Audio Selector to run from the Mains Supply. This was decided as the Ampere/Hour rating was going to be too high for a standard PP3 9V Battery, mainly because of the LCD Backlight.This supply voltage is then Regulated down to 5V, through a regulation chip, and distributed to all of the IC’s requiring a 5V VDD.The Op-Amps required a + 9V Supply, so the introduction of the NMS0509C Chip was required. This chip has an input of 5V and gives two outputs of +9V and -9V. The problem with it drawing 5V is that there is extra load on the 5V Regulator. This meant that a relatively large heat-sink had to bee fitted the regulator for protection.I finally had to make a 2.5V reference for the following reason:The Digital potentiometers, which are controlled by the PIC via the SPI Bus, do have certain limitations. Once of the limitations I was faced with were the allowed voltage levels on the Resistor Terminals. The problem was that the resistors could not handle a negative voltage, which would be faced with my inputted audio signals. The levels available to me were a minimum of 0V and a maximum of VDD, which in my case was +5V.The solution was to bias the input to ensure that at no point would it fall below 0V or rise above +5V. To do this I needed to supply a 2.5V Reference Voltage so that this could be connected to the same points that Ground would normally be connected. This has the effect of moving the entire waveform 2.5V higher on the graph. To re-bias the waveform after this section of the circuit, the 2.5V Reference was also connected to the positive pins of the two Op-Amps, this brought the waveform back down to the 0V line. This biasing technique allows this section of the circuit to function appropriately, by allowing the Digital Potentiometers to amplify or attenuate the audio waveform before sending it out to the headphones.

33

Page 34: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

The software was an area which took the longest time to produce. It was necessary for me to emulate all of the code at first, to give me a general understanding of various functions when writing in “C” language.I will now try my best to clearly explain the code, as it is written in Appendix x. I will firstly explain the “main.c” code and then move onto the “config.h” code.

Lines Title Explanation

1-16 Header

This is a standard header which is used throughout the code to help explain each routine. It allows the programmer to see the various dependencies for that part of the code, preventing the need of trawling through the entire routine to determine if any changes are necessary.

17-22 Include Files

These are the files necessary for the code to work. There are variables within the main code which are pulled from these include files.The “config.h” file is a hex file which I wrote.

24-62PIC

Configuration Bits

This section configures the PIC. The variables used here are pulled from the “p18cxxx.h” include file. It allows the user to simply type “on” or “off”, rather than typing a mass of code each time they want a certain ability.This is something Dave Bethell wrote and supplied me with, saving me a lot of time.

64-73Global

Variables

These are the variables that are used throughout the code. It is necessary to have Global Variables when the same variable needs to be considered in more than one routine. Otherwise local variables can be used.

86-172 MainThis is the main code. Within this part of the code all of the subroutines are called, either directly or through another subroutine.

89Local

Variable

Here I have declared “i” as a local variable, as it will only be used for the delay counting in this section. I will not need its value in other routines.

34

Page 35: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

91-99Configuring

Ports

Here I configure the pins of the PIC. I can do this one of two ways: either configure the whole port to do a certain function on various pins by loading it with a hex value (line 92 for example), or by configuring individual pins (line 94 for example).

101-105SPI Chip

Select Setting

When loading the Digital Potentiometer chips they need their Chip select pin held low. This part of the code holds them all high, preventing any values being written to the pots until it is later requested intentionally.

107-109 Display Setup

This is the code necessary for the Display to be suitably setup. The information was extracted from the MPLAB C18 C COMPILER LIBRARIES Document.

111-115 Test Cursor

This part of the code is effectively an on/off switch. When the code is emulated within ISIS, it is set in DEBUG mode when being compiled within MPLAB. This means that a cursor will flash so that you can see which information has been written. When the same code is being compiled to be put into the real PIC, it is set in RELEASE mode. This removes the cursor so that there is a clean screen on the device.

117-118 SplashScreen This will run the splash screen subroutine.

120-121Input Channel

Setup

Initially, Channel 1 needs to be sent to the output. This part of the code turns the first LED on and also energises the coil for the first Relay. This means that as soon as the Audio Selector is switched on, there will be a signal at the output from the Channel 1 input.

123-127Glyph

Loading

I have created seven of my own Glyphs for the project. This part of the code loads those Glyphs into the LCD RAM.

35

Page 36: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

130-136Initial Volume,

Treble and Bass Settings

This section loads the four channels with their initial settings. The variable “i” is used to select the individual channel, so i=0 is the initial setting in the for loop. This will set Channel 1 at the desired levels as identified by the decimal numbers.Once the for loop has been completed once the value of i will increment, so i=1 which will then load Channel 2 with the same settings, and so on.It is therefore possible to change the initial settings of the four channels by changing the decimal number in this section.

141-151 Delay

Using the same DEBUG and RELEASE modes as used in the Test Cursor switch, two delays have been implemented into the code.During the emulation (DEBUG mode) the code actually runs more slowly so it is only necessary for the delay to loop around twice, however in the real PIC (RELEASE mode) the delay has to run twenty four times to appear the same.The Delay code was taken from the MPLAB C18 C COMPILER LIBRARIES Document.

154-155 Clear LCDThis section clears the LCD so that new text can be displayed and not overwritten.

157-158 StartUpScreenThis section runs the Start Up Screen Subroutine, asking the user to press the Enter Button.

161-163Do-While

Loop

This section checks to see if the Enter Button is being pressed, otherwise no further code will be compiled.

166-171Endless While

LoopThis section will run only two subroutines, indefinitely.

184-190 SplashScreen Displays four lines of text when called.

36

Page 37: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

201-207 StartUpScreenDisplays three lines of text which request the user to press the Enter Button.

220 ChannelSelectMenuThe beginning of the Channel Select Menu, which allows the user to select the channel they want to listen to and edit its properties.

223-224 Clear LCD Clears the display.

227-230 Display Text Puts channel text onto the display.

233-234Update and Cursor

Variables

Sets the Update Variable to 1 so that the next step will compile. Sets the Cursor Variable to 0 so that the cursor is displayed.

237-245 MenuCursorDo the MenuCursor routine until the Enter Button is pressed.

259-265 ScreenTextSubroutine to write text to the display in a programmer friendly method.

278-309 TestButtons

Loads the SwitchStat Variable with variable NONE, which equals 0. Then each of the Push Buttons are tested to check if they are being pressed by the user. If they are then the SwitchStat Variable is loaded with a specific number which can then be evaluated later on.The Update Variable is also loaded as true.The Back Button was given a Delay of 0.1 Seconds as there was a bounce when tested, this would cause the back button to actually go back two steps rather than one, the delay prevents this.

324 MenuCursorThe start of the MenuCursor Subroutine, which displays the Cursor on the right hand side of the LCD.

37

Page 38: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

326-344Cursor Variable

Control

This section controls a variable called Cursor. It is the value of this variable which controls the location of the cursor on the screen. If the Up or Down Buttons are pressed then the Cursor Variable will increment or decrement by 1. There is also a loop around feature to enable the user to only press one button if desired.

346-376 Cursor on DisplayThis is the section of code which writes the cursor position to the display, depending on the value of the Cursor Variable.

377 Selection VariableThe value of the Cursor Variable is then loaded into another Variable called Selection, which is used later on.

393 ChanSelectThis is the beginning of the ChanSelect Subroutine, which controls the settings displayed on the LCD.

395 i Variable Another local variable called “i”.

402-411 Menu Information

This section loads various pieces of text onto the LCD. It also writes the Channel number which is loaded in the variable channel on line 403.

413-433 I2C Update

This section requests the I2C Bus is updated with the necessary values required to switch individual Relays and LED’s on, depending on the selected channel, controlled through a switch statement.

38

Page 39: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

436-442Display Volume

Setting

Here the initial Volume Bars are displayed.Line 436 sets the starting position for the Bars to be written to, which is right after the “VOLUME:-“, previously displayed.On Line 72 there is a variable which houses all nine of the addresses for the Volume Glyphs found in the “config.h” code, in the correct order. This information is written to the display, but only with correlation of the local “i” variable which begins as i=0 on line 438.There are effectively four Volume Variables available (one for each channel), they are depicted as:

Volume[0] = for Channel 1Volume[1] = for Channel 2Volume[2] = for Channel 3Volume[3] = for Channel 4

These variables were previously loaded with initial values on line 132, which are the values then written onto the display.So vol_glyphs will then equal 2, and only display 0x5f and 0x02.

444-486Display Tone

Setting

There is a similar principle with the Treble and Bass settings, where the initial value is loaded in. However it is different slightly as the Treble and Bass Settings need to start in the middle, giving a + adjustment from the centre point, i.e Gain or Attenuation, as this isn’t faced with the Volume Setting.The two sections basically check that the initial setting is either less than 3 or greater than 4, depending on the value depends which if statement will be compiled.

39

Page 40: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

493-503Menu Cursor

Control

This section navigates the menu cursor until the Enter Button is pressed, at which point the UpdateParameter Subroutine is run.

517UpdateParameter

Subroutine

The beginning of the UpdateParameter Subroutine, where the Volume, Treble and Bass Settings can be adjusted.

521Parameter Switch

Statement

The values of the cursor and channel are brought into this subroutine, and renamed param and ch_sel.This Switch Statement evaluates the value of param (also known as cursor) which will let the code determine if the parameter to update is the Volume, Treble or the Bass.

523-566 Volume Case

In this Case the Push Buttons are tested and the variable SwitchStat used, to determine which direction the user wants the volume to go, up or down, controlled through if else statements.If the user presses the Up Button the Variable volume[ch-sel] will increment by one. This is capped at a level of eight with another if else statement on line 536. This prevents the code from wanting to display bars off of the scale.Line 541 sets the starting position for the code to write to the LCD. This has a direct relationship with the value loaded in the volume[ch_sel] variable as otherwise the new glyph will replace the existing glyph in the address 0x48. This way the old glyph will remain and the new glyph will be written next to it.The glyphs are then written to the display as described above in the Display Volume Setting section.

562UpdateSPI (Volume)

Before the end of the Treble Case, the UpdateSPI Subroutine is called. This allows the Volume digital potentiometers to be updated and controlled with a direct relationship to the bars being displayed on the screen.

40

Page 41: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

565 Back Button

The code will use the Up and Down Buttons to control the Bar levels, hence disabling their use of controlling the cursor.By pressing the Back Button the user can now control the cursor again.

568-631 Treble Case

This Case in the Switch Statement works in a similar principle as the Volume Case, with a slight difference.When it comes to updating the display (line 585 and 609) another if else statement has to be introduced to control the removal of the glyphs as well as the writing of them. So when the Treble is at full Gain or Attenuation all the glyphs on one side are displayed, however when the user wants to go back the other way, the previous glyph now needs to be deleted.

627 UpdateSPI (Treble)

Before the end of the Treble Case, the UpdateSPI Subroutine is called. This allows the Treble digital potentiometers to be updated and controlled with a direct relationship to the bars being displayed on the screen.

633-696 Bass CaseThis works in an identical fashion as the Treble Case, as the bar levels are identical.

695 UpdateSPI (Bass)

Before the end of the Bass Case, the UpdateSPI Subroutine is called. This allows the Bass digital potentiometers to be updated and controlled with a direct relationship to the bars being displayed on the screen.

41

Page 42: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

716-814 UpdateSPI

This Subroutine controls the loading of data to the SPI Controlled Digital Potentiometers.It is broken down into four identical sections, which are evaluated under a switch statement. The variable spi_sel is a char value pulled from the call of the subroutine which is called ch-sel. This allows the values of individual channels to be loaded to their independent potentiometers.Line 725 is the beginning of the loading of the Channel 1 Volume, Treble and Bass Settings. On Line 726 the Chip Select line is held low, allowing all the Digital Pots connected to that line to receive the data.Line 727-732 is the writing of code to Potentiometer 0, which controls the Right Earpiece Audio Signal.The Channel 1 Chip Select line is then held high again, preventing information being written to the chip.Line 735 lowers the Chip Select Line again and enables the Left Earpiece Audio Signal Digital Potentiometers to be controlled over lines 736-741. Before setting the Chip Select line to high once more.

745-763 Channel 2This section does an identical process as described above, but for only the Channel 2 settings.

765-783 Channel 3This section does an identical process as described above, but for only the Channel 3 settings.

785-802 Channel 4This section does an identical process as described above, but for only the Channel 4 settings.

827-856 Update I2C

This section updates the I2C chip which controls the Relays and LED’s. The reason for the address being loaded is because the I2C is generally used as a Bus Expander, where more than one I2C chips can be used. Each would then have its own address.

42

Page 43: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Now briefly the “config.h” file…

21-34 DefinesHere are my Defines used within my “main.c” code.

37-46 Prototypes The Prototypes were also kept inside the “config.h” code, to clean up the “main.c” code.

50-70 Delay

This is the Delay used in my “main.c” code. It calls for No Operation 18 times, which is then multiplied my however many times the programmer wants the delay.More information can be found in the MPLAB C18 C COMPILER LIBRARIES Document.

73-80 DelayA 15mS delay used by the LCD, to help prevent corruption upon reset.

83-90 DelayA 5mS delay used by the LCD, to help prevent corruption upon a clear screen request.

92-158 GlyphsHere are the seven glyphs used in my “main.c” code. They are loaded into the LCD RAM and then called in the order seen here.

43

Page 44: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Evaluation

Overall I am very pleased with how the project went. There were times during the course of the project where I doubted if I would finish in time or be able to explain the circuit clearly enough to express understanding.I am also very pleased with the amount of clarity I was able to bring forward through this Project Report. It was a very daunting task at the beginning of the report to have to try and explain my way through every aspect of the design and include the countless problems I faced along the way. I was unable to explain all of the problems as there were so many of them!

There were a few problems which affect my end result. Firstly I will explain a slight error on my part when drilling the hole for the Reset Button. I measured 29mm from the bottom and 31mm from the side, but ended up marking it the other way around. This means that the Reset Button is still accessible, but it is 2mm South-East of the marked out location.

Another problem faced was with the lack of space inside the case. This meant I could only incorporate one channel inside and then had to use my Prototype Channel as the second. It still works correctly and switches between the two, but it is definitely an area which would need revising when I come to make version 2 of this design.A rectification for the lack of space is the miniaturisation technique used in PCB through hole and surface mount manufacturing processes. It was only because I was running out of time at the end of the project that the circuit was not implemented onto PCB. Below are three images of the same PCB design which I created illustrating the size difference between stripboard and PCB through hole. The PCB has two channels on and it takes up the same amount of space as one channel on stripboard. This is the first design of the Channel Board as well, so I am sure with a rework and the introduction of surface mount IC’s and components, there will be the capability of having all four channels on a single board.

For the Project Plan, I had set myself 50 Tasks to complete, with their own start and end dates. It was clear from about February time that the plan was difficult to follow as dates could not be efficiently met, due to various reasons, but mainly the availability of the programming lessons. Each week would only teach me a small section of what I needed to know, so it meant that a month could go by without having made much progress on the specifics of the project. It was not until about March/April time that the programming really started to take shape and produced results.An area I missed out was the design of the actual circuit on stripboard or PCB. This meant I had to spend a lot of time on the design without actually recording any advancement in the project.In Hindsight I would have allowed more flexibility between the tasks, but then this could have led me to have a funnel effect on the workload towards the end of the project.

44

Page 45: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

During the Audio Test, there was a considerable lack of Treble change when varying the treble selection on both channels. This was partly expected as the Emulated Bode Plots example the levels of gain and attenuation are too high in the frequency range to make much audible difference. We hear between 20Hz and 20,000Hz, so with the majority of the Treble changing past the 20K region, we cannot hear most of it.I would have to change the component values in the Tone Control Circuit to try and bring the gain/attenuation back down to an audible range. This woul have to be done in version 2 of the project.

During the build of the project there were many ideas chucked around about implementing further hardware to make usability even friendlier.One of the key points of the project was to reduce the need of having to mess around with cables. This is a problem that still exists to an extent.I had an initial idea to design wireless modules which can plug into the audio devices and then communicate to the audio selector. This is something which I could still do, however obtaining the necessary licenses to transmit wirelessly may be the deciding factor on the implementation of the technology.The implementation of additional channels would also be something to consider, as it is often impossible to determine how many inputs would be necessary for different users. I thought that the possibility of having an interface which new channel boards can be added and removed, with the user selecting the number of channels required during the start-up of the device.The device currently resets all the channels upon start-up which means the user has to redefine the levels of Volume, Treble and Bass desired for each channel. If a memory chip was integrated such as EPROM then the selections would be automatically saved, creating a more user friendly device.Removal of the Push Buttons would also be an option to increase a fully integrated unit. To miniaturise the whole device, I could implement a touch-screen display which would enable the user to have a handheld module. The settings could be swept with a thumb, rather than incremented/decremented one at a time. This would, however, take a much longer time to implement as it is far more technical than simply outputting the information to the screen.I could also implement a Remote Control, so that the user can control the device from across the room, rather than having to manually change it with the device in their hands.Finally, I think that a more advanced sound system could be implemented into the output channel. This would allow more advanced systems such as surround sound to be implemented into the device, but this would also require more circuitry to get it to work.

45

Page 46: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

46

Page 47: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

47

Page 48: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

I was not happy with how my presentation went. Unfortunately the morning of the presentation I opened the file and was presented with an error stating the text within the file was not indexed, whatever that means. This meant I had to put together a new presentation the same morning causing a rushed approach and imminent reduced clarity in my explanation of my design. From my point of view, as the presenter, I didn’t find a comfortable groove, which usually comes naturally when I do presentations. I believe that this was entirely down to my lack of preparation because of having to produce and prepare speech for a new presentation within a couple of hours.That being said, I do feel I got the majority of the information I needed across, to explain how my circuitry worked.I found it surprising how quickly the 15 minutes went once I got underway. I think I spent closer to 20-25 minutes including the demonstration. A point I emphasised on during the presentation was that I received help during the creation of the software. Dave Bethell has helped two more people this year as well as a relatively large number of people throughout previous years of their apprenticeship and University programmes. I am very grateful for the time and effort he has given to me to aid me when things were unclear. And although he pointed me in the right direction on more than one occasion all the code was written by myself, which is something others cannot say. On that note, Dave complimented me on being the most committed person he has ever taught, which is very pleasing to hear.I spent the entire weekend before the presentation turning my neatly constructed and fully functioning prototype board into a working circuit on strip-board. This took me around 20 hours out of the 48 hour weekend, and was a phenomenal achievement considering the resources available to me. The plan was to then implement this into my door wedge shaped box ready for the presentation so that I could hand it in afterwards. However I was suffering from a lot of noise on the output of the circuit, which was not acceptable. I ended up spending all of Monday morning trying to locate errors with the circuit, of which there was only one...a track break on the left audio input meant that there was a short between that input and part of the op-amp output. By simply cutting the track I managed to remove all of the noise completely, but had compromised being able to get my circuit into the box. I have agreed to install the circuit into the box and hand it in with the project report in two weeks time.A printout of my presentation, presented on the 24th May 2011, can be found in Appendix xiii at the back of this report.

ConclusionTo conclude, I feel this report, although expansive, is completely relevant to the criteria set out in the Project and Design Report Assignments.Due to the size of my project, I felt that it was necessary to break it down into sections and then explain my way through each. This allowed me to cover everything that was relevant to express my understanding of the circuit and detail ways in which it could be made better in the future. Finally, if you have made it to this point in the report you deserve a cup of tea.

48

Page 49: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bibliography

Through guidance from my lecturer, the following text books, catalogues, software and websites I was able to complete this report:

Books

Higher National Engineering Second Edition By Mike Tooley & Lloyd DingleISBN: 978-0-7506-6177-5

Catalogues

N/A

Software

1. Proteus’ ISIS 7 Professional ECAD Package2. Proteus’ ARES 7 Professional ECAD Package3. MPLAB IDE v8.434. Pro/DESKTOP 2000i25. Microsoft Office Word 20036. Microsoft Office PowerPoint 20037. Microsoft Office Excel 20038. Microsoft Office Project 20039. Microsoft Paint

Websites

1. http://en.wikipedia.org/wiki/TRS_connector 2. http://sound.westhost.com/project94.htm 3. http://www.electro-tech-online.com/general-electronics-chat/85965-

relays-analog-switch-ics-better-audio-switching.html4. http://www.cplusplus.com/doc/tutorial/introduction/ 5. http://www.farnell.com/datasheets/36610.pdf 6. http://www.murata-ps.com/data/power/ncl/kdc_nmr.pdf 7. http://www.txc.com.tw/download/products/c/9B-2008-P03.pdf 8. http://www.farnell.com/datasheets/60451.pdf 9. http://www.farnell.com/datasheets/26302.pdf 10.http://www.farnell.com/datasheets/66186.pdf 11.http://www.farnell.com/datasheets/78152.pdf 12.http://www.farnell.com/datasheets/12247.pdf 13.http://www.farnell.com/datasheets/66206.pdf 14.http://www.farnell.com/datasheets/11742.pdf 15.http://www.farnell.com/datasheets/50929.pdf 16.http://www.farnell.com/datasheets/41012.pdf 17.http://www.farnell.com/datasheets/494357.pdf 18.http://www.farnell.com/cad/358250.pdf 19.http://www.farnell.com/datasheets/11802.pdf

49

Page 50: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix i

Project Plan

50

Page 51: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix ii

Menu Selection Test Procedure

51

Page 52: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Menu Selection Test Procedure

OperationNumber

Requirement Outcome

1 Check ALL equipment for signs of damage.

2Connect the 9V, 2A (18 Watts) Power Supply Unit to the 2.5mm Socket.

3Ensure the Display Backlight is illuminated with a bright Blue colour.

4

Check the Display contents for accuracy, it should read:

5 Confirm that the Write Cursor is NOT flashing.

6Wait approximately 5 seconds for the Display to clear and create new text.

7

Check the Display contents for accuracy, it should read:

8Press and release the UP, DOWN and BACK Buttons to ensure there is no response.

HNC YEAR 2 PROJECTAUDIO SELECTOR

BYBRENDAN BURR

PLEASE SELECTA CHANNEL:

ENTER <

52

Page 53: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

9Now press and release the ENTER Button, ensuring the Display has been cleared and new text created.

10

Check the Display contents for accuracy, it should read:

11Press and release the BACK Button to ensure there is no response.

12

Press and release the DOWN Button once, whilst checking the Display moves the Cursor one line down, also ensuring the previous Cursor has been removed.

13 Repeat Op-12 once.

14Repeat Op-12 once more, ensuring the Cursor has returned to its starting position on line 1, in accordance with Op-10 image.

CHANNEL 1: <CHANNEL 2:CHANNEL 3:CHANNEL 4:

CHANNEL 1:CHANNEL 2: <CHANNEL 3:CHANNEL 4:

53

Page 54: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

15

With the Cursor situated on “CHANNEL 4:”, press and release the UP Button once, whilst checking the Display Moves the Cursor one line up, also ensuring the previous Cursor has been removed.

16 Repeat Op-15 once.

17Repeat Op-15 once more, ensuring the Cursor has returned to its starting position on line 4.

18With the Cursor situated on “CHANNEL 1:”, press and release the ENTER Button, ensuring the Display has been cleared and new text created.

19

Check the Display contents for accuracy, it should read:

(Note: The actual Display should illustrate incrementing bars, rather than underscores as illustrated above.)

CHANNEL 1:CHANNEL 2:CHANNEL 3: <CHANNEL 4:

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + <TREBLE :- _ + BASS :- _ +

54

Page 55: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

20

Press and release the DOWN Button once, whilst checking the Display moves the Cursor one line down, also ensuring the previous Cursor has been removed.

21 Repeat Op-20 once.

22Repeat Op-20 once more, ensuring the Cursor has returned to its starting position on line 2, in accordance with Op-19 image.

23

With the Cursor situated on “BASS:”, press and release the UP Button once, whilst checking the Display Moves the Cursor one line up, also ensuring the previous Cursor has been removed.

24 Repeat Op-23 once.

25Repeat Op-23 once more, ensuring the Cursor has returned to its starting position on line 4.

26With the Cursor situated on “VOLUME:”, press and release the ENTER Button, ensuring the Cursor has inverted in colour.

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ + <BASS :- _ +

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ + <BASS :- _ +

55

Page 56: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

27Press and release the ENTER Button again to ensure there is no response.

28

Press and release the DOWN Button once, whilst checking the Display removes ONE Bar only, also ensuring the previous bar has been removed.

29

Repeat Op-28 three times ensuring each cycle only removes one bar.

30 Check that the DOWN Button is now in-operable.

31

Press and release the UP Button once, whilst checking the Display adds ONE Bar only, also ensuring the previous bars remain.

CHANNEL 1 MENUVOLUME:- _ _ _ _ + <TREBLE :- _ + BASS :- _ +

CHANNEL 1 MENUVOLUME:- _ + <TREBLE :- _ + BASS :- _ +

CHANNEL 1 MENUVOLUME:- _ _ + <TREBLE :- _ + BASS :- _ +

56

Page 57: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

32

Repeat Op-31 seven times ensuring each cycle only adds one bar.

33 Check that the UP Button is now in-operable.

34 Repeat Operations 28-33 as desired.

35Once the Volume Level has been set for Channel 1, press and release the BACK Button, ensuring the Cursor has inverted in colour.

36With the Cursor situated on “TREBLE:”, press and release the ENTER Button, ensuring the Cursor has inverted in colour.

37

Press and release the DOWN Button once, whilst checking the Display adds ONE Bar only, also ensuring the previous bars remain.

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ _ _ _ _+ <TREBLE :- _ + BASS :- _ +

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ _ + <BASS :- _ +

57

Page 58: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

38

Repeat Op-37 three times ensuring each cycle only adds one bar.

39 Check that the DOWN Button is now in-operable.

40

Press and release the UP Button once, whilst checking the Display removes ONE Bar only, also ensuring the previous bars remain.

41

Repeat Op-40 three times ensuring each cycle only removes one bar.

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ _ _ _ _ + <BASS :- _ +

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ _ _ _ + <BASS :- _ +

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ + <BASS :- _ +

58

Page 59: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

42

Press and release the UP Button once, whilst checking the Display adds ONE Bar only, also ensuring the previous bars remain.

43

Repeat Op-42 three times ensuring each cycle only adds one bar.

44 Check that the UP Button is now in-operable.

45 Repeat Operations 37-43 as desired.

46Once the Treble Level has been set for Channel 1, press and release the BACK Button, ensuring the Cursor has inverted in colour.

47With the Cursor situated on “BASS:”, press and release the ENTER Button, ensuring the Cursor has inverted in colour.

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ _ + <BASS :- _ +

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ _ _ _ _+ <BASS :- _ +

59

Page 60: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

48

Press and release the DOWN Button once, whilst checking the Display adds ONE Bar only, also ensuring the previous bars remain.

49

Repeat Op-48 three times ensuring each cycle only adds one bar.

50 Check that the DOWN Button is now in-operable.

51

Press and release the UP Button once, whilst checking the Display removes ONE Bar only, also ensuring the previous bars remain.

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ + BASS :- _ _ + <

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ + BASS :- _ _ _ _ _ + <

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ + BASS :- _ _ _ _ + <

60

Page 61: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

52

Repeat Op-40 three times ensuring each cycle only removes one bar.

53

Press and release the UP Button once, whilst checking the Display adds ONE Bar only, also ensuring the previous bars remain.

54

Repeat Op-53 three times ensuring each cycle only adds one bar.

55 Check that the UP Button is now in-operable.

56 Repeat Operations 48-54 as desired.

57Once the Bass Level has been set for Channel 1, press and release the BACK Button, ensuring the Cursor has inverted in colour.

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ + BASS :- _ + <

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ + BASS :- _ _ + <

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + TREBLE :- _ + BASS :- _ _ _ _ _+ <

61

Page 62: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

58

Take note of the Channel Setup.

VOLUME: -_ _ _ _ _ _ _ _ _ +TREBLE : -_ _ _ _ _ _ _ _ _ +BASS : -_ _ _ _ _ _ _ _ _ +

59Press and release the BACK Button, ensuring the Display has been cleared and new text created.

60

Check the Display contents for accuracy, it should read:

61 Repeat Operations 18-61.

62

Take note of the Channel 2 Setup.

VOLUME: -_ _ _ _ _ _ _ _ _ +TREBLE : -_ _ _ _ _ _ _ _ _ +BASS : -_ _ _ _ _ _ _ _ _ +

63

Take note of the Channel 3 Setup.

VOLUME: -_ _ _ _ _ _ _ _ _ +TREBLE : -_ _ _ _ _ _ _ _ _ +BASS : -_ _ _ _ _ _ _ _ _ +

64

Take note of the Channel 4 Setup.

VOLUME: -_ _ _ _ _ _ _ _ _ +TREBLE : -_ _ _ _ _ _ _ _ _ +BASS : -_ _ _ _ _ _ _ _ _ +

65When entering the Channel Menus again, the users’ configurations should remain unchanged.

66

CHANNEL 1: <CHANNEL 2:CHANNEL 3:CHANNEL 4:

62

Page 63: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Press and release the RESET Button to clear all configurations, rebooting the system to display Op-4 image.

67Disconnect the 9V, 2A (18 Watts) Power Supply Unit from the 2.5mm Socket.

68Store all equipment in an area free from Electro-Static sources.

63

Page 64: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix iii

Audio Test Procedure

64

Page 65: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Audio Test Procedure

OperationNumber

Requirement Outcome

1 Check ALL equipment for signs of damage.

2Connect Primary Audio Device to Channel 1, using one of the Black 7m, 3.5mm Stereo Cables.

3Connect Secondary Audio Device to Channel 2, using one of the Black 7m, 3.5mm Stereo Cables.

4Connect Tertiary Audio Device to Channel 3, using one of the Black 7m, 3.5mm Stereo Cables.

5Connect Quaternary Audio Device to Channel 4, using one of the Black 7m, 3.5mm Stereo Cables.

6Connect Wireless Transmitter to the 3.5mm Stereo Output.

7Connect the 9V, 2A (18 Watts) Power Supply Unit to the 2.5mm Socket.

8Ensure the Display Backlight is illuminated with a bright Blue colour.

9

Check the Display contents for accuracy, it should read:

Also check that there is sound coming from the output and that it is representative of the Primary Audio Device.

HNC YEAR 2 PROJECTAUDIO SELECTOR

BYBRENDAN BURR

65

Page 66: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

10Wait approximately 5 seconds for the Display to clear and create new text.

11Check that the LED above the Channel 1 Input is illuminated, and that no other LED’s are illuminated.

12

Check the Display contents for accuracy, it should read:

13Now press and release the ENTER Button, ensuring the Display has been cleared and new text created.

14

Check the Display contents for accuracy, it should read:

15With the Cursor situated on “CHANNEL 1:”, press and release the ENTER Button, ensuring the Display has been cleared and new text created.

PLEASE SELECTA CHANNEL:

ENTER <

CHANNEL 1: <CHANNEL 2:CHANNEL 3:CHANNEL 4:

66

Page 67: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

16

Check the Display contents for accuracy, it should read:

(Note: The actual Display should illustrate incrementing bars, rather than underscores as illustrated above.)

17 Set the Volume, Treble and Bass as desired.

18Notice an audible difference in the selected audio device, in relation to the setting being changed.

19

Once the Volume, Treble and Bass Levels have been set for Channel 1, press and release the BACK Button, ensuring the Cursor has inverted in colour.

20

Check the Display contents for accuracy, it should read:

21

Enter into Channel 2 Menu and check that the LED above the Channel 2 Input is illuminated, and that no other LED’s are illuminated. Also notice that the audio output has switched to the Secondary Audio Device.

CHANNEL 1 MENUVOLUME:- _ _ _ _ _ + <TREBLE :- _ + BASS :- _ +

CHANNEL 1: <CHANNEL 2:CHANNEL 3:CHANNEL 4:

67

Page 68: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

22Repeat Operations 15-20 to set the Volume, Treble and Bass Levels for the Secondary, Tertiary and Quaternary Audio Devices.

23Check that there is no interference between the selected audio device and the other devices connected but switched off.

24Press and release the RESET Button to clear all configurations, rebooting the system to display Op-9 image.

25Disconnect the 9V, 2A (18 Watts) Power Supply Unit from the 2.5mm Socket.

26Disconnect the Primary Audio Device from Channel 1.

27Disconnect the Secondary Audio Device from Channel 2.

28Disconnect the Tertiary Audio Device from Channel 3.

29Disconnect the Quaternary Audio Device from Channel 4.

30Disconnect the Wireless Transmitter from the 3.5mm Stereo Output.

31Store all equipment in an area free from Electro-Static sources.

68

Page 69: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix iv

Emulated Menu Selection Test

69

Page 70: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

70

Page 71: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

71

Page 72: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

72

Page 73: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

73

Page 74: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

74

Page 75: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

75

Page 76: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

76

Page 77: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

77

Page 78: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

78

Page 79: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

79

Page 80: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

80

Page 81: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

81

Page 82: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

82

Page 83: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

83

Page 84: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

84

Page 85: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix v

Emulated & Real Bode Plots

85

Page 86: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bass Pot set at 0%

Frequency (Hz) Decibel Characteristic10 -15.6 Attenuation

100 -14.5 Attenuation1,000 -5.95 Attenuation10,000 0 N/A

100,000 0 N/A

86

Page 87: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bass Pot set at 13%

Frequency (Hz) Decibel Characteristic10 -10.6 Attenuation

100 -9.74 Attenuation1,000 -4.59 Attenuation10,000 0 N/A

100,000 0 N/A

87

Page 88: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bass Pot set at 25%

Frequency (Hz) Decibel Characteristic10 -7.03 Attenuation

100 -6.24 Attenuation1,000 -3.18 Attenuation10,000 0 N/A

100,000 0 N/A

88

Page 89: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bass Pot set at 38%

Frequency (Hz) Decibel Characteristic10 -3.66 Attenuation

100 -2.9 Attenuation1,000 -1.55 Attenuation10,000 0 N/A

100,000 0 N/A

89

Page 90: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bass Pot set at 50%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 0 N/A

100,000 0 N/A

90

Page 91: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bass Pot set at 63%

Frequency (Hz) Decibel Characteristic10 2.44 Gain

100 3.13 Gain1,000 1.67 Gain10,000 0 N/A

100,000 0 N/A

91

Page 92: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bass Pot set at 75%

Frequency (Hz) Decibel Characteristic10 5.56 Gain

100 6.22 Gain1,000 3.17 Gain10,000 -0.1 Attenuation

100,000 0 N/A

92

Page 93: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bass Pot set at 88%

Frequency (Hz) Decibel Characteristic10 9.46 Gain

100 10 Gain1,000 4.7 Gain10,000 -0.1 Attenuation

100,000 0 N/A

93

Page 94: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Bass Pot set at 100%

Frequency (Hz) Decibel Characteristic10 14.1 Gain

100 14.5 Gain1,000 5.95 Gain10,000 -0.1 Attenuation

100,000 0 N/A

94

Page 95: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Treble Pot set at 0%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 -1.79 Attenuation

100,000 -13.5 Attenuation

95

Page 96: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Treble Pot set at 13%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 -1.49 Attenuation

100,000 -8.28 Attenuation

96

Page 97: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Treble Pot set at 25%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 -1.07 Attenuation

100,000 -5.03 Attenuation

97

Page 98: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Treble Pot set at 38%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 -0.5 Attenuation

100,000 -2.28 Attenuation

98

Page 99: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Treble Pot set at 50%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 0 N/A

100,000 0 N/A

99

Page 100: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Treble Pot set at 63%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 0.5 Gain

100,000 2.45 Gain

100

Page 101: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Treble Pot set at 75%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 1.07 Gain

100,000 5.03 Gain

101

Page 102: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Treble Pot set at 88%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 1.52 Gain

100,000 8.7 Gain

102

Page 103: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Treble Pot set at 100%

Frequency (Hz) Decibel Characteristic10 -0.7 Attenuation

100 0 N/A1,000 0 N/A10,000 1.79 Gain

100,000 14 Gain

103

Page 104: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix vi

Audio Selector Wiring & Stripboard Diagrams

104

Page 105: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix vii

Case CAD Rendering

105

Page 106: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix viii

Test Images

106

Page 107: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Prototype Boards

107

Page 108: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Control and Voltage Circuits

108

Page 109: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Channel 1 Board

109

Page 110: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Push Buttons

110

Page 111: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Display & Input/Output Mountings

111

Page 112: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Input/Output Ports

112

Page 113: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Push Buttons & Display

113

Page 114: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Complete Unit

114

Page 115: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Splash Screen

115

Page 116: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

First Screen

116

Page 117: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Channel Select Menu

117

Page 118: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Channel 1 Menu

118

Page 119: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Inverted Cursor

119

Page 120: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Channel 1 LED

120

Page 121: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Channel 2 LED

121

Page 122: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix ix

Full Costing Breakdown

122

Page 123: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

123

Page 124: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix x

Completed Software Code

124

Page 125: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.c/***************************************************************************** * * Audio Selector v1.00. * *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * FileName: Main.c * Dependencies: See 'includes' below. * Processor: PIC18F4550 * Compiler: MCC18 * Linker: MPLAB * * Version Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * 1.00 Brendan Burr APR '11 First writing. * *****************************************************************************/#include <p18cxxx.h>#include <delays.h>#include "xlcd.h"#include "config.h"#include <spi.h>// PIC Configuration bits#pragma config PLLDIV = 5 // (20 MHz crystal on PICDEM FS USB board)#pragma config CPUDIV = OSC1_PLL2#pragma config USBDIV = 2 // Clock source from 96MHz PLL/2#pragma config FOSC = HSPLL_HS#pragma config FCMEN = OFF#pragma config IESO = OFF#pragma config PWRT = OFF#pragma config BOR = ON#pragma config BORV = 3#pragma config VREGEN = ON //USB Voltage Regulator#pragma config WDT = OFF#pragma config WDTPS = 32768#pragma config MCLRE = ON#pragma config LPT1OSC = OFF#pragma config PBADEN = OFF#pragma config CCP2MX = ON#pragma config STVREN = ON#pragma config LVP = OFF#pragma config ICPRT = OFF // Dedicated In-Circuit Debug/Programming

125

Page 126: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

#pragma config XINST = OFF // Extended Instruction Set#pragma config CP0 = OFF#pragma config CP1 = OFF#pragma config CP2 = OFF#pragma config CP3 = OFF#pragma config CPB = OFF#pragma config CPD = OFF#pragma config WRT0 = OFF#pragma config WRT1 = OFF#pragma config WRT2 = OFF#pragma config WRT3 = OFF#pragma config WRTB = ON // Boot Block Write Protection#pragma config WRTC = OFF#pragma config WRTD = OFF#pragma config EBTR0 = OFF#pragma config EBTR1 = OFF#pragma config EBTR2 = OFF#pragma config EBTR3 = OFF#pragma config EBTRB = OFF// Prototypes:void SplashScreen(void);void StartUpScreen(void);void ChannelSelectMenu(void);void ScreenText(char position, const rom char *text);void TestButtons(void);void MenuCursor(char start,char end);void ChanSelect(char channel);void UpdateParameter(char param, char ch_sel);// Delay routines for LCD:// Delay for 18 clock cycles (used by xlcd)void DelayFor18TCY(void)1F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.c{ Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop();

126

Page 127: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Nop(); Nop();}// Delay for Power-on reset (used by xlcd)void DelayPORXLCD (void){Delay1KTCYx(75); // Delay of 15ms // Cycles = (TimeDelay * Fosc) / 4 // Cycles = (15ms * 20 MHz) / 4 // Cycles = 75,000 return;}// Delay for 5ms (used by xlcd)void DelayXLCD (void){Delay1KTCYx(25); // Delay of 5 ms // Cycles = (TimeDelay * Fosc) / 4 // Cycles = (5ms * 20MHz) /4 // Cycles = 25,000 return;} // End of DelayXLCD// Defines:#define CH1SPI_CS LATCbits.LATC0#define CH2SPI_CS LATCbits.LATC1#define CH3SPI_CS LATCbits.LATC2#define CH4SPI_CS LATCbits.LATC6#define UP_BUTTON !PORTBbits.RB2#define DN_BUTTON !PORTBbits.RB3#define EN_BUTTON !PORTBbits.RB4#define BK_BUTTON !PORTBbits.RB5#define NONE 0#define UP 1#define DOWN 2#define ENTER 3#define BACK 4// Variables:char switchstat = 0;char update = 0;char cursor = 0;char selection = 0;char volume [4];char treble [4];char bass [4];char vol_glyphs[9] = {0x5F, 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0xFF};char ton_glyphs[9] = {0xFF, 0x06, 0x05, 0x03, 0x5F, 0x03, 0x05, 0x06, 0xFF};/***************************************************************************** * Name: main *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

127

Page 128: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

* * Dependencies: None. * Output: None. * Description: Main routine containing initialisation commands, LCD setup2F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.c * commands, splash-screen code and main 'while' loop. * *****************************************************************************/void main(void){// Variable used for delay counting etc..char i;// Configuring ports...TRISB = 0x3C;LATB = 0x00;TRISCbits.TRISC0 = 0;TRISCbits.TRISC1 = 0;TRISCbits.TRISC2 = 0;TRISCbits.TRISC6 = 0;TRISD = 0x00;LATD = 0x00;// Set-up display for use...OpenXLCD(FOUR_BIT & LINES_5X7);DelayXLCD();// In Debug mode let's see the cursor...#ifdef __DEBUGWriteCmdXLCD(DON & CURSOR_ON & BLINK_ON);DelayXLCD();#endif// Display welcome screen...SplashScreen();// Load the LCD RAM with user glyphs...SetCGRamAddr(0x08);DelayXLCD();putsXLCD(LCDGlyphs);DelayXLCD();// Setup initial levels for vol, treb & bass...for (i=0; i<4; i++){volume[i] = 1;treble[i] = 2;bass[i] = 4;}// Delay for 5 seconds// set i<24 for real code// set i<2 for simulation#ifdef __DEBUGfor(i=0; i<2; i++){

128

Page 129: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Delay10KTCYx(255);}#elsefor(i=0; i<24; i++){Delay10KTCYx(255);}#endif// Clear the LCD Screen...WriteCmdXLCD(0x01);DelayXLCD();// Display select channel menu...StartUpScreen();// Loop until ENTER Button is pressed...doTestButtons();while(switchstat != ENTER);// Loop until doomsday...while(1){ChannelSelectMenu();3F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.cChanSelect(selection);}} // End of main/***************************************************************************** * Name: SplashScreen *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Dependencies: None. * Output: None. * Description: Displays information about the project and its creator on * the LCD. * *****************************************************************************/void SplashScreen(void){ScreenText(0x01,"HNC YEAR 2 PROJECT");ScreenText(0x43,"AUDIO SELECTOR");ScreenText(0x1D,"BY");ScreenText(0x58,"BRENDAN BURR");} // End of SplashScreen/***************************************************************************** * Name: StartUpScreen *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

129

Page 130: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

* * Dependencies: None. * Output: None. * Description: Gives instructions and asks the user to press 'Enter'. * *****************************************************************************/void StartUpScreen(void){ScreenText(0x00,"PLEASE SELECT");ScreenText(0x40,"A CHANNEL:");ScreenText(0x61,"ENTER");ScreenText(0x67,"<");} // End of StartUpScreen/***************************************************************************** * Name: ChannelSelectMenu *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Dependencies: None. * Output: None. * Description: Shows the channel selection menu and provides the calls to * subroutines to test the buttons and update the cursor * position. * *****************************************************************************/void ChannelSelectMenu(void){// Clear the LCD Screen...WriteCmdXLCD(0x01);DelayXLCD();// Write menu text...ScreenText(0x00,"CHANNEL 1:");ScreenText(0x40,"CHANNEL 2:");ScreenText(0x14,"CHANNEL 3:");ScreenText(0x54,"CHANNEL 4:");// Set update true so cursor is displayed...update = 1;cursor = 0;// Loop until ENTER is pressed...do{TestButtons();if (update){// Move the cursor...MenuCursor(0,3);}4F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.c

130

Page 131: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

}while (switchstat != ENTER);} // End of ChannelSelectMenu/***************************************************************************** * Name: ScreenText *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Dependencies: char position - location on LCD in Hex format (0xnn). * const rom char *text - pointer to text to be written at * location. * Output: None. * Description: Writes text to a given location on the display. * *****************************************************************************/void ScreenText(char position, const rom char *text){SetDDRamAddr(position);DelayXLCD();putrsXLCD(text);DelayXLCD();} // End of ScreenText/***************************************************************************** * Name: TestButtons *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Dependencies: None. * Output: switchstat, update. * Description: Tests the push-buttons and returns the button pressed via * switchstat. If UP or DOWN is pressed, update is also set * true. * *****************************************************************************/void TestButtons(void){switchstat = NONE;if(UP_BUTTON){switchstat = UP;update = 1;while(UP_BUTTON);return;}else if(DN_BUTTON){switchstat = DOWN;update = 1;while(DN_BUTTON);return;

131

Page 132: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

}else if(EN_BUTTON){switchstat = ENTER;while(EN_BUTTON);return;}else if(BK_BUTTON){switchstat = BACK;while(BK_BUTTON);return;}} // End of TestButtons/***************************************************************************** * Name: MenuCursor *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Dependencies: char start - start position (0-3). * char end - end position (1-3). * Output: selection. * Description: Moves the cursor in the right-most column of the display * using start and end as limiting values. E.g. if start = 1 * and end = 3, the cursor will only move in the lower three * lines of the display.5F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.c * *****************************************************************************/void MenuCursor(char start,char end){switch (switchstat){case UP:cursor--;if (cursor < start)cursor = end;update = 1;break;case DOWN:cursor++;if (cursor > end)cursor = start;update = 1;break;default:break;}

132

Page 133: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

if (update){switch (cursor){case 0:ScreenText(0x13,"<");ScreenText(0x53," ");ScreenText(0x27," ");ScreenText(0x67," ");break;case 1:ScreenText(0x13," ");ScreenText(0x53,"<");ScreenText(0x27," ");ScreenText(0x67," ");break;case 2:ScreenText(0x13," ");ScreenText(0x53," ");ScreenText(0x27,"<");ScreenText(0x67," ");break;case 3:ScreenText(0x13," ");ScreenText(0x53," ");ScreenText(0x27," ");ScreenText(0x67,"<");break;default:break;}selection = cursor;update = 0;}} // End of MenuCursor/***************************************************************************** * Name: ChanSelect *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Dependencies: char channel - channel for which information is to be * displayed. * Output: None. * Description: Displays the current settings for channel and allows user * to adjust values. * *****************************************************************************/void ChanSelect(char channel){char i;

133

Page 134: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

// Clear the LCD Screen...6F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.cWriteCmdXLCD(0x01);DelayXLCD();// Write menu information...ScreenText(0x03,"CHANNEL ");WriteDataXLCD(channel + 0x31);DelayXLCD();ScreenText(0x0D,"MENU");ScreenText(0x40,"VOLUME:-");ScreenText(0x51,"+");ScreenText(0x14,"TREBLE:-");ScreenText(0x25,"+");ScreenText(0x54,"BASS :-");ScreenText(0x65,"+");// Display initial volume setting...SetDDRamAddr(0x48);DelayXLCD();for (i=0; i<(volume[channel]+1); i++){WriteDataXLCD(vol_glyphs[i]);DelayXLCD();}// Display initial treble setting...if (treble[channel]>3){SetDDRamAddr(0x20);DelayXLCD();for (i=4; i<(treble[channel]+1); i++){WriteDataXLCD(ton_glyphs[i]);DelayXLCD();}}else if (treble[channel]<4){SetDDRamAddr(0x1C+treble[channel]);DelayXLCD();for (i=treble[channel]; i<5; i++){WriteDataXLCD(ton_glyphs[i]);DelayXLCD();}}// Display initial bass setting...if (bass[channel]>3){SetDDRamAddr(0x60);DelayXLCD();

134

Page 135: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

for (i=4; i<(bass[channel]+1); i++){WriteDataXLCD(ton_glyphs[i]);DelayXLCD();}}else if (bass[channel]<4){SetDDRamAddr(0x5C+bass[channel]);DelayXLCD();for (i=bass[channel]; i<5; i++){WriteDataXLCD(ton_glyphs[i]);DelayXLCD();}}// Set update true so cursor is displayed...update = 1;cursor = 1;// Loop until BACK is pressed...do{TestButtons();7F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.cif (update){// Move the cursor...MenuCursor(1,3);}if (switchstat == ENTER)UpdateParameter(cursor, channel);}while (switchstat != BACK);} // End of ChanSelect/***************************************************************************** * Name: UpdateParameter *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Dependencies: char param - parameter to adjust (Volume, Treble or Bass). * char ch_sel - selected channel (1 - 4). * Output: volume[n], treble[n] and bass[n]. * Description: Provides indication of parameter being adjusted and allows * user to select/listen to adjustment. * *****************************************************************************/void UpdateParameter(char param, char ch_sel){

135

Page 136: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

char i;switch (param){case 1: // VolumeSetDDRamAddr(0x53);DelayXLCD();WriteDataXLCD(0x01);DelayXLCD();do{TestButtons();if (update){if (switchstat == UP){volume[ch_sel]++;if (volume[ch_sel]>8)volume[ch_sel]=8;else{// update the displaySetDDRamAddr(0x48 + volume[ch_sel]);DelayXLCD();WriteDataXLCD(vol_glyphs[volume[ch_sel]]);DelayXLCD();}}else if (switchstat == DOWN){volume[ch_sel]--;if (volume[ch_sel]<0)volume[ch_sel]=0;else{// update the displaySetDDRamAddr(0x48 + volume[ch_sel] + 1);DelayXLCD();putrsXLCD(" ");DelayXLCD();}}// update bus here.update = 0;}}while (switchstat != BACK);break;case 2: // TrebleSetDDRamAddr(0x27);DelayXLCD();WriteDataXLCD(0x01);DelayXLCD();

136

Page 137: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

8F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.cdo{TestButtons();if (update){if (switchstat == UP){treble[ch_sel]++;if (treble[ch_sel]>8)treble[ch_sel]=8;else{// update the displayif (treble[ch_sel]<5){SetDDRamAddr(0x1C + (treble[ch_sel] - 1));DelayXLCD();putrsXLCD(" ");DelayXLCD();}else{SetDDRamAddr(0x1C + treble[ch_sel]);DelayXLCD();WriteDataXLCD(ton_glyphs[treble[ch_sel]]);DelayXLCD();}}}else if (switchstat == DOWN){treble[ch_sel]--;if (treble[ch_sel]<0)treble[ch_sel]=0;else{// update the displayif (treble[ch_sel]<4){SetDDRamAddr(0x1C + treble[ch_sel]);DelayXLCD();WriteDataXLCD(ton_glyphs[treble[ch_sel]]);DelayXLCD();}else{SetDDRamAddr(0x1C + (treble[ch_sel] + 1));DelayXLCD();

137

Page 138: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

putrsXLCD(" ");DelayXLCD();}}}// update bus here.update = 0;}}while (switchstat != BACK);break;case 3: // BassSetDDRamAddr(0x67);DelayXLCD();WriteDataXLCD(0x01);DelayXLCD();do{TestButtons();if (update){if (switchstat == UP){bass[ch_sel]++;if (bass[ch_sel]>8)bass[ch_sel]=8;else{9F:\AgustaWestland\BTEC HNC\Year 2\Engineering Project\ASSY 2 - Implement Project\main REAL.c// update the displayif (bass[ch_sel]<5){SetDDRamAddr(0x5C + (bass[ch_sel] - 1));DelayXLCD();putrsXLCD(" ");DelayXLCD();}else{SetDDRamAddr(0x5C + bass[ch_sel]);DelayXLCD();WriteDataXLCD(ton_glyphs[bass[ch_sel]]);DelayXLCD();}}}else if (switchstat == DOWN){bass[ch_sel]--;if (bass[ch_sel]<0)

138

Page 139: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

bass[ch_sel]=0;else{// update the displayif (bass[ch_sel]<4){SetDDRamAddr(0x5C + bass[ch_sel]);DelayXLCD();WriteDataXLCD(ton_glyphs[bass[ch_sel]]);DelayXLCD();}else{SetDDRamAddr(0x5C + (bass[ch_sel] + 1));DelayXLCD();putrsXLCD(" ");DelayXLCD();}}}// update bus here.update = 0;}}while (switchstat != BACK);break;default:break;}update = 1;switchstat = NONE;} // End of UpdateParameter10

139

Page 140: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix xi

Manufacturers Datasheets

140

Page 141: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix xii

Internet Research

141

Page 142: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

Appendix xiii

Presentation

142

Page 143: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

143

Page 144: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

144

Page 145: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

145

Page 146: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

146

Page 147: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

147

Page 148: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

148

Page 149: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

149

Page 150: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

150

Page 151: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

151

Page 152: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

152

Page 153: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

153

Page 154: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

154

Page 155: BTEC HNC - Engineering Project - All

Brendan Burr BTEC Higher National Certificate in ElectronicsEngineering Design

155