EV3 Camera Controller

The Challenge

Recently I was forwarded an email from Rick Sanchez, a Technology/Astronomy teacher at Clear Creek Middle School in Buffalo WY regarding an interesting technology challenge he was working on with a student...

Hello all,

Attached are the photos of a project concept I have been working on with a student. The idea was to create a robot that could be programmed to take pictures of the sky at any altitude and direction. The photos attached show an example of the concept although it was not programmed. Just a design example.

Big idea is to give students an idea of what it takes to manage robotically controlled telescopes like Yerkes:

Bonus abilities

Please feel free to add more.

Rick sent these pictures of the work in progress:

Robot of Rick Sanchez Robot of Rick Sanchez Robot of Rick Sanchez Robot of Rick Sanchez Robot of Rick Sanchez Robot of Rick Sanchez Robot of Rick Sanchez Robot of Rick Sanchez Robot of Rick Sanchez Robot of Rick Sanchez Robot of Rick Sanchez

Challenge Accepted

I've also thought about a Lego Mindstorms project to simulate a telescope's control system so I decided to give it a try for fun to see how it would work for a 4-H project. Here's what I've got so far...

The first step was to come up with a way to hold my cell phone. I wanted an easy way to get the cell phone in and out yet still hold the phone securely.
Robot of Cliff Nieuwenhuis

Next, I thought about how the robot would tell the camera to take the picture. I decided against attempting a USB or Bluetooth control simply because the idea of doing it mechanically seemed more fun and I was intrigued by Rick's use of a stylus. My phone will take a picture if the volume button is pressed, so I designed a way for a motor to spin a gear that is linked to an arm that presses the button that takes the picture. (...that lives in the house that Jack built ☺️)
Robot of Cliff Nieuwenhuis Robot of Cliff Nieuwenhuis Robot of Cliff Nieuwenhuis

Even though I haven't even started on the problem of pointing the camera I wanted to see if the EV3 could actually take a picture by turning the motor. So I decided to test it by writing a quick test script:

Note: I use the EV3 Mindstorms Education kit, but I don't care for the EV3 software. Instead, I run ev3dev on the EV3 brick. Ev3dev is a Linux operating system that runs on the EV3 from a SD card. This is great because if I want to go back to the LEGO software, all I need to do is remove the SD card! The big benefit of using the ev3dev operating system is that it allows allows a programmer to control the EV3 devices with just about any programming language that runs on Linux, like Python, Javascript, C, C++, Lua, Java, FreePascal, and more. In my case, I just wrote a simple script.
Find out more about ev3dev here: http://www.ev3dev.org/

#!/bin/bash
#
# Turn the motor one time to press the camera button
#

# EV3dev allows a programmer to control an EV3 by reading and writing
# to files, just like one would read or write to a text file.
# All the files related to the motor that operates the camera switch
# are in a folder called /sys/class/tacho-motor/motor0, so I start by
# setting up a variable so I don't need to type that part out every time.

MOT=/sys/class/tacho-motor/motor0

# Provide some output for troubleshooting. The "echoed" text shows up on the EV3 screen.
echo "Get Ready"

# Reset the EV3
# Commands for the EV3 are made by using echo too, but in this case the output of echo
# is directed to the motor's command file instead of the screen.
echo reset > $MOT/command

# Next we set up the EV3 to operate the motor a specific way
echo "Get Set"

# When finished running the motor the EV3 should put breaks on
# (not coast to a stop)
echo break > $MOT/stop_command

# Tell the motor it's new target position (for EV3, 360 = 1 revolution)
# I chose 270 after sone trial and error because it makes the motor
# stop in the right place.

echo 270 > $MOT/position_sp

# Set the duty cycle. This is sort of a power setting.
# Valid settings are integers from -100 to 100. 0 = no power, 100 = max
# power, and -100 = max power but in the opposite direction!

echo 80 > $MOT/duty_cycle_sp

# Now make it happen!
echo "GO!!"
echo run-to-rel-pos > $MOT/command


echo "Finished"
exit 0;

Below is a video showing me securing my phone in the mount and then taking a few pictures. So far so good!

Next Steps

Now that I've got my phone in a LEGO holder, I'm going to start making the mount that will point the camera. I'll post progress photos here.

If you are interested in this project, or have suggestions, comments, or questions, feel free to contact me by email at cliff@nieusite.com.

 


LEGO® MINDSTORMS® Education EV3 Product Description

This pack includes all you need to teach using LEGO® MINDSTORMS® Education EV3 in a Homeschool setting. It enables students to build, program, and test their solutions based on real-life robotics technology. With the EV3 Core Set, EV3 Software and EV3 Expansion Set, students will be able to:

For more information see the Mindstorms page: https://education.lego.com/en-us/products/ev3-homeschool-combo-pack/5003480