The Raspberry Pi requires 5 Volts - if you've fed it 12 Volts you've killed it. Powering the Pi using the GPIO pins bypasses the fuses that might have saved the Pi if you had used the micro USB connector.
If smoke came out - you've provided too much power to the Pi somehow. That board appears to be designed for an Arduino which has 5V outputs, the Pi's GPIO ...
The problem was that there was no ground between the L298N and the Raspberry Pi. By wiring the Ground (-'ve) terminal on the L298N to a ground pin on the Raspberry (as well as the batteries) it then worked.
I would recommend that you use a Opto Coupler. An Opto coupler consist of a LED (Light Emitting Diode) and a Photo sensitive transistor.
That will create a safety isolation between your motor that creates nasty electrical spikes and your precious Raspberry Pi.
Take a look at the Youtube video for more detailed info https://www.youtube.com/watch?v=pYENAGK8qH4
A GPIO can only supply a little current, perhaps 60mA or so, whereas the 3V3 rail can supply up to 1 amp depending on the Pi model.
It is probably not safe to draw more than say 20mA from a GPIO for an extended period (which may be of the order of seconds) as they are not designed for that purpose and you may destroy the GPIO and/or the Pi.
It is also ...
The 50 mA limit is for the GPIO.
The 3V3 pins are not GPIO.
You can draw as much current from the 3V3 pins as is available from the power supply. If you attempt to draw more current than is available the Pi will reboot.
The library source code is linked to from the SB Components website, where there is a link:
Get the library source code from GitHub
This leads you to this GitHub repository, which contains PiMotor.py, which would seem to be the library you want.
Simply download that repository, extract the files to the directory of your script, and then running import ...
I agree with the answer by CoderMike that you've probably fried your Pi. Based on the wiring diagram though, I differ in thinking that it might have been avoidable with this hardware if you had connected it different.
You put 5 V into the shield's logic circuits by connecting the shield's Vin to the 5 V pin on the Pi. That's the orange-ish line near the ...
If you read the documentation, there are two mistakes in your code. First, just use import l293d. Second, use motor1 = l293d.DC(22, 18, 16)
There isn't a motor attribute, but there is a DC attribute for DC motors.
This runs on my system.
jay@gotham:~/python$ python3 test.py
[l293d]: Can't import RPi.GPIO; test mode has been enabled:
Stepper 28byj48 unipolar OK with uln2003
Slit the red wire so there are only two windings
Measured ohms across coils. Pin 1 ic - 5v pos ... (OMG, 16 connection
I did the same thing a long while ago. I vaguely remember I performed the following operation converting the stepper from unipolar to bipolar.
Open the casing
Cut away ...
6V motors usually work fine with 5V (other than the fact that they run at 80%..85% of it max speed). However, powering a motor from the Pi is only possible for very small motors, which have stall current that the Pi can provide without a significant voltage drop. Even toy motors are often rated for 2A stall current or more, which can easily reboot the Pi ...
In general things like motor, wav, and lcd shields are designed to fit an Arduino. That does not mean they won't work with other MCU's or SBC's like the Pi.
Some of the difference include:
usually 5 volt based logic.
form factor and pinout to match the arduino (usually an uno or deumilanove - but there are some designed for some of the other Arduino's).
Both the Pi and an Arduino should be able to handle the decision making. The Pi will be better once the decision making becomes more complicated.
The Pi is just as good as an Arduino at controlling motors.
Neither the Pi nor an Arduino can control a DC motor directly. They both need the support of external hardware to safely switch the currents involved.
You have misunderstood how PWM is used to control DC motor speed.
To control the speed you vary the duty cycle, not the frequency. The frequency should be fixed at a reasonable value for your motor driver board. Say anything over 100 Hz.
A duty cycle of 0% stops the motor. A duty cycle of 100% sets the motor full on.
The voltage applied to the motor ...
Your design has some shortcommings
There is no direct 5V output
the 3v3 probaply isn't strong enaugh to drive a relay so you need a transistor too and a diode to protect the Pi 5v
the accumulated cost for the components exceed the price for a ready L298 H-bridge module ($2.5-$3) for which instructions are available
On another (related) note - I see from the spec sheet that the module's power supply (not the motor supply) should be 6.5-12v... and you're powering it with 4xAA batteries, which is fine when they are fresh, since new, quality batteries output closer to 1.7v (around 6.8v total); but in THEORY, you're running a 6.5v device with a 6v battery pack...
According to documentation page for the l293d Python library, you've used syntax that's incorrect. The docs suggest this may work:
motor1 = l293d.DC(22, 18, 16)
then the rest of your code.
"The only thing is that I connected the 3.3V of the L293D on a 5V pin, but I assumed it is not a big deal..."
Translation AKA edited as is common on this forum
**I am using common power source for all devices **
IT IS A HUGE DEAL !
Electromechanical devices are
1. power hungry
2. when initialized /started they are EXTREMELY power hungry - tech term ...
the spike caused by motors, drops the controller voltage.
in this case (the pi), it will drop to 4.6 v for example, which is enough to cause to to reboot.
either use an adapter for rpi, or give it another clean power source.
plus, for the same reason DIY quadcopters have separate batteries dedicated for the controller.
This shows (my) pigpio library being used to control a variety of devices.
A Raspberry Pi controlling a variety of motors and sensors.
The pan-tilt head is moved by a pair of servos. The head holds a
sonar ranger and an ADXL345 3-axis accelerometer. The servos control
pins are connected directly ...
I would suggest to do the testing in 2 steps:
(1) Check by hand if jumper wire 5V, Gnd signals can move motor forward and backward.
(2) If motor can turn manually, then start writing the python program.
I googled and found almost all the L298N modules have the similar input and output terminal connectors. The following is my quick and dirty hardware ...
A quick rule of thumb for if the GPIO is suitable for some type of input is to ask if the information you want is digital. That is, if the information you want is either on or off. Considering you're looking to track a variable position, the GPIO probably isn't suitable.
You might be able to use a linear encoder of some type and use the GPIO to count ...
I did a similar project with a Power Wheels Wild Thing and an Arduino. I settled on buying a couple of BTS7960B motor controllers. They are rated for 43 amps, and I assume they will work for a Pi though I haven't done it myself.
Someone used these controllers on a Pi, they may have some helpful pointers.
Below is a simple diagram showing how to hook it up.
The most helpful link on that I found is this one: https://business.tutsplus.com/tutorials/controlling-dc-motors-using-python-with-a-raspberry-pi--cms-20051.
The diagram below shows essentially how the L293D works:
However, I strongly recommend you use an L298 motor driver instead because the amps out for the L293D is maxed at 600mA (the stall current is ...
There is more than one type of motor driver board using the L298N.
The typical board has two voltage inputs and a common ground.
One voltage input is to drive the motors. The other voltage input is to provide logic power to the module.
Typically the board has a jumper which can be fitted to supply logic power from the motor supply. If that is fitted DO NOT ...
From your description the batteries can not supply enough power for a
sustained period. They are drained after four seconds of use until you give them a period of rest when they recover enough for a few more seconds.
You need more powerful batteries or smaller motors.
Bouncing means you have extra edges in the signal, so the error you get from it can only be a higher count, not lower.
De-bouncing means your software ignores the edges which come faster than expected, so it can remove those extra edges, or, if the de-bounce time is too high, ignore legitimate edges, leading to a lower count. As far as I can tell there is no ...
I will only cover one issue (that is not covered is existing answer).
You are only looking at one of the outputs of the encoder. This output can bounce, therefore you have a bounce filter. This filter can cause you to miss edges, and get a low count.
If you take into consideration both outputs, then you can let it bounce (you need no filter). You may get a ...