Create a program that will automatically adjust a variable resistor until the ma
ID: 667121 • Letter: C
Question
Create a program that will automatically adjust a
variable resistor until the maximum power is transferred
to the load resister. Refer to Figure 1 for details.
Create a program to find the maximum power transfer
to a load. The program should receive a keyboard input
representing the value of the power supply and the size
of the load resister. The program should then simulate
driving a motor controlled variable resistor by
incrementally changing the value of a variable resister.
A working C program file should satisfy the Project
Requirements.
A working demonstration with multiple test cases.
Explanation / Answer
#include <math.h>
#include <stdio.h>
int main(){
double motor, powerSupply, current, resistor1,resistor2, resistor2Power, motorPower, resistors1And2, maximumPower;
while ( resistor2 < 1) {
powerSupply = 16;
current = 0;
resistor2 = 10000;
motor = 0;
resistor2Power = 0;
motorPower = 0;
resistors1And2 = 0;
printf (" New Voltage and the Load: ");
resistor1 = 100;
/* Make sure the input voltage entered is within the range. If not then it will loop until an input within the range is entered*/
while (( powerSupply < 1) || (powerSupply > 15)){ // check the voltage range
printf (" Enter the value for the Power supply between 1 to 15 volts ");
scanf ("%lf", &powerSupply);
if (( powerSupply < 1) || (powerSupply > 15)){ //check if correct value for power supply is entered or not*/
printf (" %.1lf volts ", powerSupply); // display what was entered
printf ("Value for the input voltage is out of the range and may damage the equipment "); //display error message that wrong power supply is entered
}
}
/* Make sure the input load resistance value is within the range. If not then it will loop until a value within the range is entered*/
while (motor < 100 || motor > 5000){
printf (" Enter the value for the motor between 100 to 5000 ");
scanf ("%lf", &motor);
if (motor < 100 || motor > 5000){ //check if correct value for the load resistance is entered or not
printf ("%.0lf ohms ", motor); // display what was entered
printf ("Value for the input load resistance is out of the range and may damage the equipment "); //display error message that wrong value for load resistance is entered
}
}
resistor2 = motor; // entry point for the output R2
while (resistor2 >= 0){ // starting of the countdown loop
resistors1And2 = resistor1 + resistor2; //add both the resistor values together
current = powerSupply / (resistors1And2 + motor); //calculate the current for the circuit V=IR
resistor2Power = current * resistor2 * current; //I * R = volts * amps = watts
motorPower = current * motor * current;
printf ("Output: %.0f R1 and R2: %.0f RL: %.0f R2 Power: %.15lf ", resistor2, resistors1And2, motor, resistor2Power);
printf (" Motor Power: %.15lf %c", motorPower);
if (resistors1And2 == motor) { //check whether the value of total resistance and load resistance are equal
printf (" Equal "); //display equal
}
if (resistors1And2 != motor) {
printf (" Unequal "); //display unequal
}
resistor2 = resistor2 - 1; //increment the count down
}
if (motorPower > .001){
maximumPower = motorPower * 1000;
printf ("Max power transferred to RL: %f mWatts ", maximumPower);
}
if (motorPower < .001) {
maximumPower = motorPower * 1000000;
printf ("Max power transferred to RL: %f uWatts ", maximumPower);
}
}
return (0);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.