I have a function called doCalibrate()
which does iteration to move the stepper (GPIO Raspberry), let’s say normally this function runtime is only 3 seconds.
This script was called from 2 source
- executed from
if __name__ == '__main__':
which is when the script executed, here’s the script
if __name__ == '__main__':
doCalibrate()
- executed from socketio, here’s the script
@sio.on(f'ms-calibrate')
def receive_calibrate(data):
print(f"[SOCKET] Received calibrate")
room_number = data['room_number']
if (room_number == this_room_number):
doCalibrate()
the first source
runs the doCalibrate function for 3 seconds
which is the actual time, but the second source
runs the doCalibrate function for 5 seconds
which is not the actual and optimal time.
Actually there is another function that make stepper move, but every action that comes from socket made the stepper move slower, but if the action come from let’s said hardcode
from the script or from call api every 1 minute and read index docalibrate is 1
the stepper speed is normal. Here’s my stepper moving algorithm
for j in range(int(stepes)):
GPIO.output(step_pin, 1)
time.sleep(delays)
GPIO.output(step_pin, 0)
time.sleep(delays)
I expect the speed of stepper is same when the source is from socket or hardcode or from API, i have tried make 2 doCalibrate()
function but speed still the same.
3