logo

使用LCD模块,3分钟就死机,请问是什么原因?

2022-09-19 07:42
S
pso6

前几天买了OpenMV4 Cam H7 R2 ,运行正常,为了调试方便,购买了一块LCD模块,在PC上调试一切正常,偶尔提示 Fame Capable Time out.

但是只要脱机运行,运行不要几分钟就泵机了,请问大家遇到过么?该怎么解决这个问题?

import sensor, image, time, math,lcd
thresholds = [(0, 58, 7, 67, -16, 127),
           (0, 47, -128, 6, -128, 28)]
DisplayColor=[(0,0,0),(255,0,0),(0,0,0),(0,0,255)]
PraRoi=(185,106,12,27)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 10000)
sensor.set_auto_gain(True)
sensor.set_auto_whitebal(True)
lcd.init()
clock = time.clock()
lcd.set_backlight(50)
i=1
dcx=0
dcy=0
while(True):
    clock.tick()
    img = sensor.snapshot()
    codenum=0
    img.draw_rectangle(PraRoi,color=(0,255,0))
    for blob in img.find_blobs(thresholds,roi=PraRoi, pixels_threshold=10, area_threshold=10,merge=False):
        img.draw_edges(blob.min_corners(), color=(255,0,0))
        if blob.code()==1 :
                 codenum=1
                 dcx=int(blob.cx())
                 dcy=int(blob.cy())
                 img.draw_string(5,5,str(blob.code())+"x"+str(dcx)+" y"+str(dcy),scale = 2)
        elif  blob.code()==2:
                 img.draw_string(5,35,str(blob.code())+"x"+str(blob.cx())+" y"+str(blob.cy()),scale = 2)
                 deltaX=" x"+"{0:>3}".format(str(blob.cx()-dcx))
                 deltaY=" y"+"{0:>3}".format(str(blob.cy()-dcy))
                 img.draw_string(5,60,deltaX+deltaY,scale = 2)
                 codenum=2
                 if  blob.cx()-dcx <0 or blob.cx()-dcx >50  :
                     img.draw_string(5,80,str(i)+deltaX+deltaY,scale = 2,color=(255,0,0))
                     i=i+1
                     if i>30 :
                        i=0
                        dcx=blob.cx()
                        dcy=blob.cy()
        img.draw_cross(blob.cx(), blob.cy(),color=DisplayColor[blob.code()])
    lcd.display(img,x_scale=0.4,x_scale=0.6)
    print(clock.fps())

泵机以后LCD模块全亮,画面静止不动。

2022-09-20 09:19
S
pso6

经过一天的分析和实验,

先说结论:MCU性能不够

分析原因可能有三个

(1)可能使用了自动增益和白平衡,运算量增大。(提供了光源,光源切换不久就泵机了。)

(2)blobs分析 运算量大(发热量明显增加,这个可能是正常的温升)

(3) LCD模块需要显示整个摄像头的图像 增加了 Scale ,导致运算量加大。(目前只是猜测)

目前解决方法:

因为工业设备中用光源是必须提供的,增加28*28*10的散热片, 降了5-10°的样子(昨天MCU烫手,今天散热片摸起来烫但不明显),放弃LCD的Scale, Blobs分析的Roi 区域调整,将显示字符串的位置调整,方便调试

状况:

目前已经跑了一个晚上,目前一切正常,今天继续试跑一天。

后续增加补光模块,用Pin控制LED用于程序运行状态的显示。

2022-09-26 11:38
S
pso6

2楼的分析可能是错的,问题依旧没有解决!

请大家给分析一下是什么原因!

为了解决散热,我将整个模块从保护壳(自制滴塑料密封结构)拿到室内环境,

泵机现象再次出现。

泵机前,主板上的红色的ED闪几下,然后LCD屏突然最亮(亮度最大,图像停止更新!),MCU芯片温度无异常(估计30-40摄氏度而已)。

我要崩溃了。

这个问题不解决,产线上使用的想法是泡汤了。请问大家是否遇到过这个现象,能帮我分析一下原因么?

2022-09-26 20:21
I
网红小智智 星瞳科技

你脱机运行的电源是什么?使用USB供电脱机运行是否正常?

2022-09-27 13:43
S
pso6

绿联的7口USB3.0 HUB, 绿联的供电电源是12V2A。

2022-09-27 18:34
I
网红小智智 星瞳科技

你用电脑的USB脱机运行也会死机吗?

2022-09-27 18:42
I
网红小智智 星瞳科技

可有可能是代码在哪里报错了,脱机运行看不到。

可以在代码最外面加 try, 如果捕获异常就闪灯

import sensor, image, time
sensor.reset()                      # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA)   # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000)     # Wait for settings take effect.
clock = time.clock()                # Create a clock object to track the FPS.

try:
    # raise "error"
    while(True):
        clock.tick()                    # Update the FPS clock.
        img = sensor.snapshot()         # Take a picture and return the image.
        print(clock.fps())              # Note: OpenMV Cam runs about half as fast when connected
                                        # to the IDE. The FPS should increase once disconnected.
except:
    from pyb import LED
    
    red_led   = LED(1)
    while(True):
        red_led.on()
        time.sleep_ms(1000)
        red_led.off()
        time.sleep_ms(1000)
2022-09-30 11:13
S
pso6

@kidswong999 在 [使用LCD模块,3分钟就死机,请问是什么原因?](/post/27331) 中说:

> 你用电脑的USB脱机运行也会死机吗?

一样的,电源的可能性个人感觉不可能,因为没有其它需要大电流的设备,每个USB口至少应该有500mA的电流(手机充电试过了电流应该可以到2A)。

2022-09-30 11:19
S
pso6

@kidswong999 在 [使用LCD模块,3分钟就死机,请问是什么原因?](/post/27332) 中说:

> 可有可能是代码在哪里报错了,脱机运行看不到。

>

> 可以在代码最外面加 try, 如果捕获异常就闪灯

>

>

> ```

> import sensor, image, time

> sensor.reset() # Reset and initialize the sensor.

> sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)

> sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)

> sensor.skip_frames(time = 2000) # Wait for settings take effect.

> clock = time.clock() # Create a clock object to track the FPS.

>

> try:

> # raise "error"

> while(True):

> clock.tick() # Update the FPS clock.

> img = sensor.snapshot() # Take a picture and return the image.

> print(clock.fps()) # Note: OpenMV Cam runs about half as fast when connected

> # to the IDE. The FPS should increase once disconnected.

> except:

> from pyb import LED

>

> red_led = LED(1)

> while(True):

> red_led.on()

> time.sleep_ms(1000)

> red_led.off()

> time.sleep_ms(1000)

>

> ```

谢谢,为了直观,我增加了一个记录用时(秒)的计算 ,并在LCD上显示:

import sensor, image, time, math,lcd,pyb
thresholds = [(0, 58, 7, 67, -16, 127),
		   (0, 47, -128, 6, -128, 28)]
DisplayColor=[(0,0,0),(255,0,0),(0,0,0),(0,0,255)]
PraRoi=(75,75,20,84)
sensor.reset()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 5000)
sensor.set_auto_gain(True)
sensor.set_auto_whitebal(True)
lcd.init()
clock = time.clock()
lcd.set_backlight(50)
i=1
dcx=0
dcy=0
t1=pyb.millis()
while(True):
	clock.tick()
	img = sensor.snapshot()
	codenum=0
	img.draw_rectangle(PraRoi,color=(0,255,0))
	for blob in img.find_blobs(thresholds,roi=PraRoi, pixels_threshold=20, area_threshold=20,merge=False):
		img.draw_edges(blob.min_corners(), color=(255,0,0))
		if blob.code()==1 :
				 codenum=1
				 dcx=int(blob.cx())
				 dcy=int(blob.cy())
				 img.draw_string(5,5,str(blob.code())+"x"+str(dcx)+" y"+str(dcy),scale = 2)
		elif  blob.code()==2:
				 img.draw_string(5,35,str(blob.code())+"x"+str(blob.cx())+" y"+str(blob.cy()),scale = 2)
				 deltaX=" x"+"{0:>3}".format(str(blob.cx()-dcx))
				 deltaY=" y"+"{0:>3}".format(str(blob.cy()-dcy))
				 img.draw_string(5,60,deltaX+deltaY,scale = 2)
				 codenum=2
				 if  blob.cx()-dcx <0 or blob.cx()-dcx >50  :
					 img.draw_string(5,80,str(i)+deltaX+deltaY,scale = 2,color=(255,0,0))
					 i=i+1
					 if i>30 :
						i=0
						dcx=blob.cx()
						dcy=blob.cy()
		img.draw_cross(blob.cx(), blob.cy(),color=DisplayColor[blob.code()])
	t2=pyb.elapsed_millis(t1)/1000
	img.draw_string(5,130,str(int(t2)),scale = 4,color=(255,0,0))
	lcd.display(img,x_scale=0.4,x_scale=0.6)
	print(clock.fps())

结果是,基本不到200S以后就泵机了,运行的视频和泵机后的视频已经发给客服了,很奇怪的是,昨天有一次跑了大概4600s后泵机,今天还在跑看看具体情况。

节后买个独立电源。

2022-09-30 11:27
S
pso6

哦,忘了两个事,

1) 因为发热量大,散热块与摄像头有接触,可能高温影响了摄像头(几秒以后画面是黑白的),我将散热快调转了180°,摄像头温度降下来了。

2)换了一个焦距4.0的镜头,提高识别像素的分辨率。

其它的没有变动。

供大家参考分析