4

This is the problem: using this tutorial and Adafruit_Python_GPIO libs when start pwm and step up with DutyCycle and frequency I hear a weak sound from motor but unfortunely it doesn't move.

Wiring

enter image description here

Code

    import RPi.GPIO as GPIO
    from time import sleep

    ENABLE_PIN = 25
    IN1 = 24
    IN2 = 23
    ENGINE_FREQ = 500

    class pump:
        def __init__(self):
            self.enable_pin = ENABLE_PIN
            self.in1_pin = IN1
            self.in2_pin = IN2

            GPIO.setmode(GPIO.BCM)

            GPIO.setup(self.enable_pin, GPIO.OUT)
            GPIO.setup(self.in1_pin, GPIO.OUT)
            GPIO.setup(self.in2_pin, GPIO.OUT)

            self.pwm = GPIO.PWM(self.enable_pin, ENGINE_FREQ)

        def start(self):
            self.pwm.start(0)

            GPIO.output(self.in1_pin, True)
            GPIO.output(self.in2_pin, False)
            self.pwm.ChangeDutyCycle(100)

        def stop(self):
            self.pwm.stop()
            #GPIO.cleanup()

    if __name__ == '__main__':
        p = pump()
        p.start()
        sleep(5)
        p.stop()
        GPIO.cleanup()

What is wrong?

1

The code looks fine.

That suggests

  • loose wiring
  • weak batteries
  • stalled motor
| improve this answer | |
  • putting batteries pack directly to motor, it work's fine. – pepperav Oct 24 '16 at 8:57
  • @pepperav It's a good idea to also edit such diagnostic information into your question so all relevant information is in one place. The schematic looks fine. Perhaps your wiring doesn't match the schematic. The L293D will drop a volt or so. – joan Oct 24 '16 at 9:33
  • I have set dtoverlay=pwm-2chan in /boot/config.txt – pepperav Oct 24 '16 at 9:47
  • @pepperav For any particular reason? I repeat edit new information into your question. – joan Oct 24 '16 at 10:15
  • because I thought that PWM was disabled. I'm using raspbian jessie lite. – pepperav Oct 24 '16 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.