Welcome Anonymous
Fledgling
Fledgling
It is currently Mon Sep 25, 2017 9:26 am

All times are



Post new topic Reply to topic  [ Array ] 
Author Message
PostPosted: Tue Jul 01, 2014 5:40 pm 
Offline
Emperor
Emperor
User avatar

Joined: Wed Aug 04, 2010 2:37 pm
Posts: 754
Location: Decherd, Tennessee
I have been playing around with a control board I designed for a couple months now but there is a few things I simply can not figure out. The NAP 3 stuff is scattered around everywhere in my code to make the cjip go to low power but the 25,000 = 1 hour is simply not working on the simulator running in real time with no delay or in the real camera build I done to test the board out in. the time 1002 is = to 1 hour on the camera refresh timer. The time variable 41 is = to 1 minute on the walk test time out timer. None of it is adding up but it is working perfectly. If the board is not going into low power mode won't it eat up batteries??? I am at a loss. Chip is running at setfreq m4 as well. Here is the code so you guys can rip it apart and tell me what you think. Load it in a simulator and see what you come up with.....

'Picaxe 20M2 Chip
'Code for still pictures
'Dip 1 and 2 controls the delay settings
'Dip 3 is for Daytime only mode. Switch 3 on is daytime only mode.
'Dip 4 is for Trail or Feeder modes. Switch 4 on is Feeder mode - off is trail mode

symbol CdsInput = B.4
symbol CdsPowerOut = B.3
symbol LedOut = B.5
symbol CamSht = B.7
symbol CamPwr = B.6
symbol StatusLED = C.0
symbol Spotlight = B.0
symbol Mic = C.5
symbol ExtraOutput = C.7
symbol ExcDay = B.1
symbol ExcNight = B.2
symbol PirInput = pinc.6
symbol FeederModeIn = pinC.4 ' Dip Switch 4 input
symbol DaymodeIn = pinC.3 ' Dip Switch 3 input
symbol DIP1 = pinC.1 ' Dip Switch 1 input
symbol DIP2 = pinC.2 ' Dip Switch 2 input

symbol WalkTestOnOff = bit1
symbol DayStatus = bit0
symbol PirCheck = bit2
symbol DayLevel = b4
symbol DaySetting = b5
symbol NightSetting = b6
symbol Counter = b7
symbol FeederMode = bit5
symbol CameraOn = bit4
symbol CameraRefreshTimer = w9
symbol CameraRefreshTime = w10
symbol CameraShutterTime = w11

disablebod
setfreq m4
' set the pins as outputs and low value
low LedOut
low CamPwr
low CamSht
low StatusLED
low Mic
low Spotlight
low ExcDay
low ExcNight
low ExtraOutput
Low CdsPowerOut

' set input pins as inputs
Input c.6 'pir input
Input c.4 'dip4 input
Input c.3 'dip3 input
Input c.2 'dip2 input
Input c.1 'dip1 input

' set default variable settings
CameraOn = 0
DayStatus = 1
DaySetting = 128
NightSetting = 117
PirCheck = 0
w13 = 0
WalkTestOnOff = 1 '1 = On 0 = Off
Sleep 1 ' To let power settle if needed before checking dip switch settings


'Setup camera timing for the rest of the operation of the camera

'check for type 1 camera settings Sony P41,W1,W5,W7,W290
'CameraRefreshTime = 1800 '1800 = 1 hour
'CameraShutterTime = 1200 '1.2 seconds

'check for type 2 camera settings Sony P32,P52,P72,W35,W55 Pentax E50,E90 Nikon L10,L11,L14
CameraRefreshTime = 1800 '1800 = 1 hour
CameraShutterTime = 1500 '1.5 seconds

'check for type 3 camera settings Sony S40,S600,W200,W220,W230 Samsung A503 Fuji J10
'CameraRefreshTime = 1800 '1800 = 1 hour
'CameraShutterTime = 2000 '2 seconds

'check for type 4 camera settings Panasonic
'CameraRefreshTime = 900 '900 = 30 minutes
'CameraShutterTime = 2000 '2 seconds

High LedOut
High StatusLED
Pause 1000
Gosub TurnOnCamera
NAP 9
Gosub TurnOffCamera
Pause 1000
Low LedOut
Low StatusLED
sleep 1
CameraRefreshTimer = 0
NAP 3

WalkTest:
if WalkTestOnOff = 1 then
NAP 6 ' pause for 1 second
PirCheck = 1
if PirInput = 1 then
high LedOut
high StatusLED
NAP 7 ' light led for 2.3 seconds
low LedOut
low StatusLED
sleep 2 ' pause low power for 3 seconds to allow pir to settle
w13 = 0
endif
if w13 >= 41 then ' approx 1 minute
gosub FlashLED
nap 7
goto CheckMode ' start main program loop
endif
w13 = w13 + 1
' increment loop counter
goto WalkTest
endif

CheckMode:
' check if Feeder Mode dip switch is on
if FeederModeIn = 0 then
goto FeederModeMain ' run in feeder mode
nap 3
else
goto TrailModeMain ' run in trail mode
nap 3
endif


FeederModeMain:
PirCheck = 1
if PirInput = 1 then
gosub CheckCDS
NAP 3
if DayModeIn = 1 and DayStatus = 0 then 'it is night time and daytime only switch is on
pause 100
goto FeederModeMain
endif
if CameraOn = 0 then 'if camera is off turn it on
nap 3
Gosub TurnOnCamera
pause CameraShutterTime
endif
high CamSht ' Press Shutter Button to take picture
pause 2100
low CamSht
sleep 1
gosub TurnOffCamera
gosub StartDelay
CameraRefreshTimer = 0
endif
CameraRefreshTimer = CameraRefreshTimer + 1
if CameraRefreshTimer >= CameraRefreshTime and DayStatus = 0 then
Gosub TurnOnCamera
Sleep 5
Gosub TurnOffCamera
Sleep 1
CameraRefreshTimer = 0
else
Sleep 1
endif
pause 1000
goto FeederModeMain



TrailModeMain:
PirCheck = 1
if PirInput = 1 then
gosub CheckCDS
NAP 3
if DayModeIn = 0 and DayStatus = 0 then 'it is night time and day only switch is on
pause 1000
goto TrailModeMain
endif
if CameraOn = 0 then ' if camera is off turn it on
Gosub TurnOnCamera
pause CameraShutterTime
endif
high CamSht ' Press Shutter Button to take picture
pause 2100
low CamSht
if DayStatus = 0 then 'it is night time and camera's flash needs to recharge
nap 8 'pause 4 seconds to allow flash to recharge
else
endif
CameraRefreshTimer = 0 'reset camera refresh counter/timer
pause 1000
w13 = 0
endif


if CameraOn = 1 then
w13 = w13 + 1 'increment temporary counter for camera on time
if w13 >= 15 then 'camera timer set to 30 seconds no activity
Gosub TurnOffCamera
w13 = 0
sleep 2
endif
endif

CameraRefreshTimer = CameraRefreshTimer + 1
if CameraRefreshTimer >= CameraRefreshTime then
Gosub TurnOnCamera
Sleep 5
Gosub TurnOffCamera
Sleep 1
CameraRefreshTimer = 0
else
pause 1000
endif
pause 1000
goto TrailModeMain

CheckCDS:
High CdsPowerOut
pause 600
readadc CdsInput, DayLevel
low CdsPowerOut
if DayLevel >= DaySetting then 'it is daytime
DayStatus = 1
endif
if DayLevel < NightSetting then 'it is night time
DayStatus = 0
end if
return

StartDelay:
if DIP1 = 1 and DIP2 = 1 then 'Dip 1 and Dip 2 OFF = No Delay
if Daystatus = 0 then
sleep 2 'if camera has a slave flash this needs to be 12000
else
pause 1000
endif
end if
if DIP1 = 0 and DIP2 = 1 then 'Dip 1 ON and Dip 2 OFF = 15 second delay
Sleep 8
end if
if DIP1 = 0 and DIP2 = 0 then 'Dip 1 and Dip 2 ON = 30 second delay
Sleep 15
endif
if DIP1 = 1 and DIP2 = 0 then 'Dip 1 OFF and Dip 2 ON = 1 minute delay
Sleep 29
endif
return

TurnOnCamera:
high CamPwr
pause 500
low CamPwr
CameraOn = 1
return

TurnOffCamera:
high CamPwr
pause 1100
low CamPwr
CameraOn = 0
return

FlashLED:
let b8 = 10
for Counter = 1 to b8
high LedOut
high StatusLED
pause 200
low LedOut
low StatusLED
pause 200
next Counter
return


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 02, 2014 6:52 am 
Offline
Royal
Royal
User avatar

Joined: Tue Feb 23, 2010 9:49 pm
Posts: 313
Hey Jim, sorry for not looking at this sooner. After looking at it a while, let's say the board is in trail mode, so you are looping continually through "TrailModeMain". If none of the if statements are true, then you are only doing this:

TrailModeMain:
PirCheck = 1
"I removed all of the if statements here"
pause 1000
goto TrailModeMain

So, you aren't getting any low power here because a pause doesn't put the chip to sleep.

_________________
Imagehttp://www.snapshotsniper.com/HomeBrewProducts.htm


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 03, 2014 7:29 pm 
Offline
Fledgling
Fledgling

Joined: Thu Jan 19, 2012 7:36 pm
Posts: 21
That code looks familiar maybe you would like some flash code with that order :)


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 04, 2014 9:10 am 
Offline
Moderator
Moderator
User avatar

Joined: Mon Feb 01, 2010 5:45 pm
Posts: 4385
Location: Sussex County NJ
Running through the simulator I get the walktest timer taking longer than a minute, quite a bit actually. Hmmm

_________________
Image trailcamkits.com


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 04, 2014 11:12 am 
Offline
Moderator
Moderator
User avatar

Joined: Mon Feb 01, 2010 5:45 pm
Posts: 4385
Location: Sussex County NJ
How about this?

Code:
'Picaxe 20M2 Chip
'Code for still pictures
'Dip 1 and 2 controls the delay settings
'Dip 3 is for Daytime only mode. Switch 3 on is daytime only mode.
'Dip 4 is for Trail or Feeder modes. Switch 4 on is Feeder mode - off is trail mode

symbol CdsInput = B.4
symbol CdsPowerOut = B.3
symbol LedOut = B.5
symbol CamSht = B.7
symbol CamPwr = B.6
symbol StatusLED = C.0
symbol Spotlight = B.0
symbol Mic = C.5
symbol ExtraOutput = C.7
symbol ExcDay = B.1
symbol ExcNight = B.2
symbol PirInput = pinc.6
symbol FeederModeIn = pinC.4 ' Dip Switch 4 input
symbol DaymodeIn = pinC.3 ' Dip Switch 3 input
symbol DIP1 = pinC.1 ' Dip Switch 1 input
symbol DIP2 = pinC.2 ' Dip Switch 2 input

symbol WalkTestOnOff = bit1
symbol DayStatus = bit0
symbol PirCheck = bit2
symbol DayLevel = b4
symbol DaySetting = b5
symbol NightSetting = b6
symbol Counter = b7
symbol FeederMode = bit5
symbol CameraOn = bit4
symbol CameraRefreshTimer = w9
symbol CameraRefreshTime = w10
symbol CameraShutterTime = w11

disablebod
setfreq m4
' set the pins as outputs and low value
low LedOut
low CamPwr
low CamSht
low StatusLED
low Mic
low Spotlight
low ExcDay
low ExcNight
low ExtraOutput
Low CdsPowerOut

' set input pins as inputs
Input c.6 'pir input
Input c.4 'dip4 input
Input c.3 'dip3 input
Input c.2 'dip2 input
Input c.1 'dip1 input

' set default variable settings
CameraOn = 0
DayStatus = 1
DaySetting = 128
NightSetting = 117
PirCheck = 0
w13 = 0
WalkTestOnOff = 1 '1 = On 0 = Off
Sleep 1 ' To let power settle if needed before checking dip switch settings


'Setup camera timing for the rest of the operation of the camera

'check for type 1 camera settings Sony P41,W1,W5,W7,W290
'CameraRefreshTime = 1800 '1800 = 1 hour
'CameraShutterTime = 1200 '1.2 seconds

'check for type 2 camera settings Sony P32,P52,P72,W35,W55 Pentax E50,E90 Nikon L10,L11,L14
CameraRefreshTime = 1800   '1800 = 1 hour
CameraShutterTime = 1500 '1.5 seconds

'check for type 3 camera settings Sony S40,S600,W200,W220,W230 Samsung A503 Fuji J10
'CameraRefreshTime = 1800 '1800 = 1 hour
'CameraShutterTime = 2000 '2 seconds

'check for type 4 camera settings Panasonic
'CameraRefreshTime = 900   '900 = 30 minutes
'CameraShutterTime = 2000 '2 seconds

High LedOut
High StatusLED
Pause 1000
Gosub TurnOnCamera
NAP 9
Gosub TurnOffCamera
Pause 1000
Low LedOut
Low StatusLED
sleep 1
CameraRefreshTimer = 0
NAP 3

WalkTest:
if WalkTestOnOff = 1 then
Pause 1000 ' pause for 1 second
PirCheck = 1
if PirInput = 1 then
high LedOut
high StatusLED
NAP 7 ' light led for 2.3 seconds
low LedOut
low StatusLED
sleep 2 ' pause low power for 3 seconds to allow pir to settle
w13 = 0
endif
if w13 >= 26 then ' approx 1 minute
gosub FlashLED
nap 7
goto CheckMode ' start main program loop
endif
w13 = w13 + 1
' increment loop counter
goto WalkTest
endif

CheckMode:
' check if Feeder Mode dip switch is on
if FeederModeIn = 0 then
goto FeederModeMain ' run in feeder mode
nap 3
else
goto TrailModeMain ' run in trail mode
nap 3
endif


FeederModeMain:
PirCheck = 1
if PirInput = 1 then
gosub CheckCDS
NAP 3
if DayModeIn = 1 and DayStatus = 0 then 'it is night time and daytime only switch is on
pause 100
goto FeederModeMain
endif
if CameraOn = 0 then 'if camera is off turn it on
nap 3
Gosub TurnOnCamera
pause CameraShutterTime
endif
high CamSht ' Press Shutter Button to take picture
pause 2100
low CamSht
sleep 1
gosub TurnOffCamera
gosub StartDelay
CameraRefreshTimer = 0
endif
CameraRefreshTimer = CameraRefreshTimer + 1
if CameraRefreshTimer >= CameraRefreshTime and DayStatus = 0 then
Gosub TurnOnCamera
Sleep 5
Gosub TurnOffCamera
Sleep 1
CameraRefreshTimer = 0
else
Sleep 1
endif
Nap 3
goto FeederModeMain



TrailModeMain:
PirCheck = 1
if PirInput = 1 then
gosub CheckCDS
NAP 3
if DayModeIn = 0 and DayStatus = 0 then 'it is night time and day only switch is on
pause 1000
goto TrailModeMain
endif
if CameraOn = 0 then ' if camera is off turn it on
Gosub TurnOnCamera
pause CameraShutterTime
endif
high CamSht ' Press Shutter Button to take picture
pause 2100
low CamSht
if DayStatus = 0 then 'it is night time and camera's flash needs to recharge
nap 8 'pause 4 seconds to allow flash to recharge
else
endif
CameraRefreshTimer = 0 'reset camera refresh counter/timer
pause 1000
w13 = 0
endif


if CameraOn = 1 then
w13 = w13 + 1 'increment temporary counter for camera on time
if w13 >= 15 then 'camera timer set to 30 seconds no activity
Gosub TurnOffCamera
w13 = 0
sleep 2
endif
endif

CameraRefreshTimer = CameraRefreshTimer + 1
if CameraRefreshTimer >= CameraRefreshTime then
Gosub TurnOnCamera
Sleep 5
Gosub TurnOffCamera
Sleep 1
CameraRefreshTimer = 0
else
pause 1000
endif
Nap 3
goto TrailModeMain

CheckCDS:
High CdsPowerOut
pause 600
readadc CdsInput, DayLevel
low CdsPowerOut
if DayLevel >= DaySetting then 'it is daytime
DayStatus = 1
endif
if DayLevel < NightSetting then 'it is night time
DayStatus = 0
end if
return

StartDelay:
if DIP1 = 1 and DIP2 = 1 then 'Dip 1 and Dip 2 OFF = No Delay
if Daystatus = 0 then
sleep 2 'if camera has a slave flash this needs to be 12000
else
pause 1000
endif
end if
if DIP1 = 0 and DIP2 = 1 then 'Dip 1 ON and Dip 2 OFF = 15 second delay
Sleep 8
end if
if DIP1 = 0 and DIP2 = 0 then 'Dip 1 and Dip 2 ON = 30 second delay
Sleep 15
endif
if DIP1 = 1 and DIP2 = 0 then 'Dip 1 OFF and Dip 2 ON = 1 minute delay
Sleep 29
endif
return

TurnOnCamera:
high CamPwr
pause 500
low CamPwr
CameraOn = 1
return

TurnOffCamera:
high CamPwr
pause 1100
low CamPwr
CameraOn = 0
return

FlashLED:
let b8 = 10
for Counter = 1 to b8
high LedOut
high StatusLED
pause 200
low LedOut
low StatusLED
pause 200
next Counter
return

_________________
Image trailcamkits.com


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 22, 2014 3:05 am 
Offline
Moderator
Moderator
User avatar

Joined: Mon Feb 01, 2010 5:45 pm
Posts: 4385
Location: Sussex County NJ
Latest code seems to be working ok Jim

Image
Image

_________________
Image trailcamkits.com


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

All times are


Who is online


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