[PYTHON] Using Akizuki Denshi's 4WD car FT-MC-004 with Raspberry Pi

Let's run Akizuki Denshi's four-wheeled vehicle FT-MC-004 with Raspberry Pi.

What is FT-MC-004?

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.

Make a stay for Raspberry Pi

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). DSC_0092 (2).JPG DSC_0095 (2).JPG Image of attaching Raspberry Pi Place this on top of FT-MC-004.

Place on FT-MC-004

This time, I used a Raspberry Pi in a case instead of putting it directly. DSC_0402 (2).JPG DSC_0404 (2).JPG The power was from a USB battery. We do not recommend using the Raspberry Pi 5V as it may burn out the wiring. DSC_0413 (2).JPG

Move the motor driver

Let's move it. FT-MC-004 is controlled by inputting the PWM frequency to the motor driver.

From Akizuki Denshi's materials

[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.

program

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()

Lengthened program

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

Using Akizuki Denshi's 4WD car FT-MC-004 with Raspberry Pi
Using a webcam with Raspberry Pi
Create a car meter with raspberry pi
MQTT RC car with Arduino and Raspberry Pi
GPGPU with Raspberry Pi
DigitalSignage with Raspberry Pi
Using the digital illuminance sensor TSL2561 with Raspberry Pi
Indoor monitoring using Raspberry Pi
Mutter plants with Raspberry Pi
I tried using the DS18B20 temperature sensor with Raspberry Pi
[Raspberry Pi] Stepping motor control with Raspberry Pi
Control the motor with a motor driver using python on Raspberry Pi 3!
Use vl53l0x with Raspberry Pi (python)
Serial communication with Raspberry Pi + PySerial
OS setup with Raspberry Pi Imager
Try using ArUco on Raspberry Pi
Try L Chika with raspberry pi
VPN server construction with Raspberry Pi
Try moving 3 servos with Raspberry Pi
[Note] Using 16x2-digit character LCD (1602A) from Python with Raspberry Pi
Detect analog signals with A / D converter using python on Raspberry Pi 3!
Measure SIM signal strength with Raspberry Pi
Pet monitoring with Rekognition and Raspberry pi
Detect "brightness" using python on Raspberry Pi 3!
Hello World with Raspberry Pi + Minecraft Pi Edition
Build a Tensorflow environment with Raspberry Pi [2020]
Make Raspberry Pi speak Japanese using OpenJtalk
Get BITCOIN LTP information with Raspberry PI
Try fishing for smelt with Raspberry Pi
Programming normally with Node-RED programming on Raspberry Pi 3
Improved motion sensor made with Raspberry Pi
Try Object detection with Raspberry Pi 4 + Coral
Run servomotor on Raspberry Pi 3 using python
Power SG-90 servo motor with raspberry pi
Working with sensors on Mathematica on Raspberry Pi
Use PIR motion sensor with raspberry Pi
Make a wash-drying timer with a Raspberry Pi
Infer Custom Vision model with Raspberry Pi
Operate an oscilloscope with a Raspberry Pi
Detect temperature using python on Raspberry Pi 3!
Inkbird IBS-TH1 value logged with Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
Discord bot with python raspberry pi zero with [Notes]
Media programming with Raspberry Pi (preparation for audio)
Detect slide switches using python on Raspberry Pi 3!
Try using a QR code on a Raspberry Pi
I tried L-Chika with Raspberry Pi 4 (Python edition)
Detect magnet switches using python on Raspberry Pi 3!
Automatic launch of Raspberry Pi programs using Systemd
Send data from Raspberry Pi using AWS IOT
Enjoy electronic work with GPIO on Raspberry Pi
Power on / off your PC with raspberry pi
Use Majoca Iris elongated LCD with Raspberry Pi
CSV output of pulse data with Raspberry Pi (CSV output)
Observe the Geminids meteor shower with Raspberry Pi 4
Get CPU information of Raspberry Pi with Python
Sound the buzzer using python on Raspberry Pi 3!
Create a visitor notification system using Raspberry Pi
Play with your Ubuntu desktop on your Raspberry Pi 4
Get temperature and humidity with DHT11 and Raspberry Pi
Connect your Raspberry Pi to your smartphone using Blynk