为什么数字识别的lenet保存到CAM以后运行一直显示This function is unavailable on your OPENMV Cam
B
brgi
@brgi
0
声望
11
楼层
580
资料浏览
0
粉丝
0
关注
brgi 发布的帖子
-
有关于数字识别的问题?
-
RE: 想问下关于openmv直流电机的控制?
那么如果我不需要这个刹车功能的话,那么是不是也可以用两个引脚来控制电机正反转和速度了?一个引脚输出pwm信号给平均电压,一个高低电平变换来实现正反转?
-
有关于PCA9685的问题
为什么我按照官网上的例程复制的代码在控制舵机时一直会报错?
下面第一段是报错提示Traceback (most recent call last): File "<stdin>", line 10, in <module> File "servo.py", line 10, in __init__ File "pca9685.py", line 17, in __init__ File "pca9685.py", line 35, in reset File "pca9685.py", line 23, in _write OSError: [Errno 110] ETIMEDOUT MicroPython v1.9.4-4548-g24c934f79 on 2019-03-23; OPENMV4 with STM32H743 Type "help()" for more information. >>>
以下是官网复制的例程
import utime import ustruct class PCA9685: def __init__(self, i2c, address=0x40): self.i2c = i2c self.address = address self.reset() def _write(self, address, value): self.i2c.writeto_mem(self.address, address, bytearray([value])) def _read(self, address): return self.i2c.readfrom_mem(self.address, address, 1)[0] def reset(self): self._write(0x00, 0x00) # Mode1 def freq(self, freq=None): if freq is None: return int(25000000.0 / 4096 / (self._read(0xfe) - 0.5)) prescale = int(25000000.0 / 4096.0 / freq + 0.5) old_mode = self._read(0x00) # Mode 1 self._write(0x00, (old_mode & 0x7F) | 0x10) # Mode 1, sleep self._write(0xfe, prescale) # Prescale self._write(0x00, old_mode) # Mode 1 utime.sleep_us(5) self._write(0x00, old_mode | 0xa1) # Mode 1, autoincrement on def pwm(self, index, on=None, off=None): if on is None or off is None: data = self.i2c.readfrom_mem(self.address, 0x06 + 4 * index, 4) return ustruct.unpack('<HH', data) data = ustruct.pack('<HH', on, off) self.i2c.writeto_mem(self.address, 0x06 + 4 * index, data) def duty(self, index, value=None, invert=False): if value is None: pwm = self.pwm(index) if pwm == (0, 4096): value = 0 elif pwm == (4096, 0): value = 4095 value = pwm[1] if invert: value = 4095 - value return value if not 0 <= value <= 4095: raise ValueError("Out of range") if invert: value = 4095 - value if value == 0: self.pwm(index, 0, 4096) elif value == 4095: self.pwm(index, 4096, 0) else: self.pwm(index, 0, value)