Dealing with too much activity

212

Senior Member
I couldn't think of the right title to call this...sorry..but I'll try to explain. I have a video camera connected to a RF video unit. I have a RF remote PIR that, when motion is seen, sends a signal to a receiver connected to a Picaxe 08M. This 08M turns on the camera and transmitter, sending the video to my house. This has been working very well, and I owe that to the Picaxe... and to you guys for all the help educating me on its use. This camera set-up is battery powered, and until now, a 5 watt solar panel was enough to keep its battery up.

But....I moved the camera to another location, watching over a deer feeder filled with corn. I'm thinking I will get to watch turkeys...wild hog...maybe even a deer. NOPE...not so far...so far, I have been getting tons of bird videos, and squirrels attacking the feeder motor to make more corn fall out. At night I'm getting probably 6 hours of raccoons camping under the feeder. OH....I had always blamed feeder damage on squirrels. They do hang on the timer/motor, but that's not what keeps messing them up I bet. These coons must weigh 20~30 lbs, and they hang on the motor two at a time sometimes!

Anyway, I want/need to limit the time the camera is on....over a certain period of time. I know a little more now, so I can do the simple stuff, but I'm looking for ideas on something that seems more of a challenge. I don't want to change the code too much, because I like the way it is working, but I want to have it where it will keep from running the battery down in one night.

Here is what I have in mind to do, but haven't come up with the HOW. I think I would keep track of the events received from the remote PIR unit, and if it exceeds soooo many in, maybe, 30 minutes, then I need to give the battery a break.

Here is what I have so far, please excuse the lack of comments for now, but it is pretty simple. I can also turn the camera on with my hand held,that part is fine.




Code:
low 0     'transmitter relay mosfet (npn)
input 1	'normally low...goes high when relay turns on...not used for this unit
input 2	'normally high..goes low when remote PIR is triggered
high 4	'grounds call button on a hand held radio to send call
disablebod
pause 2000

'-----------------------------------------------------------------------------------
'this part is for testing the sensor placement and aligning camera
'the camera is turned on for this 5 minutes, and every time remote sensor
'is triggered, the "call" is sounded to let me know it has seen me move in front of the PIR


start_up:

w1 = 4000		'about 5 minutes with no interruption
high 0                               'turn on camera and transmitter relay
Do While w1 > 0
if pin2 = 0 then                  'pin2 goes low when remote PIR receiver is active
low 4                               ' this grounds the call button on my hand held to send the "call"
pause 100
high 4
pause 5000
else                                  'if no remote PIR event is seen, count down the time anyway
nap 2
w1 = w1 - 1
endif
Loop 
w1 = 0
low 0                                'turn off camera...wait 10 seconds and go to main
pause 10000
goto main

'---------------------------------------------------------------------------------
'this is where the camera is off and waiting for something to happen

Main:

if pin3 = 0 then turn_camera_on	'if remote call is pushed on my hand held radio
if pin2 = 0 then remote_trigger_seen	'if motion is seen by remote PIR
nap 2`
goto main

'----------------------------------------------------------------------
'this is what happens if I press the call button on my hand held

turn_camera_on:

high 0               'turn on camera and transmitter so I can see what is going on 
pause 3000
low 4                 'press call button on radio inside case with the video transmitter>>
pause 100          '>>this just verifies it is working still I guess
high 4
for b1 = 1 to 5    'I wanted to watch the scene for 5 minutes
pause 60000
next b1
low 0
pause 10000
goto main

'---------------------------------------------------------------------------
'this happens when remote PIR detects motion

remote_trigger_seen:

b2 = 0
b3 = 0
high 0                                       'turn on the camera and transmitter
pause 3000
low 4                                        'send the call to my hand held to let me know I'm receiving video
pause 100
high 4
Do While b2 < 3 and b3 < 10        'I'm leaving the camera on for 3 minutes at a time, up to 10
Setint %00000000,%00000100     'watch for another PIR event even while camera is on
pause 60000
b2 = b2 + 1
b3 = b3 + 1
loop
setint off
low 0
goto check_timer



interrupt:

pause 60000
b2 = 1
b3 = b3 + 1
Setint %00000000,%00000100
return



'---------------------------------------------------------------------------------
'this is the part that I'm using to limit the "on time"
'right now, it limits the time to about 10 minutes total
'if it has been on 10 minutes, I wait 5 minutes before returning to main
'if it has been less than 10, I wait 10 seconds before going to main
'the 10 second wait is to let my recording device stop and 
'get ready for another event to record

check_timer:

if b3 = 10 then         'been on for 10 minutes solid, so wait 5 minutes before going to main
for b4 = 1 to 5
pause 60000
next b4
endif
pause 10000            'if on for less than 10 minutes, wait just 10 seconds
goto main
 
Last edited:

Dippy

Moderator
I'm probably alone in not understanding, so are you really asking:-

1. I'd like to limit the camera ON time to no more than 10 minutes (or whatever) in any hour.

or

2. I'd like the camera to switch ON for no more than 10 minutes between 00:00 to 06:00 hours.

or

3. I'd like the camera to switch ON for no more than 10 minutes with a 10 minute break.

or

4. I'd like the camera to switch ON for no more than 10 minutea after each event trigger.

or none of the above.... if so can you pose the question as a pseudo Basic recipe?


Aplogies if some of the above is already in the code, but I've got to go and get the newspaper as the paper boy has been run over by Andrew Cowan's Megabot ;)
 

BeanieBots

Moderator
My approach would be to set up another counter/timer.
This could either be in software or hardware.
Whenever the camera is on, increment the counter every whenever.
When the camera is off, either reset the counter or count it down, or count down faster, which ever gives the desired effect.

Then, simply test the counter value in addition to the normal tests before turning on. Continue testing during the on phase.
 

RexLan

Senior Member
I would "electrify" the whole rig that the target animal does not need to touch and that will take care of the critters pronto. In their approach path is the best bet.

I had to finally do that with my door molding on the shed. Damn ground hog would come and gnaw on it to the point of ruining it. Nothing worked but when I finally hot wired it he moved out like a bolt of lightening and never came back ...LOL. It won't hurt them but it will knock the crap out of them and the first mouth full was all it took!
 

adumas

Member
Hi... I'm interested in the circuit schematic... Could you post what you have, or explain how you connected everything up?
 

212

Senior Member
My apologies to Dippy and others for not being real clear in what I am after; I'm not real sure myself yet. Once I figure out exactly what I want to do, it will be much easier to do it huh. I don&#8217;t want to disable the thing for long periods of time, and I don&#8217;t want to reduce the sensitivity either. Maybe reduce the &#8220;on time&#8221; if there are multiple events within a certain amount of time or something??? I was hoping to hear some ideas&#8230;keep them coming!

I considered using a camera flash unit knock the crap out of them coons, to keep them off the feeder. It's only about 330 volts coming from a 500uf cap, but it sure gets my attention when I accidentally touch them lol...I can do that using another radio real easy, so I can zap them while I&#8217;m watching it :) I might be able to keep the birds away by putting a plastic owl down there, but I like to watch the birds too, just not continuously all day long.

adumas, I'll have to actually draw the circuit schematic for you, I will do that when I can make myself take the time. I hate drawing those because I'm sooo bad at it. Believe me, if was difficult to build, I wouldn't have one. The hard part is finding the parts needed at the right price, and will they actually work like they claim...
 

eclectic

Moderator
212
Just out of interest, could you post some photo's of the unit,
either just the unit or unit in place.

I own a cheap 9volt wireless camera and this could be
a useful project for it.

e
 

adumas

Member
Ditto on the camera ..

I don't think the diagram has to be that sophisticated...

You could even just write out what happens, one relay is for the camera and is connected to pin 1, etc...
 

hippy

Ex-Staff (retired)
You will most likely want to consider a Finite State Machine at least in terms of design and perhaps also for implementation.

In basic operation you would have three states, say 'idle', 'recording' and 'locked-out' and you move between states depending on activity and expiration of timeouts. So 'animal activity' would move from 'idle' to 'recording', a timeout would then move to 'locked-out' where further animal activity has no effect until a later timeout and the state has moved to 'idle' again.

You can then extend that to more states and more complicated timing, for example you could record for half an hour then lock-out, or maybe record for 10 minutes, keep recording for up to half an hour if there is still activity or go to lock-out if activity ceases. The time in lock-out may also be fixed or could be dependant upon how long the prior recording was for. You might want to vary all times depending upon how much battery life is predicted to be left.

You could implement your design as separate code sections ( each a 'state' ), with each being primarily a DO-LOOP with IF-THEN jumps out to other code sections ( often the easiest implementation ), or you could have an event-driven system which decides what to do then by inspecting current state and timers.

Code:
Idle:
  Do
    If animal_activity Then StartRecording
  Loop

StartRecording:
  Gosub TurnRecorderOn
  Goto Recording

Recording:
  timeout = 30 ' minutes
  Do
    If timeout = 0 Then StopRecording
    Gosub Pause60seconds
    timeout = timeout - 1
  Loop

StopRecording:
  Gosub TurnRecorderOff
  Goto LockedOut

LockedOut:
  timeout = 30 ' minutes
 Do
    If timeout = 0 Then Idle
    Gosub Pause60seconds
    timeout = timeout - 1
  Loop
 

212

Senior Member
hippy, did you look at my code up there??? I'm doing pretty close to what you recommended already, but it took me days to figure it out lol.. Yes, you got what I need right there, I just need to make myself decide to do it. I'm real bad about "what if" Like what if...something I want to see comes along while the camera is in LockedOut: It might be Bigfoot...or someone burying some treasure or something!!! I guess I will reduce the on time, and increase the LockedOut:, but only after multiple events in a row...and only if these events are all within say 10 minutes. I'm sorta doing that now, but I will also reduce the on time to go with what I have. Most of the time I point the camera looking at a little watering hole I made for them. The animals don't stay that long there, and I get a LOT of different visitors all during the day and night...mostly at night.

I need to take advantage of the daylight, and get some outside things done today. I promise I will gather up some more info on the unit ....tonight.
 

hippy

Ex-Staff (retired)
One of the hardest part of any program is in determining what the algorithm should be, how it responds and when. It's often hard to find the pefect algorithm, sometimes impossible, and sometimes beyond resource capabilities ( time, money or sheer effort ). I guess this would be where people would suggest AI aproaches, but that's a whole new ball game.
 

212

Senior Member
I had to google that AI aproaches...artificial intelligence. One guy claimed his controller could tell the mood of an animal, and not take a picture if it was tense. A tense animal might be scared away by the camera you know... Hogwash...all it really does is wait for another detection within a few seconds before taking the picture lol... I said he needed to add a retinal eye scan to it, to determine the age and species too, so he doesn't waste pictures on animals he doesn't want pictures of, or the same one over and over.

I came in for some iced tea, and edited in a few comments on the posted code, posted on page one. I'll do a better job later...
 

212

Senior Member
Been thinking, and have this so far. I still want to reduce the camera "on time" to 1 minute per event, if there is a lot of activity, in a 20 minute (or so) time period??? I MIGHT get it, but any help would sure be appreciated :)

I'm going to go round up a few pictures now...

Main:
If motion is seen then &#8220;motion seen&#8221;

Motion seen:

Start &#8220;on time&#8221; counter
Start &#8220;total on time&#8221; counter
Start &#8220;event&#8221; counter&#8230;keep track of PIR detections
Turn on cam
Signal me
Sets interrupt
Do while &#8220;on time&#8221; is less than 4 and &#8220;total on time&#8221; is less than 11
Wait 1 min
Add 1 to &#8220;on time&#8221;
Add 1 to &#8220;total on time&#8221;
Loop
Turn off interrupt
Turn off cam
Go to check timers


Interrupt:

Add 1 to &#8220;event&#8221; counter
Add 1 to &#8220;total on time&#8221;
Restart &#8220;on time&#8221; counter
Wait 1 minute
Return

Check timers:

If &#8220;total on time&#8221; = 10 minutes and &#8220;event&#8221; counter = (20 more detections) then
Wait 15 minutes
If &#8220;total on time&#8221; = 10 minutes and &#8220;event &#8220; counter is less than (20) then
Wait 5 minutes
Else
Wait 10 seconds
Goto main
 

212

Senior Member
RF video

I found a few pictures that I took of different set-ups. There are more somewhere, but I don't take time to name them and put them where I can find them later...I usually just delete them after a while anyway. I have been playing with PIR activated cameras for several years, and lately using remote PIR units too. Only within the last several months have I found the Picaxe, and have been asking a lot of questions. I owe all I know to the good people on this forum...THANKS!

I will get to the schematic too, but like I said somewhere, I hate that part, and really stink at it. I have used the same stuff to make several units differently...recycling saves $$$ This is a good remote PIR unit to use, if that is the way you want to go. I like being able to point the camera where the scene looks best, and that isn't always the best way to get reliable detections... The picture on the upper right is of the universal VCR controller that I made to use with this stuff. It is the reason I got into the Picaxe in the first place :)

http://search.harborfreight.com/cpisearch/web/search.do?keyword=driveway+alert&Submit=Go


The antenna you use will make or break the success you have, and use more battery than you think you need too.
 

Attachments

212

Senior Member
I'm still working on a better schematic to post on here:rolleyes:, but this is what I had drawn for myself to go by. I used the extra pin for my Driveway Alert receiver trigger...
 

Attachments

Top