ET156 Introduction to C Programming Appendix B Project for This

advertisement
ET156
Introduction to C Programming
Appendix B
Project for This Course
The project is worth 15% of the total grade. Note: Use Visio to create charts and diagrams.
Goal: Develop a program that will automatically adjust a variable resistor until the maximum power is
transferred to a load resister.
Purpose: For this project, you will create a prototype of a circuit designed to transfer the maximum
power to a load. The program will receive a keyboard input representing the value of the power supply
and the size of the load resister. The program will simulate driving a motor controlled variable resistor
by incrementally changing the value of a variable resister.
Requirements:
1. Analyze the following program requirement.
• You are designing a circuit that will automatically adjust circuit resistance until the maximum
power is delivered to the load.
• The circuit consists of a programmable power supply, a variable resistor, a fixed resister, and a
programmable load resistor. Examine the schematic:
• The user will enter the value of the Programmable Power Supply and the value of the Programmable
Load. The program must automatically adjust the variable resistor R2 until the maximum power is
transferred. R2 is a 0 to 10k ohm potentiometer that is controlled by the program.
• The Programmable Power Supply has a range of 1 to 15 VDC and is accurate to .1 V increments. The
Programmable Load has a range of 100Ω to 5kΩ and is accurate to 1Ω. Values that are not within range
will damage the equipment and cannot be accepted!
• After valid values are entered, the program will automatically adjust R2 until the power delivered to
RL is at the maximum value.
• The program must output these values until the maximum power transferred:
R2 RL PR2 PRL
• When the maximum power is obtained, the following message must be provided. Maximum power
transfer to RL is XXX.X P Watts. (X numbers, P metric prefix)
1
ET156
Introduction to C Programming
Appendix B
Program requirements:
1. Programmable Power Supply
a. Valid output range is 1 to 15VDC.
b. Valid voltages are in increments of .1V.
2. Programmable Load
a. Valid values are 100Ω to 5kΩ.
b. Valid resistance increments are 1 ohm.
3. Program Input
a. The program must not allow illegal input values.
b. The program must either be tuning or waiting for new power and load values with the
following message. Input request: “New Voltage and Load: “
4. Program Output
a. The output must have the following structures.
Output: “R1+R2
RL Power Power R2
RL”
“100
1000
.008
.08”
b. The final output message must look like the following:
Maximum power transferred to RL is 99.1 m Watts.
c. Invalid inputs must have corresponding messages that advise the user to provide valid inputs.
5. Tuning Characteristics
a. Tuning must occur in 1Ω increments.
b. Maximum power is transferred in accordance with the maximum
power transfer theorem!
6. Components
a. R1 is fixed at 100 ohms.
b. R2 can vary from 0 to 5k ohms.
Deliverables, Requirements, and Timeline
Project Part 1:
1. Visit Books 24x7 in the ITT Tech Virtual Library. Read Chapter 1, Section 1 in Embedded Software:
The Works by Colin Walls. Create a Word document that answers the following questions:
o How are prototypes used when developing an embedded system?
o What are the input and output parameters of the system?
2. Brainstorm the requirement and develop a rough algorithm for YOUR project:
main
3. Sketch a structure chart for the application.
2
ET156
Introduction to C Programming
Appendix B
4. Create a project called MaxPower and add a source file called main.
a. Design and implement a simple program that will accept the desired voltage, the load, and the
value of R2 and then calculate and output I, PR1, PR2, and PRL.
Declare variables:double V, I, R2, RL, VR1, VR2, VRL, PR1, PR2, PRL;
Ask for input: printf("Enter Voltage: ");scanf("%lf", &V); add load and R2
Add Calculations:
I = V/(R1 + R2 + RL);
VR1 = I * R1;
VR2 = I * R2;
VRL = I * RL;
PR1 = I * VR1;
PR2 = I * VR2;
PRL = I * VRL;
Print output to screen:
printf("\n(R1+R2+RL)/V\tRL Power\tPower R2\tRL\n");
printf("------------\t------------\t------------\t--\n");
printf("%.4f\t\t %.4f\t\t%.4f\t\t%.4f\t\n\n\n", I, PR1, PR2, PRL);
print code when it is working, screen print prgm, turn in for a project grade.
Assigned in Unit 2
Due in Unit 3
Project Part 2:
1. Create a Word document that identifies the style guidelines you plan to use to make your code easier
to read.
2. Analyze the project requirements and create a block diagram that identifies all of the major steps for
the system.
3. Modify your project code to include a decision statement that checks to see if the inputs are valid.
a. Output a message whenever an illegal value is entered.
b. Output a message that indicates whether PR1+PR2 and PRL are equal or unequal.
Assigned in Unit 4
Due in Unit 5
Project Part 3:
1. Draw a flowchart that shows the flow of the main function of your program as it currently exists.
2. Modify your program to output a message that indicates whether PR1+PR2 is equal to PRL or PR1+PR2 is
greater than PRL or PR1+PR2 is less than PRL.
Assigned in Unit 5
Due in Unit 6
3
ET156
Introduction to C Programming
Appendix B
Project Part 4:
1. Modify the flowchart to include all of the major steps indicated in Part 2.
2. Design the detail level of your algorithm.
3. Implement your Input module per the requirement that the program is either tuning with a new
voltage and load or awaiting the selection of new values.
Assigned in Unit 6
Due in Unit 8
Project Part 5:
1. Modify the flowchart if required.
2. Continue to add detail to your algorithm.
3. Design and implement the tuning portion of the program. This will require a loop that automatically
changes the value of the variable resistor until the requirement is met.
4. Design and implement the output portion of the program.
Assigned in Unit 6
Due in Unit 8
Project Part 6:
1. Create function calls for each user input.
2. Make sure the code is working properly.
3. Print the code and print the screen shot of it running.
4. Turn in for a grade.
Assigned in Unit 8
Due in Unit 9
Project Part 7:
1. Create the pseudocode for the finished program.
2. Make sure the code is working properly.
3. Print the code and print the screen shot of it running.
4. Turn in for a grade.
Assigned in Unit 9
Due in Unit 10
4
Download