C
C#2y ago
MattK

❔ Using a loop I need to increment voltage by 0.1.

At each increment the power dissipated in R2 (P2) should be calculated (should be able to use P2 = V2 * I2). The voltage loop should stop when P2 = 1.5. Having a hard time figuring out how to get P2 to be calculated at each increment since V2 and I2 would be needed and those would need to calculated first.
14 Replies
MattK
MattKOP2y ago
90% sure that code is rubbish
MattK
MattKOP2y ago
this is another attempt
Doombox
Doombox2y ago
why do while?
for(decimal v = 0; v < 1.5m; v += 0.1m)
for(decimal v = 0; v < 1.5m; v += 0.1m)
would even suffice if you simply need to increase the voltage by 0.1 per increment, then in the loop you can do whatever you need to do what are you actually trying to calculate? can't figure it out looks like ohms law to me, but to what end
MattK
MattKOP2y ago
Trying to calculate power( P = VI ). Let me grab a photo of the circuit for clarification
MattK
MattKOP2y ago
essentially I'm trying to calculate what source voltage for V1 would deliver 1.5 watts to R2 the loop itself should terminate after it reaches that point
Doombox
Doombox2y ago
ah good old resistor circuits, got 2 in series with the 1 in parallel, you don't necessarily need to brute force this with software honestly though I haven't done electronics in a while, you should be able to trial and error this one pretty quick uhh would 25 volts do it? not sure if my brain is awake enough to remember electronics stuff I barely paid attention to in the first place pepelaff
MattK
MattKOP2y ago
haha
Doombox
Doombox2y ago
not sure what source voltage you would need, can't quite recall how parallel resistors affected voltage
Doombox
Doombox2y ago
if memory serves, resistors in parallel doesn't change the voltage across the terminals only get a voltage divider effect from series resistors
Anton
Anton2y ago
use an infinite loop (while(true)) and check the conditions and break manually
ringsig
ringsig2y ago
series resistance
= R_1 + R_2
-> R_s

split voltage into ratio R1:R2 and get V_2
V_2 = V * R_2 / (R_1 + R_2)

power from voltage and resistance
P = V^2 / R

write P_2 in terms of resistances and V using expression for V_2
P_2
= V_2^2 / R_2
= (V * R_2 / (R_1 + R_2))^2 / R_2
= (V * R_2)^2 / (R_2 * (R_1 + R_2)^2)
= V^2 * R_2^2 / (R_2 * (R_1 + R_2)^2)
= V^2 * R_2 / (R_1 + R_2)^2

V^2 = P_2 * (R_1 + R_2)^2 / R_2

V = sqrt(P_2 * (R_1 + R_2)^2 / R_2)

P_2 = 1.5

V = sqrt(1.5 * (R_1 + R_2)^2 / R_2)

with specified values:
R_1 = 100
R_2 = 150
R_3 = 150

V
= sqrt(1.5 * (100 + 150)^2 / 150)
= sqrt(1.5 * 250^2 / 150)
= sqrt(1.5 * 62500 / 150)
= sqrt(625)
= 25
series resistance
= R_1 + R_2
-> R_s

split voltage into ratio R1:R2 and get V_2
V_2 = V * R_2 / (R_1 + R_2)

power from voltage and resistance
P = V^2 / R

write P_2 in terms of resistances and V using expression for V_2
P_2
= V_2^2 / R_2
= (V * R_2 / (R_1 + R_2))^2 / R_2
= (V * R_2)^2 / (R_2 * (R_1 + R_2)^2)
= V^2 * R_2^2 / (R_2 * (R_1 + R_2)^2)
= V^2 * R_2 / (R_1 + R_2)^2

V^2 = P_2 * (R_1 + R_2)^2 / R_2

V = sqrt(P_2 * (R_1 + R_2)^2 / R_2)

P_2 = 1.5

V = sqrt(1.5 * (R_1 + R_2)^2 / R_2)

with specified values:
R_1 = 100
R_2 = 150
R_3 = 150

V
= sqrt(1.5 * (100 + 150)^2 / 150)
= sqrt(1.5 * 250^2 / 150)
= sqrt(1.5 * 62500 / 150)
= sqrt(625)
= 25
If you need the voltage in an increment of 0.1 rounding up: ceil(V * 10) / 10
ringsig
ringsig2y ago
On paper
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server