Sony LanC Program


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90


    Did you find this post helpful? Yes | No

    Default

    Sorry no luck
    I even tried it with my hc42
    the only thing different is I'm using a 16f676 XT_OSC @ 4
    were you @ 10

    right now I'm trying to keep all my camera in the woods. I ran and got a couple to help you test.
    I maybe out of pocket next few days with will try to do more testing later
    " be nice it's people like me that make people like you look smart"
    yes I read the datasheet, of the 300 pages I understood 10

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


    Did you find this post helpful? Yes | No

    Default sony

    Grounded Thank you for testing the setup.
    I also tried it and it would turn off and turn back on but nothing else, so I started looking at the program and in the power_on sub you will see at the bottom the counter value is 300, counter is a var byte so it would never return to the program. I use this value when looking at the data stream on the scope this keep the loop running and made it easy to see my timing I could do this at each step.
    So I guess you have to take them out when posting the code MY BAD.
    its things like this that make a project take longer than you expect!!!
    I reposted the correct program take a look when you get a chance

    Thanks Again Grounded

    Larry

  3. #3
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90


    Did you find this post helpful? Yes | No

    Default

    Right
    and I not sure but:
    should line 58 be pauseus 208
    and should there not be
    pauseus 104 between line 141 and 142

    Code:
    48 Command_byte2: 'tell camera that a command is to follow special commands
    49 gosub sync_byte
    50 pauseus 80 'pause for camera's start bit to finish
    51 input portb.2 'first byte to send (LSB 1ST)Hex 28 %0010,1000
    52 pauseus 312
    53 low portb.2
    54 pauseus 104
    55 input portb.2
    56 pauseus 104
    57 low portb.2
    58 pauseus 104
    59 input portb.2 'Stop bits set high
    60 Return
    61
    62 Start:
    63 counter
    
    
    
    
    
    129
    130 Record_off:
    131 gosub Command_byte2
    132 gosub Sync_bit
    133 low portb.2
    134 pauseus 104
    135 input portb.2 'Start Recording
    136 pauseus 208 'Power on Command 29 (LSB 1ST) %0010,1001
    137 low portb.2
    138 pauseus 104
    139 input portb.2
    140 pauseus 104
    141 low portb.2
    142 input portb.2
    143 pauseus 208
    144 input portb.2 'Stop bits set high
    145 counter = counter +1
    146 if counter = 5 then Return
    147 goto Record_off
    " be nice it's people like me that make people like you look smart"
    yes I read the datasheet, of the 300 pages I understood 10

  4. #4
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    167


    Did you find this post helpful? Yes | No

    Default sony

    Maybe their not being used that was a test of a second command byte
    command_byte2 can be removed along with record off hex 29
    record on also will stop recording.

  5. #5
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90


    Did you find this post helpful? Yes | No

    Smile

    OK
    just let me know when and were you post the corrected code and I will try to test for you
    Thanks for working and sharing this.
    My Lanc controller programed in assembly and using 1 pin to read and write
    works great. But just being a hobbyist programmer figuring out the pieces
    to do this with PBP would help me learn

    so again thank you for letting be apart of this
    " be nice it's people like me that make people like you look smart"
    yes I read the datasheet, of the 300 pages I understood 10

  6. #6
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    167


    Did you find this post helpful? Yes | No

    Default sony lanC

    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

  7. #7
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    167


    Did you find this post helpful? Yes | No

    Default sony lanc

    Grounded

    Here is LanC using loops and no bitbanging you can send serial data to the pic in the form of hex numbers and it will try these commands on the camera.
    like 5e



    Code:
    
    @ 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   word
    Bits        var   byte
    
          pause 2000
    
          Serial_data:
       Serin2 portb.3,84,[value]
          counter = 0
          pause 20
       if value =" " then goto serial_data
       If value =$5C THEN gosub wakeup
       serout2 portb.4,84,[value]
          gosub Send_command
          goto Serial_data
                         
          Send_command:                     'This section converts the hex value stored in the vairable value             
          gosub command_byte                'to the eight bits of data and sends the correct High Low commands   
          gosub sync_bit                    'needed to control the LanC device.  
       For Bits = 0 to 7
       Command_bit = value.0[Bits]
       if command_bit = 1 then
       low portb.2
       else
       input portb.2      
       endif
       pauseus 80
       next
          counter = counter + 1
          if counter = 3 then return
          goto Send_command
    
          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
    
          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, 10:54
  2. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 19:51
  3. Replies: 1
    Last Post: - 23rd May 2009, 10:22
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  5. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 15:30

Members who have read this thread : 0

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