Time lapse setup
Time lapse setup
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
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.
Re: Time lapse setup
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.
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:
- https://picamera.readthedocs.org/en/release-1.9/ Seer the Basic Recipe section on how to operate the RPi Camera via Python
- http://raspi.tv/2013/how-to-use-wiringp ... n-raspbian how to use Python WiringPi to control and monitor GPIO pins
I haven't played around much with an Arduino, but happy to help out on the RPi side of things.
Re: Time lapse setup
Hmm, rereading your initial post, you could do something like this:
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.
- take a RPi camera photo
- raise RPi pin high (to notify Arduino that's the RPi has finished taking photo)
- Arduino sees the RPi pin go high
- Arduino moves servo X (if it needs to)
- Arduino moves server Y (if it needs to)
- Has any of the Servos reached their 180 degree limit (or are you using 360 deg. continuous servers?)
- Arduino raise one of it's pins high (to notify the RPi that it's finished moving the servos)
- RPi monitors the Arduino pin to see when it's ready to take another photo
- 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.
Re: Time lapse setup
this FREE magazine has a lot of interesting tutorials: http://www.raspberrypi.org/magpi/
Happy reading!
Happy reading!
Re: Time lapse setup
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
#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.
Re: Time lapse setup
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?
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?
Re: Time lapse setup
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.
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.
Re: Time lapse setup
Bring it along on Sat. if your coming. Love to see it all ![Smile :)](./images/smilies/icon_e_smile.gif)
![Smile :)](./images/smilies/icon_e_smile.gif)
Re: Time lapse setup
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. ![Wink ;)](./images/smilies/icon_e_wink.gif)
![Wink ;)](./images/smilies/icon_e_wink.gif)
I know everything about nothing.
Re: Time lapse setup
All the best with the recovery and hope to see you at the next meeting!
Re: Time lapse setup
Welcome the the club!!
It gets better over time.
It gets better over time.
Re: Time lapse setup
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
![Smile :)](./images/smilies/icon_e_smile.gif)
BLOG: https://my.makeraddiction.com/
Thingiverse: https://www.thingiverse.com/seaton/
Github: https://github.com/madeinoz67
Thingiverse: https://www.thingiverse.com/seaton/
Github: https://github.com/madeinoz67