Hello Mr. Kwagyeman,
I have used a simple program to turn off a machine using OpenMV cam H7. I used the following code from the example files found in the forum. The idea is that to stop the machine if the camera sense more pixels of red colour in the frame. In our production process, the colour will reveal slowly and we can sense the pixels and set a limit to send the stop signal.
import sensor, image, time, pyb
from pyb import LED
from pyb import Pin
red_led = LED(1)
green_led = LED(2)
p = pyb.Pin('P0', pyb.Pin.OUT_PP,pyb.Pin.PULL_NONE)
p.value(1)
def led_control(x):
if (x&1)==0: red_led.off()
elif (x&1)==1: red_led.on()
if (x&2)==0: green_led.off()
elif (x&2)==2: green_led.on()
threshold = (30, 100, 20, 127, 20, 127), # generic_red_thresholds (code 1)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
clock = time.clock()
while(True):
clock.tick()
img = sensor.snapshot()
blob_list = img.find_blobs(threshold, pixels_threshold=200, area_threshold=200)
red_bool = 0
green_bool = 0
for b in blob_list:
br = b.rect()
l = (b.w() + b.h())
lm = l/2
if b.code() & (lm < 140): # No stop - Started seeing colour
red_bool = 0
green_bool = 2
img.draw_rectangle(b.rect(), color=(255,0,0), thickness=2)
img.draw_cross(b.cx(), b.cy(), color=(255,0,0), thickness=2)
p.value(1)
elif b.code() & (lm > 140): # Stop - Colour intensity reached
green_bool = 0
red_bool = 1
pyb.delay(2000)
p.value(0)
led_control(red_bool | green_bool)
I used a 3VDC (3v to 24v relay to connect the OpenMV H7 to the machine’s switch.
I had an issue in sending the 3v completely as output. When I measure the output voltage, it shows 1.75 V and sometimes 1.5V.
And suddenly the openMV is not working and there is a message to the laptop saying that there is a power surge on the USB port. I think something damaged the circuit. When I plug it in again, it heats up quickly and doesn’t work.
Is there any solution for this or I need to buy another product?
If I am successful with this project, I will buy 36 to 40 more openMV and use it for all the machines in our production line. Kindly guide me through this project. Thank you.