I am controlling a stepper motor using PWM on a RPi 4 and python. The motor has a controller/driver (BLDC-8015A) that accepts 0-3.3V to set the rotational speed. According to the documentation, this signal can be analog or a PWM signal. Raspi does not have an analog option. That's why I'm going for the PWM approach.
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) pwm = GPIO.PWM(23,1000) #pwm on pin 23 at 1kHz pwm.start(0) #should start with 0% == 0V, is 0.1A
However, this gives me something around 0.1 Amps and my motor rotates slowly. I assume its something similar to that: https://arduino.stackexchange.com/questions/75602/very-small-pwm-when-timer-says-zero
Is there a similar way for RPis, or a completely different reason and solution?
EDIT: TLDR: use proper power supply... While following some of the suggestions below I found that if I set a pin to 'low' it is not actually 0. Same thing again, I get a small voltage
GPIO.setmode(GPIO.BCM) GPIO.setup(23,0) GPIO.output(23,0)
Now it gets weird. I noticed that the voltage becomes higher if the Raspi is busy with other even minor tasks. For example, if I scroll quickly through my program in Thonny (python editor) the voltage increases from about 30mA to above 100mA. That doesn't sound much but is 3% duty. I then tried the original raspi power supply. No problem anymore. Before, I used a DC/DC converter to get from 24V battery voltage to 5.1V for the raspi. I guess I'll have to figure that out now.