DUE NOW Lab 9 - resistances
description
Transcript of DUE NOW Lab 9 - resistances
![Page 1: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/1.jpg)
DUE NOW
»Lab 9 - resistances
![Page 2: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/2.jpg)
Your task..
• Create a program that allows the user to enter as many individual resistance values (in Ohms) as the user wants. When the user wants to stop entering values, s/he will enter a negative or zero value. When done, tell the user the equivalent value in both series and parallel. DO NOT USE ARRAYS or material not taught. Use material taught in the lecture yesterday.
𝑅𝑒𝑞𝑢=𝑅1+𝑅2+𝑅3
𝑅𝑒𝑞𝑢=1
( 1𝑅1+ 1𝑅2
+ 1𝑅3 )
![Page 3: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/3.jpg)
The series shouldn’t even be worth any points…
• Example from the slides (last Thursday and yesterday!)
• Equation for the lab
• What repeats?
![Page 4: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/4.jpg)
That part is easy (if you practice the slides)
%surface counting %by Dr. Pembridge
clcclear % prompt for a surface (and give directions)fprintf('Note: a negative/zero surface quits.\n');surface = input('Enter surface (m2): '); sumSurfaces = 0; %start result at zero % while surface is positivewhile surface>0 % “running total”: add surfaces as they are given sumSurfaces = sumSurfaces + surface; % ask for next surface value surface = input('Next surface: ');end % display total surface to the screenfprintf('All the surfaces add up to %.4f m2.\n', sumSurfaces);
![Page 5: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/5.jpg)
That part is easy (if you practice the slides)
%resistance counting %by Caroline
clcclear % prompt for a resistance (and give directions)fprintf('Note: a negative/zero resistance quits.\n');resistance = input('Enter resistance (Ohms): '); sumResistances = 0; %start result at zero % while resistance is positivewhile resistance >0 % calculate series setup sumResistances = sumResistances + resistance ; % ask for next resistance value resistance = input('Next resistance: ');end % display total resistance to the screenfprintf('All the resistances (series) add up to %.4f Ohms.\n', sumResistances);
![Page 6: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/6.jpg)
Test as you go…
%resistance counting %by Caroline
clcclear % prompt for a resistance (and give directions)fprintf('Note: a negative/zero resistance quits.\n');resistance = input('Enter resistance (Ohms): '); sumResistances = 0; %start result at zero % while resistance is positivewhile resistance >0 % calculate series setup sumResistances = sumResistances + resistance ; % ask for next resistance value resistance = input('Next resistance: ');end % display total resistance to the screenfprintf('All the resistances (series) add up to %.4f m2.\n', sumResistances);
ugh.. I need to skip lines in the output..
![Page 7: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/7.jpg)
About the parallel..
• Don’t try to simplify the equation– the simple fact that we don’t have ALL resistance values from the start
prevents ANY simplification anyways!
• Instead, find WHAT repeats and WHAT doesn’t!
inside the loop
below the loop
![Page 8: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/8.jpg)
Implement 3 more lines…
% prompt for a resistance (and give directions)fprintf('Note: a negative/zero resistance quits.\n');resistance = input('Enter resistance (Ohms): '); sumResistances = 0; %start result at zerodenominator = 0; %start denominator at zero % while resistance is positivewhile resistance >0 % calculate series setup sumResistances = sumResistances + resistance ;
% calculate parallel setup denominator = denominator + 1/resistance;
% ask for next resistance value resistance = input('Next resistance: ');end % display both resistance equivalent to the screenfprintf(‘\nAll the resistances (series) add up to %.4f Ohms.\n', sumResistances);fprintf('and in parallel, it''ll be equivalent to %.4f Ohms.\n', 1/denominator);
![Page 9: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/9.jpg)
For those adventurous ones…• Add a little bit!
% prompt for a resistance (and give directions)fprintf('Note: a negative/zero resistance quits.\n');resistance = input('Enter first resistance (Ohms): '); sumResistances = 0; %start result at zerodenominator = 0; %start denominator at zerores_nb = 2; %start counter to display 2nd in loop..etc % while resistance is positivewhile resistance >0 % calculate series setup sumResistances = sumResistances + resistance ;
% calculate parallel setup denominator = denominator + 1/resistance;
% ask for next resistance value fprintf('Enter resistance #%d: ', res_nb); resistance = input(''); res_nb = res_nb+1; %update for next loopend % display both resistance equivalent to the screenfprintf('\nAll the resistances (series) add up to %.4f Ohms.\n', sumResistances);fprintf('and in parallel, it''ll be equivalent to %.4f Ohms.\n', 1/denominator);
![Page 10: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/10.jpg)
TEST!!!• Add a little bit!
% prompt for a resistance (and give directions)fprintf('Note: a negative/zero resistance quits.\n');resistance = input('Enter first resistance (Ohms): '); sumResistances = 0; %start result at zerodenominator = 0; %start denominator at zerores_nb = 2; %start counter to display 2nd in loop..etc % while resistance is positivewhile resistance >0 % calculate series setup sumResistances = sumResistances + resistance ;
% calculate parallel setup denominator = denominator + 1/resistance;
% ask for next resistance value fprintf('Enter resistance #%d: ', res_nb); resistance = input(''); res_nb = res_nb+1; %update for next loopend % display both resistance equivalent to the screenfprintf('\nAll the resistances (series) add up to %.4f Ohms.\n', sumResistances);fprintf('and in parallel, it''ll be equivalent to %.4f Ohms.\n', 1/denominator);
![Page 11: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/11.jpg)
A variety of engineering…
• Lab02 – Math (Do 2 lines intersect?)• Lab03/04 – Math (land purchase) & Civil (buckling)• Lab05 – Civil (buckling) & Fluids (Flow through pipe)• Lab06 – Civil/Aero (buckling & cement ratio)• Practice Exam1 – Math & Environmental (Heating House)• Exam1 – Environmental (Windmill)• Lab08 – Math (tiles)• Lab09 – Electrical (resistances)• Lab10 – Mechanical (reduction gears)
![Page 12: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/12.jpg)
Reduction gears
• reduction gear - gearing that reduces an input speed to a slower output speed.
![Page 13: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/13.jpg)
Math is rather simple…
• Some gears are “drivers”, others are “driven”
– Gears 1,3,5 are called “Drivers” since they drive the other gears. – Gears 2,4,6 are called “Driven” since they are driven by the other
gears.
• Given an input speed ( “omega” in rad/s), the output speed is:
𝜔𝑜𝑢𝑡1 3 5 2 4 6
![Page 14: DUE NOW Lab 9 - resistances](https://reader035.fdocuments.in/reader035/viewer/2022062315/5681617a550346895dd108da/html5/thumbnails/14.jpg)
Your task…
1. Prompt the user for the input angular velocity (in radians/sec). Check validity! Trap the user while invalid.
2. Prompt the user for the total number of gears. Check validity as well. The client requires more than 4 gears at all times.
3. Use a for loop to prompt for the number of teeth on each gear. Assume the user enters valid numbers of teeth at this time, and again alternates appropriately.
4. Complete calculations properly, and display the value of with 1 decimal place.5. Use an if statement to indicate in which direction the last gear rotates compared
to gear #1.
Tons of Bonus ideas possible here! Just make sure to code it in a separate file. Zip and submit and print both in that case. Use your imagination!