DXG 125 with AIO code?
-
bkflow
- Posts: 56
- Joined: Mon Feb 01, 2010 2:38 pm
DXG 125 with AIO code?
Can anyone help me with the timing on my ir exchanger in the code for the dxg 125. I have the electronics123 exchanger and im using tcscou's code. Thanks Brad
- bowgod02
- Posts: 476
- Joined: Tue Feb 16, 2010 3:20 pm
Re: DXG 125 with AIO code?
This was a code I used that had the 5v exchanger I think. It used a remote array so that wouldnt fit your build but you might be able to see if it runs your exchanger.
Code: Select all
'=========================
'DXG 125 Video Cam w/ Remote 940nm IR Arrays using the driveway alert for the transmitter/receiver,
'5v exchanger runs off of a sister board, and sound amp.
'Amps + wire connects to C+ on the AIO
'Amps - wire connects to SP on the AIO.
'Transmitter + wire connects to S+ on the AIO
'Transmitter - wire connects to S- on the AIO
'Signal wire from exchanger connects to C.2 (phototransistor's collector)
'125V's shuter/shutter common connect to PW and CM
'125V's power/power common connect to F+ and F- (single channel opto needed in place of the MOC3023 was with appropriate jumpers)
'Record times and delays can be changed under "time variables"
'=========================
' Walktest length is 30 seconds
' led will flash rapidly when motion is sensed during walktest
' led will flash 4 times indication walktest is over
'Last change on 04_06_11
'*************************************************************
#picaxe20x2
#no_data
#no_table
disablebod
'=====================================================
' Map Ports
'=====================================================
Symbol PT_IN = B.0 ' Photo Transistor input
Symbol CDS_Out = C.5 ' Output to LDR voltage Divider
Symbol Shutter_Out = B.3 ' slave flash opto
Symbol Array_Out = C.3 ' Slave Mosfet
Symbol Exchanger_Out = C.2 ' Photo Transistor output
Symbol Sound_Out = C.1 ' Spare Mosfet
Symbol Battery_Monitor = B.6 ' ADC Input for battery monitor
Symbol LDR_IN = B.5 ' LDR ADC Input
Symbol Exch_Power = B.7 ' Exchanger power on to sister board
Symbol Power_Out = C.4 ' 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 Activity_Flag = B7
Symbol Normal_OP = B8
Symbol CamRefresh = B9
Symbol Activity_Count = B10
Symbol Event_Delay = B11
Symbol CamEvent_Flag = B12
Symbol Cam_Mode = B13
Symbol Flash_Flag = b14 ' Flag to count the # of flashes seen
Symbol TO_Counter = W1 ' Timeout counter
Symbol First_Flash = b15
Symbol Wait_Loop = W2
Symbol CDS_Value = b16
Symbol Night_Flag = b17
Symbol Day = b18
Symbol Night = b19
Symbol SlaveRefresh = b20
Symbol FlashCharge = b21
Symbol RECTime = W14
Symbol PIRDelay = W15
Symbol Exchanger_Position = b22
'=====================================================
' Set Port Directions
'=====================================================
Output PT_IN
Output CDS_Out
Output Power_Out
Output Array_Out
'Input Power_Mon
Output Sound_Out
Output Battery_Monitor
Input LDR_IN
Output Exchanger_Out
Output Power_Out
Output LED_Out
Input PIR_In
Output B.4
Input C.0
Input C.7
Output B.7
Output A.0
Output Exch_Power
'=====================================================
'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 LED_Out
Gosub CamInit
pause 5000
Low LED_Out
'****************************************************
'Check Dip Switches to get Record Time and Delay Time
'****************************************************
Gosub Get_Time_Variables
Powerup:
WlkTestTime = 2 ' set walk test timer to last for 30 seconds
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
Activity_Flag = 0
Activity_Count = 0
Normal_OP = 1 ' board is operating in normal mode if 0. Activity mode or walktest if 1
Night = 128 ; lux level 7 = 100k(R16) 2v @ 4v 2 X 256 / 4 = 128
Day = 117
Night_Flag = 0
SlaveRefresh = 0
Exchanger_Position = 0
' Do initial board setup for light & battery levels
GoSub CdsChk
'=====================================================
'Configure Interrupts
hintsetup %01000100 'set HINT2(PIR) & HINT1(FLASH) to trigger Interrupt at rising edge
'Setintflags %00001000,%00001000 'enable interrupt flags
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 PIR_Event = 1 Then GoSub PIR_INTService
' 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
EndIf
' Increment counters & timers
Inc BkGrnd_Timer
If WlkTestFlag = 1 And WlkTestTime <> 0 Then Dec WlkTestTime : EndIf
'If WLKTestFlag = 0 Then Inc CamRefresh : EndIf
If Activity_Flag = 1 And Activity_Count >= 0 Then Dec Activity_Count : EndIf
GoSub CdsChk
'If Night_Flag = 1 Then Inc SlaveRefresh :EndIf
Sleep 7
GoTo Main
Interrupt:
'sertxd ("Interrupt ",10,13)
If hint1flag = 1 Then ' Flash has been detected
'sertxd ("Flash Interrupt ",10,13)
First_Flash = 1
Inc Flash_Flag
hint1flag = 0
'Setintflags %00000010,%00000010 'enable interrupt flags FOR FLASH ONLY!
EndIf
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
ValidPIR = 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
'***********************************************************************************
'Motion was detected so this section controls camera, array, etc...
If Activity_Flag = 0 And WlkTestFlag = 0 Then
If Night_Flag = 1 Then
GoSub ArrayOn 'Turn on array
EndIf
GoSub CamPWR ' Power up cam
'Gosub ArrayOff
High Sound_Out ' Turn on Sound PreAmp
GoSub Check_Exchanger
Gosub ArrayOff
pause 100
GoSub Shutter ' Record
Pause RECTime ' record for 30 seconds
Gosub Shutter
'Gosub ArrayOff
Low Sound_Out
Pause 4000 ' pause before powering off
Gosub CamPwr
Low Exch_Power
Gosub ArrayOn
pause 1500
Gosub ArrayOff
EndIF
EndIF
Pause PIRDelay ' Pause before allowing another PIR interrupt
'************************************************************************************
PIR_INTService_Exit:
Setintflags %00000100,%00000100
Return
LED_Blink:
Byte_Var = 0
For Byte_Var = 0 To 19
Toggle LED_Out
Pause 40
Next
Return
Get_Time_Variables:
If PinC.7 = 0 Then
RecTime = 15000 '*****
Else
RecTime = 30000 '*****
Endif
If PinC.0 = 0 Then
PIRDelay = 5000 '*****
Else
PIRDelay = 60000 '*****
Endif
Return
CamPWR:
High Power_Out
pause 300
Low Power_Out
Return
Shutter:
High Shutter_Out
pause 500
Low Shutter_Out
Return
ArrayOn:
High Array_Out
Return
ArrayOff:
Low Array_Out
Return
ExchangerNight:
High Exchanger_Out
Return
ExchangerDay:
Low Exchanger_Out
Return
CamInit:
' DelayMS 2
GoSub CamPWR
GoSub ArrayOn
pause 1000
Gosub ArrayOff
High Exch_Power
pause 1400
Gosub ExchangerNight
Exchanger_Position = 1
pause 3000
Gosub ExchangerDay
Exchanger_Position = 0
pause 3000
Gosub ExchangerNight
Exchanger_Position = 1
pause 3000
Gosub ExchangerDay
Exchanger_Position = 0
Pause 5000
Gosub ArrayOn
pause 1000
Gosub ArrayOff
pause 1000
GoSub CamPWR
'GoSub ArrayOff
Low Exch_Power
Return
Check_Exchanger:
High Exch_Power
Pause 1400
If Night_Flag = 1 and Exchanger_Position = 1 Then
EndIf
If Night_Flag = 0 and Exchanger_Position = 1 Then
Gosub ExchangerDay
Exchanger_Position = 0
EndIf
If Night_Flag = 1 and Exchanger_Position = 0 Then
Gosub ExchangerNight
Exchanger_Position = 1
EndIf
If Night_Flag = 0 and Exchanger_Position = 0 Then
EndIf
Return
CdsChk:
High CDS_Out 'Turn on pin to supply voltage to cds voltage divider
readadc 10 , CDS_Value ' Read light value
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
Night_Flag = 1 ' Its dark so set flag
Else
Night_Flag = 0 ' Daylight so clear flag
EndIf
CdsChk_Exit:
Return