Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part II: The voltage divider can be used to allow multiple pushbuttons to share a single analog input pin on a microcontroller. The key is

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Part II: The voltage divider can be used to allow multiple pushbuttons to share a single analog input pin on a microcontroller. The key is having enough of a \"band\" around each voltage point to reduce the possibility of misinterpreting which switch was actually pressed (see figure below). V No SW DC Band for no SW For example, any voltage within the SW4 band Band around SW5 should be interpreted as switch SW4 being pressed. ""F'lYJ Ideally, the bands should be roughly equal in size, though the bands at either end tend to be smaller. This is usually okay since a direct connection to either ground (when S W1 is pressed) or VDC (when Band around 5W3 no switch is pressed) presents a strong and unambiguous voltage. Band around SW4 LTLY_L"T"' SW2 Band around S W2 Band around S W1 SW1 0 The task is to choose a \"reasonable\" set of resistor values so that the bands are as optimized as possible. An alternative method would be to optimize the gaps between switch voltages instead, which reduces some of the computation needed2. The equations for the Vow of each switch are dependent on the resistor values. Changing one value of R can affect all of the calculated Vom, so it is not as easy to pick resistors as you may think. Creating a program to help you try out different R values will make the design process quicker. For this part of the problem, your choices for R1, R2, R3, R4, and R5 are restricted to these standard 5% resistor values3: 1K, 1.2K, 1.5K, 1.8K, 2.2K, 2.7K, 3.3K, 3.9K, 4.7K, 5.6K, 6.8K, 8.2K, 10K Note that 1K is 1000 Q, 1.2K is 1200 9, etc. Each R in your design can have a different value. What you need to do: Write a Python script that: 0 Sets up the resistor values. 0 You do not need to prompt the user for the values. You are allowed to hard code the values for the R variables so you can change one at a time without having to re-enter all of the others. 0 Calculates and displays the output voltage Vow when each switch is pressed. 0 Calculates the gap voltages between each pair of switches. 0 Displays a bar plot of the gap voltages between each pair of switches. 0 Be sure to properly label and title your graph. Note: Record the script's output values, bar plot, and your nal \"best\" resistor values in the document to keep everything in one place for the grader. > Save the script using this file name: hw3_p5. py Hint: First try all the resistors having the same value and look at the results. If they are not satisfactory, then change resistors one at a time to see the effect. You can examine the equations to give you a clue about how the resistors affect the result, or you can simply do some judicious trial and error testing. In any case, your solution does NOT have to be perfect or exactly match the Instructor's sample. It just has to be reasonable, so if you wanted to use it for the project, you will already have a \"good enough\" design. Again, remember to use just the standard values previously mentioned. Note: The sample runs below assume Voc = 5 V. The results for 3.3 V will look the same, but scaled down. The actual resistor values used are NOT displayed here, so that you can discover your own set. Sample Run: For the case that all resistors have the same value ... Vout when SW1 pressed = 0.00 V Vout when SW2 pressed = 2.50 V Vout when SW3 pressed = 3. 33 V Vout when SW4 pressed = 3.75 V Vout when SW5 pressed = 4.00 V Vout when no switch pressed = 5.00 V Voltage Gap Between Pairs of Switch Voltages 2.5 If all the resistors are chosen to have the same resistance value, the 2.0 gap voltages are not uniformly S distributed, with some having a very wide gap, but others having hardly any at all. In particular, 0.5 there will be a much higher possibility of switch reading errors 0.0 1 & 2 2 & 3 3 & 4 4 & 5 5 & No for SW3, SW4, and SWs. This is a Switch Pair bad design. Sample Run: For the case that the resistors are well chosen ... Vout when SW1 pressed = 0.00 V Vout when SW2 pressed = 1.02 V Vout when SW3 pressed = 1.95 V Vout when SW4 pressed = 2.86 V Vout when SW5 pressed = 3.87 V Vout when no switch pressed = 5.00 VSample Run: For the case that the resistors are well chosen ... Vout when SW1 pressed = 0.00 V Vout when SW2 pressed = 1.02 V Vout when SW3 pressed = 1.95 V Vout when SW4 pressed = 2.86 V Vout when SW5 pressed = 3.87 V Vout when no switch pressed = 5.00 V Voltage Gap Between Pairs of Switch Voltages In this case, the chosen resistors 1.0 1 produce a decently flat distribution 0.8 of gap voltages, so that the Gap Voltage (V) 0.6 probability of switch reading errors is minimized. This is a good 0.4 enough design. 0.2 - 0.0 1 & 2 2 & 3 3 & 4 4 & 5 5 & No Switch Pair0'\" Assume each S is a momentary contact push-button switch, and that at most only one switch is pressed at a time. VDc is the voltage that powers the circuit, and V0.\" is the output voltage. From the slides about interfacing three switches to a single microcontroller GPIO pin: 51 pressed: Vout = 0 R2 r .. : V = V 82 p CSSCd out R1+R2 DC R2+R3 1' t t I V = S3 p CSSCd out R1+R2+R3 DC No switch pressed: Vout = VDC Part I: a) Write the KVL loop equation for the circuit if m switch S4 is pressed. b) Using the equation from Part (a), simplify and derive for the current I. c) Using the result from Part (b), derive the output voltage V0.\" in terms of the R values and VDC. d) Derive the output voltage V0\

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Physics by Example

Authors: W. G. Rees

1st edition

521449758, 521445140, 9780521449755, 978-0521445146

More Books

Students also viewed these Physics questions