I’m trying to build a heliostat using an openmvcam. A heliostat is a device that tracks the sun and employs a mirror to reflect it to the same target through the day. Basically I will attach a Mirror to a 2 axis (pan/tilt) mount and let the camera take control over the servos. The camera will face the mirror and makes sure that the sun always stays in the center of the frame. So the camera in the same direction as the target.
So far I attached the openmvcam to a 2 axis gimbal mount (very cheap one I have to say)
I used a lamp for my model sun for now, and attached a Kodak Wratten #88A Filter to the lens. This is an infrared-pass sensor that will only let wavelengths above 800nm or so through. I thought this might make the image simpler.
The code I took from various threads and the blob detection example. (THANKS!)
import sensor, image, time grey_threshold = (50, 255) # You may need to tweak he above settings for tracking green things... # Select an area in the Framebuffer to copy the color settings. sensor.reset() # Initialize the camera sensor. sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed. sensor.skip_frames(10) # Let new settings take affect. sensor.set_whitebal(False) # turn this off. clock = time.clock() # Tracks FPS. sensor.set_vflip(True) #invert display camera is mounted upside down! from pyb import Servo #x_pos = 1200 # default #y_pos = 1200 # default x_min = 1000 x_max = 1800 y_max = 1800 y_min = 1000 x_gain = 1.00 # You have to tweak this value to stablize the control loop. # You also may need to invert the value if the system goes # in the wrong direction. y_gain = -2.00 # You have to tweak this value to stablize the control loop. # You also may need to invert the value if the system goes # in the wrong direction. xServo = Servo(1) yServo = Servo(2) x_pos=1000 y_pos=1000 #xServo.pulse_width(x_pos) #yServo.pulse_width(y_pos) while (True): clock.tick() img = sensor.snapshot() blobs = img.find_blobs([grey_threshold]) if blobs: for b in blobs: img.draw_cross(b, b) x = b y = b x_error = x - (img.width()/2) y_error = y - (img.height()/2) x_pos += x_error * x_gain y_pos += y_error * y_gain # Clamp output between min and max if (x_pos > x_max): x_pos = x_max if (x_pos < x_min): x_pos = x_min # Clamp output between min and max if (y_pos > y_max): y_pos = y_max if (y_pos < y_min): y_pos = y_min xServo.pulse_width(int(x_pos)) yServo.pulse_width(int(y_pos))
right now it will track a lamp perfectly ok in X dimension but if I activate Y (up and down) everything will crash and the mount moves violently. The cam actually gets dismounted from linux. If I manually set pulses in a test script the mount moves well in both directions. I don’t know if i am missing something. I’ve tried different y_gain variables but I don’t see any improvements.
Any help would be appreciated, even if you guys tell me to get a better servo mount