This updated has been tested using 4mhz and 10mhz and the timing was changed from 80mS to 60mS. It has been tested without pulldown resistors
although not looked at with a scope. Three resistors is all thats needed to interface with a camera two each 2k resistors from lanc line to pins portb.1 and portb.2 with a 10k to 20k pulldown from portb.1 to ground. program will wait 5 minutes and take a 10 second video turn off for 5 minutes wake and take a 10 second video ON and ON.
Turn camera on, then power pic after 5 seconds pic will power down camera and in 5 minutes will wake an make a video, you get the idea.
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
pause 5000
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 60 '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:
counter = 0
gosub Power_off
pause 2000
gosub DelayTime
counter = 0
gosub Wakeup
gosub Power_on
pause 500
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 = 3 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 = 3 then Return
goto Record_on
DelayTime: 'Sets delay time in minutes
For Time = 0 to 4 'How many one minute delays
pause 60000 'One minute delay time
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