I'm using a Raspberry Pi pico w with the following code:
When I set the frequency to 250hz, about 30% of the motor starts to spin slightly, about 35% stops, > 35% starts to spin in the opposite direction.
During the rotation process, the motor keeps spinning and stopping.
How do I change this to ensure that the motor continues to run?
Code:
from machine import Pinfrom machine import PWMpwmPin = Pin(15)pwmOutput = PWM(pwmPin)while True: frequency = float(input("Enter pwm frequency in Hz : ")) if frequency >= 0: pwmOutput.freq(int(frequency)) break else: print("frequency cannot be negative. Enter again ") continuedef duty(): duty_cycle = float(input("Enter duty_cycle in percentage : ")) duty_cycle = int(duty_cycle * 65535/ 100) print("duty_cycle = ", duty_cycle) return duty_cyclewhile True: duty_cycle = duty() if 0 <= duty_cycle <= 65535: pwmOutput.duty_u16(duty_cycle) else: print("Unsuitable range, please enter again") continue
During the rotation process, the motor keeps spinning and stopping.
How do I change this to ensure that the motor continues to run?
- Image may be NSFW.
Clik here to view.
- Image may be NSFW.
Clik here to view.
Statistics: Posted by 1417766861 — Thu May 16, 2024 2:50 am