Progress on the Four-legged Robot: Getting the Legs Moving /Raspberry pi pico /MS18

I’ve recently made significant progress on the four-legged robot project I started a while ago. 

I have managed to assemble most of the parts and have reached the point where I can move its legs. 

It seems like it won’t be long before the robot will be able to walk.

Circuit Diagram

For the prototype, I’ve drawn a simple circuit diagram. 

The plan is to use two DC-DC converters (one for the Raspberry Pi Pico W and another for the servo motors), but currently, I’m powering them separately using USB bus power and a stabilized power supply. 

I’m concerned about the noise from the servos, so I’m thinking of keeping the power supplies separate. However, if a sufficiently large electrolytic capacitor does the job, I might just use one power source. 

The RMT module is for an infrared remote control receiver. Additionally, though not yet installed, I plan to equip it with a distance sensor (HC-SR04).

Given that this is a prototype, I’ve built it on a universal circuit board.

Programming

I did a quick test using Micropython in Thonny. Here’s a snippet of the code:

from machine import Pin, PWM
import time

SV_FREQ = 50.0 #Hz
MAX_DUTY = 65535.0 #uint16 max 
MIN_SV_PULSE = 0.5 #ms
MAX_SV_PULSE = 2.5 #ms

def get_pulse_width(angle):
    pulse_ms = MIN_SV_PULSE + (MAX_SV_PULSE - MIN_SV_PULSE)*angle/180.0
    x = (int)(MAX_DUTY * (pulse_ms*SV_FREQ/1000.0))
    return x

correction = [0, 0, 10, 0, 0, 0, -10, -5] # Correction values to set neutral position
servo = []

servo.append(PWM(Pin(2))) #Front Right Leg
servo.append(PWM(Pin(3))) #Front Right Shoulder
servo.append(PWM(Pin(4))) #Front Left Leg
servo.append(PWM(Pin(5))) #Front Left Shoulder
servo.append(PWM(Pin(6))) #Rear Right Leg
servo.append(PWM(Pin(7))) #Rear Right Shoulder
servo.append(PWM(Pin(8))) #Rear Left Leg
servo.append(PWM(Pin(9))) #Rear Left Shoulder

snum = len(servo)

# Move all servos to neutral position (90 degrees)
for i in range(snum):
    servo[i].freq(int(SV_FREQ))
    servo[i].duty_u16(get_pulse_width(90 + correction[i]))

time.sleep(0.5)
# Alternate all servos between 60 and 120 degrees
while True:
    for i in range(snum):
        servo[i].duty_u16(get_pulse_width(60))
    
    time.sleep(0.5)
    for i in range(snum):
        servo[i].duty_u16(get_pulse_width(120))

    time.sleep(0.5)

I’m using Miuzei MS18 servo motors, which I found on Amazon. 

They are cheaper than SG90. However, I couldn’t find a detailed manual of MS18. Only some specifications are on the package of them. In addition, the PWM cycle was not specified, which was a bit concerning. 

They seem to be imitations of SG90, so they do work fine at 50Hz same as SG90.

Next, I aim to achieve walking motion.

コメント

タイトルとURLをコピーしました