CritterGetter GENERATION 2.0 Basic Code

Post Reply
User avatar
FIREMANJIM
Posts: 783
Joined: Wed Aug 04, 2010 2:37 pm
Location: Decherd, Tennessee

CritterGetter GENERATION 2.0 Basic Code

Post by FIREMANJIM »

For you guys who are still buying my boards from me here is the Standard Basic Code for the Critter Getter GENERATION 2.0 Board. I will post some more codes as I have time...

Code: Select all

#REM
PROGRAMMING FOR THE NEW CRITTERGETTER GENERATION 2.0 CAMERA CONTROLLER
CONTROLS ALL 4 BASIC TYPES OF CAMERAS FROM DIP SWITCHES
DIP 1 CONTROLS THE DELAY BETWEEN PICTURES IF IN FEEDER MODE (DIP 2 IS OFF)
DIP 1 OFF = 1 MINUTE DELAY  
DIP 1 ON  = 6 MINUTE DELAY
DIP 2 CONTROLS THE MODE OF OPERATION
DIP 2 OFF = FEEDER MODE (DELAY CONTROLLED BY DIP 1)
DIP 2 ON = TRAILMASTER MODE (FASTEST PICTURES POSSIBLE)
DIPS 3 & 4 SELECTS THE TYPE OF CAMERA USED
DIP 3 OFF  DIP 4 OFF = TYPE 1 CAMERA 1.2 SECOND SHUTTER DELAY
DIP 3 OFF  DIP 4 ON  = TYPE 2 CAMERA 1.5 SECOND SHUTTER DELAY
DIP 3 ON   DIP 4 OFF = TYPE 3 CAMERA 2.0 SECOND SHUTTER DELAY
DIP 3 ON   DIP 4 ON  = TYPE 4 CAMERA 2.0 SECOND SHUTTER DELAY HOLD POWER BUTTON (PANASONICS)
#ENDREM

Symbol DIP3 = pinB.0
Symbol DIP2 = pinB.1
Symbol DIP1 = pinB.2
Symbol Out2 = B.3
Symbol Cam2Sht = B.4
Symbol Cam2Pwr = B.5
Symbol Out3 = B.6
Symbol CamSht = B.7
Symbol CDSPwr = C.0
Symbol CDSRead = C.1
Symbol PIRInput = pinC.2
Symbol Out1 = C.3
Symbol SerialIn = pinC.4
Symbol DIP4 = pinC.5
Symbol CamPwr = C.6
Symbol LED = C.7
'List Inputs
Input B.0	'Dip 3 Input
Input B.1	'Dip 2 Input
Input B.2	'Dip 1 Input
Input C.2	'PIR Sensor Input
Input C.4	'Serial Programming Input
Input C.5	'Dip 4 Input
'List the Outputs and make them low
Low Out2
Low Cam2Sht
Low Cam2Pwr
Low Out3
Low CamSht
Low CDSPwr
Low Out1
Low CamPwr
Low LED
'List Bit Variables
Symbol DayStatus = Bit0
Symbol CameraOn = Bit1
Symbol Type4 = Bit2
'List Byte Variables
Symbol LightLevel = B4
Symbol DaySetting = B5
Symbol NightSetting = B6
Symbol Counter = B7
'List Word Variables
Symbol FeederDelay = W7
Symbol WalkTestTimer = W8
Symbol CameraRefreshTimer = W9
Symbol CameraRefreshTime = W10
Symbol TrailMasterTimer = W11
Symbol ShutterDelay = W12
Symbol CheckCDSTimer = W13

Disablebod	'Disable the chips Brownout function

'Set standard variables
DayStatus = 1
CameraOn = 0 
Type4 = 0 
DaySetting = 35
NightSetting = 20
WalkTestTimer = 0 
CameraRefreshTimer = 0 
TrailMasterTimer = 0 
CheckCDSTimer = 0 
Nap 5	'Allow Power to settle so we can check some dip switch settings
If DIP1 = 1 Then		'Dip 1 is OFF so Feeder Delay is set for 1 minute
	FeederDelay = 27
ElseIf DIP1 = 0 Then	'Dip 1 is ON so Feeder Delay is set for 6 minutes
	FeederDelay = 157
EndIf
Nap 5	'Allow power to settle so we can check Dips 3 & 4
If DIP3 = 1 and DIP4 = 1 Then 	'Dip 3 and Dip 4 is OFF so Type 1 camera is selected
	ShutterDelay = 1200		'1.2 second delay
	CameraRefreshTime = 25000	'Refresh camera once every hour if its dark
ElseIf DIP3 = 1 and DIP4 = 0 Then	'Dip 3 is OFF and Dip 4 is ON so Type 2 camera is selected
	ShutterDelay = 1500		'1.5 second delay
	CameraRefreshTime = 25000
ElseIf DIP3 = 0 and DIP4 = 1 Then	'Dip 3 is ON and Dip 4 is OFF so Type 3 Camera is selected
	ShutterDelay = 2000		'2.0 second delay
	CameraRefreshTime = 25000
ElseIf DIP3 = 0 and DIP4 = 0 Then	'Dip 3 and Dip 4 are both ON so Type 4 Camera is selected
	ShutterDelay = 2000		'2.0 second delay
	CameraRefreshTime = 25000
	Type4 = 1				'Type 4 camera selected so we will hold the power button down
EndIf
Nap 3
'Let's turn on the camera and power everything up for 30 seconds so pir circuit can stabalize
High LED	'Turn on the status led
Pause 500
High CamPwr	'Turn ON the camera
Pause 500
If Type4 = 0 Then
	Low CamPwr
EndIf
Sleep 14	'pause 30 seconds to allow pir circuit to stabilize
High CamPwr	'Turn the camera OFF
Pause 500
Low CamPwr
Pause 500
Low LED	'turn the led off
Nap 5		'Allow power to stabalize before we check the cds to see if it is day or night
High CDSPwr 'Apply power to CDS sensor
Nap 5     	'Allow power to settle
Readadc     CDSRead, LightLevel
Low CDSPwr
If LightLevel < NightSetting then
   	DayStatus = 0
ElseIf LightLevel >= DaySetting then
	DayStatus = 1 
EndIf
CheckCDSTimer = 0
CameraRefreshTimer = 0 
Nap 3

WalkTest:
If PIRInput = 1 Then
	Pause 50
	If PIRInput = 0 Then
		GoTo WalkTest
	EndIf
	High LED
	Nap 6     	'Pause low power for 1.1 seconds
	Low LED
	Nap 8  	'Pause low power for 4 seconds
	WalkTestTimer = 0
EndIf
If WalkTestTimer >= 208 then	'Approx 30 seconds 
      Let B8 = 10	'Here is where you set the #of led flashes when walk test ends
      For Counter = 1 to B8
	High LED
	Pause 200
	Low LED
	Pause 200
	Next Counter
      Pause 1000
	SetInt %00100000, %00100000	'Set the PIR Interrupt so when motion is detected
	Pause 500
      GoTo MainProgramLoop	'Start main program loop
EndIf 
WalkTestTimer = WalkTestTimer +  1	'Increment loop counter              
GoTo WalkTest

MainProgramLoop:
If CameraOn = 1 Then
	TrailMasterTimer = TrailMasterTimer + 1	'Increment timer for TrailMasterMode
	If TrailMasterTimer > 208 Then	'Approximately 30 seconds
		High CamPwr	'Turn Off the camera
		Pause 500
		Low CamPwr
		CameraOn = 0 'Camera is off
		CameraRefreshTimer = 0 
		TrailMasterTimer = 0
		Sleep 2
	EndIf
EndIf

CameraRefreshTimer = CameraRefreshTimer + 1	'Increment timer for camera refresh every hour
If CameraRefreshTimer > CameraRefreshTime Then
	If DayStatus = 0 Then	'It is dark outside so lets turn on the camera and refresh the flash
		High CamPwr
		If Type4 = 0 Then
			Low CamPwr
		EndIf
		CameraOn = 0 
		Sleep 5	'Leave camera ON for 10 seconds to refresh the flash capacitor
		High CamPwr
		Pause 500
		Low CamPwr
		CameraOn = 0 
		Sleep 2
	ElseIf DayStatus = 1 Then	'Its Daytime outside so no need to turn on the camera
		Sleep 2
	EndIf
CameraRefreshTimer = 0
EndIf

CheckCDSTimer = CheckCDSTimer + 1	'Increment the timer for checking the cds sensor
If CheckCDSTimer > 2084 Then	'Check the CDS Every 5 Minutes
	Nap 5
	High CDSPwr
	Nap 5     	'Allow power to settle
	Readadc     CDSRead, LightLevel
	Low CDSPwr
	If LightLevel < NightSetting then
   		DayStatus = 0
	ElseIf LightLevel >= DaySetting then
		DayStatus = 1 
	EndIf
CheckCDSTimer = 0
Nap 3
EndIf
Nap 3
GoTo MainProgramLoop


Interrupt:
If CameraOn = 0 Then	'PIR has sensed motion so lets turn on the camera
	High CamPwr	'Push the power button
	Pause 500
	If Type4 = 0 Then
		Low CamPwr
	EndIf
	CameraOn = 1	'Camera Is ON
	Pause ShutterDelay	'Pause the shutter delay
EndIf
High CamSht	'Push the shutter button to take a picture
Pause 3000
Low CamSht
If DIP2 = 1 Then	'Dip 2 is OFF so we are running in feeder mode so let's turn off the camera
	Pause 2000
	High CamPwr	'Turn OFF the camera
	Pause 500
	Low CamPwr
	CameraOn = 0 	'Camera is now OFF
	CameraRefreshTimer = 0
	TrailMasterTimer = 0 
	Sleep FeederDelay	'Sleep the amount of time selected by Dip 1 before we look for motion again
	SetInt %00100000, %00100000	'Reset the Interrupt for the next PIR detection
	Return	'Return to the Main Program Loop
EndIf
If DayStatus = 1 Then	'Its daytime so no need for any extra time to recharge flash
	Pause 1000
ElseIf DayStatus = 0 Then	'Its dark outside so lets pause a few seconds and let flash charge
	Pause 4000
EndIf
TrailMasterTimer = 0	'Reset the TrailMaster Timer 
CameraRefreshTimer = 0 	'Reset the camera refresh Timer
SetInt %00100000, %00100000	'Reset the Interrupt for the next PIR detection
Return	'Return to the Main Program Loop
Post Reply