Motor

OpenMV has IO port to drive all kinds of electrical motor

Stepping motor

What is stepping motor?

Stepping motor is open-loop control eletrical motor that can turn electric impulse signal into angular displacement or linear displacement,which is the main power element in the modern digital procedure control system,whose application is extremely extensive.

Like 3D printer and mechanical arms.

Stepping motor driving module

Many chips and modules can be used to control stepping motor.We use a simple module EasyDriver。

To be simple,control direction through dir,give an impulse to step,the motor will move.

Wiring

Install module

module code in this link

把这个类的代码保存成stepper.py文件,放到OpenMV的根目录中。

Code

# 步进电机控制 - By: 小智智- 周日 4月 2 2017

from pyb import Pin

from stepper import Stepper

import time

step_pin = Pin('P0')
dir_pin = Pin('P1')

my_stepper = Stepper(step_pin,dir_pin)

print("relative angle move test begin:", my_stepper.read_pos())
my_stepper.rel_angle(180)#相对角度控制
print("relative angle move test end:", my_stepper.read_pos())

time.sleep_ms(1000)

print("steps angle move test end:", my_stepper.read_pos())
my_stepper.steps(-400)#步进脉冲控制
print("steps angle move test end:", my_stepper.read_pos())

time.sleep_ms(1000)

print("absolute angle move test begin:", my_stepper.read_pos())
my_stepper.abs_angle(0)#绝对角度控制
print("absolute angle move test end:", my_stepper.read_pos())

time.sleep_ms(1000)

DC Motor

教程26 - 电机扩展版控制直流电机:https://singtown.com/video

What is DC Motor?

The rotation speed of DC motor is in direct proportion to voltage.

Driving module

Numerous driving module can drive DC motor,here we use TB6612FNG,double H shape bridge.

Wiring

Code

Waiting to add

Servo

OpenMV2 has two pin for servo,P7,P8

OpenMV2 has three pin for servo,P7,P8,P9

Wire

Check power

Servo belongs to equipment with huge current.in such a case,external power source must be used(stabilized voltage supply,lithium battery and so on), USB是无法给舵机供电的!

Code

# Servo Control Example
#
# This example shows how to use your OpenMV Cam to control servos.

import time
from pyb import Servo

s1 = Servo(1) # P7
s2 = Servo(2) # P8
#s3 = Servo(3) # P9 Only for OpenMV3 M7
while(True):
    for i in range(-90,90):
        s1.angle(i)
        s2.angle(i)
        time.sleep_ms(10)
    for i in range(90,-90):
        s1.angle(i)
        s2.angle(i)
        time.sleep_ms(10)

PCA9685连接多个舵机

宝贝链接:https://singtown.com/product/49277

视频教程25 - pca9685控制多个舵机:https://singtown.com/learn/50057/

PCA9685模块,只使用2个引脚(I2C协议),就可以控制16个PWM通道,也就是16个舵机或者16个LED灯。你甚至可以连接62个模块,依然只用2个引脚,可以控制992个PWM!

连线

代码

点击运行,即可

results matching ""

    No results matching ""