DIY DIY Timelapse Camera : Pi-Lapse

yes, in fact its not really something specific to the pi to be honest. any system suffering voltage lows will exhibit one problem or the other. different flash chips would cope differently I imagine. but it seemed like others had had similar issue with the pi and I can understand why.
In my case I'd switched to powering the Pi from the GPIO port, more convenient as it reduced cabling. On the control box there is a 3.5A 5V supply that provides the USB hub, the control electronics and down to the Pi as well. I think that architecture was not coping under load and put a reasonable amount of impedance on the 5V supply rail as the Pi would see it. So the 5V would not be 5V at the Pi end of the cable, and it would dip even more when current is required. likely dangerously low for the flash.

something else to note, not all USB chargers and USB charge cables are the same. for the pi normally they recommend a 1.5 or 2A charger. Also the cable you use can determine the power going through. better thicker AWG cable is better. the cheap ebay cables dont do well for high speed charging..also some devices handle sync and charge-only cables differently, only charging at max rate from a charge-only cable.
I had this issue with my Nexus 7 tablet, it would drain faster than it would charge, very annoying. it was slow even when new, but this was painful.
In the end I ordered a couple things, a 3.5A high power charger adaptor, made specifically to fast charge tablets
and some usb cables up to the job. the difference was incredible, i use it for tablet, phone etc, its very good. right now it runs the pi and I have 2 more sets on order :)
http://www.amazon.co.uk/PortaPow-3-...=UTF8&qid=1387201060&sr=8-3&keywords=portapow
http://www.amazon.co.uk/PortaPow-Ch...=UTF8&qid=1387201070&sr=8-2&keywords=portapow

first tests with timelapse snaps ran overnight btw, it gathered 110 images in each of 4 different folders succesfully. day mode capture looks like its working , night mode not yet for some reason, will have a look at it later.
 
good progress since the last update, got the new system all working as far as it was before the SD crashed, and continued the debugging on from there.
Lots of little tweaks to the scripts since they are now running on timer as CRON jobs;


plmon.sh : checks every minute what time of "day" it is and sets the lights in the correct state. also checks the pause button, enables/disables the webcam servers (pause mode only) etc. It picks up its settings from a pilapse.cfg configuration file where all the settings are, storage folders, which cameras to enable, whether to capture day & night or just day etc etc. The "day" is the day as far as the plant is concerned, I mean the period between the grow lighting on and off can happen anywhere in the 24hr clock.


tlsnap.sh : the timelapse capture script. this handles all the logic of taking the right shots whether day or night and storing them in various directories. it also updates the timestamps icons and overlays this. It creates a directory structure on the fly ordered by the grow day number.




both scripts use a locking mechanism to avoid clashing. plmon just skips if the lock is established by tlsnap. tlsnap has three retries after 10s each, and will try to finish its job. If all the retries are exhausted there are now some safety mechanisms to try and clear down the setup and lock files and gain control again. this routine hasn't been used though, I was cautious in implementing it. I added lots of debug output also so I have a few log files that are generated so I can see later what happened or figure the cause of an issue.


One such issue popped up yesterday, second USB webcam seems to have locked up for some reason. debug logs came in useful and so some more safety code has gone in to try and at least detect and report an issue by email. I couldnt find a way to clear the error by software, nor usb reset nor uvcvideo restart would resolve it... only replugging the USB worked :(
It wouldn't break the system anyway, the other cams carry on ahead with their jobs.
Did some reading and some others have had issues with the uvcvideo module and different webcams so, im soak testing again now (12hrs+ right now) to see if I can make it happen again or not. and test if a Pi reboot would help resolve it.


last few niggles to resolve but nearly there now :)
 
The USB camera seems to be holding up OK now, hasn't crashed in the last 24hrs so maybe things not as bad as I worried. In any case its good that Ive implemented some debug output and email capability, so if any of the cameras is not playing ball I will know about it soon. also it attaches the relevant log file so if Im out I can see what happened :)
I'll also use that facility to send out a daily report and notification when the timelapse vids are ready, maybe with a link. going to string together that code next.
 
Last edited:
sorry guys didn't update in a few days but that's cos theres a lot been going on and wrestling with one issue in particular. 3 white widow auto seeds have been soaking and popped out yesterday.
since its cold weather though, im starting them in a propagator to give them a decent chance. they are going well in that thing, I will give them a few days more then put them in the chamber to grow.


a few days ago I setup the system in the grow area, strapped the control box up on to the wall and the robot on the floor. getting it up and running was not as straightforward as I hope though...
first thing to get stuck on was network cable, seemed the length Id wanted to run into the room just wouldn't work between the pi and the router (other eqpt was working but lossy). In the end it seemed easier to go wifi, so that's what I did, adding a nano wifi adaptor to the USB hub. That was the first of the install problems solved (or so I thought).
Second was that there was flickering in the lights, the grow light and the white lights. since I was testing before with regular bulbs, I didn't "see" the issue. but with the led's that can turn on and off fast, they didn't ride it out, so the issue was a bit of a surprise
icon_e_smile.gif

Got to it with a bit of debug, looks like Fotek relay's only part work at 5V control voltage. They are rated 3V up but 5V just wont hold the relay steady ON. I jacked up the drive voltage to 7.5 and the lighting is now switching on/off OK and no flicker at all. After some head scratching I rerouted the high side supply of the level shifter driving those relays to the arduino-bot's motor voltage (7.5V). Thankfully it was not so hard once the problem was understood.

So far so good I started the timelapse running and left it be to see how it got on. Seems all went well until something went wrong six hours later and the pi was left in a weird state of coma. Over the last couple days I have been trying to get to the bottom of that one still. adding more debug code to try and work out what happens when it crashes, modifying behaviour, changing HW setup...
whats happened is that the HD is no longer on the hub, but direct to the pi. HD and Pi share a USB supply and are not connected at 5V to anyone else. Also I have increased the min memory limit according to
http://stevenhickson.blogspot.co.uk/201 ... ashes.html

it did run perfectly stable on the bench before so had to try revert things, removed the wifi adaptor and instead made use of a couple of powerline networking units I had in the garage. If it is a memory low issue, then the USB wifi adaptor wont help things - it will consume more memory than just a straight lan connection, and draw more power. this is the latest thinking anyway.

its been running happy for some hours already, lets see how it is in the morn... hope I got the fix this time round, need to have it stable cos in a few days it'll be "showtime"
icon_e_smile.gif
 

Attachments

  • 33.jpg
    33.jpg
    66.1 KB · Views: 56
has been a bit frustrating last few days, I summarised quite a bit of the last few days work, but had to go back and forth changing one thing then another and seeing if it holds steady or not.
good news so far, the thing has run something like 20hrs now without an issue, so might well have been related to adding the wifi adaptor in there.
the adaptor itself is the maplin nano, there lots of people that have used it against the pi with luck as well but I knew from the start running a wifi adaptor puts some memory and processor load on the pi and I wanted to keep it off the pi. that's why I ran the long cable in as first choice. still the powerline networking adaptors seems to be doing a good job.


tracked the last log messages in the last fails, they were just during / after running the convert command to manipulate the large jpg coming off the main camera, adding the timestamp graphic. makes sense that this task would require a bunch of memory in an instant, so this could have been when it hit a dangerous low and stalled.


20+ hrs is the longest continuous time its managed by a long shot (post install), so I think we might be good now. good thing en route solving this issue at least I also enabled the pi's watchdog so if it has any less drastic version of a OS crash, it should reboot itself ;
Ricardo's Workbench: Auto-reboot a hung Raspberry Pi using the on-board watchdog timer


its not necc. that the wifi adaptor is bad btw, its just that with everything else going on, the pi probably ran out of resource. there is a bunch of stuff like the SAMBA server and other background processes running in this setup. In case any one else goes with the wifi, id recommend making the minimum memory limit adjustment I mentioned in the last post, and also perhaps implement a nice reboot when memory is running low ;
The Raspberry Pi Hobbyist: Low Memory Automatic Reboot


when I re set up the pi after the SD card crash episode, I skipped my earlier step with installing VNC server , the remote desktop server. this was thinking forward so now since Im "done", I've disabled the pi from booting into the desktop to conserve resources, and no need for remote desktop as I can make a SSH connection and run any commands, reconfigure etc.
looking good... if it carries on like this I'll soon declare it ready for action :)


then I need to tweak the lighting so it looks good in the camera's, mylar makes it difficult on the cameras. may even need to stick a white backdrop behind, not sure, but that wont take long to experiment and get right. should be able to start the thing running for real, maybe Wednesday I think.
 
noted the system crashed last night after 55 hours ish. This time it was good since I could debug a bit more and saw that the USB hub seemed to have locked up. even after a reboot of the pi and re-insertion of the hub the connected devices were not accessible, only repowering the hub fixed it. I have heard that some hubs can give stability issues also, so this will be the next thing to be swapped out now.
I think the backpowering and memory were still important before since there has been a big improvement. Two suspects at the moment actually, one of the cameras seemed to be stuck with the blue "in action" light jammed on when it crashed, so hub and camera are suspect. Ill switch out the hub first then re-test to see if the camera goes into that state again. At least these are extra camera's so wont affect the main vid.
 
hi folks!! just a quick update today. things been pretty good since the new usb hub went in, no further crashes. I've also implemented a twice daily reboot at convenient times between captures, so things stay reasonably fresh. with that and the other safeguards, I think it stands a good chance of making it through the grow without too much spanner work.

the little plants are still in the propagator, be ready in a few days to go in a pot and under the cameras, want to give them a good start for this one.
only couple things to tidy up, one is that the tilt servo needs a clean or change, after all the thousands of cycles of soak testing it went through, I think the pot and wiper arm could do with a clean since there is some jitter every now and then, which shows through in the timelapse vid as a vertical shaking. shouldn't be too much hassle to sort that one.
 
hi guys!!!
been a few days again, few things have happened ;
the white widows were not coming on strong as Id hoped, not sure but ive had those seeds a while and decided to order something fresh in instead seeing as we'll timelapse it.
so I dropped some auto blueberry from dutch passion in the propagator and this time a lot better. day 3 today so they have all popped out and begin their journeys.
Im starting out with a few so can choose the best one to shoot full time later.
the pi has been Ok on the whole but annoyingly sometimes still went into crashes. im just going to have to assume its to do with fswebcam and the whole usb camera plot. in the end I have made another solution for when this happens. now an extra GPIO of the pi is toggled every minute by a CRON job. The GPIO is watched by another circuit, another little processor, MSP430 is monitoring that line. Should it stop for 7 minutes or more, it will switch its relay and close the Pi P6 header - the RESET switch. That seems to working well so on the odd occasion it does bomb out, this will recover it quickly so really we wont miss anything in the timelapse. just ride over it. the seven minutes was an estimate for a slow reboot with fsck check , so the MSP doesn't reboot it again whilst its still trying to reboot ;)
Ah I also swapped out that tilt servo that was noisy for a new one, and shortened the length of the main cam arm a bit. that stopped any tendency to oscillate when disturbed. now the timelapse does not have the annoying vertical jitter it had earlier.
ill do some more config and sort the pots out like I want tmrw probably, start the cameras rolling for proper.
hold on folks, should have some early footage coming through in the next days :)
 
Damn I have to catch up on all this. And you're probably gunna get slapped again. And we're probably gunna have to pm back and forth about fun tech stuff. And I'm hungry, so Imma fix that and read up. ;)
:d5:

Mean time, keep up the good work.
 
Thoroughly impressed, sir. You display a graduate level understanding of all sorts of computer and electronic engineering. And you're kind enough to share your expertise with AFN - too awesome. You've been duly repped and I'll keep you in mind should I ever be in dire need of a genius. You'd be surprised - happens a lot with me.
 
Back
Top