Welcome Anonymous
Fledgling
Fledgling
It is currently Fri Jun 23, 2017 11:24 am

All times are



Post new topic Reply to topic  [ Array ] 
Author Message
PostPosted: Wed May 02, 2012 8:02 pm 
Offline
Fledgling
Fledgling

Joined: Fri Jul 08, 2011 5:48 am
Posts: 73
I have been having bad luck with codes lately. The code that I got from this site for a (S40 4 wire hack with slave) does not work properly. Would anyone happen to have an s40 code they would share?


Top
 Profile  
Reply with quote  
PostPosted: Thu May 03, 2012 5:23 pm 
Offline
Emperor
Emperor
User avatar

Joined: Fri Aug 13, 2010 8:35 pm
Posts: 552
Location: central kentucky
You can try the S600 fast hack code it's about the same timing.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 03, 2012 7:18 pm 
Offline
Fledgling
Fledgling

Joined: Fri Jul 08, 2011 5:48 am
Posts: 73
yes I have a s600 code but its not with a slave. I need an S40 fast hack with Slave.


Top
 Profile  
Reply with quote  
PostPosted: Thu May 03, 2012 8:07 pm 
Offline
Emperor
Emperor
User avatar

Joined: Fri Aug 13, 2010 8:35 pm
Posts: 552
Location: central kentucky
'=========================
'Sony S40 4 wire
'=========================




#picaxe20x2
'#terminal 9600
#no_data
#no_table
disablebod

'=====================================================
' Map Ports
'=====================================================
Symbol CDS_Out = C.5 ' Output to LDR voltage Divider
Symbol LC_Out = C.1 ' Lens cover switch
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 CamPwrState = B7
Symbol Normal_OP = B8
Symbol CamPwrDownTimer = B10
Symbol Event_Delay = B11
Symbol CamEvent_Flag = B12
Symbol Cam_Mode = B13
Symbol PRELOAD = 63890 ' approx 15 sec at 31khz
Symbol CDS_Value = b16
Symbol Night_Flag = b17
Symbol Day = b18
Symbol Night = b19
Symbol TimerLimit = b23
Symbol CamRefresh = W12

'=====================================================
' Set Port Directions
'=====================================================
Output CDS_Out
Output LC_Out
Output Battery_Monitor
Input LDR_IN
Output Shutter_Out
Output Power_Out
Output LED_Out
Input PIR_In
Input C.7
Input C.6
Input B.7
Input C.0

`=====================================================
`Camera settings
`=====================================================
'Delay after power on
symbol Shutter_pause = 2000

'Amount of time that can pass before the camera needs refreshed
'value=(10*timeinseconds/147)-1
'example if a 73.5s refresh is needed you would set it equal to 4
'4=(10*73.5/147)-1
Symbol CamRefreshLimit = 244

'Timervalue1 and Timervalue2 are in multiples of 5 sec
'Timer value to be used if C.0 is Low
Symbol Timervalue1 = 3

'Timer value to be used if C.0 is High
Symbol Timervalue2 = 6

'=====================================================
'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
High LC_Out
GoSub CamPWR
pause 5000
GoSub CamPWR
Low LC_Out
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 = 2 ' # of 15sec periods to wait before another cam event occurs
CamEvent_Flag = 0 ' Set flag to off
Cam_Mode = 1
Normal_OP = 1 ' board is operating in normal mode if 0. Activity mode or walktest if 1
Night = 155; lux level 7 = 100k(R16) 2v @ 4v 2 X 256 / 4 = 128
Day = 144
Night_Flag = 0
' Do initial board setup for light & battery levels
GoSub CdsChk
'=====================================================
'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:
'=====================================================
if Pinb.7 = 0 then 'Set TimerLimit to Number x 5 in seconds
TimerLimit = Timervalue1

else
TimerLimit = Timervalue2
endif

CamPwrDownTimer =0 'resets CamPWRDownTimer so timer can inc properly

If CamPwrState = 1 and pinC.7 = 1 then 'power cam down and wait 1 min if C.7 is jumpered
gosub CamPwr
do while CamPwrDownTimer <= 12 and pinC.7 = 1
pause 5000
inc CamPwrDownTimer
loop
endif

If CamPwrState = 1 then 'if cam is on starts the cam power down timer and checks for PIR event
Do While CamPwrDownTimer <= TimerLimit 'pauses for 5 sec x TimerLimit checking for a PIR event each time
If PIR_Event = 1 Then 'checks Pir for activity. Starts PirIntService and exits timing loop if found
Gosub PIR_IntService
exit
Endif
Pause 5000 'Five sec pause
Inc CamPwrDownTimer
Loop
Inc TimerLimit
If CamPwrDownTimer = TimerLimit then GoSub CamPwr 'turns cam off if timer finished counting
Else
If PIR_Event = 1 Then GoSub PIR_INTService
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 'Camrefresh timer is passive using the time the processor is in its sleep cycle.

GoSub CdsChk
Sleep 7 'increases the time the processor sleeps by 2.1s:1 on x1 and x2 pics. Ex a value of 2 = 4.2s
If CamRefresh = CamRefreshLimit Then 'set equal to (value+1)x(sleep time). Time will be in seconds. ex (4+1)x14.7s=73.5s refresh
CamRefresh = 0 'time
GoSub CamPwr
Pause 5000
GoSub CamPwr
EndIf
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


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 WlkTestFlag = 0 Then
If CamPWRState = 0 then GoSub CamPWR ' Turn the camera on for the first time
Pause Shutter_pause
Gosub Shutter
EndIf


EndIf

PIR_INTService_Exit:
'sertxd ("PIR Exit ",13,10)
Setintflags %00000100,%00000100
ValidPIR = 0
Return

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

Next
Return


CamPWR:
if campwrstate = 0 then 'stuff to do when cam is turned on
High LC_Out
endif
High Power_Out
pause 250
Low Power_Out
CamPwrState = CamPwrState ^ 1 'Toggles CamPwrState Var
if CamPwrState = 0 then 'stuff to do when cam is turned off
Low LC_Out
Endif
Return

Shutter:
High Shutter_Out
pause 1000
Low Shutter_Out
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
Else
Night_Flag = 0 ' Daylight so clear flag
EndIf
CdsChk_Exit:

Return


Top
 Profile  
Reply with quote  
PostPosted: Thu May 03, 2012 8:10 pm 
Offline
Emperor
Emperor
User avatar

Joined: Fri Aug 13, 2010 8:35 pm
Posts: 552
Location: central kentucky
See if this will work .I have used it before. It seems to work ok.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 04, 2012 7:15 am 
Offline
Fledgling
Fledgling

Joined: Fri Jul 08, 2011 5:48 am
Posts: 73
Is this code with slave? Either something is wrong with my board or this code dosent work either.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 04, 2012 10:14 am 
Offline
King
King
User avatar

Joined: Tue Feb 16, 2010 3:20 pm
Posts: 482
It doesnt look like it has the slave portion in it.

You can take an existing cam with slave code and just add in the fast hack control part of the code and change the proper timings for the s600.
Or take the fast hack code you have and add in slave control from another code where its needed. .


Top
 Profile  
Reply with quote  
PostPosted: Fri May 04, 2012 10:55 am 
Offline
Fledgling
Fledgling

Joined: Fri Jul 08, 2011 5:48 am
Posts: 73
I don't know how the fast hack part works though. Not sure I can pull that off. Not too savy with this code thing.


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