I'm working on a manufacturing project using a Raspberry Pi 4 with 8GB of RAM, DM556 step motor drivers, and 10 stepper motors. The idea is to have a single main Python script with a GUI, where I can input specific values that translate to RPMs, as well as toggle the on/off function for each motor. When a motor is turned on, the main application sends the relevant information to separate scripts (e.g., motor_1.py) to run at the desired RPM. When a motor is stopped, the corresponding script is terminated by the main application.
All 10 stepper motors need to run at separate RPMs continuously in one direction (to operate blood pumps transferring liquid at specific rates). The main application is functioning well, but I’m facing issues with the stepper motor scripts. When using time.perf_counter() - start_time) < half_pulse_interval, a single script consumes about 25% of my CPU usage, making it impossible to run all 10 motors simultaneously. Using time.sleep reduces CPU usage to around 7% per script, but the RPM accuracy is compromised and I can't achieve speeds higher than 70 RPM (while around 90 RPM is needed for some motors).
Here’s the current setup:
1. Each stepper motor has its own step motor driver.
2. There is a shared power supply for all the stepper motor drivers.
3. The Raspberry Pi 4 CPU has been safely overclocked to 2 GHz.
4. All unnecessary applications have been disabled or removed.
5. Each motor_x.py script is launched using the subprocess.Popen function.
Do you have any ideas on how I can optimize / upgrade this project to send pulses more efficiently, without relying on busy-waiting functions that work well but consume excessive CPU resources?
All 10 stepper motors need to run at separate RPMs continuously in one direction (to operate blood pumps transferring liquid at specific rates). The main application is functioning well, but I’m facing issues with the stepper motor scripts. When using time.perf_counter() - start_time) < half_pulse_interval, a single script consumes about 25% of my CPU usage, making it impossible to run all 10 motors simultaneously. Using time.sleep reduces CPU usage to around 7% per script, but the RPM accuracy is compromised and I can't achieve speeds higher than 70 RPM (while around 90 RPM is needed for some motors).
Here’s the current setup:
1. Each stepper motor has its own step motor driver.
2. There is a shared power supply for all the stepper motor drivers.
3. The Raspberry Pi 4 CPU has been safely overclocked to 2 GHz.
4. All unnecessary applications have been disabled or removed.
5. Each motor_x.py script is launched using the subprocess.Popen function.
Do you have any ideas on how I can optimize / upgrade this project to send pulses more efficiently, without relying on busy-waiting functions that work well but consume excessive CPU resources?
Statistics: Posted by EPSIOFFICIAL — Fri Sep 27, 2024 9:54 pm — Replies 1 — Views 61