day/night determination

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

day/night determination

Post by tbass »

I used this code to make sure the board was seeing night when I thought it was night. dkirk mentioned there may be a variance with the cds between sources. I have some from Yeti, some from digikey, radio shack, and tayda. I didn't take the time to figure out if there are differences, or what the differences are.

Code: Select all

#rem

Coded By: tbass
Coded On: 2/26/2011
Reason: To determine my own ADC for day and night.

#endrem

#picaxe20x2                
#terminal 9600
#no_table
disablebod


'###################################################################################################
'# Give the ports descriptive names
'###################################################################################################
Symbol inCDS = B.5        	'CDS input to read light level
Symbol outCDS = C.5        'CDS Output to power CDS while checking light levels
Symbol outLED = B.2        'LED output
					
Input inCDS
Output outCDS

Symbol intADCVal = b4		'This is an integer value of the ADC reading
Symbol intCount	= b6		'This is an integer to count with
Symbol dayThreshold = b7	'This is an integer to determine the day/night adc value

'###################################################################################################
'# Set up the ADC
'###################################################################################################
adcsetup = %010000000000	'Set up B.5 as an ADC Input

'########################
'
'	Change dayThreshold higher if the board thinks it is night but it is not
' 	Change it lower if the board thinks it is daylight and it is not
'
'########################

dayThreshold = 130

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
  	
    sertxd ("CDS ", #intADCVal,13,10)
    sertxd ("Again",13,10)
    
    '########################
    '
    '	Change dayThreshold higher if the board thinks it is night but it is not
    ' Change it lower if the board thinks it is daylight and it is not
    '
    '########################
    
    If intADCVal > dayThreshold then
    	for intCount = 1 to 10
    		toggle outLED	'blink 5 times
    		pause 300
    	next
    Else
    	for intCount = 1 to 6
    		toggle outLED	'blink 3 times
    		pause 300
    	next
    EndIf
     
	Sleep 2

goto getCDS
User avatar
jjkscf
Posts: 1343
Joined: Sun Jan 31, 2010 4:39 pm

Re: day/night determination

Post by jjkscf »

Fantastic info Tony, I could even follow it....I have a build that is right down this alley
Joe
Bowmanpa
Posts: 31
Joined: Mon Mar 01, 2010 10:34 am

Re: day/night determination

Post by Bowmanpa »

Tony,
Do you have to have and exchanger to use with the AIO board or does the AIO control the Day/Night part too?

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

Re: day/night determination

Post by tbass »

I'm not sure what you are asking. What are you trying to build?
Bowmanpa
Posts: 31
Joined: Mon Mar 01, 2010 10:34 am

Re: day/night determination

Post by Bowmanpa »

A P32 that takes Color day pics and IR night pics. I should have read the Topic closer I see that you are trying to find out what cds works better with the AIO board for day/night sensativity correct so if so my bad.

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

Re: day/night determination

Post by tbass »

Not exactly. This is just to calibrate it for the cds used, and the lens used. You may need to change the value depending on if you have a white, gray, brown, or otherwise colored fresnal. Or if you locate the cds outside the build where it can get a ton of light.
Bowmanpa
Posts: 31
Joined: Mon Mar 01, 2010 10:34 am

Re: day/night determination

Post by Bowmanpa »

I see. My bad for not really reading everything first before I posted my reply.
User avatar
johnnydeerhunter
Posts: 4384
Joined: Mon Feb 01, 2010 5:45 pm
Location: Sussex County NJ

Re: day/night determination

Post by johnnydeerhunter »

I have been playing with this tonight and it's really a neat program to mess with.

Thanks Tony :cheers
Post Reply