Jump to content
bowgod02

Slave Control

Recommended Posts

I've been working on this one for a little bit to see if it would be possible. A couple weeks ago I got a trigger working with the 08M chip using smclarks code he has posted on the "triggering with picaxe" post. So I thought about trying a full slave control using the 14M chip. I have a couple little bugs to work out but its starting to show some promise I think. I used the same 08M code as a starting point and threw everything on the breadboard and went from there. Thanks to smclark for the 08M code he posted up and for answering some of my questions along the way. Here is a video clip and a couple pics for now. I'll get up the code I'm working on and a few of the bugs that I have and see if we can figure them out.

 

 

 

The breadboard

009-6.jpg

 

Pic taken during the video. Hard to tell from the video if its working in sync...

010-5.jpg

 

th_001-34.jpg

Edited by bowgod02

Share this post


Link to post
Share on other sites
 

That big mess of wires sure looks nice to me, especially when that flash fires. Nice!

 

smclark, thank you very much for sharing!

Share this post


Link to post
Share on other sites
 

Thanks 212. I'll have to solder this baby up if I can work out the bugs. One of the bugs I'm having is on first powerup the slave will trigger on the first flash. After that, all is well and it flashes in sync. Then I want to try and put the chip to sleep if its daylight for a set time then awake and check for daylight again and again till it gets dark. That way I can save power also. I still have to work out the day/night and I have been working on that a little this morning. I thought I remembered TC showing me how to check for light value a little while ago in simulator but I'll have to check my pm's and see if I saved that.

Share this post


Link to post
Share on other sites
 

Nice Job Ron! Do you have the problem with the first flash trigger in a dark room? I ran into this problem when I was testing the code for the AIO a503 code. What happens is that when the detection circuit is powered up, the flash flag gets incremented because the light in the room causes the pin to go high.

Share this post


Link to post
Share on other sites
 

That makes sense, but if the light makes the pin go high, the trigger should kick it into the timeout routine and it get canceled out?

Share this post


Link to post
Share on other sites
 

I'll try it out in the bathroom and see if it still causes it to trigger on the first flash for the first trigger. I also had to lower the time_ out value to 35 for it to time out. If I go any higher it was taking forever to timeout and toggle the led and reset. Even if I set it to 40, it would take about 9 seconds to toggle and reset.

Share this post


Link to post
Share on other sites
 

I just tried it in the bathroom with the lights out three times powering it up and it triggered on the second flash all three times. Then I tried it with the lights on and after I had adjusted the timeout number from earlier, I got a timeout then it triggered on the second flash again. So when I was having the trouble earlier I didnt have the timeout value adjusted and was still too high and it wasnt getting the reset before the cameras flash. I noticed this when I was running it in simulator this morning that the value was way too big to work properly. So thats one bug thats fixed now.... :)

Share this post


Link to post
Share on other sites
 

I did this pretty fast so I'll have to recheck it when I get back from the woods. Or if any fresh eyes wants to recheck as well??

 

 

post-4111-1288045499_thumb.jpg

 

Edited by bowgod02

Share this post


Link to post
Share on other sites
 

This is the code as I have it right now on the breadboard. I still have to get the day/night working the way I want it to and then do some real testing of it. Anybody see anything major wrong so far besides the day/night control?

 

 '*************** Slave control and trigger using picaxe 14M chip ******************

'Last change on 10_27_10

' Input from PT on input 3
' Input from CDS om input ADC4
' Output to led on output 1
' Output to trigger slave on output 4
' Output power to PT on output 0
' Output power to slave flash mosfet on output 2
' Output to CDS on output 3


Symbol Flash_Flag = b11       ' Flag to count the # of flashes seen 
Symbol Fire_Flag = b12        ' Flag to fire the slave flash
Symbol TO_Counter = W1        ' Timeout counter
Symbol Slave_Refresh = W2     ' Slave refresh timer
Symbol Flash_On = 2           ' Flash Charge Mosfet
Symbol CDS_OUT = 3            ' Power to CDS
Symbol PT = 0                 ' Power to PT
Symbol Night_Flag = b13
Symbol CDS_Value = b10
Symbol Day = b9
Symbol Night = b8

Night = 128; lux level 7 = 100k(R16) 2v @ 4v 2 X 256 / 4 = 128
Day = 117


setint %00000001,%00000001 'activate interrupt when pin0 only goes high

disablebod

High 1
pause 500
low 1
pause 500
High 1
pause 500
low 1
pause 2000

GoSub CdsChk
IF Night_Flag = 1 Then GoSub Slave_Charge


Main:
' Main loop monitoring flags to determine what function to run based on flags set


If Slave_Refresh = 40 And Night_Flag = 1 Then 
GoSub Slave_Charge

EndIf

If Flash_Flag <> 0 Then inc TO_Counter EndIF  ' Start counter if first flash detected
If TO_Counter = 35 then Gosub TimeOut  ' Timeout here if no other flash detected.  Adjust value if necessary to fit camera.
If Fire_Flag = 1 then ' Fire the flash if flag is set.  Disable interrupts.
Setint off
Gosub Fire_Flash
EndIF

GoSub CdsChk
    If Night_Flag = 1 Then 
    Inc Slave_Refresh 
    let pins = %00000001
    EndIf
    
    If Night_Flag = 0 Then

let pins = %00000000
sleep 130
Endif
   
    
Goto Main








'============================
'SUBS
'============================

Interrupt:  'Try and get out of the interrupt sub as quick as possible.  Mainly just set flags and exit.  Pauses or loops will cause timing issues.
If Flash_Flag <=2 then inc Flash_flag EndIf
Do while pin0 = 1 'Loop around until the pin goes low. This is necessary in order to detect the second flash. For some reason the pin does not go low right away.
Loop
If Flash_Flag = 2 Then  'Set fire flag once second flash is detected.
Fire_flag = 1
EndIF
setint %00000001,%00000001 'Turn interrupts back on.
Return


Fire_Flash:
High Flash_On       ' Turn on slave flash mosfet
High 4              ' Trigger slave
pause 500
Low 4
Low Flash_On        ' Turn off slave flash mosfet
Flash_flag = 0      ' Reset flags
Fire_Flag = 0
TO_Counter = 0
Slave_Refresh = 0   ' Restart our 10min period
Gosub Slave_Charge  ' Slave fired so we need to recharge
setint %00000001,%00000001 ‘ Turn Interrupt back on
Return


TimeOut:
Flash_Flag = 0      ' Reset flags
TO_Counter = 0 
Gosub Flash_Led     ' Flash Led to indicate time out.
Return

Flash_Led:
For b0 = 1 To 50
Toggle 1
pause 20
Next
Return


Slave_Charge:
High Flash_On
Pause 10000          ' charge for 10sec
Low Flash_On
Slave_Refresh = 0    ' restart our 10min period
Return

CdsChk:
    High CDS_Out                       'Turn on pin to supply voltage to cds voltage divider
    readadc 4 , CDS_Value    ' Read light value
    'IF Night_Flag IS SET THEN WE CHECK TO SEE IF THE LIGHT LEVEL IS > = 117 IF ADC GREATER OR = THEN STILL DARK AND EXIT
    'IF ITS BELOW 117 THEN WE CLEAR NITEFLG AND RETURN
    'IF Night_Flag = 0 THEN CHECK TO SEE IF ADC ABOVE 128 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
        Night_Flag = 1              ' Its dark so set flag
        
    Else
        Night_Flag = 0              ' Daylight so clear flag
    EndIf

CdsChk_Exit:

Return

Edited by bowgod02

Share this post


Link to post
Share on other sites
 

Once you bring in the camera something I did to have the slave charge longer between night pics was to run a jumper from slave power output to a available input then used a if statement to check for the high input then just add a 3 second pause for slave to charge longer between night pics. I used the if statement after the pause to load pic to memory. Hope that made sense, good job.

Share this post


Link to post
Share on other sites
 

Changed up the code a little bit. Any of you guys want to run this in simulator and see if you see any faults with what I have so far?

Share this post


Link to post
Share on other sites
 

Ok, here I am with the code as of now. What I'm trying to do is if its light out, have the chip goto sleep for 5 minutes then wake up and check for light again. This is the part of the code that is giving me the trouble...

 

'If Night_Flag = 0 Then

'let pins = %00000000

'sleep 130

'Endif

 

If I uncomment this part of the code and download it I cant get the slave to trigger not one time. Slave is charged indicated by the neon bulb so I'm not sure why this part would cause a problem if its indeed dark in the room. If I leave this part commented then it works flawless and never misses a single flash.

 

 

 

 

'*************** Slave control and trigger using picaxe 14M chip ******************

'Last change on 10_27_10

' Input from PT on input 3
' Input from CDS om input ADC4
' Output to led on output 1
' Output to trigger slave on output 4
' Output power to PT on output 0
' Output power to slave flash mosfet on output 2
' Output to CDS on output 3


Symbol Flash_Flag = b11       ' Flag to count the # of flashes seen 
Symbol Fire_Flag = b12        ' Flag to fire the slave flash
Symbol TO_Counter = W1        ' Timeout counter
Symbol Slave_Refresh = W2     ' Slave refresh timer
Symbol Flash_On = 2           ' Flash Charge Mosfet
Symbol CDS_OUT = 3            ' Power to CDS
Symbol PT = 0                 ' Power to PT
Symbol Night_Flag = b13
Symbol CDS_Value = b10
Symbol Day = b9
Symbol Night = b8

Night = 128; lux level 7 = 100k(R16) 2v @ 4v 2 X 256 / 4 = 128
Day = 117


setint %00000001,%00000001 'activate interrupt when pin0 only goes high

disablebod

High 1
pause 500
low 1
pause 500
High 1
pause 500
low 1
pause 2000

GoSub CdsChk
IF Night_Flag = 1 Then GoSub Slave_Charge


Main:
' Main loop monitoring flags to determine what function to run based on flags set


If Slave_Refresh = 40 And Night_Flag = 1 Then 
GoSub Slave_Charge

EndIf

If Flash_Flag <> 0 Then inc TO_Counter EndIF  ' Start counter if first flash detected
If TO_Counter = 35 then Gosub TimeOut  ' Timeout here if no other flash detected.  Adjust value if necessary to fit camera.
If Fire_Flag = 1 then ' Fire the flash if flag is set.  Disable interrupts.
Setint off
Gosub Fire_Flash
EndIF

GoSub CdsChk
    If Night_Flag = 1 Then 
    Inc Slave_Refresh 
    let pins = %00000001
    EndIf 
    
'If Night_Flag = 0 Then
'let pins = %00000000
'sleep 130
'Endif

   
    
Goto Main








'============================
'SUBS
'============================

Interrupt:  'Try and get out of the interrupt sub as quick as possible.  Mainly just set flags and exit.  Pauses or loops will cause timing issues.
If Flash_Flag <=2 then inc Flash_flag EndIf
Do while pin0 = 1 'Loop around until the pin goes low. This is necessary in order to detect the second flash. For some reason the pin does not go low right away.
Loop
If Flash_Flag = 2 Then  'Set fire flag once second flash is detected.
Fire_flag = 1
EndIF
setint %00000001,%00000001 'Turn interrupts back on.
Return


Fire_Flash:
High Flash_On       ' Turn on slave flash mosfet
High 4              ' Trigger slave
pause 500
Low 4
Low Flash_On        ' Turn off slave flash mosfet
Flash_flag = 0      ' Reset flags
Fire_Flag = 0
TO_Counter = 0
Slave_Refresh = 0   ' Restart our 10min period
Gosub Slave_Charge  ' Slave fired so we need to recharge
setint %00000001,%00000001 ‘ Turn Interrupt back on
Return


TimeOut:
Flash_Flag = 0      ' Reset flags
TO_Counter = 0 
Gosub Flash_Led     ' Flash Led to indicate time out.
Return

Flash_Led:
For b0 = 1 To 50
Toggle 1
pause 20
Next
Return


Slave_Charge:
High Flash_On
Pause 6000          ' charge for 10sec
Low Flash_On
Slave_Refresh = 0    ' restart our 10min period
Return

CdsChk:
    High CDS_Out                       'Turn on pin to supply voltage to cds voltage divider
    readadc 4 , CDS_Value    ' Read light value
    

    'IF Night_Flag IS SET THEN WE CHECK TO SEE IF THE LIGHT LEVEL IS > = 117 IF ADC GREATER OR = THEN STILL DARK AND EXIT
    'IF ITS BELOW 117 THEN WE CLEAR NITEFLG AND RETURN
    'IF Night_Flag = 0 THEN CHECK TO SEE IF ADC ABOVE 128 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
        Night_Flag = 1              ' Its dark so set flag
        
    Else
        Night_Flag = 0              ' Daylight so clear flag
    EndIf

CdsChk_Exit:

Return

Share this post


Link to post
Share on other sites
 

I have not done any slave work with the picaxe yet. I don't have the answer, or maybe it is? Why do you have

'let pins = %00000000 before sleep 130? Maybe try taking that out? I'll look at it some more.

Share this post


Link to post
Share on other sites
 

I have that in there TC to turn off the PT before sleep.

 

 

I just tried this and it didnt work so I'll try taking out the let pins = %00000000

part and see what happens

 

GoSub CdsChk

If Night_Flag = 1 Then

Inc Slave_Refresh

let pins = %00000001

else

let pins = %00000000

'EndIf

'Else

'If Night_Flag = 0 Then

'let pins = %00000000

sleep 130

Endif

 

 

 

Goto Main

Edited by bowgod02

Share this post


Link to post
Share on other sites
 

No deal. I took everything out except the sleep command it it wont fire if I have a sleep in there. I checked the cds again with Debug and had a value of 156 so its seeing dark so it shouldnt be going to sleep at all.. Strange...

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

×