2

I am attempting to run a PWM on a pump using rpi.GPIO using the following code:

def run_PWM_on_pump():
    gpio.setmode(gpio.BOARD)
    gpio.setup(8, gpio.OUT)
    p = gpio.PWM(8, 0.5) #also works at 5000 frequency, 100 duty cycle
    p.start(15)
    time.sleep(2)
    p.stop()

However, the only time this PWM results in the pump running, is by that configuration (0.5 frequency, 15 duty cycle) or any frequency at 100 duty cycle. We have tried lowering the voltage manually, and the pump does indeed run at lower voltages, but for some reason the PWM is not working as expected.

EDIT: the pump is rated for 24 volts, but we were able to get the pump to run by providing 12 volts.

EDIT2: Pump is connected to the PI via GPIO, turning the gpio pin on causes the pump to stay on until the pin is turned off. To do this, I am using rpi.GPIO's built in PWM functions/GPIO functions. No hardware PWM as far as I know is built into the board.

EDIT3: Link to the pump can be found here: https://www.usplastic.com/catalog/item.aspx?itemid=117560

Pump normally operates at 24V with <2.2A of current.

Tmello225
  • 97
  • 2
  • 9
  • Please edit your question and explain how you are driving the pump and show a full software listing. – joan Oct 31 '19 at 17:37
  • @joan edited, is there anything else I should add? – Tmello225 Oct 31 '19 at 17:40
  • A link to the pump specs would be useful. The board has fully hardware PWM available from GPIO 12/13/18/19. – joan Oct 31 '19 at 17:44
  • @joan The pump can be found here, although there isn't much there in terms of specs for the pump itself https://www.usplastic.com/catalog/item.aspx?itemid=117560

    From what I gathered, it operates at 24V, with a current of <2.2A

    – Tmello225 Oct 31 '19 at 17:46
  • Please edit your question and add information there, not in comments. Not all people read comments to understand the question. – Ingo Oct 31 '19 at 17:49
  • 1
    @Ingo Sorry about that, edited the question to add the information. – Tmello225 Oct 31 '19 at 17:51
  • @joan are those pins board numberings? Or are those the BCM pin numbers? – Tmello225 Oct 31 '19 at 17:52
  • They are GPIO numbers, i.e. BCM numbers. – joan Oct 31 '19 at 17:59
  • There is nothing in the pump specs to suggest it has any GPIO control, let alone by PWM. – joan Oct 31 '19 at 18:01
  • @Tmello225, Ah, let me see. You seem not setting GPIO pin to PWM mode properly: (1) https://raspberrypi.stackexchange.com/questions/99315/run-the-program-in-the-laptop-and-use-the-raspberry-gpios-pwm-to-control-servos (2) def setGpioPinPwmMode(gpioPinNum, frequency): pwmPinObject = GPIO.PWM(gpioPinNum, frequency) return pwmPinObject (3) def pwmPinChangeFrequency(pwmPinObject, frequency): pwmPinObject.ChangeFrequency(frequency) return (4) def pwmPinChangeDutyCycle(pwmPinObject, dutyCycle): pwmPinObject.ChangeDutyCycle(dutyCycle) return – tlfong01 Nov 01 '19 at 00:33
  • @Tmello225, My answer to the question referred to my comment above has a fully debugged program to do PWM controlling servo. The program can control any thing requiring PWM: servo, motor, pump etc. – tlfong01 Nov 01 '19 at 00:37
  • @Tmello225, You don't need the pump to test. I always put the pump aside. I connect a LED and 1k to the PWM, eg, GPIO18, and set PWM to a very low speed, and duty cycle perhaps 50%, and use my stupid human eyes to watch the LED blinking. I once played with pumps, solenoid values, servos, dc motors, I never tested python program with the devices connected. I first connect the status LED, and if it does blink, then I add on the pump, without removing the LED, because they can work together at the same time, ie, one PWM GPIO pin can drive the pump and series register LED at the same time, – tlfong01 Nov 01 '19 at 02:17

0 Answers0