0
simple ramp rate question
How would i ramp a variable at a rate of 50volts per second and then put it in a loop to check when the variable has reached 1000?
4 Respuestas
+ 2
Oh you need it per second? Here ya go😁
import time
from time import sleep
ramp = 50
var = 0
while var <= 1000:
var += ramp
time.sleep(1)
Time.Sleep() halts the execution of the program for a number of seconds, I told it to wait 1 second each time the loop iterates
I hope this is what you wanted
+ 1
Is this wat you mean?
This will increase the voltage by 50V every time the loop is iterated through
volts = int(input())
while volts <= 1000:
volts += 50
If you want the rate itself to increase exponentially it'll look something like this (just off the top of my head)
ramp = 50
var = int(input())
while var <= 1000:
var += ramp
ramp += 50
+ 1
Hmm thanks. I think my challenge is I need it to ramp at 50 volts per second. The first option starts at 50 and adds 50 to that value at a rate as fast as the computer can go. The second one changes the ramp value each time. I need that ramp rate to stay at 50v/s the entire time my loop runs until a separate variable hits 1000. I just can’t figure out how to store the ramp as a function of time.
+ 1
Hi Thomas! Exactly! Thanks so much. This should do it.