Help with a camera controlling sequence

Discussion in 'The Projects Forum' started by joshzstuff, Mar 17, 2011.

  1. joshzstuff

    Thread Starter Member

    Sep 22, 2010
    30
    0
    Hello, I'm starting a video surveillance camera project and I would really appreciate your input as to direction and methods.

    Here are the details:

    -The camera I am using will be activated by a Passive Infrared sensor (PIR) (or also possibly a sound detector)
    -The camera must be turned on and started by the sensor, then it must be shut off in the absence of sensor feedback.

    Here is how the camera operates normally:

    Cam has 2 buttons, 1) ON 2) Start/Stop

    - ~2sec After the "ON" button is pressed the "Start" button can be used.
    - When the "Start/Stop" button is pressed again, the video will stop & Cam goes into "STANDBY" mode for 65sec
    - in "STANDBY" the "Start" button will start recording, but after 65 sec the Cam auto shuts off
    (and must then again be turned "ON" before the "Start" can be used.)

    Below is the sequence I devised to run the Cam off the motion sensor(s):
    [​IMG]
    I will need to break into the buttons to send the pulses to the camera.

    I am considering 2 paths to execute this sequence:
    1) Discrete components (i.e. retrigerable monostable vibrators)
    2) Programing a microcontroller

    This would be my first microcontroller project, but if I do go that route, it appears the Micro could be very basic.

    Any suggestions will be appreciated, thanks for reading.

    P.S. What line diagram programs do you use?
    I did this one in a paint program and I know there has to be a better way!
    Thanks.
     
  2. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230
    There is a very large community doing just what you want. Game cams are highly commercialized.

    Go the micro route. One basic reason is that you will want to condition a variety of trigger inputs. You've suggested at least two possibilities, but I can tell you, that once you get into it, you'll be happy to have the resources. One of my triggers is a variable gain PIR that self calibrates it's sensitivity, another is an RF transmitter that fires a zooming still camera with panning function.

    Another reason for micro control is power management. If you plan on battery driven devices, you want to total control over your consumption.

    The best reason though is the infinintely variable logic you can place between your triggers and camera. Be it timers, trigger sequencing, handling nuisance triggering, sensitivity, etc, etc.
    Only the best, pencil and paper.
     
  3. joshzstuff

    Thread Starter Member

    Sep 22, 2010
    30
    0
    Hehe, yes that's where I developed it, but I wanted something more web friendly for the forum :)

    Thanks 'info' for the tip.
    Do you think it is appropriate to discuss this here or would it be better to look for such a forum?
    Are you a member of a particular forum, or do you recommend one?

    I was leaning that direction, and micro controllers are something I've been wanting to learn.
    Can you recommend a good beginner/suitable controller for the task?
    Should we move this topic to the micro-controller section, or do you think I should seek out the game-cam community?
    Thanks 'Info'
     
  4. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230
    I would certainly suggest you research the online resources. Not sure what specific camera you will be using, but I'd look at the hack resources for that model as well.

    I use a range of Atmel 8051 core devices. There are many tools freely available with tons of coding examples, tutorials, hardware docs, etc. The PIC is popular with many here on the forum.

    I tend to be a bit secretive as some of my devices are seeing commercial use, and don't have the time for tutorial, but would certainly share some of my experiences.
     
  5. joshzstuff

    Thread Starter Member

    Sep 22, 2010
    30
    0
    Thanks Info,

    no need to divulge any production secrets ;)
    I think the PicAXE line would serve my purposes for this relatively simple project. As you suggest I think there is pretty good support for that platform here, but should this thread be moved to the "microcontroller" forum?

    thanks
     
  6. joshzstuff

    Thread Starter Member

    Sep 22, 2010
    30
    0
    Well, I've started my development with the PicAXE 08M, but I may have run into a bit of a snag with that chip for the program I need . . .

    I am trying to program the "re-trigger" portion of my circuit.
    (This appears to be something simpler in discreet hardware than on the 'basic' micros.)
    I was hoping to pull this off with a PicAXE 08M however I don't think it supports parallel processing.
    I have a PicAXE 18M2 coming, and the 'M2' versions are supposed to support parallel processes.

    I think I know just what to do if I can use a separate (parallel) sub-command . . . However, I would much prefer to use the smaller chip.
    (I've read that I may be able to use a pwm peripheral, however I don't think I want to go that route either)

    So my question is:
    Does this re-trigger option for the 'wait' command require the higher chip, or does anyone know a way I can do it with the PicAXE 08M?

    Thanks
     
  7. joshzstuff

    Thread Starter Member

    Sep 22, 2010
    30
    0
    Thanks,

    I don't know if your acquainted with the PicAXE line and basic, but I've made some progress with my 08M MC.

    Problem:
    I ran into a snag where the chip won't do what the simulator does . . . I'll explain below

    Here is the basic program that corresponds to the flow sheet:

    Code ( (Unknown Language)):
    1. symbol StSt = b1      'Start/Stop button
    2. symbol Power = b0    'Power button
    3. symbol sensor = pin3    'PIR sensor
    4.  
    5. let dirs = %00000011
    6.  
    7. main1:
    8. wait 2
    9. goto main
    10.  
    11. Main:
    12.  
    13.     if sensor = 0 then goto main
    14.     if sensor = 1 then high Power  'turn Cam ON
    15.     pause 300
    16.     low Power  
    17.    
    18.     pause 2900
    19.    
    20.     high 1                'start Cam
    21.     pause 200
    22.     low 1
    23.     endif
    24.                         'Changed 'gosub' to 'goto'
    25.     goto startagain            'STACK ERROR- > nested gosubs
    26.    
    27.  
    28.  
    29. startagain:  
    30. for w1 = 1 to 800
    31.   pause 10
    32.    if sensor = 1 then startagain
    33. next w1
    34. high 1
    35. pause 300
    36. low 1
    37.  
    38. Standby:
    39. for w2= 1 to 5100
    40.         pause 10
    41.     if sensor = 1 then high 1
    42.     pause 300
    43.     low 1
    44.     goto startagain endif        'Changed 'gosub' to 'goto'
    45.                           'STACK ERROR- > nested gosubs
    46. '    
    47.     next w2
    48.    
    49.     pause 3000
    50.    
    51.     goto main
    The new program adds some features from the old:
    - It starts the cam at first run "cam priming"
    - has safety 'resets' encase the cam and the picAxe & cam timing goes out of sync (sometimes temperature affects this) "heartbeat" "safety"
    - I included the principal of Technical's code with an inc that determines if the PIR is tripped by a 'nuisance' signal "nuisance"
    - if the 'nuisance' condition fails the recording goes to a shorter recording first "shortRec"


    I tried to label the significant parts of code, sorry if it's more complex than it needs to be (but I'm open for any criticism)

    (Sorry for the lengthy code, the relevant section is "CloseRec")

    Code ( (Unknown Language)):
    1. symbol Power = b0        'Power button
    2. symbol StSt = b1      'Start/Stop button
    3. symbol Time = b2
    4. symbol detect = b3
    5. symbol ready = b4
    6. symbol retrigger = b5
    7. symbol heartbeat = b6
    8. symbol Ncount =b7
    9.  
    10. symbol sensor = pin3    'PIR sensor
    11.  
    12. let dirs = %00000011
    13.  
    14.                             ;goto start     ;@sim@
    15.  
    16. main1:
    17. wait 2                'Program delay
    18.  
    19. high 1                'diagnostic sequence
    20. pause 200
    21. low 1
    22. pause 300
    23. high 1
    24. pause 600
    25. low 1
    26. wait 4
    27.  
    28. high Power                'Cam priming sequence
    29. pause 300
    30. low Power
    31.  
    32. pause 4500
    33.  
    34. high 1
    35. pause 300
    36. low 1
    37.  
    38. wait 4
    39.  
    40. high Power
    41. pause 2000
    42. low Power
    43.  
    44. wait 3
    45.  
    46.  
    47. goto main
    48.  
    49. Main:
    50.  
    51.     high 1            'safety reset
    52.     pause 200
    53.     low 1
    54.  
    55. for heartbeat= 1 to 5600                    
    56.     pause 10
    57.    
    58.     if sensor = 1 then goto Start
    59.    
    60. next heartbeat
    61.    
    62.     high 1            'safety reset2 (heartbeat)
    63.     pause 200
    64.     low 1
    65.     goto main
    66.  
    67.  
    68. Start:
    69.    
    70.     high Power            'power cam
    71.     pause 200
    72.     low power    
    73.    
    74.         let Ncount = 0
    75.         let detect = 0        
    76. for Time = 1 to 10        'nuisance prevention
    77.     pause 350
    78.     if sensor = 1 then inc detect endif
    79.  
    80.     if detect > 4 then inc Ncount endif 'sensitivity setting
    81. next Time
    82.    
    83.     ;pause 3500
    84.    
    85.     if Ncount > 0 then high 1    'nuisance pass
    86.         pause 300
    87.         low 1
    88.         goto startagain endif
    89.    
    90.  
    91. goto ShortVid                'nuisance fail
    92.  
    93. ShortVid:
    94.  
    95. high 1
    96. pause 300
    97. low 1
    98.  
    99. for retrigger = 1 to 400                        '@sim@
    100.           pause 10
    101.          
    102.        if sensor = 1 then startagain
    103. next retrigger
    104. goto CloseRec    
    105.    
    106. CamStart:                'start Cam
    107.     high 1            
    108.     pause 200
    109.     low 1
    110.  
    111.  
    112. startagain:  
    113. for retrigger = 1 to 800                        '@sim@
    114.           pause 10
    115.        if sensor = 1 then startagain
    116. next retrigger
    117.  
    118. CloseRec:                'close recording
    119. high 1            
    120. pause 300
    121. low 1
    122.  
    123.     pause 2550            'restart buffer
    124.    
    125.  
    126. Standby:
    127. for ready = 1 to 5100                             '@sim@
    128.         pause 10
    129.     if sensor = 1 then high 1
    130.         pause 300
    131.         low 1
    132.    
    133.         goto startagain endif    'Changed 'gosub' to 'goto'
    134.                          'STACK ERROR- > nested gosubs
    135. '    
    136. next ready
    137.    
    138.     pause 3000            'restart program buffer
    139.                                 ;goto start     ;@sim@
    140.     goto main
    The problem lies in the "CloseRec:" (or before it)
    It works perfectly in the simulator, but it won't work on the chip

    The camera will start, but it will never close again.

    The only reason I could see there being a difference from the simulation was if I timed the pulses to short, but I don't think I've done that.

    feel free to critique the code, I'm sure a stepped all over convention when programing it [​IMG]
     
Loading...