Sony LanC Program


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    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

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


    Did you find this post helpful? Yes | No

    Default

    Yep
    that about how I run mine
    power up pic & camera it take a 10 sec. test movie then powerdown
    until INTERRUPT from PIR

    change 470 res. to 1k on each pin .no pull down res.
    I will try to test for you by 2morrow afternoon and post
    thanks
    " 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

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


    Did you find this post helpful? Yes | No

    Default

    Sorry but I'm just not having any luck with this.
    look this over and see if I missed anything.

    hardwire:
    1k resistor from portc.5 to Lanc line
    1k resistor from portc.4 to Lanc line
    Lanc ground to system ground
    put the PBP code in and nothing

    I can drop in my assembly code in and lift portc.5 wire it works
    it 's got to be that the PBP timing is off but I don't have a scope to check

    after playing with this Lanc stuff for about 2 years let me share some of things I learned the hardway.
    1. this one cause me to lose more hair than all others put together
    the Lanc line can backfeed a small amount of voltage to the chip
    which can and will keep the program running with supply to the chip turn off
    which means that cycling power may not reset the program to the begining
    what I do is use a double pole power switch that not only kills power to the board but also opens the lanc line
    2. 27 record and 29 stop are listed under special commands
    2827 and 2829 none of my cameras with work with this
    BUT THEY WILL WORK USING 1827 & 1829
    3. I put my cams to sleep with 185E and wake up with the standard pulse lanc line low then send the record command I have never had to use the
    185C power on command ( on my command sheet it list 5c but does not
    tell what it is .

    4. I think most people that does this shift 48 to 52us to read and write in the middle of the bit

    maybe some one else on the forum can come up with some answers
    Sorry I could not make it work

    Code:
    '****************************************************************
    '*  Name    : pbp_1.BAS                                      *
    '*  Author  : GROUNDED                                   *
    '*  Notice  : Copyright (c) 2009 Copyright (c)                  *
    '*          : All Rights Reserved                               *
    '*  Date    : 9/23/2009                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : portc.4 read /portc.5 write                 *
    '*          : testing sending Lanc commands using PBP          *
    '****************************************************************
    
     '****************************************************************
       pic16F676
    @ __config _XT_OSC & _WDT_ON & _MCLRE_OFF & _CP_OFF
    
    
    PAUSE 5000
    
    CMCON = 7                   'COMPARATOR OFF
    VRCON = 0                   'VOLTAGE REF. DISABLE
    TRISA = %00001000           'MAKE A.2 & A.3 INPUTS
    TRISC = %00000000		    'MAKE .C.0,C.1 PORTC INPUTS .4 &.5 FOR LANC USE
    ANSEL = %00000000 	
    OPTION_REG=%01000000        'RAISING EDGE/WEAK PULL UP  
    WPUA = %00000000            'NO WEAK PULLUPS  
    
    HIGH PORTC.0  :PAUSE 10000 :LOW  PORTC.0
                        
       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:                     
       syncbyte = 0                      
       while syncbyte < 700
       pulsin portc.4, 1, syncbyte
       wend
       Return
    
          Sync_bit:                        
       syncbit = 0                        
       while syncbit < 9
       pulsin portc.4, 0, syncbit
       wend
          Return
       
          Command_byte:                    
          gosub sync_byte
       pauseus 80                          
       input portc.5               'first byte to send (LSB 1ST)Hex 18 %0001,1000
       pauseus 312    '000
       low portc.5
       pauseus 208    '11
       input portc.5
       pauseus 312    '000
       input portc.5                       '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 portc.5                       'Power off command #5E (LSB 1ST) %0101,1110
       pauseus 104    '0      
       low portc.5
       pauseus 416    '1111
       input portc.5
       pauseus 104    '0
       low portc.5
       pauseus 104    '1
       input portc.5
       pauseus 104    '0
       input portc.5                       'Stop bits set high
          counter = counter + 1
          if counter = 3 then Return              
          goto Power_off
       
          Power_on:
          gosub Command_byte
          gosub Sync_bit                     
       input portc.5                       
       pauseus 208     '00         'Power on Command 5C (LSB 1ST) %0101,1100
       low portc.5
       pauseus 312     '111
       input portc.5
       pauseus 104     '0
       low portc.5
       pauseus 104     '1
       input portc.5
       pauseus 208     '00 ????? maybe 104
       input portc.5                       'Stop bits set high
          counter = counter + 1
          if counter = 5 then Return
          goto Power_on
    
          Record_on:
          gosub Command_byte
          gosub Sync_bit                     
       low portc.5                         'Start Recording
       pauseus 208   '11                      'Record On 33 (LSB 1ST) %0011,0011
       input portc.5
       pauseus 208    '00
       low portc.5
       pauseus 208    '11
       input portc.5
       pauseus 208    '00
       input portc.5                       '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 portc.5       'This wakes camera up for short period to accept commands
       pause 500
       input portc.5
       pause 100
             Return
    " 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 lanc

    Grounded
    I ran it today and my camera would turn off only, nothing else, Yesterday everything was working great. Then I remembered why I used two pins while setting this up. So I installed a 20k resistor from stamp pin b1 sync pin to ground and everything started working perfectly. I used two pins because I did not want to pull the sending line low, my scope showed only 3vdc on my camera not the 5vdc I expected.

    grounded
    2. 27 record and 29 stop are listed under special commands
    2827 and 2829 none of my cameras with work with this
    BUT THEY WILL WORK USING 1827 & 1829

    Yes I found the same thing remember the command_byte2 that I said was not used that was hex 28.

    grounded
    3. I put my cams to sleep with 185E and wake up with the standard pulse lanc line low then send the record command I have never had to use the
    185C power on command ( on my command sheet it list 5c but does not
    tell what it is .

    I understand, and have not tried this yet ( but will ) when setting something up I always use the full steps first, and then take the shortcuts later I would not be sure it works with all camers or not.

    grounded
    4. I think most people that does this shift 48 to 52us to read and write in the middle of the bit

    Your talking about sending data to the first two bytes, not sending right after the syncbit but waiting until the middle of the 1.4 ms frame and sending then. I have a sinc_bit which looks for the camers syncbit and sends right after it finishes so my timing is right on not just sending somewhere in the middle. But when using a different osc 4mhz and not 10 mhz it could be too tight for a slower speed and this is something I need to check.

    Now let me ask this Did you camera Power Down when you first turned on the pic's power. there is no delay so if the camera is not on and the switch between the camera and pic is not on and the pic is powered it will go into limbo and do nothing. So everything must be on then power the pic it should turnoff the camera immediately and be in sync.

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


    Did you find this post helpful? Yes | No

    Default

    Larry no the cam did not turn off, it just "did nothing"
    But I really be leave the problem is in the tight time this needs and my 4mhz
    maybe my problem with using PBP code. I no were near smart enough to know the if, &'s and butts of this but I have been told more than once that because of the timing you could not do this with PBP but I'm sure hoping that you
    are someone here will prove then wrong

    pm sent
    " 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

    Grounded
    I don't know whats wrong! I do indeed have it running right now, It has been running all day taking pictures every 15 minutes for 5 seconds at a time. PBP does indeed work and the timing is really not that tight. I did notice your using xt setting I have always used HS mode, have not looked over your program much yet. I see no reason that 4 mhz would not work.

  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 try this I made some changes in your program headers see if this works better for you.


    Code:
    	@ DEVICE PIC16F676, HS_OSC, WDT_ON, PWRT_ON, PROTECT_OFF
    	DEFINE OSC 4
    	TRISC = %00010000
    
       command_bit var   bit 
       syncbit     var   byte
       syncbyte    var   word
       counter     var   byte
       value       var   byte
       Bits        var   byte
       Time        var   byte
    
    	PAUSE 2000
    	Goto start
    
          Sync_byte:                     
       syncbyte = 0                      
       while syncbyte < 700
       pulsin portc.4, 1, syncbyte
       wend
       Return
    
          Sync_bit:                        
       syncbit = 0                        
       while syncbit < 9
       pulsin portc.4, 0, syncbit
       wend
          Return
       
          Command_byte:                    
          gosub sync_byte
       pauseus 80                          
       input portc.5               'first byte to send (LSB 1ST)Hex 18 %0001,1000
       pauseus 312    '000
       low portc.5
       pauseus 208    '11
       input portc.5
       pauseus 312    '000
       input portc.5                       '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 portc.5                       'Power off command #5E (LSB 1ST) %0101,1110
       pauseus 104    '0      
       low portc.5
       pauseus 416    '1111
       input portc.5
       pauseus 104    '0
       low portc.5
       pauseus 104    '1
       input portc.5
       pauseus 104    '0
       input portc.5                       'Stop bits set high
          counter = counter + 1
          if counter = 3 then Return              
          goto Power_off
       
          Power_on:
          gosub Command_byte
          gosub Sync_bit                     
       input portc.5                       
       pauseus 208     '00         'Power on Command 5C (LSB 1ST) %0101,1100
       low portc.5
       pauseus 312     '111
       input portc.5
       pauseus 104     '0
       low portc.5
       pauseus 104     '1
       input portc.5
       pauseus 208     '00 ????? maybe 104
       input portc.5                       'Stop bits set high
          counter = counter + 1
          if counter = 5 then Return
          goto Power_on
    
          Record_on:
          gosub Command_byte
          gosub Sync_bit                     
       low portc.5                         'Start Recording
       pauseus 208   '11                      'Record On 33 (LSB 1ST) %0011,0011
       input portc.5
       pauseus 208    '00
       low portc.5
       pauseus 208    '11
       input portc.5
       pauseus 208    '00
       input portc.5                       '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 portc.5       'This wakes camera up for short period to accept commands
       pause 500
       input portc.5
       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 Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 18:51
  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 : 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