Welcome Anonymous
Fledgling
Fledgling
It is currently Sun Sep 24, 2017 8:04 am

All times are



Post new topic Reply to topic
Author Message
PostPosted: Mon Aug 01, 2011 5:28 pm 
Online
Moderator
Moderator
User avatar

Joined: Mon Feb 01, 2010 5:45 pm
Posts: 4385
Location: Sussex County NJ
This is a 3 flash camera. Not my code I just added the dip delays and made some other changes (with the help of Bowgod)

Code:
' Pentax E50, three flash camera
' For personal use only
' Activity mode with slave to take pics for 30 seconds if triggered and then shut down and reset.
' Also has various dip delays
' Four position dip switch with overhanging legs 1 through 4 solder jumpered to V+
' all dips off activity/trail mode
' Dip 1 on -30 second delay
' Dip 2 on -1 minute delay
' Dip 3 on -2 minute delay
' Dips 1,2,3&4 on -5 minute delay
' Dip 4 on used with dips 1,2&3 will double the delay for night time pictures.
' Dip 4 on in activity mode will give a 1 minute delay at night

'=========
'07/04/11
'=========
'Look for lines marked with ***. These areas are where timings may need changed for different
'camera setups.

#picaxe20x2
'#terminal 9600
#no_data
#no_table
disablebod

'=====================================================
' Map Ports
'=====================================================
Symbol PT_IN = B.0 ' Photo Transistor input
Symbol CDS_Out = C.5 ' Output to LDR voltage Divider
Symbol Flash_Out = C.4 ' slave flash opto
Symbol Flash_Charge = C.3 ' Flash Charge Mosfet
Symbol PT_Out = C.2 ' Photo Transistor output
Symbol Video_Out = C.1 ' Spare Mosfet used to push video button
Symbol Battery_Monitor = B.6 ' ADC Input for battery monitor
Symbol LDR_IN = B.5 ' LDR ADC Input
Symbol Shutter_Out = B.4 ' Shutter Mosfet
Symbol Power_Out = B.3 ' Power Mosfet
Symbol LED_Out = B.2 ' LED
Symbol PIR_In = B.1 ' Input from PIR Circuit
Symbol BkGrnd_Timer = B1
Symbol Byte_Var = B2
Symbol ValidPIR = B3
Symbol PIR_Event = B4
Symbol WlkTestFlag = B5 ' Walk test status flag
Symbol WlkTestTime = B6 ' Number of 15 sec periods for walk test
Symbol Activity_Flag = B7
Symbol Normal_OP = B8
Symbol CamRefresh = B9
Symbol Activity_Count = W5
Symbol Event_Delay = B11
Symbol CamEvent_Flag = B12
Symbol Cam_Mode = B13
Symbol PRELOAD = 63890 ' approx 15 sec at 31khz
Symbol Flash_Flag = b14' Flag to count the # of flashes seen
Symbol TO_Counter = W1 ' Timeout counter
Symbol First_Flash = b15
Symbol Wait_Loop = W2
Symbol CDS_Value = b16
Symbol Night_Flag = b17
Symbol Day = b18
Symbol Night = b19
Symbol SlaveRefresh = b20
Symbol FlashCharge = b21
Symbol PT_On = b22


'=====================================================
' Set Port Directions
'=====================================================
Input PT_IN
Output CDS_Out
Output Flash_Out
Output Flash_Charge
Output PT_Out
Output Video_Out
Output Battery_Monitor
Input LDR_IN
Output Shutter_Out
Output Power_Out
Output LED_Out
Input PIR_In
Input C.7
Input C.0
Input B.7
Input C.6
Output A.0


'=====================================================
'Pullups
'=====================================================
'Disable all PUs
pullup %00000000

'=====================================================
' Configure ADC
'=====================================================
adcsetup = %010000000000 'make adc 10 a input
'============================================================================

' STARTUP
'============================================================================

; Allow board to stabilize for 20 sec

High LED_Out
pause 5000
GoSub CamPWR
pause 5000
GoSub CamPWR
pause 20000
Low LED_Out




Powerup:
WlkTestTime = 2 ' set walk test timer to 15sec intervals of timer
WlkTestFlag = 1 ' Turn on walk test mode
CamRefresh = 0
Event_Delay = 0 ' # of 15sec periods to wait before another cam event occurs
CamEvent_Flag = 0 ' Set flag to off
Cam_Mode = 1
Activity_Flag = 0
Activity_Count = 0
Normal_OP = 1 ' board is operating in normal mode if 0. Activity mode or walktest if 1
Night = 215   ' *** CDS value when night ***
Day = 204    ' *** CDS value when day
Night_Flag = 0
SlaveRefresh = 0
' Do initial board setup for light & battery levels
GoSub CdsChk
IF Night_Flag = 1 Then GoSub Slave_Charge
'=====================================================
'Configure Interrupts
hintsetup %01100110 'set HINT2(PIR) & HINT1(FLASH) to trigger Interrupt at rising edge
Setintflags %00000100,%00000100 'enable interrupt flags


'=====================================================
Main: ' Main loop that checks for a PIR event, charges slave, turns off the cam if in trail mode and increments counters & timers, then sleeps for 15 secs and does it all over again:
'=====================================================
Setintflags %00000100,%00000100 'enable interrupt flags
If PIR_Event = 1 Then GoSub PIR_INTService

' Slave charge every 10 minutes for 10 seconds if night_flag = 1 (40 15 second periods)
If SlaveRefresh = 40 And Night_Flag = 1 Then'***change here for different refresh time for slave***
   GoSub Slave_Charge
   SlaveRefresh = 0 ' restart our 10min period
   EndIf
If CamRefresh = 250 and Night_Flag = 1 Then'*** change here for different refresh time for cam***
   Gosub RefreshCam
   CamRefresh = 0
   Endif

 


' Turn off walk test if time is up
If WlkTestFlag = 1 And WlkTestTime = 0 Then
WlkTestFlag = 0 'turn off walk test If Time is up
Byte_Var = 0 ' Flash LED to indicate walk test over
For Byte_Var = 0 To 7
pause 400
Toggle LED_Out
Next
Pause 3000 ' pause so CdsCHK does not see led and think it's day time
EndIf



' Increment counters & timers
Inc BkGrnd_Timer
If WlkTestFlag = 1 And WlkTestTime <> 0 Then Dec WlkTestTime : EndIf
'If WLKTestFlag = 0 Then Inc CamRefresh : EndIf
'If Activity_Flag = 1 And Activity_Count >= 0 Then Dec Activity_Count : EndIf

If Night_Flag = 1 Then Inc SlaveRefresh :EndIf
If Night_Flag = 1 Then Inc CamRefresh :Endif

GoSub CdsChk
Sleep 7
GoTo Main


Interrupt:
'sertxd ("Interrupt ",13,10)
If hint2flag = 1 Then 'Check to see if INT2 has been triggered
PIR_Event = 1 'Set the PIR event flag
hint2flag = 0 'reset hint2flag to 0
EndIf

If hint1flag = 1 Then ' Flash has been detected
'sertxd ("Flash Flags ", #Flash_Flag,13,10)
First_Flash = 1
IF PT_On = 0 then Inc Flash_Flag :endif
hint1flag = 0
Setintflags %00000010,%00000010 'enable interrupt flags FOR FLASH ONLY!
EndIf


hintflag = 0

Return


PIR_INTService:

PIR_Event = 0
; +++++++ Now See how long the port is high ++++++++++++++
Byte_Var = 0 'clear the counter
Do While Pinb.1= 1 'While the PIR is high (motion detected)
Inc Byte_Var 'Inc our counter
'Pause 1 'un-comment for a longer period
If Byte_Var >= 2 Then
ValidPIR = 1 'flag the motion detected as valid
Exit
EndIf
Loop



If ValidPIR = 1 Then 'If valid motion then
ValidPIR = 0

' WalkTest
If WlkTestFlag = 1 Then 'if walktest then turn on led to indicate PIR event
WlkTestTime = 2 'reset walktest timer back to original count again
Byte_Var = 0
For Byte_Var = 0 To 19
Toggle LED_Out
Pause 20
Next
Pause 4000; wait a few secs to settle PIR
GoTo PIR_INTService_Exit
EndIf


If Night_Flag = 1 Then
High PT_Out ' Turn on PT to detect flash
Setintflags %00000010,%00000010 'enable interrupt flags FOR FLASH ONLY!
High Flash_Charge
EndIf

Flash_Flag = 0

If WlkTestFlag = 0 Then
GoSub CamPWR    ' Turn the camera on for the first time
Pause 1500      ' *** Change time here for different cameras ***
      If night_flag = 1 then
     Gosub Fire_Flash
  Else
    Gosub Shutter
    EndIf
pause 5000      '*** delay after pic is taken to save picture. Change if needed ***

Gosub ActivityDly
 

If Night_Flag = 1 Then
Pause 5000 'Allow flash to recharge
Low Flash_Charge 'and then turn off
Low PT_Out
SlaveRefresh = 0
Endif
GoSub CamPWR
Pause 4000


GoSub DipDLY



'EndIF
Goto PIR_INTService_Exit


PIR_INTService_Exit:
'sertxd ("PIR Exit ",13,10)
Setintflags %00000100,%00000100
ValidPIR = 0
Activity_Count = 0
Activity_Flag = 0
CamRefresh = 0
'Return
GoTo Main


LED_Blink:
Byte_Var = 0
For Byte_Var = 0 To 19
Toggle LED_Out
Pause 20

Next
Return


CamPWR:
High Power_Out
pause 500     '*** change here if to hold cams power button down longer or shorter ***
Low Power_Out
Return

Shutter:
High Shutter_Out
pause 3000     '*** change here to hold down shutter button longer or shorter ***
Low Shutter_Out

Return


ActivityDly:
If PinC.7 = 0 and PinC.0 = 0 and PinB.7 = 0 and PinC.6 = 0 and Night_Flag = 0 Then
Gosub Activity
Endif
If PinC.7 = 0 and PinC.0 = 0 and PinB.7 = 0 and PinC.6 = 1 and Night_Flag = 0 Then
Gosub Activity
Endif 
If PinC.7 = 0 and PinC.0 = 0 and PinB.7 = 0 and PinC.6 = 0 and Night_Flag = 1 Then
Gosub Activity
Endif

Return   

DipDLY:
If PinC.7 = 1 and PinC.0 = 0 and PinB.7 = 0 and PinC.6 = 0 and Night_Flag = 0 Then
Pause 30000 '30 seconds
Endif
If PinC.7 = 1 and PinC.0 = 0 and PinB.7 = 0 and PinC.6 = 1 and Night_Flag = 0 Then
Pause 30000 '30 seconds
Endif
If PinC.7 = 0 and PinC.0 = 1 and PinB.7 = 0 and PinC.6 = 0 and Night_Flag = 0 Then
Pause 60000 '1 minute
Endif
If PinC.7 = 0 and PinC.0 = 1 and PinB.7 = 0 and PinC.6 = 1 and Night_Flag = 0 Then
Pause 60000 '1 minute
Endif
If PinC.7 = 0 and PinC.0 = 0 and PinB.7 = 1 and PinC.6 = 0 and Night_Flag = 0 Then
for b23 = 1 to 5 ' 5 loops
pause 24000 ' wait 24 seconds per loop making the delay 2 minutes
next b23
Endif
If PinC.7 = 0 and PinC.0 = 0 and PinB.7 = 1 and PinC.6 = 1 and Night_Flag = 0 Then
for b23 = 1 to 5 ' 5 loops
pause 24000 ' wait 24 seconds per loop making the delay 2 minutes
next b23
Endif
If PinC.7 = 1 and PinC.0 = 1 and PinB.7 = 1 and PinC.6 = 1 and Night_Flag = 0 Then
for b23 = 1 to 5 ' 5 loops
pause 60000 ' wait 1 minute per loop making the delay 5 minutes
next b23
Endif 
If PinC.7 = 0 and PinC.0 = 0 and PinB.7 = 0 and PinC.6 = 1 and Night_Flag = 1 Then
Pause 45000 ' 1 minute taking into account delays after picture is taken
Endif
If PinC.7 = 1 and PinC.0 = 0 and PinB.7 = 0 and PinC.6 = 0 and Night_Flag = 1 Then
Pause 15000 '30 seconds taking into account delays after picture is taken
Endif
If PinC.7 = 1 and PinC.0 = 0 and PinB.7 = 0 and PinC.6 = 1 and Night_Flag = 1 Then
Pause 45000 ' 1 minute taking into account delays after picture is taken
Endif
If PinC.7 = 0 and PinC.0 = 1 and PinB.7 = 0 and PinC.6 = 0 and Night_Flag = 1 Then
Pause 45000 '1 minute taking into account delay after picture is taken
Endif
If PinC.7 = 0 and PinC.0 = 1 and PinB.7 = 0 and PinC.6 = 1 and Night_Flag = 1 Then
for b23 = 1 to 5 ' 5 loops
pause 21000 ' wait 21 seconds per loop making the delay 2 minutes taking into
         ' account delay after picture is taken
next b23
Endif
If PinC.7 = 0 and PinC.0 = 0 and PinB.7 = 1 and PinC.6 = 0 and Night_Flag = 1 Then
for b23 = 1 to 5 ' 5 loops
pause 21000 ' wait 21 seconds per loop making the delay 2 minutes taking into
         ' account delay after picture is taken
next b23
Endif
If PinC.7 = 0 and PinC.0 = 0 and PinB.7 = 1 and PinC.6 = 1 and Night_Flag = 1 Then
for b23 = 1 to 5 ' 5 loops
pause 45000 ' wait 45 seconds per loop making the delay 4 minutes taking into
         ' account delay after picture is taken
next b23
Endif
If PinC.7 = 1 and PinC.0 = 1 and PinB.7 = 1 and PinC.6 = 1 and Night_Flag = 1 Then
for b23 = 1 to 5 ' 5 loops
pause 57000 ' wait 57 seconds per loop making the delay 5 minutes taking into
         ' account delay after picture is taken
next b23
Endif

Return



Fire_Flash:
SetFreq m16
flash_flag = 0
'sertxd ("Flash Start ",13,10)
'Gosub Shutter
High Shutter_Out
Do
Inc TO_Counter
If TO_Counter =10000 Then
Flash_Flag = 0 ' Reset flags
TO_Counter = 0
'GoSub Flash_Led ' Flash Led to indicate time out.
GoTo Flash_Exit
EndIf
Loop while flash_flag <> 3

' FireFlash


'If Flash_Flag = 2 Then
High Flash_Out

pause 400

Low Flash_Out
Flash_Flag = 0 ' Reset flags
TO_Counter = 0
'FlashCharge = 1 ' Flash fired so set flag to charge it.
GoTo Flash_Exit

'EndIf


Flash_Exit:
Low Shutter_Out
First_Flash = 0
Flash_Flag = 0
'Low PT_Out
SetFreq m8
'sertxd ("Flash Exit ",13,10)

Return

Flash_Led:
For b0 = 1 To 50
Toggle LED_Out
pause 20
Next
Return


CdsChk:
High CDS_Out 'Turn on pin to supply voltage to cds voltage divider
readadc 10 , CDS_Value ' Read light value
'sertxd ("CDS Value ",#CDS_Value,13,10)
'IF Night_Flag IS SET THEN WE CHECK TO SEE IF THE LIGHT LEVEL IS > = 144 IF ADC GREATER OR = THEN STILL DARK AND EXIT
'IF ITS BELOW 144 THEN WE CLEAR NITEFLG AND RETURN
'IF Night_Flag = 0 THEN CHECK TO SEE IF ADC ABOVE 155 THEN WE SET NITEFLG AND RETURN
Low CDS_Out 'Turn off voltage divider
If Night_Flag = 1 And CDS_Value >= Day Then
GoTo CdsChk_Exit 'already set and Still dark so we exit
Else
Night_Flag = 0 ' already set and Daylight so clear flag
EndIf
If Night_Flag = 0 And CDS_Value >= Night Then
Night_Flag = 1 ' Its dark so set flag
Gosub Slave_Charge ' Charge the slave up also
Else
Night_Flag = 0 ' Daylight so clear flag
EndIf
CdsChk_Exit:

Return


Slave_Charge:
High Flash_Charge
Pause 10000 ' *** Time slave is on during refresh ***
Low Flash_Charge
Return

RefreshCam:
Gosub CamPWR
pause 4000   '*** Time cam is on during refresh at night ***
Gosub CamPWR
Return

Activity:
   Activity_Flag = 1
   Activity_Count = 300 '*** set activity counter to 300 allowing 30sec ***
      
      Do while Activity_Count > 0

   If PinB.1 = 1 and Night_Flag = 1 Then
      Gosub Fire_Flash
pause 5000  '*** let PIR settle and charge cams flash before allowing another pic***
      Endif
   If PinB.1 = 1 and Night_Flag = 0 Then
      Gosub Shutter
pause 5000  '*** pause here after pic is taken at day to let PIR settle ***
      Endif
   pause 100
      Dec Activity_Count
Endif
    Loop
Endif
Return

_________________
Image trailcamkits.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic

All times are


Who is online

Array


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group