Jump to content
Lv2Hunt

Anyone Want To Help With Picaxe Problem?

Recommended Posts

After doing the cam functions sub, try a "Return" instead of "goto Main 'do it all over again" and see if that works. I have read that you should always do a return, but don't know for sure how important that is.

 

Have also read that you can run into troubles calling one sub from another. Maybe try moving this line "gosub CdsChk 'check for day or night" from the cam functions sub to the if statement where you are checking for motion like this:

 

If pir = 1 then 'if motion is sensed

gosub CdsChk 'check for day or night

gosub Cam_Functions 'go to take picture

endif

Edited by ghoot

Share this post


Link to post
Share on other sites
 

Made some code changes timer should check for daylight every 5 minutes and increment camera and slave timers, camera and slave should refresh every 25 minutes, you may try this may work better, not sure how your flash fires?did not mess with that part of code, take a look may give you some ideas

 

#REM

CANON A620

WHITETAIL WHITTLE
SHARP SHOOTER WITH SLAVE
PICAXE 18M2 CHIP

1 MINUTE DELAY WITH SWITCH 1 (B.1) OFF
3 MINUTE DELAY WITH SWITCH 1 (B.1) ON
2 FLASH CAMERAS WITH SWITCH 2 (B.0) OFF
3 FLASH CAMERAS WITH SWITCH 2 (B.0) ON

#ENDREM

DISABLEBOD

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'18M2 Pin Out

'B.0 switch
'B.1 switch
'B.2 unused
'B.3 unused
'B.4 spare opto
'B.5 camera shutter
'B.6 camera power
'B.7 led
'C.0 slave mosfet
'C.1 slave opto
'C.2 CDS "read light"
'C.3 CDS power
'C.4 program
'C.5 PIR
'C.6 PT (in)
'C.7 PT (out)

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'NAMING PINS

symbol Flash_count_switch = PinB.0
symbol delay_switch = PinB.1
symbol unused1 = B.2
symbol unused2 = B.3
symbol spare_opto = B.4
symbol shutter = B.5
symbol campwr = B.6
symbol led = B.7
symbol slave_charge = C.0
symbol trigger_slave = C.1
symbol cds_read = PinC.2
symbol cds_power = C.3
symbol program = pinC.4
symbol pir = PinC.5
symbol PT_IN = pinC.6
symbol PT_OUT = C.7

'NAMING VARIABLES

symbol day=w5
day=120

symbol Walktest_Timer = w6 'walktest timer
symbol PTTimer = w7 'PT timer
symbol SlaveRefreshTimer = w8 'Slave refresh timer
symbol SlaveRefreshTime = w9 'how long until slave refreshes
symbol CameraRefreshTimer = w10 'camera refresh timer
symbol CameraRefreshTime = w11 'how long until camera refreshes
symbol CdsCheckTimer = w12 'Cds timer
symbol CdsCheckTime = w13 'how long until cds needs to be checked

symbol CDS_Value = b5 'reading from cds
symbol Day_Night_Value = b1 'a set value that determines day or night
symbol Arm_Blinks = b2 'loop to blink led to show walktest complete

symbol Night_Flag = b6 'keeps track of night or day
symbol SlaveOn = bit1 'keeps track of slave ON or OFF
symbol CameraOn = bit2 'keeps track of camera ON or OFF

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'SETTING VARIABLES

'Day_Night_Value = 144 'adjust this number for CDS value
Night_Flag = 0 'set Night_Flag
SlaveOn = 0 'set SlaveOn
CameraOn = 0 'set CameraOn
CameraRefreshTime = 5 'THIS NUMBER CHANGES HOW LONG UNTIL THE CAMERA REFRESHES (AT NIGHT)(APPROX EVERY 60 MINUTES AT 50000)
SlaveRefreshTime = 5 'THIS NUMBER CHANGES HOW LONG UNTIL THE SLAVE REFRESHES (AT NIGHT) (APPROX EVERY 10 MINUTES AT 8336)
SlaveRefreshTimer=0
CameraRefreshTimer=0
'CdsCheckTime = 8336 'THIS NUMBER CHANGES HOW LONG UNTIL THE CDS IS CHECKED (APPROX EVERY 10 MINUTES AT 8336)

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'SETTING INPUTS/OUTPUTS

input b.0
input b.1
output unused1
output unused2
output spare_opto
output shutter
output campwr
output led
output slave_charge
output trigger_slave
input c.2
output cds_power
input c.5
input c.6
output PT_OUT

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Camera_Test:

high led 'power on led
high slave_charge 'turn on slave
sleep 2 'pause 4 seconds
gosub CamOn 'power camera on
sleep 3 'turn cam on for 6 seconds
gosub CamOff 'power camera off
low slave_charge 'turn off slave
low led 'power off led
pause 500 'pause 500 ms
goto Walk_test 'move to walk test

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Walk_test:

Walktest_Timer = 300 '300 for 30 second walk test
Do While Walktest_Timer > 0
If Pir = 1 then 'if pir detects motion then
high led 'power on led
pause 1000 'keep led on for a 1 second
low led 'power off led
Walktest_Timer = 300 'reset timer if walk test is interrupted
sleep 1 'pause for approx 2.1 sec for pir to settle
endif
Walktest_Timer = Walktest_Timer - 1 'decrease W0 timer by 1
pause 100 'pause 100 ms
loop
for Arm_Blinks = 1 to 4 'loop for 4 times to flash led to show walk test complete
high led 'power on red led
pause 500 'pause 1/2 second
low led 'turn off led
pause 500 'pause 1/2 second
next Arm_Blinks
sleep 1 'pause for approx 2.1 sec

goto CdsChk 'inital cds check

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'Main: 'LOOP THAT CHECKS FOR MOTION, CHECKS CDS, REFRESHES CAMERA, AND REFRESHES SLAVE

Stand_By:
W1=2912
do
if pir = 1 then goto Cam_Function
dec W1
pause 100 
loop while W1>0
goto CdsChk
goto Stand_By

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Cam_Function:

if Night_Flag=1 then 
goto NightPic
else
goto DayPic


NightPic:
high PT_OUT 'turn on PT
high slave_charge 'turn on slave
SlaveOn = 1 'slave is on
SlaveRefreshTimer = 0 'reset timer

if CameraOn = 0 then 'if camera is off turn it on
gosub CamOn 'power on camera
endif
pause 2500 'pause between power and shutter

setfreq m32
high Shutter ' Press Shutter Button to start the picture taking process
PTTimer = 0

if Flash_count_switch = 0 then ' skip ahead a flash if a two flash camera
goto twoflash
endif

do while PT_IN = 1 and PTTimer < 10000 ' wait for first flash
PTTimer = PTTimer + 1
loop

if PTTimer < 10000 then
PTTimer = 0
endif

do while PT_IN = 0 and PTTimer < 10000 ' wait for first flash to end
PTTimer = PTTimer + 1
loop

if PTTimer < 10000 then
PTTimer = 0
endif

twoflash:

do while PT_IN = 1 and PTTimer < 10000 ' wait for second flash
PTTimer = PTTimer + 1
loop

if PTTimer < 10000 then
PTTimer = 0
endif

do while PT_IN = 0 and PTTimer < 10000 ' wait for second flash to end
PTTimer = PTTimer + 1
loop

if PTTimer < 10000 then
PTTimer = 0
endif

do while PT_IN = 1 and PTTimer < 10000 ' wait for Third flash
PTTimer = PTTimer + 1
loop

if PTTimer < 10000 then ' do not trigger flash if we have timed out
high trigger_slave
pause 200
low trigger_slave
endif

low Shutter
setfreq m4

sleep 2 'pause after pic taken to save to card (approx 4 seconds)
gosub CamOff 'power off camera
sleep 5 'pause 10 more seconds for slave to charge

low PT_OUT 'turn off PT
low slave_charge 'turn off slave
SlaveOn = 0 'slave is off
SlaveRefreshTimer = 0 'reset timer
CameraRefreshTimer = 0 'reset timer
endif
goto Delay


DayPic:
if CameraOn = 0 then 'if camera is off turn it on
gosub CamOn 'power on camera
endif
pause 2500 'pause between power and shutter
gosub ShutterPic 'shutter picture
sleep 2 'pause after pic taken to save to card (approx 4 seconds)
gosub CamOff 'power off camera
CameraRefreshTimer = 0 'reset timer

goto Delay


Delay:
if delay_switch = 1 then
sleep 28 '1min delay approx. (28 x 2.1 = 58.8 secs)
else
sleep 84 '3 minute delay approx.
endif
goto Stand_By 'do it all over again

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ShutterPic:

high shutter
pause 300 'pause 300 ms
low shutter
return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

CamOn:

high campwr
pause 300 'pause 300ms
low campwr
CameraOn = 1

return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

CamOff:

high campwr
pause 300 'pause 300ms
low campwr
CameraOn = 0

return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Camera_Refresh:

high campwr 'turn on camera
pause 300
low campwr
sleep 3 'pause for approx. 6.3 seconds for camera to refresh
high campwr 'turn off camera
pause 300
low campwr
pause 300

CameraOn = 0

Return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Slave_Refresh:

high slave_charge 'turn on slave
pause 10000 'pause for approx. 10 seconds for slave to charge
low slave_charge 'turn off slave

SlaveOn = 0

Return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

CdsChk:

High cds_power 'Turn on pin to supply voltage to cds voltage divider
pause 200
readadc c.2, CDS_Value 'Read light value
Low cds_power 'Turn off voltage divider

If CDS_Value <= day Then
Night_Flag = 1 'Night
else
Night_Flag=0
endif

Inc CameraRefreshTimer 'add 1 to camera refresh timer



if CameraRefreshTimer >= CameraRefreshTime then 'if camera refresh timer is reached then
gosub Camera_Refresh 'refresh camera
CameraRefreshTimer = 0 'reset timer
endif

if Night_Flag=1 and SlaveRefreshTimer = 0 then
gosub Slave_Refresh
endif

if Night_Flag = 1 then 'IF NIGHT
Inc SlaveRefreshTimer 'add 1 to slave refresh timer
endif

if SlaveRefreshTimer >= SlaveRefreshTime then 'if slave refresh timer is reached then
gosub Slave_Refresh 'refresh slave
SlaveRefreshTimer = 0 'reset timer
endif


'if Night_Flag = 0 then 'IF DAY
'CameraRefreshTimer = 0 'reset timer
'SlaveRefreshTimer = 0 'reset timer
'endif

goto Stand_By

Share this post


Link to post
Share on other sites
 

Well that code didn't work either. 😡

I had similar problems with that code as I did mine.

 

For some reason the code is going to cam_functions when the slaverefreshtimer is reached? And I don't know why. I have tried probablly 25 different arrangements of code but no cigar.

 

I have tried an intterupt for the pir and I like the interrupt because it appears to be a lot faster. But once the slaverefreshtimer Is reached it goes to cam functions? The camera comes out and takes a picture with the slave. This is all at night of course.

Share this post


Link to post
Share on other sites
 
 

Johnny,

 

I don't think that's it because before I added any refresh codes I had the board running and firing the slave and it never reset. Also if it reset the board it would start over with camera-test and walktest modes. This is just jumping into my cam-functions part of code.???

Weird???

Share this post


Link to post
Share on other sites
 
 

I will post it tonight when I get home. I will also try and take a video so you understand what my problem is.

Share this post


Link to post
Share on other sites
 
 

I placed duct tape over the fresnel so the cds would think its night and also so it would not pick up me walking in front of it. I set the timer after walktest was completed and the main loop started. The slaverefresh is set to approx. 15 minutes. you will see that in my code i turned on the led to indicate that the slave refresh was running. after the led turns off which in the code is "low led" under slaverefreshtimer. the camera comes on snaps a picture with the slave and shuts back off?????????????

 

why is it doing this? nothing from what I can tell in the code is telling it to do this?

Share this post


Link to post
Share on other sites
 
 

 

Johnny,

You may have been right?

 

So i did an experiment and I swapped the camera refresh time and slave refresh time. So the slave refresh is 1 hour and camera refresh is 15 min. I did this so I could test the camera refresh and not have to wait around an hour. and it works perfect.

 

Now the kicker is that the camera refresh code and slave refresh code is exactly the same other than one is refreshing the camera and one is turning the slave on. So my thought is that it has something to do with the slave??

 

I am starting to think that my code has been right all along and something is interfering with something else?????

Share this post


Link to post
Share on other sites
 

That's possible, one other thing I would check is that your chip is a 18m2, not just an 18m, I'm having some flash backs to issues I had when I started with the 14m2 doing the SSII fasthack add on board. The other thing you can do to see if it's inference from the cap charging is to disconnect the slave from the build and run the program as you had it when it was giving you problems.

Share this post


Link to post
Share on other sites
 

I un hooked the slave power wires and the code ran as it should

 

The weird thing is that there are other parts of the code where the slave charges and no problems there.

The slave charges at startup under camera test.

 

It also charges after every night pic and no problems????

 

Not sure why there is a problem here?

 

I think Some how the slave charging is making the code go to cam_functions part of the code?

Share this post


Link to post
Share on other sites
 
 
 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×