【发布时间】:2020-09-25 21:21:18
【问题描述】:
我知道互联网上有很多关于 OV7670 的信息(例如http://forum.arduino.cc/index.php?topic=159557.0),我阅读了很多关于它的信息,但似乎缺少一些东西。
首先,我研究了如何从相机逐个像素地读取以构建矩形 600 X 480 图像,考虑到此处文档中描述的 HREF、VSYNCH 和 PCLOCK,这很容易理解: http://www.voti.nl/docs/OV7670.pdf。我将 XCLOCK 理解为我需要作为一种循环控制器提供给 OV7670 的输入,而 RESET 将用于重置它。
所以在这一点上,我认为这种相机的功能可以通过连接以下引脚来实现:
- D0..D7 - 用于连接到 arduino 数字引脚 0 到 7 的数据(像素)作为 arduino 板上的 INPUT
- XCLK - 用于连接到 arduino 数字引脚 8 的相机时钟作为 arduino 板的 OUTPUT
- PCLK - 用于连接到 arduino 数字引脚 9 的像素时钟作为 arduino 板上的 INPUT
- HREF - 定义线路何时开始/结束连接到 arduino 数字引脚 10 作为 arduino 板上的 INPUT
- VSYCH - 定义帧何时开始/结束连接到 arduino 数字引脚 11 作为 arduino 板上的 INPUT
- GRD - 接地连接到 arduino GRD
- 3V3 - 3,3 INPUT 连接到 arduino 3,3v
- RESET - 连接到arduino RESET
- PWDN - 连接到 arduino GRD
在我看来,这种方法的实现类似于: 代码:
for each loop function do
write high to XCLK
if VSYNCH is HIGH
return;
if HREF is LOW
return;
if lastPCLOCK was HIGH and currentPCLOCK is LOW
readPixelFromDataPins();
end for
我的readPixelFromDataPins()基本上只读取了第一个字节(因为我只是在测试我是否可以从相机中读取一些东西),它是这样写的:
代码:
byte readPixelFromDataPins() {
byte result = 0;
for (int i = 0; i < 8; i++) {
result = result << 1 | digitalRead(data_p[i]);
}
return result;
}
为了检查是否正在从相机读取某些内容,我只是将其打印到串行 9600,从数据引脚读取的字节作为数字。但目前我只收到零值。我用来检索图像的代码存储在这里:https://gist.github.com/franciscospaeth/8503747。
使 OV7670 与 Arduino 一起工作的人是否已经弄清楚我做错了什么?我想我用错了 XCLOCK 对吧?我该怎么做才能让它工作?
我搜索了很多,但没有找到任何使用 arduino 的相机的 SSCCE (http://sscce.org/),如果有人有请告诉我。
这个问题也出现在 arduino 论坛 (http://forum.arduino.cc/index.php?topic=211741.0) 上。
【问题讨论】: