logo

舵机拓展版接上电连上这两个电机,使用示例程序测试只有中间的电机正常动红色圈的那边电机没反应,然后电机对调重复测试结果相同

2022-06-23 21:18
G
latx
19a95296-3d69-4217-903e-ac66cc9b2258.jpg
2022-06-23 23:01
I
网红小智智 星瞳科技

用的什么代码。发一下具体的代码文本。

2022-06-23 23:47
G
latx
# Motor Shield PWM Example
#
# This example shows off how to control the motor shield on your
# OpenMV Cam. The motor shield is controlled by using the PYB module
# which lets you do PWM to control the speed and set digital I/O pin
# states. The motor shield needs 6 I/O pins for both motors.

import pyb

# These pins control our direction while the other PWN pins
# below control the speed. The direction for each motor
# is set by an H-Bridge where A0/1 are the two sides of
# one H-Bridge driver. B0/1 are another H-Bridge.
pinADir0 = pyb.Pin('P3', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
pinADir1 = pyb.Pin('P2', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
pinBDir0 = pyb.Pin('P1', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
pinBDir1 = pyb.Pin('P0', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)

# Dir0/1 must be not equal to each other for forward or backwards
# operation. If they are equal then that's a brake operation.
# If they are not equal then the motor will spin one way other the
# other depending on it's hookup and the value of dir 0.
pinADir0.value(0)
pinADir1.value(1)

# Dir0/1 must be not equal to each other for forward or backwards
# operation. If they are equal then that's a brake operation.
# If they are not equal then the motor will spin one way other the
# other depending on it's hookup and the value of dir 0.
pinBDir0.value(0)
pinBDir1.value(1)

# Create a timer object running at 1KHz which which will power the
# PWM output on our OpenMV Cam. Just needs to be created once.
tim = pyb.Timer(4, freq=1000)

# Use the timer object to create two PWM outputs on the OpenMV Cam.
# These timers control the speed of the motors. You will be setting
# the PWM percentage of these timers repeatedly in your loop.
chA = tim.channel(1, pyb.Timer.PWM, pin=pyb.Pin("P7"))
chB = tim.channel(2, pyb.Timer.PWM, pin=pyb.Pin("P8"))

while (True):

    for i in range(100):
        pyb.delay(100)
        chA.pulse_width_percent(i)
        chB.pulse_width_percent(99-i)

    for i in range(100):
        pyb.delay(100)
        chA.pulse_width_percent(99-i)
        chB.pulse_width_percent(i)
2022-06-24 10:53
G
latx

@kidswong999

# Motor Shield PWM Example
#
# This example shows off how to control the motor shield on your
# OpenMV Cam. The motor shield is controlled by using the PYB module
# which lets you do PWM to control the speed and set digital I/O pin
# states. The motor shield needs 6 I/O pins for both motors.

import pyb

# These pins control our direction while the other PWN pins
# below control the speed. The direction for each motor
# is set by an H-Bridge where A0/1 are the two sides of
# one H-Bridge driver. B0/1 are another H-Bridge.
pinADir0 = pyb.Pin('P3', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
pinADir1 = pyb.Pin('P2', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
pinBDir0 = pyb.Pin('P1', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)
pinBDir1 = pyb.Pin('P0', pyb.Pin.OUT_PP, pyb.Pin.PULL_NONE)

# Dir0/1 must be not equal to each other for forward or backwards
# operation. If they are equal then that's a brake operation.
# If they are not equal then the motor will spin one way other the
# other depending on it's hookup and the value of dir 0.
pinADir0.value(0)
pinADir1.value(1)

# Dir0/1 must be not equal to each other for forward or backwards
# operation. If they are equal then that's a brake operation.
# If they are not equal then the motor will spin one way other the
# other depending on it's hookup and the value of dir 0.
pinBDir0.value(0)
pinBDir1.value(1)

# Create a timer object running at 1KHz which which will power the
# PWM output on our OpenMV Cam. Just needs to be created once.
tim = pyb.Timer(4, freq=1000)

# Use the timer object to create two PWM outputs on the OpenMV Cam.
# These timers control the speed of the motors. You will be setting
# the PWM percentage of these timers repeatedly in your loop.
chA = tim.channel(1, pyb.Timer.PWM, pin=pyb.Pin("P7"))
chB = tim.channel(2, pyb.Timer.PWM, pin=pyb.Pin("P8"))

while (True):

    for i in range(100):
        pyb.delay(100)
        chA.pulse_width_percent(i)
        chB.pulse_width_percent(99-i)

    for i in range(100):
        pyb.delay(100)
        chA.pulse_width_percent(99-i)
        chB.pulse_width_percent(i)
2022-06-24 21:31
I
网红小智智 星瞳科技

估计是你OpenMV焊接的不对,联系售后检查维修。