Sony LanC Program


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153

    Default Sony LanC Program

    'Testing Sony LanC control of video camera [email protected] (Larry) 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



    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

    Command_byte2: 'tell camera that a command is to follow special commands
    gosub sync_byte
    pauseus 80 'pause for camera's start bit to finish
    input portb.2 'first byte to send (LSB 1ST)Hex 28 %0010,1000
    pauseus 312
    low portb.2
    pauseus 104
    input portb.2
    pauseus 104
    low portb.2
    pauseus 104
    input portb.2 'Stop bits set high
    Return

    Start:
    counter = 0
    gosub Power_off
    pause 10000
    counter = 0
    gosub Wakeup
    gosub Power_on
    pause 10000
    counter = 0
    gosub Record_on
    pause 20000
    counter = 0
    gosub Record_on
    pause 10000
    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 = 300 then Return
    goto Power_on

    Record_on:
    gosub Command_byte
    gosub Sync_bit
    low portb.2 'Start Recording
    pauseus 208 'Power on Command 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

    Record_off:
    gosub Command_byte2
    gosub Sync_bit
    low portb.2
    pauseus 104
    input portb.2 'Start Recording
    pauseus 208 'Power on Command 29 (LSB 1ST) %0010,1001
    low portb.2
    pauseus 104
    input portb.2
    pauseus 104
    low portb.2
    input portb.2
    pauseus 208
    input portb.2 'Stop bits set high
    counter = counter +1
    if counter = 5 then Return
    goto Record_off

    Wakeup:
    low portb.2 'This wakes camera up for short period to accept commands
    pause 500
    input portb.2
    pause 100
    Return

  2. #2
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default Sony LanC

    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

  3. #3
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default Sony Lanc

    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

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 09:54
  2. Sony LanC Program
    By l_gaminde in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 3rd October 2009, 19:43
  3. Replies: 1
    Last Post: - 23rd May 2009, 09:22
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 14:30

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts