>>> 星瞳科技|OpenMV中国官方网站 <<<

>>> 星瞳科技店铺地址|OpenMV中国官方代理,全球九大代理商之一 <<<

>>> OpenMV3 Cam M7 官方高配版上市啦~戳我戳我戳我~ <<<

>>> 星瞳科技-OpenMV中文教程网 <<<

原文:
https://openmv.io/docs/openmv/quickref.html

摄像头的简要信息 FAQ

  • 供电的电压范围(不用USB)?
    VCC/VIN 必须小于7V. 我们推荐 5V 输入.

  • USB电源和外置电源可以同时供电吗?
    可以,VCC/VIN 引脚 和 USB供电是或逻辑,这个或逻辑电路保护你的OpenMV摄像头

  • 电流消耗是多少?
    大概150mA。 这其实决定于你做什么。比如写入图片/视频到SD卡会增加消耗电流。

  • 板上的3.3V引脚可以引出多大的电流?
    稳压器的额定电流为500mA。你应该可以从这个引脚安全的输出150mA。请注意,如果你通过USB供电,并使用将近500mA的电流,你可能遇到限电。

  • 这些引脚兼容5V的逻辑吗(5V tolerant)?

PIN_0 == PB15 -> 5V 兼容 (3.3V 输出) (I/O)
PIN_1 == PB14 -> 5V 兼容 (3.3V 输出) (I/O)
PIN_2 == PB13 -> 5V 兼容 (3.3V 输出) (I/O)
PIN_3 == PB12 -> 5V 兼容 (3.3V 输出) (I/O)
PIN_4 == PB10 -> 5V 兼容 (3.3V 输出) (I/O)
PIN_5 == PB11 -> 5V 兼容 (3.3V 输出) (I/O)
PIN_6 == PA5 -> 5V 兼容 (3.3V 输出) (I/O)
    在ADC模式下,这个引脚模拟信号0V-3.3V输入(不是5V兼容)
    在DAC模式下,这个引脚模拟信号0V-3.3V输出(不是5V兼容)
PIN_7 == PD12 -> 5V 兼容 (3.3V 输出) (I/O)
PIN_8 == PD13 -> 5V 兼容 (3.3V 输出) (I/O)

再次强调,在ADC/DAC模式下 PIN_6(PA5)不是5V兼容的。

  • 每个引脚的最大输出电流是多少?
PIN_0 == PB15 -> 25mA 拉电流或灌电流
PIN_1 == PB14 -> 25mA 拉电流或灌电流
PIN_2 == PB13 -> 25mA 拉电流或灌电流
PIN_3 == PB12 -> 25mA 拉电流或灌电流
PIN_4 == PB10 -> 25mA 拉电流或灌电流
PIN_5 == PB11 -> 25mA 拉电流或灌电流
PIN_6 == PA5 -> 25mA 拉电流或灌电流
PIN_7 == PD12 -> 25mA 拉电流或灌电流
PIN_8 == PD13 -> 25mA 拉电流或灌电流

我们强烈建议不要用I/O引脚去直接给大负载供电,而是使用I/O引脚去驱动一个三极管来给负载供电。

  • LCD 扩展版使用了哪几个I/O引脚?

    PIN_0 (PB15), PIN_2 (PB13), PIN_3 (PB12), PIN_6 (PA5), PIN_7 (PD12), 和PIN_8 (PD13).
    如果你需要,可以通过切断LCD拓展板背面的走线,断开PIN_6(PA5)。

  • 红外拓展板使用哪几个I/O引脚?
    PIN_4 (PB10) 和 PIN_5 (PB11).

pyb控制

详见pyb

import pyb

pyb.delay(50) # wait 50 milliseconds
pyb.millis() # number of milliseconds since bootup
pyb.repl_uart(pyb.UART(2, 9600)) # duplicate REPL on UART(2) - first argument must be 2 - don't use anything else.
pyb.wfi() # pause CPU, waiting for interrupt
pyb.freq() # get CPU and bus frequencies
pyb.freq(60000000) # set CPU freq to 60MHz
pyb.stop() # stop CPU, waiting for external interrupt

LEDs

详见 pyb.LED

from pyb import LED

led = LED(1)
led.toggle()
led.on()
led.off()

备注:

LED_R == 1 (内置红色LED)
LED_G == 2 (内置绿色LED)
LED_B == 3 (内置蓝色LED)
LED_I == 4 (内置红外LED)

引脚

详见pyb.Pin

from pyb import Pin

p_out = Pin('PB15', Pin.OUT_PP)
p_out.high()
p_out.low()

p_in = Pin('PB15', Pin.IN, Pin.PULL_UP)
p_in.value() # get value, 0 or 1

备注:

PIN_0 == PB15
PIN_1 == PB14
PIN_2 == PB13
PIN_3 == PB12
PIN_4 == PB10
PIN_5 == PB11
PIN_6 == PA5
PIN_7 == PD12
PIN_8 == PD13

舵机控制

详见pyb.Servo

from pyb import Servo

s1 = Servo(1) # servo on position 1 (PB15, VIN, GND)
s1.angle(45) # move to 45 degrees
s1.angle(-60, 1500) # move to -60 degrees in 1500ms
s1.speed(50) # for continuous rotation servos

备注:

Servo1 == PB15
Servo2 == PB14
Servo3 == PB13
Servo4 == PB12

外部中断

详见 pyb.ExtInt

from pyb import Pin, ExtInt

callback = lambda e: print("intr")
ext = ExtInt(Pin('PB15'), ExtInt.IRQ_RISING, Pin.PULL_NONE, callback)

时钟

详见pyb.Timer

from pyb import Timer

tim = Timer(1, freq=1000)
tim.counter() # get counter value
tim.freq(0.5) # 0.5 Hz
tim.callback(lambda t: pyb.LED(PB15).toggle())

PWM (宽度脉冲调制)

详见pyb.Pinpyb.Timer

from pyb import Pin, Timer

p = Pin('PB15') # PB15 has TIM2, CH1
tim = Timer(2, freq=1000)
ch = tim.channel(1, Timer.PWM, pin=p)
ch.pulse_width_percent(50)

备注

PIN_0 == PB15
PIN_1 == PB14
PIN_2 == PB13
PIN_3 == PB12
PIN_4 == PB10
PIN_5 == PB11
PIN_6 == PA5
PIN_7 == PD12
PIN_8 == PD13

ADC (analog to digital conversion)

详见pyb.Pin 和 :pyb.ADC

from pyb import Pin, ADC

adc = ADC(Pin('PA5'))
adc.read() # read value, 0-4095

备注:

PIN_ADC == PA5
0-3.3V == 0-4095

DAC (digital to analog conversion)

详见pyb.Pinpyb.DAC

from pyb import Pin, DAC

dac = DAC(Pin('PA5'))
dac.write(120) # output between 0 and 255

备注:

PIN_DAC == PA5

UART (串口)

详见pyb.UART

from pyb import UART

uart = UART(3, 9600) # first argument must be 3 - don't use anything else
uart.write('hello')
uart.read(5) # read up to 5 bytes

备注:

PIN_TXD == PB10
PIN_RXD == PB11
PIN_RTS == PB14
PIN_CTS == PB13

SPI bus

详见pyb.SPI

from pyb import SPI

spi = SPI(2, SPI.MASTER, baudrate=200000, polarity=1, phase=0) # first argument must be 2 - don't use anything else
spi.send('hello')
spi.recv(5) # receive 5 bytes on the bus
spi.send_recv('hello') # send a receive 5 bytes

备注:

PIN_MOSI == PB15
PIN_MISO == PB14
PIN_SCLK == PB13
PIN_SS == PB12

I2C bus

详见pyb.I2C

from pyb import I2C

i2c = I2C(2, I2C.MASTER, baudrate=100000) # first argument must be 2 - don't use anything else
i2c.scan() # returns list of slave addresses
i2c.send('hello', 0x42) # send 5 bytes to slave with address 0x42
i2c.recv(5, 0x42) # receive 5 bytes from slave
i2c.mem_read(2, 0x42, 0x10) # read 2 bytes from slave 0x42, slave memory 0x10
i2c.mem_write('xy', 0x42, 0x10) # write 2 bytes to slave 0x42, slave memory 0x10

备注:

PIN_SCL == PB11 (You must provide you own pull ups)
PIN_SDA == PB10 (You must provide you own pull ups)