Why my H bridge keep burning when i activate only the b motors (or only the a)

43 views Asked by At

i try to build a very small rc car using 4 motors with my raspberry using th gpio pin but it only work when i set all the motors to turn, when i only set one motors to turn it blow up

My build: https://i.stack.imgur.com/q1BY0.png

I tried to use two h bridge to use only the A side with one and only the A side with the other when i press my key.up to activate all of them it work perfectly same for key.down it work perfect. but when i press my key right or left the motors turn for a demie seconds and stop but the led on the h bridge keep lighting normal but i think its because there is 12v.

    import RPi.GPIO as GPIO
import time
import json
from flask import Flask
from flask import request
import sys
app = Flask(__name__)
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)

MotorgauchePlus = 16
MotorgaucheMoin = 18
MotordroitePlus = 22
MotordroiteMoin = 24


GPIO.setup(MotorgauchePlus,GPIO.OUT)
GPIO.setup(MotorgaucheMoin,GPIO.OUT)
GPIO.setup(MotordroiteMoin,GPIO.OUT)
GPIO.setup(MotordroitePlus,GPIO.OUT)

def Avant():
    print ("Going forwards")
    GPIO.output(MotorgauchePlus,GPIO.HIGH)//IT WORK
    GPIO.output(MotorgaucheMoin,GPIO.LOW)
    GPIO.output(MotordroitePlus,GPIO.HIGH)
    GPIO.output(MotordroiteMoin,GPIO.LOW)


def Arriere():
    print ("Going backwards")
    GPIO.output(MotorgauchePlus,GPIO.LOW)//IT WORK
    GPIO.output(MotorgaucheMoin,GPIO.HIGH)
    GPIO.output(MotordroitePlus,GPIO.LOW)
    GPIO.output(MotordroiteMoin,GPIO.HIGH)
def Gauche():
    print ("Left")
    GPIO.output(MotorgauchePlus,GPIO.LOW)//ai caramba
    GPIO.output(MotorgaucheMoin,GPIO.HIGH)
    GPIO.output(MotordroitePlus,GPIO.LOW)
    GPIO.output(MotordroiteMoin,GPIO.LOW)
def Droite():
    print ("Right")
    GPIO.output(MotorgauchePlus,GPIO.LOW)//same
    GPIO.output(MotorgaucheMoin,GPIO.LOW)
    GPIO.output(MotordroitePlus,GPIO.HIGH)
    GPIO.output(MotordroiteMoin,GPIO.LOW)

def Stop():
    GPIO.output(MotorgauchePlus,GPIO.LOW)//That work
    GPIO.output(MotorgaucheMoin,GPIO.LOW)
    GPIO.output(MotordroitePlus,GPIO.LOW)
    GPIO.output(MotordroiteMoin,GPIO.LOW)

@app.route('/', methods=['POST'])
def AvanOuArriere():
    Alors = request.form['Alors']
    if Alors == "Quite":
        GPIO.output(MotorgauchePlus,GPIO.LOW)
        GPIO.output(MotorgaucheMoin,GPIO.LOW)
        GPIO.output(MotordroitePlus,GPIO.LOW)
        GPIO.output(MotordroiteMoin,GPIO.LOW)
        GPIO.cleanup()
        sys.exit()
        return("oklm")
    elif Alors == "Avant":
        Avant()
    elif Alors == "Gauche":
        Gauche()
    elif Alors == "Droite":
        Droite()
    elif Alors == "Arriere":
        Arriere()
    elif Alors == "Stop":
        Stop()
    else:
        pass
    return("oklm")
try:
    if __name__ == "__main__":
        app.run(host='0.0.0.0', port=5000)
except Exception as e:
    print(e)
    GPIO.output(MotorgauchePlus,GPIO.LOW)
    GPIO.output(MotorgaucheMoin,GPIO.LOW)
    GPIO.output(MotordroitePlus,GPIO.LOW)
    GPIO.output(MotordroiteMoin,GPIO.LOW)
    GPIO.cleanup()

I'm completly lost because to activate a motor i only need to set one pin to HIGH and another to LOW, thats what i do for activate all of them and it work ! Maybe its because i set MotordroitePlus to LOW and MotordroiteMoin to also LOW but its in the Stop function and it work also like it should do so i need your help because im missing something.

0

There are 0 answers