Thanks Grounded this works great for me, I added a timer and commented out the line that calls it I have my camera set up outside and will be taking movies every hour for 10 seconds. The Code below should be good for testing, the code as is should cycle through, Camera Off, Camera On, Record on, Record off, Camera Off then back through.
turn the camera on first when you power the pic it will turn off the camera.
I am not using the pull down resistor at this time and I am using 1k resistors from pins 1,2 to lanC line, and yes once you get it running use one pin for both.
Code:
'Testing Sony LanC control of video camera [email protected] SCS Saturday August 29, 2009
'Sending commands is LSB first example hex 22, %00100010 you send the far right zero first then the one then three zeros
'and a one then two more zeros. The Lanc port is held in the high state by the camera, Pulling the pin low is a 1
'I used input command to keep the line in its high state at 5vdc, and low to pull the line low for a 1. So again
'using the hex 22 example %00100010, input,low,input,input,input,low,input,input.
@ DEVICE PIC16F84,HS_OSC,WDT_OFF,PWRT_ON,PROTECT_OFF
DEFINE OSC 10
command_bit var bit
syncbit var byte
syncbyte var word
counter var byte
value var byte
Bits var byte
Time var byte
Goto start
Sync_byte: 'Sync_byte looks for the inter_frame gap 5.4mS to 7mS at the end of every
syncbyte = 0 'frame tranmissions and just before the start of the next frame
while syncbyte < 700
pulsin portb.1, 1, syncbyte
wend
Return
Sync_bit: 'Sync_Bit looks for the start_bit of each frame this is used
syncbit = 0 'in sending the second byte of a command
while syncbit < 9
pulsin portb.1, 0, syncbit
wend
Return
Command_byte: 'tell camera that a command is to follow normal commands
gosub sync_byte
pauseus 80 'pause for camera's start bit to finish
input portb.2 'first byte to send (LSB 1ST)Hex 18 %0001,1000
pauseus 312
low portb.2
pauseus 208
input portb.2
pauseus 312
input portb.2 'Stop bits set high
Return
Start:
pause 1000
counter = 0
gosub Power_off
pause 10000
'gosub DelayTime
counter = 0
gosub Wakeup
gosub Power_on
pause 3000
counter = 0
gosub Record_on
pause 10000
counter = 0
gosub Record_on
pause 500
goto Start
Power_off:
gosub Command_byte
gosub sync_bit
input portb.2 'Power off command #5E (LSB 1ST) %0101,1110
pauseus 104
low portb.2
pauseus 416
input portb.2
pauseus 104
low portb.2
pauseus 104
input portb.2
pauseus 104
input portb.2 'Stop bits set high
counter = counter + 1
if counter = 3 then Return
goto Power_off
Power_on:
gosub Command_byte
gosub Sync_bit
input portb.2 'Turn camera on from sleep mode
pauseus 208 'Power on Command 5C (LSB 1ST) %0101,1100
low portb.2
pauseus 312
input portb.2
pauseus 104
low portb.2
pauseus 104
input portb.2
pauseus 208
input portb.2 'Stop bits set high
counter = counter + 1
if counter = 5 then Return
goto Power_on
Record_on:
gosub Command_byte
gosub Sync_bit
low portb.2 'Start Recording
pauseus 208 'Record On 33 (LSB 1ST) %0011,0011
input portb.2
pauseus 208
low portb.2
pauseus 208
input portb.2
pauseus 208
input portb.2 'Stop bits set high
counter = counter + 1
if counter = 5 then Return
goto Record_on
DelayTime:
For Time = 0 to 60
pause 60000
Next Time
Return
Wakeup:
low portb.2 'This wakes camera up for short period to accept commands
pause 500
input portb.2
pause 100
Return
Bookmarks