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.
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 ...
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:
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 ...
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.
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
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 ...
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.
"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 ...
From the pictures, it looks like the chip is upside down. There's a little notch on one end that shows you where the "top" is, while you have it facing away from the top of the breadboard instead of towards it. Fortunately, based on the data sheet for the chip, this actually doesn't matter and it will function exactly the same. That's a surprise.
As pointed ...
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.
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...
Steppers are typically driven by stepper driver boards such as the TMC2208. Microcontrollers such as Arduino or Raspberry Pi send pulses to the stepper driver boards to turn the stepper motor. I assume you have already acquired a motor hat or such.
For smoothness, it is ideal to have well behaved acceleration curves for the pulse train sent to a robotic arm ...
Controlling a DC motor takes more power than the GPIO pins of a Raspberry Pi can directly source. In other words, if you try to connect a GPIO pin of a Raspberry Pi directly to a motor you will burn out the Pi.
You can control a DC motor in one direction with a transistor. Here is an example. This example uses an Arduino rather than a Raspberry Pi, but the ...
The except runs when the try fails in an error,
In the case the 'try' runs, and doesn't fail during the while loop, thus not giving a chance for the 'try' to error and then run thru the 'except' code and send thru the stop() function.
Perhaps use 'if' statements to check conditions and save the 'try' 'except' for cases you need to catch an error.
Try/Except is used to catch errors (exceptions)
Since I cannot see where you are calling go() from, I dont know if go() should be an infinite loop, but if it is
if not button_40=input(40):
continue #back to start of while True loop
A digital POT is similar to a digital DAC. You can change the output voltage by setting the input value.
As long as your motor controller just needs to sense voltage it should be fine. The digital POT will not supply much current at that voltage though, perhaps just a few milliamps.
increasing the frequency is not going to damage the motor. The frequency is how often the motor is being turned on and off, and the PWM value is the amount of one time period the motor is either on or off. Because the motor is being turned on and off, if it is not mounted properly there will be more vibration then when it is fully on (connected directly to ...
Since this is a device that needs precision, I would use a stepper motor, if a direct drive were absolutely required. In addition, I would have something that the Raspberry Pi could sense to know that the disk was in position.
If the number of positions is constant, I think a very simple mechanical device known as The Geneva Drive would be better. It was ...
If you migrate your web server from php to flask, you can give the motor command natively. Make routes as @app.route('/motor-on') and ('/motor-off'), with their respective python commands, then trigger the motor control with ajax request on button click (java script). TIP: Use gpiozero library, it is super easy and effective.
exec("python /home/pi/motor/on.py /dev/null/ 2>/dev/null/ &")
There's a > missing. To redirect the standard output, it must read
exec("python /home/pi/motor/on.py >/dev/null/ 2>/dev/null/ &")
If you don't redirect both the standard output and standard error channels, php's exec() waits for completion, regardless of an &.
Thanks to Aurora001 for pointing me to https://github.com/MomsFriendlyRobotCompany/pysabertooth. Using this library I'm able to get the motor control I wanted. A couple of side notes to add. As mentioned in the comments above, when I used the library as is I got an Attribute Error: Serial module does not include "is_open". I modified the installed ...
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 ...