Time lapse setup

Post Reply
DylanM
Maker in Training
Posts: 65
Joined: Sun Jun 22, 2014 8:39 pm
Location: Gelorup

Time lapse setup

Post by DylanM » Mon Mar 30, 2015 6:04 pm

Hi, Since I'm not the best with script (unless its visual) I was wondering if someone could help me with my raps time-lapse build.
Setup:
two servos x and y axis
one camera
Arduino
raspi

I did some research and found that you can set a raspi pin to HIGH and that can tell the arduino to turn the servo but I was wondering first how to do the raps programming so that when a photo is about to be shot it sets the pin to HIGH and second how to make sure that the audio only turns the servos 5 degrees each time.

Thanks
Dylan
I know everything about nothing.

parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Time lapse setup

Post by parkview » Mon Mar 30, 2015 8:19 pm

Hi Dylan,

I presume you have a RPi Camera? When doing a new project, I find it's good to break things down into sections and work on each section until it's working, then 'glue' them together so to speak.

Can you list out the steps, and what you have does so far, ie: can the RPi take a photo via Python scripting? How do you have the RPi communicating with the Arduino? Can you make a LED light up? Can you monitor a switch being turned on/off. Can you monitor a switch that then turns a LED on/off, all under Python control?

When you say a pin is going HIGH, do you mean the Arduino pin goes high and then the RPi see's that and then takes a RPi photo?

I don't understand what you mean by the audio part?

I presume your using the Arduino to control the servos?

Here are some RPi links for you to look into:


I haven't played around much with an Arduino, but happy to help out on the RPi side of things.

parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Time lapse setup

Post by parkview » Mon Mar 30, 2015 8:34 pm

Hmm, rereading your initial post, you could do something like this:

  1. take a RPi camera photo
  2. raise RPi pin high (to notify Arduino that's the RPi has finished taking photo)
  3. Arduino sees the RPi pin go high
  4. Arduino moves servo X (if it needs to)
  5. Arduino moves server Y (if it needs to)
  6. Has any of the Servos reached their 180 degree limit (or are you using 360 deg. continuous servers?)
  7. Arduino raise one of it's pins high (to notify the RPi that it's finished moving the servos)
  8. RPi monitors the Arduino pin to see when it's ready to take another photo
  9. go back to step 1

Essentially, you have each device monitoring a different pin to see when it can do it's bit.

there are other ways of doing this, in that the RPi could communicate via the i2c bus, or USB, or Serial ports but that can get quite tricky.

parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Time lapse setup

Post by parkview » Tue Mar 31, 2015 10:27 pm

this FREE magazine has a lot of interesting tutorials: http://www.raspberrypi.org/magpi/

Happy reading!

DylanM
Maker in Training
Posts: 65
Joined: Sun Jun 22, 2014 8:39 pm
Location: Gelorup

Re: Time lapse setup

Post by DylanM » Wed Apr 08, 2015 8:48 pm

My code so far is this:
#include <Servo.h>

Servo myservo;

int pos = 0;

void setup()
{
pinMode( 2 , INPUT);
pinMode( 13 , OUTPUT);
myservo.attach(9);
}

void loop()
{
for(pos = 0; pos <= 180; pos += 1);
int sensorVal = digitalRead(2);
{
if (sensorVal == HIGH) {
digitalWrite(13, LOW);
myservo.write(pos);
}
else {
digitalWrite(13, HIGH);
}
}
}

However the variable I have (which I copied and pasted because I thought it would work) makes the servo move all the way to 180 degrees instead of moving in increments of 1 degrees to 180 degrees (like the desc. said it would) each time pin 2 goes high.
So my real problem here is I don't understand how these variables work and I need a variable that goes in increments of 1 degrees each time a button is pressed.

Thanks
Dylan
I know everything about nothing.

parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Time lapse setup

Post by parkview » Wed Apr 08, 2015 10:04 pm

Hi Dylan,

well done with the code so far. To help troubleshoot things, you could forget about the input/output pins for the moment, and just concentrate on getting the servo moving smoothly, perhaps moving from 0 to 180deg. with a 0.3-0.5 sec pause/delay between each step?

Once you have the servo motor moving properly, then you could integrate in the control and monitoring (in/out) pins. As I am not an Arduino programmer, I found these two links (amongst many) when I Googled: arduino servo

https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors?view=all

http://arduino.cc/en/Reference/ServoWrite ; will this code work for you? Does the servo move to roughly 90 deg? Can you manually plug in other values to have to move to those?

Just thinking about it, you don't have a delay statement (http://playground.arduino.cc/Code/AvoidDelay) you could try adding in a delay(500) to see what happens. It could be that the code is running flat out, ie: moving from 0 to 180 as it should be, just very fast?

Try putting a print statement in on the RPi side, so you can track and count how many times it's running through a loop of raising the pin high and seeing the other pin going low etc.

another thought, you could try with no RPi in place, carefully manually pressing a button to see if the code works while the button lifts pin 2 high.

Maybe RPi is raising Pin 2 high, but the RPi isn't monitoring pin 13 correctly?

DylanM
Maker in Training
Posts: 65
Joined: Sun Jun 22, 2014 8:39 pm
Location: Gelorup

Re: Time lapse setup

Post by DylanM » Fri Apr 10, 2015 9:22 pm

Hi,

As you mentioned with the push button I have been working on that and I will give those links a go and add in the delay because I've seen in another code sample something similar and they had quite a few delays.
I know everything about nothing.

parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Time lapse setup

Post by parkview » Fri Apr 10, 2015 9:56 pm

Bring it along on Sat. if your coming. Love to see it all :)

DylanM
Maker in Training
Posts: 65
Joined: Sun Jun 22, 2014 8:39 pm
Location: Gelorup

Re: Time lapse setup

Post by DylanM » Sun Apr 12, 2015 1:14 pm

Hi couldn't be at this weeks meeting but I should be at next months one. Unfortunately I managed to get bit by a mosquito carrying rossriver so I haven't been very mobile most of the beginning of this year. So far only finger joints have been affected and I've been quite tired but hopefully I should be back to doing most things next month. ;)
I know everything about nothing.

parkview
Guru Maker
Posts: 603
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Time lapse setup

Post by parkview » Mon Apr 13, 2015 7:48 am

All the best with the recovery and hope to see you at the next meeting!

User avatar
Jubbp
Master Maker
Posts: 209
Joined: Sun Jun 22, 2014 8:15 pm
Location: Bunbury WA
Contact:

Re: Time lapse setup

Post by Jubbp » Tue Apr 14, 2015 3:43 pm

Welcome the the club!!

It gets better over time.

User avatar
seaton
Master Maker
Posts: 222
Joined: Tue Jun 24, 2014 11:41 am
Location: Bunbury, WA
Contact:

Re: Time lapse setup

Post by seaton » Thu Apr 16, 2015 3:46 pm

DylanM wrote:Hi couldn't be at this weeks meeting but I should be at next months one. Unfortunately I managed to get bit by a mosquito carrying rossriver so I haven't been very mobile most of the beginning of this year. So far only finger joints have been affected and I've been quite tired but hopefully I should be back to doing most things next month. ;)


Hope you are feeling better soon, at least you can use that as an excuse to play with your Arduino and RPi :)

Post Reply