This is updated code!! it uses two pins of a 16f84 b1 and b2. b1 is the sync pin which keeps the program synced with the camera using the lanc line. you need a 2k resistor from the lanc line to b1 and a 20k resistor from ground to b1, portb2 needs a 2k resistor to the lanc line. the code as written will take a 10 second movie every 15 minutes.
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 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: 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 = 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: 'Sets delay time in minutes For Time = 0 to 14 '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