I am working on a robotic project and encountering difficulties in controlling two Dc motors. Anyway, I am using raspberry Pi 3 and Dual Channel 10A DC Motor Driver to drive two DC motors (Dual shaft self-locking DC worm gear motor). I am using the driver to drive bigger motor capacity and make them work as a servo motor. I managed to send signal and run the motors but I can't stop them running. Please any help, I would be thankful.
Import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12,GPIO.OUT)
pwm=GPIO.PWM(12,100)
pwm.start(20)
time.sleep(1)
pwm.stop()
In fact, I have little knowledge on controlling the motors.. if you can guide me or show me good reference I will also be grateful .
Related
I have a Lolin MCU like this Lolin v3
I have a PCA9685 board like this cheap controller
And Im coding in microPython in the nodeMCU device. I managed to attach one of those small 9g servos to the nodeMCU board and controll it. No problem. I want to use a controller since I need more servos, so I connect the PCA like this:
PCA V+ <--> 3v3 in the mcu (5v produce no changes)
PCA GND <--> GND in the mcu
PCA SDA <--> SDA (Pin 4) in the mcu
PCA SCL <--> SCL (Pin 5) in the mcu
PCA OE <--> GND, V+ or open. Makes no difference
Now I downloaded this PCA9685.py and Servo.py from this web microPython PCA controller
I create an I2C like this
>>> i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
>>> i2c.scan()
[64, 112]
So the device is there. The cables are good, the i2c is working. But the servos won't move no matter what. Not even buzz.
I try moving the servo using
servos.position(1, us=1500)
no thing happened.. I connected several servos in several ports to make sure is port 1 not port 0 and those stupid errors.. nothing.
This is the code I'm running at the device right now:
from machine import I2C, Pin
import servo
servos = servo.Servos(I2C(scl=Pin(5), sda=Pin(4))
for i in range(16):
servos.position(i, us=1500)
Any clue ???
I am driving stepper motor using Raspberry Pi 3. I am using stepper motor driver Pololu A4988. A driver has potentiometer which we can adjust to provide specified current to the motor. My stepper motor current rating is 1 Amp and I am using 12 V 3 A power supply, but still when I start the motor power supply fluctuates. Even while using a 12V 5A power supply, the same problem is occurring. Please, Help and provide the solution.
I'm trying to talk via I2C to the gyro sensor MPU6050 which sits on a GY 521 board. But i can't get the device being detect.
I tested another i2c device (EEPROM) and got the device address detected. So i guess it has to be a hardware problem.
As far as i could find out:
RPi has a 1.8k pullup resistor on SDA and SLC already on board
my GY 521 also has also a pullup resistor (2.2k) on each line on board
Could the resistors be the problem? A good resistor value in sum would be around 5k on each line?
(The wiring should be ok, there are a lot of instructions around the net and i've checked it multiple times. I use 5v on the GY521 since it has a voltage converter)
Any help appreciated!
The problem was bad soldering.
For the record:
Using the RPi pullups in combination with the breakout board pullups works for me.
i have a raspberry pi connected with two ds18b20 temperature sensor.
-sensor1 is fixed on the outside of my garage (distance 20m from raspberry pi)
-sensor2 is just connected in a breadboard near the raspberry pi.
Everything is working well.
I decided to add sensor3 located outside and from 20m from the raspberry pi.
Now when i type :
cd /sys/bus/w1/devices
if find this:
c0-40a000061005 c2-246056869800 c2-247056869000 d0-008000001000 w1_bus_master1
instead of :
28-.....
28-.....
28-.....
each sensor ref should be start with 28-.....
what is happening with my sensors?
If unplugged the sensor1, then everything is well
if i unplug the sensor3 and let only sensor1 and sensor2 everything is well.
Which modification do we have to do when sensor are located far from the raspberry pi?
thank you
That means that the 3rd sensor doesn't have a 4.7kOhm or 10kOhm resistor between VCC and the OUT wire (black/red one if you have 4wire DS18B20).
Just connect that resistor and it will work , I had the same problem . I spent weeks to find such an easy solution. And if you get the same code after you connected the resistor , that means you didn't connected it properly.Hope will help you
Im trying to connect a MMA852Q accellerometer to a 18F2550 microcontroller. According to accellerometer datasheet i2c clock and data lines would not tolerate voltages more than 1.6- 3.7 (+0.3). Those lines have to be pulled up to 5v for microcntroller to work. Im new in to this subject and your advice to overcome this issue would be really helpful.
You could look for "I2C level shifter" for attaching buses with different voltages together.
NXP appnote 10441 (pdf) has a very neat generic one, for example.