Camera DIY Module

Expansion modules and attachments
Post Reply
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Camera DIY Module

Post by jsclownfish »

Hi all,

I am in the finishing up an old project that I started awhile ago. I have a webcam on the end of my tank, but it isn't great at really seeing things in the tank. I tried a wide lens which helps a bit on the broad perspective, but not on a specific area. I really just wanted to watch my clownfish spawning. :) The dolly is currently on my 75, but I wanted to be able to see a bigger tank when I move to the 6' tank. Anyway, the idea is to mount a camera dolly on the front of my aquarium so I can guide the webcam anywhere along the tank. :geek:

So I built this camera dolly similar to the post here http://computers.tutsplus.com/tutorials ... -cms-21539. :ugeek: I have mounted it on the tank and it seems to work pretty well. :)

The final step is to read in the camera position to the arduino controlling the Big Easy Driver https://www.sparkfun.com/products/12859. You can see it here in the works using a serial feed command from my computer...

https://www.youtube.com/watch?v=UWcj5e_zfvU

My question for the more arduino/engineering gifted folks is will the standard I2C connection to the RA system be OK with this? There is a lot more power going to the driver (12V, 2A), but it should be separate from the arduino power. I also recently purchased a power isolation board http://www.atlas-scientific.com/product ... r-iso.html which may offer some protection? I just don't want to cause havoc with the RA and the other components as a result of my amateur engineering.

Thanks for any advice/comments,
Jon
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Camera DIY Module

Post by lnevo »

This is so cool man.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Camera DIY Module

Post by rimai »

Nice :)
I think that isolator may do the job just fine.
Roberto.
fishi
Posts: 9
Joined: Sun Jan 18, 2015 1:30 pm

Re: Camera DIY Module

Post by fishi »

Awesome. I have wanted to do something like this for awhile. I dont think one cam will ever show the tank right so the ability to move it from afar would be awesome.

What did you use to mount the camera? It Specifically what is that black and white tube thing?
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Camera DIY Module

Post by jsclownfish »

The base is from OpenBuilds http://openbuildspartstore.com/mini-v-wheel-plate/ as part of the build and I just drilled a couple holes in the base and used this arm http://www.aliexpress.com/item/360-Rota ... 07229.html I had on the side of the tank.

-Jon
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Camera DIY Module

Post by jsclownfish »

I finally got the I2C communication working with my controller box and it works! :ugeek:

It is really fun to mess with and I can't wait to use it a bit more, but I still have to work out some bugs. Here is a clip of it controlled from the RA and my phone. I made a little box with the Arduino, the BigEasy Driver and a little board to receive the I2C signal input, and some LEDs to tell me if it is working even if the motor isn't.

https://www.youtube.com/watch?v=KJ7EDLtV59Q

1. If someone is a robotics guru, I think the driver heats up a bit in the box and therefore is a bit choppy when it moves a long distance. Maybe a fan or a bigger driver is needed? It runs smoothly when it's first started and acts up a bit when warm. I tried to use the enable setting to keep it off while not moving, but it stays hot. :?

2. The power isolator doesn't seem to work when I test it and the RA blinks the red led when it is inline between the add-on and the RA. I have it with the IN from the RA to the OUT add-on. Maybe that's backwards? I set it up that way as the power comes into the add-on Arduino from the I2C lines. It works fine, just makes me a bit nervous that the 12V 2A power to the motor could cause a problem.

3. I haven't figured out an elegant solution for the camera wire. It just looks ugly hanging below the track.

Any suggestions are welcome. :D Here's the Arduino code if anyone is interested (the // out code is debugging with the Serial feed)

Code: Select all

// stepper motor receive code from the RA 
// designed to input a position from the serial integer input then go to it on the dolly

#include <Wire.h>


int stp = 13;  //connect pin 13 to step
int dir = 12;  // connect pin 12 to dir
int enb = 11;  //enable pin for motor sheild
int ledred = 10;  //led poweron
int ledgreen = 9;  //led moving forward
int ledyellow = 8;  //led moving backward
int pos = 0;     //  gen counter
int newpos = 0;     // last request for a position
long dis = 0;     // calculated distance
long dist =0;
String readString;
int endx = 9500;   //end of the line
char rx_byte = 0;
String rx_str = "";
boolean not_number = false;


void setup() 
{
  Wire.begin(11); // I2C address 1q
  Wire.onReceive(receiveEvent);  
  Serial.begin(9600);
  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);
  pinMode(enb, OUTPUT);
  pinMode(ledred, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(ledyellow, OUTPUT);
  digitalWrite(ledred, HIGH);
  digitalWrite(ledyellow, LOW);
  digitalWrite(ledgreen, LOW);

}


void loop() 
{

//  Readint();
  MoveCam();
}

void MoveCam()
{
  digitalWrite(enb,HIGH);
  if (newpos != pos) 
   {
     digitalWrite(enb,LOW);
     if (newpos > pos)
     { 
      dis = newpos-pos;
      if (newpos>endx) 
      {
       digitalWrite(ledgreen, HIGH);
       digitalWrite(ledyellow, HIGH);
       newpos = 9500;
      }
      else
      {
//      Serial.print("Distance forward: ");
//      Serial.println(dis);
//      Serial.print ("current position   ");
//      Serial.println (pos);
//      Serial.print ("new position   ");
//      Serial.println (newpos);
      digitalWrite (dir, HIGH);    
      dist = dis*10;  
      for (int i=0; i < dist; i++)
      {
       digitalWrite(ledgreen, HIGH);
       digitalWrite(stp, HIGH);   
       delayMicroseconds(100);               
       digitalWrite(stp, LOW);  
       delayMicroseconds(100); 
      }
      digitalWrite(ledgreen, LOW);
//      Serial.print("Current Position from: ");
//      Serial.print(pos);
      pos=newpos;  //set the current position for comparison next time
//      Serial.print("   to    ");
//     Serial.println(pos);
      digitalWrite(enb, HIGH);
     }
   }
   else if (newpos < pos)
   {
      dis = pos-newpos;  
//      Serial.print("Distance backward: ");
//      Serial.println(dis);
      dist = dis*10;  
      digitalWrite (dir, LOW);      
      for (int i=0; i < dist; i++)
      {
       digitalWrite(ledyellow, HIGH);
       digitalWrite(stp, HIGH);   
       delayMicroseconds(100);               
       digitalWrite(stp, LOW); 
       delayMicroseconds(100); 
      }
      digitalWrite(ledyellow, LOW);
//      Serial.print("Current Position from: ");
//      Serial.print(pos);
      pos =newpos;  //set the current position for comparison next time
//     Serial.print("   to    ");
//      Serial.println(pos); 
      digitalWrite(enb, HIGH);    
     }
   }
}
  


void Readint()
{
  if (Serial.available() > 0) {    // is a character available?
    rx_byte = Serial.read();       // get the character
    if (rx_byte == 'p') {
      Serial.print ("current position   ");
      Serial.println (pos);
      Serial.print ("new position   ");
      Serial.println (newpos);
      Serial.print ("distance   ");
      Serial.println (dis);
      not_number = true;    // flag a non-number
    }    
    else if (rx_byte == '\n') {
      rx_str = "";                // clear the string for reuse
   }
  } 
}


void receiveEvent(int howMany) 
{
  if (howMany==5)  // Our custom protocol is 13 bytes
  {
    byte cmd1,cmd2,cmd3,cmd4,cmd5;

    cmd1=Wire.read();
    cmd2=Wire.read();
    cmd3=Wire.read();
    cmd4=Wire.read();
    cmd5=Wire.read();

    if (cmd1=='%' && cmd2=='%' && cmd3=='%') // the first 3 bytes of the custom protocol are $$$ to ensure it's coming from RA
    {
      newpos=(cmd4<<8)+cmd5;
    }
  }
  else
    for (int a=0;a<howMany;a++)
      Wire.read(); // if the number of bytes is not 32, discard everything
}
-Jon
User avatar
jsclownfish
Posts: 378
Joined: Mon Oct 24, 2011 7:52 pm
Location: Saint Louis

Re: Camera DIY Module

Post by jsclownfish »

I just stumbled on these Arduino polargraphs...https://www.youtube.com/watch?v=2TiCZmJC9aU
I'm thinking this might have to be Camera dolly version 2. :)

-Jon
Post Reply