Let's run Akizuki Denshi's four-wheeled vehicle FT-MC-004 with Raspberry Pi.
FT-MC-004 is Akizuki Denshi's Arduino-based 4WD car kit. The price is ¥ 2,610. 4WD Mobile Robot Platform Kits for Education FT-MC-004 http://akizukidenshi.com/catalog/g/gK-13652/
The kit configuration of FT-MC-004 is a set of 4 motors, a motor driver board, a chassis and a stay for a microcomputer board. The brother machine FT-MC-002 is a set of two motors, a motor driver board, a chassis and a stay for a microcomputer board. It is divided into two types depending on the number of motors. However, it cannot be used as it is.
It's tough to put a Raspberry Pi and a battery. For this reason, we will use Tamiya Universal Arm Set No.157 Universal Plate 2 Sheets Set (70157). Image of attaching Raspberry Pi Place this on top of FT-MC-004.
This time, I used a Raspberry Pi in a case instead of putting it directly. The power was from a USB battery. We do not recommend using the Raspberry Pi 5V as it may burn out the wiring.
Let's move it. FT-MC-004 is controlled by inputting the PWM frequency to the motor driver.
[Question] What is the pulse width input to the attached board? [Answer] Since there is no manufacturer's data, the measured values are shown below. Forward rotation: 1.2 to 1.4 (no visual change below this) Rest: 1.5 (with some dead zones in the front and back) Reversal: 1.6-1.8 (no more visual changes) Unit (ms) (C)http://akizukidenshi.com/catalog/faq/goodsfaq.aspx?goods=K-13652 It is controlled by outputting PWM to pins 4 and 17 of GPIO. ** According to another document, 1ms to 2ms, the center is 1.5ms.
The program looks like this. I'm stationary
servoX.ChangeDutyCycle(7.2)
It was made. It is possible to control forward and reverse from 6.5 to 8.5. (The front and back are not well balanced) If you do this in Python, the tires will spin for the time being.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
lp_out = 4
rp_out = 17
GPIO.setup(lp_out, GPIO.OUT)
GPIO.setup(rp_out, GPIO.OUT)
servol = GPIO.PWM(lp_out, 50)
servor = GPIO.PWM(rp_out, 50)
servol.start(0)
servor.start(0)
for i in range(1):
print("Stop")
servol.ChangeDutyCycle(7.2)
servor.ChangeDutyCycle(7.2)
time.sleep(1.5)
print("Start")
servol.ChangeDutyCycle(6.5)
servor.ChangeDutyCycle(8.0)
time.sleep(1.5)
print("Stop")
servol.ChangeDutyCycle(7.2)
servor.ChangeDutyCycle(7.2)
time.sleep(1.5)
servol.stop()
servor.stop()
GPIO.cleanup()
Let's turn it a little longer.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
lp_out = 4
rp_out = 17
GPIO.setup(lp_out, GPIO.OUT)
GPIO.setup(rp_out, GPIO.OUT)
servol = GPIO.PWM(lp_out, 50)
servor = GPIO.PWM(rp_out, 50)
servol.start(0)
servor.start(0)
for i in range(1):
print("Stop")
servol.ChangeDutyCycle(7.2)
servor.ChangeDutyCycle(7.2)
time.sleep(1.5)
print("Start")
servol.ChangeDutyCycle(6.5)
servor.ChangeDutyCycle(8.0)
time.sleep(1.5)
print("Stop")
servol.ChangeDutyCycle(7.2)
servor.ChangeDutyCycle(7.2)
time.sleep(1.5)
print("R")
servol.ChangeDutyCycle(7.2)
servor.ChangeDutyCycle(8.0)
time.sleep(1.5)
print("L")
servol.ChangeDutyCycle(5.0)
servor.ChangeDutyCycle(7.2)
time.sleep(1.5)
print("BR")
servol.ChangeDutyCycle(7.2)
servor.ChangeDutyCycle(5.0)
time.sleep(1.5)
print("BL")
servol.ChangeDutyCycle(10.0)
servor.ChangeDutyCycle(7.2)
time.sleep(1.5)
servol.stop()
servor.stop()
GPIO.cleanup()
Recommended Posts