DIY Trailcams
Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
buckshot164

Avatar / Picture

Super Moderator
Registered:
Posts: 4,122
Reply with quote  #1 
Getting started on the slave board add on.  Does anyone have one of these built that we can test on.
0
bigbassmann

Avatar / Picture

Registered:
Posts: 1,889
Reply with quote  #2 
I have a Safari/Flash Backpacker as well Charles running a S40 and trying to figure out the slave code still.
__________________
http://rcdavisgamecamerasolutions.weebly.com/
0
buckshot164

Avatar / Picture

Super Moderator
Registered:
Posts: 4,122
Reply with quote  #3 
Here is the problem.  I was wondering if anyone had working code.  Yes you can run several programs at once on the chip.  But you can only run them in the same frequency.  You would have to run the board on 32 htz.  4 hrtz is to slow to fire the camera and the slave.  I could not come up with a way around this.  This is one reason the 20x2 chip works best.  I do not know how well the batteries would last running 32 htz.  With the 20x2 chip I can switch the hertz within the program.  I will need a slave board to test my programs but I am not confident in this.
0
bigbassmann

Avatar / Picture

Registered:
Posts: 1,889
Reply with quote  #4 
Charles, you can change the hertz within the program on the 18M2+ chip the same as with the 20x2 if that helps you at all.
__________________
http://rcdavisgamecamerasolutions.weebly.com/
0
buckshot164

Avatar / Picture

Super Moderator
Registered:
Posts: 4,122
Reply with quote  #5 
No you can`t.  What is the command.  I have tried this before.  This is the difference between the x2 and m2.  You can only run one.  If this would be true you could then run a aio program on the safari which you can`t.
0
buckshot164

Avatar / Picture

Super Moderator
Registered:
Posts: 4,122
Reply with quote  #6 
This was written for a aio control board so you would have to make pin changes to make it work.  You can play with this program and see if you can get it to fire a slave fast enough and run the main board program.  We could not fire the slave fast enough.  The setfreq command is not supported on the m2 chip.

 *
start0:
#picaxe18m2
#no_data
suspend 1
disablebod
pullup %00000000

'==============================
'port map
'==============================
'Symbol PIR_IN = B.1
Symbol LED_OUT = B.2
Symbol Cam_Power = B.3
Symbol Shutter_Out = B.4 ' Shutter Mosfet
Symbol LDR_IN = B.5
Symbol PT_OUT = C.2
Symbol Flash_Out = C.6 ' slave flash opto
Symbol LDR_OUT = C.7

'==============================
'port direction
'==============================
dirsB = %00011100
dirsC = %00111100

'==============================
'Variables
'==============================
Symbol Day = B7
Day = 144      'lux level 7 = 100k(R16) 2v @ 4v 2 X 256 / 4 = 128
Symbol Night = B8
Night = 155
Symbol CamPwrState = B9
CamPwrState = 0
Symbol Power_On_Delay = W1
'time to hold in power button on camera in ms.
'Set equal to 1 if camera uses a switch instead of a momentary pushbutton
Power_On_Delay = 1
Symbol Night_flag = B10
Night_flag = 0
Symbol LDR_Value = B13
Symbol SlaveCharge = B14
SlaveCharge = 0
Symbol SlaveChargeTime = W2
'Time Required to charge up slave in ms
'Set equal to 1 if a Slave Flash isn't used
SlaveChargeTime = 10000
Symbol SlaveRefresh = B15
SlaveRefresh = 0
Symbol CamRefresh = W3
CamRefresh = 0
'Time to hold in the shutter button on camera in ms
Symbol Shutter_Time = 150
'Delay after power on
Symbol Shutter_pause = 1800
'Amount of time that can pass before the camera needs refreshed
'Value=(600/161)*(number of minutes)
Symbol CamRefreshLimit = 244

Symbol CamPwrDownTimer = B16
Symbol TimerLimit = B17
Symbol ValidPIR = B18
Symbol Flash_Flag = B19
Symbol Var1 = W10
Symbol Var2 = W11

'Timervalue1 and Timervalue2 are in multiples of 4.6 sec
'Timer value to be used if c.0 is Low
Symbol Timervalue1 = 13

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

'==============================
'Startup
'==============================
High LED_Out
pause 5000
GoSub CamPWR
pause 5000
GoSub CamPWR
pause 20000
Low LED_Out

call LDRChk
IF Night_Flag = 1 And SlaveChargeTime <> 1 Then GoSub Slave_Charge


'==============================
'Walk Test
'==============================
Var1 = 300 '30 seconds
Do While Var1 > 0
    if PinB.1 = 1 then
        Var1 = 300
        Var2 = 0
        For Var2 = 0 to 19
            Toggle LED_Out
            Pause 20
        Next
    endif
pause 100
Var1 = Var1 - 1
loop
Var1 = 0 ' Flash LED to indicate walk test over
For Var1 = 0 To 7
    Toggle LED_Out
    pause 400
Next

restart 1

Main:
Do

If CamPwrState = 1 then
    CamPwrDownTimer =0                 'resets CamPWRDownTimer so timer can inc properly
    if PinC.0 = 0 then                'Set TimerLimit to closest integer Number x 4.6 seconds of desired pause
        TimerLimit = Timervalue1               
    else
        TimerLimit = Timervalue2
    endif
    If pinC.7 = 1 then
    suspend 1
    call CamPwr
    Do While CamPwrDownTimer <= 13 and pinC.7 = 1
        sleep 2
        inc CamPwrDownTimer
    Loop
    resume 1
    Endif
    Do While CamPwrDownTimer <= TimerLimit
        sleep 2
        Inc CamPwrDownTimer
    Loop
    If CamPwrState = 1 then call CamPwr
Endif


' Increment counters & timers
Inc CamRefresh        'Camrefresh timer is passive using the time the processor is in its sleep cycle.
Inc SlaveRefresh

GoSub LDRChk


If CamRefresh = CamRefreshLimit Then
    CamRefresh = 0
    GoSub CamPwr
    Pause 5000
    GoSub CamPwr
EndIf

If SlaveRefresh = 37 then
    ' Charge slave every 10 minutes if night_flag = 1 (37 16.1 second periods)
    If Night_Flag = 1 And SlaveChargeTime <> 1 Then GoSub Slave_Charge
else
    'reset slave refresh timer and mark slave flash as being uncharged
    SlaveRefresh = 0
    SlaveCharge = 0
endif

Sleep 7
Loop

Start1:
Do

Var1 = 0 'clear the counter
Do While pinB.1 = 1 'While the PIR is high (motion detected)
    Inc Var1 'Inc our counter
    'Pause 1 'un-comment for a longer period
    If Var1 >= 2 Then
        ValidPIR = 1 'flag the motion detected as valid
        Exit
    EndIf
loop

If ValidPIR = 1 Then 'If valid motion then

    suspend 0
    If Night_Flag = 1 And SlaveChargeTime <> 1 Then
        High PT_Out ' Turn on PT to detect flash
        If SlaveCharge = 0 Then GoSub Slave_Charge 'if flash isn't charged recharge it
    EndIf


    If CamPWRState = 0 then GoSub CamPWR ' Turn the camera on for the first time
    Pause Shutter_pause
    If Night_Flag =1 And SlaveChargeTime <> 1 then
        resume 2        'Take Picture with Flash
        resume 3
    Else
        resume 2        'take picture
    EndIf
    resume 0
Endif
ValidPIR = 0
Loop


Start2:
do
suspend 2
High Shutter_Out
pause Shutter_Time
Low Shutter_Out
loop

Start3:
do
suspend 3
flash_flag = 0
Var1 = 0
Do
    If Var1 = 10000 Then       
        Flash_Flag = 0 ' Reset flags

        For Var1 = 0 To 49
            Toggle LED_Out
            pause 20
        Next

        GoTo Flash_Exit
    EndIf
    inc Var1
    if pinB.0 = 1 then
        inc flash_flag
        do until pinB.0 = 0
            if var1 = 10000 then exit
            inc var1
        loop
    endif
Loop while flash_flag <> 2

High Flash_Out
pause 400
Low Flash_Out
SlaveCharge = 0
Var1 = 0

Flash_Exit:
Low PT_Out
loop

'==============================
'Subroutines
'==============================

CamPWR:
CamPwrState = CamPwrState ^ 1                 'Toggles CamPwrState Var
if campwrstate = 1 then              'stuff to do when cam is turned on

    If Power_On_Delay = 1 then High Cam_Power : Endif

Endif
If Power_On_Delay <> 1 Then
    High Cam_Power
    pause Power_On_Delay
    Low Cam_Power
EndIf
if CamPwrState = 0 then                    'stuff to do when cam is turned off

    If Power_On_Delay = 1 then Low Cam_Power : Endif
Endif
Return


LDRChk:
High LDR_OUT 'Turn on pin to supply voltage to cds voltage divider
readadc LDR_IN , LDR_Value ' Read light value
Low LDR_OUT 'Turn off voltage divider

select case LDR_Value    'higher resistance values equal less light
    case >= Night
    Night_Flag = 1
    case <= Day
    Night_Flag = 0
    else
endselect

Return

Slave_Charge:
High C.3
Pause SlaveChargeTime ' pause to allow cap to charge up
Low C.3
SlaveRefresh = 0 ' restart our slave refresh timer.
SlaveCharge = 1
Return
0
bigbassmann

Avatar / Picture

Registered:
Posts: 1,889
Reply with quote  #7 
What is pinC.0 and B.0 used for in the above code?
__________________
http://rcdavisgamecamerasolutions.weebly.com/
0
Whitetail Whittle

Registered:
Posts: 113
Reply with quote  #8 
http://www.picaxe.com/BASIC-Commands/Advanced-PICAXE-Configuration/setfreq/

Look at this.
You can change freq with the 18m2 chip.
0
Whitetail Whittle

Registered:
Posts: 113
Reply with quote  #9 
I'm not sure either bassman. Looking at the code I thought B.0 was the Pir but I see he has PIR as B.1?????

P.S this is Brian from hagshouse.
0
buckshot164

Avatar / Picture

Super Moderator
Registered:
Posts: 4,122
Reply with quote  #10 
Yes you can change the frequency on the board.  You cannot use 2 different frequencies.  So for the slave to fire on time with the camera you need 32 htz.  This program is not designed for the Safari board and you would have to modify the inputs and outputs to work with it.  So if you would have to run the whole board on 32 htz you will drain your batteries quickly.  Yes you can write a program that will run on the the 18m2 but it will fire the slave late.  We ran into the problem with the the 20x2 but you can use setfreq to change the frequency in the program.    You can run two programs at the same time on the 18m2 but both programs must be the same frequency
0
Whitetail Whittle

Registered:
Posts: 113
Reply with quote  #11 
The board dosent have to run on 32mhz all the time?
It can run at standard 4mhz and then switch to 32mhz during the flash portion of the code Then switch back to 4mhz when it goes back to main:???

This wolnt wok?
0
bigbassmann

Avatar / Picture

Registered:
Posts: 1,889
Reply with quote  #12 
Think Charles is correct on this. After looking at the manual again it seems that the M2 parts don't support the command to switch frequencies within the program, they can only be set so that the entire program is running at the specified processor speed. When increasing the hertz you have to adjust pauses and other timing commands as well since increasing the processor speed from say 4mhz to 8mhz will reduce the timing by 1/2.  A pause of 2000 at 4mhz will be 2 seconds but the same pause time at 8mhz will only be 1 second.  Someone correct me if this isn't right.

I still would like to know what B.0 and C.0 in the code above is used for. Anyone know?

__________________
http://rcdavisgamecamerasolutions.weebly.com/
0
buckshot164

Avatar / Picture

Super Moderator
Registered:
Posts: 4,122
Reply with quote  #13 
C.0 is delay between pics.  This would be dip #2.  B.0 is a mistake caused by the miss layout of the gen 4.  Once we determined that we could not get it to work we stopped working on the program.  So there could be bugs in it.  When I write the program I might have 20 different versions that I play with.  This is just one version.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.