My AIO Code

tbass
Posts: 3251
Joined: Sun Jan 31, 2010 9:07 pm
Location: Central PA near PSU
Contact:

My AIO Code

Post by tbass »

I've been debating releasing this code for the better part of the year. I never did get a good testing done on the timings, or build the 3 dip switch addon for the cam selection. I OFFER NO SUPPORT FOR THIS CODE. DO NOT EMAIL ME, PM ME, CALL ME, PESTER ME, ABOUT THIS CODE.

Code: Select all

'###################################################################################################
#rem

Coded By: tbass
Coded On: 2/4/2011
Reason: To add functionality, previously lacking in existing code, to the PicAxe AIO
		
Additions:	All pertinent variables are at the top and named descriptively
				Flashes are counted and the flash triggered at a set count
				Timings for all camera related functions were added and variables assigned
				.
			
Notes: 	Feel free to any parts or the entire code for any purpose.
			You may buy it, I'll tell you where to send your money LOL.
			You may sell it, but please keep my piggy bank in mind if you do ;-).
			You may print it out and use it for toilet paper or nose tissue if you like.

#endrem
'###################################################################################################

#picaxe20x2                
#terminal 9600
#no_table
disablebod


'###################################################################################################
'# Give the ports descriptive names
'###################################################################################################
Symbol inPT = B.0        	'Photo transistor input (Flash sensor)
Symbol inPIR = B.1			'PIR input (Motion sensor)
Symbol outLED = B.2        'LED output
Symbol outPower = B.3      'MOSFET for camera power on
Symbol outShutter = B.4    'MOSFET for shutter press
Symbol inCDS = B.5        	'CDS input to read light level
Symbol inDips = C.7			'Dip Switch input
Symbol outCDS = C.5        'CDS Output to power CDS while checking light levels
Symbol outFlash = C.4      'Opto Output to fire the slave
Symbol outIlluminator = C.3'MOSFET to charge the slave
Symbol outPT = C.2        	'Photo transistor output to power the PT while watching for flash
Symbol outSpare = C.1      'MOSFET output for spare
Symbol outDips = C.0			'Dip Switch output to power them while checking them


'###################################################################################################
'# Set the port directions
'###################################################################################################
Input inPT						
Input inCDS
Input inPIR
Input inDips					
Output outShutter
Output outPower
Output outLED
Output outCDS
Output outFlash
Output outIlluminator
Output outPT
Output outSpare
Output outDips  
Output B.7
Output A.0
Output B.6    

'###################################################################################################
'# bits 0-13 Open for use. These form b0 and b1, so we can't use those bytes
'# We can also use bits 16 to 31 by taking them from b2 and b3 is needed
'###################################################################################################
Symbol isRunning = bit0 			'This is a boolean flag to determine run state
Symbol isCamOn = bit1				'This is a boolean flag to determine if the camera is on or not
Symbol isNight	= bit2				'This is a boolean flag to determine if it is night or not
Symbol isVideo = bit3				'This is a boolean flag to determine if we need to trigger a flash
Symbol hasAmp = bit4					'This is a boolean flag to determine if we need to turn on a pre amp
Symbol isActivity = bit5			'This is a booleam flag to determine if activity was sensed
Symbol hasFlashed = bit6			'This is a boolean flag to determine is preflash has gone off
Symbol isFired = bit7				'This is a boolean flag to determine if the slave fire
Symbol isValidated = bit8			'This is a boolean flag to determine if the PIR is valid
Symbol useSlave	= bit9			'This is a boolean flag to determine if we are using a slave or array
Symbol isTrail = bit10				'This is a boolean flag to determine if we are in trail mode
Symbol isInvalid = bit11			'This is a boolean flag to determine if the PIR was invalid for Active Routine

'###################################################################################################
'# b1-3 are being left for use as bit variables above
'# b4-19 are open for use in this section
'###################################################################################################
Symbol intADCVal = b4				'This is an integer value of the ADC reading
Symbol intRefreshTime = b5			'How long to leave the unit on while refreshing	in seconds
Symbol intCount	= b6				'This is an integer to count with
Symbol intDayThreshold = b7		'This is an integer for the break point between day and night
Symbol intWalkTest = b8				'This is an integer for timing out the walk test
Symbol intDipVal = b9				'This is an integer for holding the cam select adc value
Symbol intFlashCount = b10			'This is an integer to count the number of flashes
Symbol intNumFlashes	= b11			'This is an integer to determine how many flashes before triggering
Symbol intLenVideo = b12			'This is an integer for the video length in seconds
Symbol intShotCount = b13			'This is an integer for the number of photos per event
Symbol intPIRTimeout = b14			'This is an integer for the time out for motion
Symbol intTimeUp = b15				'This is an integer to count the seconds without motion
Symbol intCDSCheckTime = b16		'This is an integer to for the time between checking light
Symbol intCDSCheckCounter = b17	'This is an integer to count until checking light

'###################################################################################################
'# w0-4 are being left for use as bit and byte variables above
'# w10-27 are open for use in this section
'###################################################################################################
Symbol intTimeOutCounter = w15	'A counter to know when to time out
Symbol intFlashTimeOut = w16		'How long in microseconds before timing out the flash
Symbol intShutter = w17				'Delay in milliseconds to wait for shutter press
Symbol intRefresh = w18				'How long to wait to refresh in 30 second increments
Symbol intNightDelay = w19			'How long to wait between shutter in night in milliseconds
Symbol intDayDelay = w20			'How long to wait between shutter in day in milliseconds
Symbol intPowerHold = w21			'How long to hold the power button down in milliseconds
Symbol intShutterHold = w22		'How long to hold the shutter button down in milliseconds
Symbol intNightShutter = w23		'How long to hold the shutter at night in milliseconds
Symbol intEventDelay = w24			'This is an integer for the delay for feeder mode in 30 seconds intervals
Symbol intSlaveRefresh = w25		'This is an integer to count until refresh time
Symbol intSlaveRefCounter	= W26	'This is an integer to count until the next Refresh
Symbol intCamRefCounter = w27		'This is an integer to count until the next cam refresh

'###################################################################################################
'# Set up the ADC and Interrupt ports
'###################################################################################################
pullup %00000000
adcsetup = %010000001000	'Set up B.5 and C.0 as an ADC Input


'###################################################################################################
'# Set all of the flags as needed for startup
'###################################################################################################
isRunning = 0 					'This is a boolean flag to determine run state
isCamOn = 0						'This is a boolean flag to determine if the camera is on or not
isNight	= 0					'This is a boolean flag to determine if it is night or not
isVideo = 0						'This is a boolean flag to determine if we need to trigger a flash
isActivity = 0					'This is a booleam flag to determine if activity was sensed
hasFlashed = 0					'This is a boolean flag to determine if the flash has gone off
isFired = 0						'This is a boolean flag to determine if the slave has fired
isValidated = 0				'This is a boolean flag to determine if the PIR is valid
useSlave	= 1					'This is a boolean flag to determine if we are using a slave or array
hasAmp = 0						'This is a boolean flag to determine if we need to turn on a pre amp
isTrail = 1						'This is a boolean flag to determine if we are in trail mode

intRefreshTime = 5			'Time to leave camera on during refresh
intDayThreshold = 150		'The max value of ADC In before calling it night
intWalkTest = 30				'Time in seconds for walk test to end
intFlashCount = 0				'Integer to hold the flashes counted
intNumFlashes = 2				'How many flashes to count before slave fires
intLenVideo	= 30				'Time to record video in seconds
intShotCount = 1				'Number of photos to take per event
intPIRTimeout = 30			'The number of seconds to wait for motion before turning off
intCDSCheckTime = 10			'The number of 30 second intervals between checking day/night
intCDSCheckCounter = 0			'The counter for checking day/night

'Actual time delay until shutter is pressed is inPowerHold + intShutter

intFlashTimeOut = 10000		'Time to wait before timing out the flash
intShutter = 1350				'Time to wait before pressing the shutter
intRefresh = 60				'Time to wait between refreshes in 30 second increments
intNightDelay = 5000			'Time to wait between photos at night in milliseconds
intDayDelay = 2000			'Time to wait between photo during the day
intPowerHold = 300			'Time to hold the power button in milliseconds
intShutterHold = 750			'Time to hold the shutter button during the day in milliseconds
intNightShutter = 3500		'Time to hold the shutter button during the night in millseconds
intEventDelay = 10			'Time to wait between checking for motion in 30 second increments
intSlaveRefresh = 20			'Time to wait between refreshing the slave in 30 second increments
intSlaveRefCounter = 0		'Thsi is an integer to count until slave refresh time
intCamRefCounter = 0			'This is an integer to count until cam refresh time

#rem
Sleep timings		
30sec		Sleep 13

--Cam Selection--
intDipVal	Camera	Vars Set
199			P41		-=Set=-
68				P32		-=No=-
115			S40		-=No=-
138			S600		*-=Set=-*
50				W30/35	-=No=-	
55				W55		*-=Set=-*
83				A503		*-=Set=-*
43				zi8		-=No=-

#endrem

intDipVal = 199

Main:
'### Add Generic code for possible 3pos dip cam select
'### Be sure to set aside spare ports for mosfet cable amp etc
	
	If isRunning <> 1 then		'Check to see if isRunning is True
		GoSub WarmUp				'If not then Warm Up to run
	EndIf
	
	If isActivity = 1 then
		GoSub Active
	End If
	
	Sleep 13
	
	inc intCDSCheckCounter
   		'sertxd ("intCDSCheckCounter!!! ", #intCDSCheckCounter,13,10)
	
	If intCDSCheckTime = intCDSCheckCounter then
		GoSub getCDS
		intCDSCheckCounter = 0
	EndIf
	
	If isNight = 1 then
	
		inc intCamRefCounter
		
		If intSlaveRefCounter = intSlaveRefresh then
			GoSub slaveCharge
			intSlaveRefCounter = 0
		EndIf
		
		If useSlave = 1 then
			inc intSlaveRefCounter
			
			If intCamRefCounter = intRefresh then
				GoSub camRefresh
				intCamRefCounter = 0
			EndIf
		EndIf
	EndIf
	
GoTo Main

'###################################################################################################
'# Flash and Interrupt related functions
'###################################################################################################

Interrupt:

	If hint2flag = 1 Then    	'Motion has been detected
		hint2flag = 0    			'reset hint2flag to 0
		isActivity = 1				'Set the activity flag
		sertxd ("Danger Will Robinson!!! ", #isActivity ,13,10)
   EndIf
   
	If hint1flag = 1 Then  		'Camera flash went off
   		'sertxd ("Flash picked up!", #intFlashCount,13,10)
    	inc intFlashCount			'add a flash to the counter
    	hasFlashed = 1
    	If intFlashCount = intNumFlashes then	'We counted the preset number of flashes
    		High outFlash
    		isFired = 1			'Fire the slave
   		'sertxd ("Fired!!! ", #intFlashCount,13,10)
   		Low outFlash
    	EndIf

    	hint1flag = 0
    	GoSub setFlash
	EndIf

	hintflag = 0

Return

flashTimer:
	intTimeOutCounter = 0
	do
	setfreq m32
		
		hasFlashed = 0
		Pauseus 1
		
		If isFired = 1 then
			Exit
		EndIf
		
		If intTimeOutCounter = intFlashTimeOut and hasFlashed = 0 then
   		Setint off
   		sertxd ("Timed Out!!! ", #intFlashCount,13,10)
   		'GoSub Blink
			Exit
		EndIf
		
		inc intTimeOutCounter
	loop while intFlashCount <> 0
	GoSub resetFlash
	
	setfreq m8
   		'sertxd ("intFlashCount=", #intFlashCount,13,10)
   		'sertxd ("isFired=", #isFired,13,10)
   		'sertxd ("hasFlashed=", #hasFlashed,13,10)
	
Return

'###################################################################################################
'# Activity related functions
'###################################################################################################

Active:

	Do
			'sertxd ("In Active section=", #isActivity,13,10)	
		If isActivity = 1 then
			'sertxd ("Headed to Activity=", #isActivity,13,10)	
			GoSub Activity
		EndIf
		If isInvalid = 0 and isCamOn = 0 then
			'sertxd ("Kicked out because isinValid=", #isInvalid,13,10)
			Exit
		EndIf
		'sertxd ("Out of Activity section=", #isActivity,13,10)	
		If isTrail = 1 then
			dec intTimeUp
			'sertxd ("PIR Timeout=", #intTimeUp,13,10)		
			Pause 1000
		Else
			intTimeUp = 0
		EndIf
	Loop While intTimeUp > 0
	
	GoSub resetPIRTimeUp
	
	If isInvalid = 0 and isCamOn = 1 then
		GoSub Power
	EndIf
	
Return

Activity:
	
	isActivity = 0						'Reset the activity flag for next time
	GoSub validatePIR					'Help prevent false triggers
	sertxd ("PIR Valid=", #isValidated,13,10)
	If isValidated = 1 then
	GoSub getCDS
		isValidated = 0				'Reset the vallidation for next time
		If isRunning = 1 then 			'We are not in walktest
		
			'sertxd ("PIR Valid=", #isRunning,13,10)
			If isCamOn = 0 then
				GoSub Power
				Pause intShutter
			EndIf
			
			If isNight = 1 then			'It is night time
				GoSub activeNight
			Else
				GoSub activeDay
			EndIf
				
		'Walk test option
		Else									'We are in walk test mode still
			GoSub activeWalkTest
		EndIf		
	EndIf
		
	GoSub setPIR
	
Return

activeDay:

	If isVideo = 0 then		'Check if we need a trigger or not
		Do
			GoSub Shutter
			Inc intCount
		Loop While intCount < intShotCount	
	Else							'We are in video mode
		If hasAmp = 1 then
			GoSub Amp
		EndIf
		GoSub Shutter			'Go start the video
		intCount = 0
			Do
				Pause 1000		'Count the seconds
				inc intCount	'Add another second to the counter
			Loop While intCount < intLenVideo	'Keep counting until intCount = intLenVideo	
		GoSub Shutter			'stop the video
		If hasAmp = 1 then
			GoSub Amp
		EndIf
	EndIf

Return
 
activeNight:

	If useSlave = 1 then
		High outIlluminator		'Turn on Array or Slave
	EndIf
		If isVideo = 0 then		'Check if we need a trigger or not
			If useSlave = 1 then
				High outPT				'Turn on the sensor
			EndIf
			intCount = 0
			Do
				GoSub Shutter
				Inc intCount
			Loop While intCount < intShotCount
			If useSlave = 1 then
				Low outPT			'Turn the sensor back off
			EndIf
		Else
			If hasAmp = 1 then
				GoSub Amp
			EndIf
			GoSub Shutter		'Start the video
			intCount = 0
				Do
					Pause 1000		'Count the seconds
					inc intCount	'Add another second to the counter
				Loop While intCount < intLenVideo	'Keep counting until intCount = intLenVideo
			GoSub Shutter			'stop the video
			If hasAmp = 1 then
				GoSub Amp
			EndIf				
		EndIf
	If useSlave = 1 then
		High outIlluminator		'Turn off Array or Slave
	EndIf
	intSlaveRefCounter = 0
				
Return

validatePIR:

	If Pinb.1 = 1 then
		pause 50
		If Pinb.1 = 1 then
			isValidated = 1
		Else
			isInvalid = 0
		EndIf
	EndIf

Return

Blink:

	For intCount = 1 to 20
		toggle outLED
		pause 250
	Next
	
Return

'###################################################################################################
'# Camera Related Functions
'###################################################################################################

Power:
	
	If isCamON = 1 then
		High outPower
		Pause intPowerHold
		Low outPower
		isCamOn = 0
		intCamRefCounter = 0
	Else
		High outPower
		Pause intPowerHold
		Low outPower
		isCamOn = 1
	EndIf

Return

Shutter:
	
	sertxd ("I shutter with fear LoLz!!! ", #isActivity ,13,10)
	High outShutter
	
		If isNight = 1 then
			GoSub setFlash
			'sertxd ("Flash set.",13,10)
			'high outLED
			Pause intNightShutter
			If hasFlashed = 1 then
				GoSub flashTimer
			EndIf
			Low outShutter
			'low outLED
			Pause intNightDelay
		Else
			Pause intShutter
			Low outShutter
			Pause intDayDelay
		EndIf
		
	GoSub resetPIRTimeUp

Return

Amp:

	'Add code to run preamp here

Return

'###################################################################################################
'# Day/Night Related Functions
'###################################################################################################

slaveCharge:
	
	High outIlluminator
	Sleep 5
	Low outIlluminator

Return

camRefresh:
	
	If intDipVal <> 83 Then
		GoSub Power
		Sleep intRefreshTime
		GoSub Power
	EndIf

Return

getCDS:

	High outCDS						'Put the output high to the divider circuit
  	readadc 10 , intADCVal		'Read the ADC value into intADCVal
  	Low outCDS						'Put the output low again
  	
  	If intADCVal > intDayThreshold then
  		isNight = 1					'Set the flag to true because it's dark out
  	Else
  		isNight = 0					'Set the flag to false because it's light out
  	EndIf
  	
   sertxd ("CDS=", #intADCVal,13,10)
   sertxd ("intDayThreshold=", #intDayThreshold,13,10) 
    
Return

'###################################################################################################
'# Flag setting and resetting functions
'###################################################################################################

setFlash:

	hintsetup %00100010    				'set HINT1 for flash detection
	Setintflags %00000010,%00000010	'enable interrupt flags
	
Return

setPIR:

	hintsetup %01000100    				'set HINT2 for motion detection
	Setintflags %00000100,%00000100	'enable interrupt flags

Return

resetFlash:

	intFlashCount = 0						'Reset the flash counter to zero
	hasFlashed = 0							'Reset the flash detected flag to false
	isFired = 0								'Reset the flash fired flad to false

Return

resetPIRTimeUp:

	intTimeUp = intPIRTimeOut

Return

'###################################################################################################
'# Startup Only Functions
'###################################################################################################

WarmUp:

	High outLED
	GoSub getCDS					'go read the ADC value for day/night
	'GoSub getDips					'go read the ADC value for the dips
	GoSub setDips
	If useSlave = 1 and isVideo = 0 then
		GoSub slaveCharge
	EndIf
	GoSub camRefresh
	Low outLED
	
	GoSub setPIR					'enable PIR Interrupt
	GoSub walkTest					'run a walk test
	GoSub resetPIRTimeUp
	
Return

walkTest:

	Do
		If isActivity = 1 then
			GoSub Activity
		EndIf
		Pause 1000
		dec intWalkTest
		'sertxd ("Walk Test Counter ", #intWalkTest,13,10)
	Loop While intWalkTest > 0
	isRunning = 1
	GoSub Blink
	
Return

activeWalkTest:

	High outLED					'Turn on the LED
	Sleep 1						'Keep it on for 2.3 seconds
	Low outLED					'Turn off the LED
	intWalkTest = 30			'Rest the walk test counter to 30
	Sleep 1						'Turn off the LED

Return

getDips:

	High outDips						'Put the output high to the divider circuit
  	pause 300
  	readadc 3 , intDipVal		'Read the ADC value into intADCVal
  	Low outDips
  	
   'sertxd ("CDS ", #intDipVal,13,10)
   'sertxd ("Again",13,10) 
   goSub getDips
   
Return

#rem
'Try milspec resistors for accurcy from board to board
########################## CDS Value For 3 dips ############################
'199		0	0	0
'68		1	0	0
'115		0	1	0
'138		0	0	1
'50		1	1	0
'55		1	0	1
'83		0	1	1
'43		1	1	1
#endrem

setDips:
	'Add values together to calculate the true timing
	'The total delay power hold + shutter delay
	'Then sometime during the shutter hold, the cam takes a photo
	Select intDipVal
		Case 199
			'P41
			isVideo = 0						'Boolean to determine if it's video
			intRefresh = 60				'How frequently to refresh
			intRefreshTime = 3			'How long to leave on for refresh
			intPowerHold = 300			'How long to hold the power button down
			intShutter = 1350				'How long to wait before shutter
			intShutterHold = 750			'How long to hold the shutter down
			intNightDelay = 3000			'Delay between photos at night
			intNightShutter = 1000		'How long to hold the shutter down at night
			intFlashTimeOut = 10000		'Time to wait before timing out the flash
			intDayDelay = 2000			'Time to wait between photo during the day
			intNumFlashes = 2				'How many flashes to count before slave fires

		Case 68
			'P32
			isVideo = 0						'Boolean to determine if it's video
			intRefresh = 60				'How frequently to refresh
			intRefreshTime = 3			'How long to leave on for refresh
			intPowerHold = 300			'How long to hold the power button down
			intShutter = 1350				'How long to wait before shutter
			intShutterHold = 750			'How long to hold the shutter down
			intNightDelay = 5000			'Delay between photos at night
			intNightShutter = 3500		'How long to hold the shutter down at night
			intFlashTimeOut = 10000		'Time to wait before timing out the flash
			intDayDelay = 2000			'Time to wait between photo during the day
			intNumFlashes = 2				'How many flashes to count before slave fires
		Case 115
			'S40
			isVideo = 0						'Boolean to determine if it's video
			intRefresh = 60				'How frequently to refresh
			intRefreshTime = 3			'How long to leave on for refresh
			intPowerHold = 300			'How long to hold the power button down
			intShutter = 1350				'How long to wait before shutter
			intShutterHold = 750			'How long to hold the shutter down
			intNightDelay = 5000			'Delay between photos at night
			intNightShutter = 3500		'How long to hold the shutter down at night
			intFlashTimeOut = 10000		'Time to wait before timing out the flash
			intDayDelay = 2000			'Time to wait between photo during the day
			intNumFlashes = 2				'How many flashes to count before slave fires
		Case 138
			'S600
			isVideo = 0						'Boolean to determine if it's video
			intRefresh = 60				'How frequently to refresh
			intRefreshTime = 3			'How long to leave on for refresh
			intPowerHold = 300			'How long to hold the power button down
			intShutter = 1750				'How long to wait before shutter
			intShutterHold = 750			'How long to hold the shutter down
			intNightDelay = 5000			'Delay between photos at night
			intNightShutter = 3500		'How long to hold the shutter down at night
			intFlashTimeOut = 10000		'Time to wait before timing out the flash
			intDayDelay = 2000			'Time to wait between photo during the day
			intNumFlashes = 2				'How many flashes to count before slave fires
		Case 50
			'W30/35
			isVideo = 0						'Boolean to determine if it's video
			intRefresh = 60				'How frequently to refresh
			intRefreshTime = 3			'How long to leave on for refresh
			intPowerHold = 300			'How long to hold the power button down
			intShutter = 1350				'How long to wait before shutter
			intShutterHold = 750			'How long to hold the shutter down
			intNightDelay = 5000			'Delay between photos at night
			intNightShutter = 3500		'How long to hold the shutter down at night
			intFlashTimeOut = 10000		'Time to wait before timing out the flash
			intDayDelay = 2000			'Time to wait between photo during the day
			intNumFlashes = 2				'How many flashes to count before slave fires
		Case 55
			'W55
			isVideo = 0						'Boolean to determine if it's video
			intRefresh = 60				'How frequently to refresh
			intRefreshTime = 3			'How long to leave on for refresh
			intPowerHold = 300			'How long to hold the power button down
			intShutter = 1350				'How long to wait before shutter
			intShutterHold = 750			'How long to hold the shutter down
			intNightDelay = 5000			'Delay between photos at night
			intNightShutter = 3500		'How long to hold the shutter down at night
			intFlashTimeOut = 10000		'Time to wait before timing out the flash
			intDayDelay = 2000			'Time to wait between photo during the day
			intNumFlashes = 2				'How many flashes to count before slave fires
		Case 83
			'A503
			isVideo = 0						'Boolean to determine if it's video
			intRefresh = 60				'How frequently to refresh
			intRefreshTime = 3			'How long to leave on for refresh
			intPowerHold = 300			'How long to hold the power button down
			intShutter = 1800				'How long to wait before shutter
			intShutterHold = 750			'How long to hold the shutter down
			intNightDelay = 3000			'Delay between photos at night
			intNightShutter = 300		'How long to hold the shutter down at night
			intFlashTimeOut = 10000		'Time to wait before timing out the flash
			intDayDelay = 1800			'Time to wait between photo during the day
			intNumFlashes = 2				'How many flashes to count before slave fires
		Case 43
			'zi8
			isVideo = 0						'Boolean to determine if it's video
			intRefresh = 60				'How frequently to refresh
			intRefreshTime = 3			'How long to leave on for refresh
			intPowerHold = 300			'How long to hold the power button down
			intShutter = 1100				'How long to wait before shutter
			intShutterHold = 750			'How long to hold the shutter down
			intNightDelay = 5000			'Delay between photos at night
			intNightShutter = 3500		'How long to hold the shutter down at night
			intFlashTimeOut = 10000		'Time to wait before timing out the flash
			intNightDelay = 5000			'Time to wait between photos at night in milliseconds
			intDayDelay = 2000			'Time to wait between photo during the day
			intEventDelay = 10			'Time to wait between checking for motion in 30 second increments
			intFlashTimeOut = 10000		'Time to wait before timing out the flash
			intNumFlashes = 2				'How many flashes to count before slave fires
		Else
			GoSub DeadZone
	End Select

Return

DeadZone:
	Do	
		intCount = 255
		toggle outLED
		pause 300
	Loop While intCount > 5
Return
User avatar
rick
Posts: 513
Joined: Fri Aug 13, 2010 8:35 pm
Location: central kentucky

Re: My AIO Code

Post by rick »

I OFFER NO SUPPORT FOR THIS CODE. DO NOT EMAIL ME, PM ME, CALL ME, PESTER ME, ABOUT THIS CODE
Well your no fun at all.LOL
tbass
Posts: 3251
Joined: Sun Jan 31, 2010 9:07 pm
Location: Central PA near PSU
Contact:

Re: My AIO Code

Post by tbass »

quite true. I saw what smclark and some of the other guys went through. They were constantly being bothered privately instead of folks openly discussing stuff so everyone could learn. I've also known a few folks to ask them for help and then throw some blame when things didn't work flawlessly. I'm just trying to nip it in the bud.
buckshot164
Posts: 758
Joined: Tue Feb 16, 2010 6:19 am

Re: My AIO Code

Post by buckshot164 »

Pm sent to aggitate you.
tbass
Posts: 3251
Joined: Sun Jan 31, 2010 9:07 pm
Location: Central PA near PSU
Contact:

Re: My AIO Code

Post by tbass »

I don't have any messages?
User avatar
rick
Posts: 513
Joined: Fri Aug 13, 2010 8:35 pm
Location: central kentucky

Re: My AIO Code

Post by rick »

Tony, been looking at you code and was trying to find out which dip switch is on and which is off. but the more I looked the dumber I got, If you could shine some light on it I would be thankful.
gkowen
Posts: 114
Joined: Sun Jan 31, 2010 9:02 pm

Re: My AIO Code

Post by gkowen »

I love it when the code comes together.
tbass
Posts: 3251
Joined: Sun Jan 31, 2010 9:07 pm
Location: Central PA near PSU
Contact:

Re: My AIO Code

Post by tbass »

rick wrote:Tony, been looking at you code and was trying to find out which dip switch is on and which is off. but the more I looked the dumber I got, If you could shine some light on it I would be thankful.
I originally had it set up to add on a set of resistors and readadc to determine which of the three switches were in which position. I never got the bugs worked out of it. That is why you manually assign intDipVal right before main. I assume that is the part you were asking about?
tbass
Posts: 3251
Joined: Sun Jan 31, 2010 9:07 pm
Location: Central PA near PSU
Contact:

Re: My AIO Code

Post by tbass »

This is basically what I had intended. The problem was that the ADC would vary from setup to setup. I had initially thought about trying milspec resistors, but figured a code change would have been a better option. I was going to try setting up a range for each dip setting and check for a value in the range. If that makes better sense.
You do not have the required permissions to view the files attached to this post.
gkowen
Posts: 114
Joined: Sun Jan 31, 2010 9:02 pm

Re: My AIO Code

Post by gkowen »

You sure that resistor is a 220K? That doesn't make much change in voltage at the ADC input when the switches are changed. I'd use something like 10K and 22K in the switch network. I haven't used your chip but you don't have enough voltage change when you change switches.
Post Reply