Sony LanC Program


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

    Thumbs up Sony LanC Program

    I have a starter program for Sony Lanc posted, with docs on Lanc using PBP ( the top two programs ) if anyone is intrested. this is done in bit banging and can be adapted to loops with some timing changes. all you need is a camera (video / Still ) one resistor and a pic chip.

    http://gaminde.net/SCS/

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


    Did you find this post helpful? Yes | No

    Smile lanc

    very interested in this
    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

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


    Did you find this post helpful? Yes | No

    Default Sony lanc

    Try it out and let me know if you need help

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


    Did you find this post helpful? Yes | No

    Default Reply



    If anyone tries this program please report your results and your
    camera's make/model. Have improvements report this also.

    Thanks Larry

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


    Did you find this post helpful? Yes | No

    Default

    I have spent a few hours on this and the only way that I can even get it to work sometimes is: read and write with the same pin
    This is the way my Lanc controllers that I build work programmed in assembly.
    or the one I built using the elm interface chip.
    using your starter 33 is the only hex that will record or stop
    on mine I can use 27 or 33 record and 29 or 33 stop not sure what that's all about.
    right now IF it does start recording some times it will flicker between rec and standby. I will try to work on it some more and post were I'm @
    I have 5 different Sony corders I use one a mini dv and they are all interchangeble on my board
    thanks for working and sharing this and I hope what I have posted helps
    " 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
    153


    Did you find this post helpful? Yes | No

    Default sony

    Ok sounds like you changed the program some to test different hex commands?

    You need the two different pins portb1 and and portb2 one looks for interframe gaps and startbits the other sends commands did you use the pulldown resistor on Portb1 and did you use two resistors one for each pin to the lanc line and of course ground I did it this way for testing so I could put the scope on either lead and check for pulse voltage. I found sometimes I needed the pulldown resistor to get clean pulses that would go 0 to 3vdc not 1.3 to 3vdc. Thanks for testing this, sometimes no matter how much you work on something, when someone tries it, it may or may not work and this is what I wanted to see.

    Now try the program as written turn the camera on first then turn the pic on the camera will shutoff wait 10 seconds turn on wait 10 seconds record wait 20 seconds stop record wait 10 seconds and turn off and go through all this again Im using a DCR-HC20 sony camera. I listed the commands that worked with my camera. Let me know what happens.

    Larry
    Last edited by l_gaminde; - 23rd September 2009 at 03:41.

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


    Did you find this post helpful? Yes | No

    Default sony

    I have my camera on the desk Im using a BS2 to read the data stream comming from the camera and It works using serin 9600 and reversing the hex


    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    value VAR Byte(8)
    syncbyte VAR Word
    a VAR Byte
    a = %11111111

    start:
    Sync_byte:
    syncbyte = 0
    DO WHILE syncbyte < 3200
    PULSIN 1, 1, syncbyte
    LOOP

    SERIN 1,84,[value(0),value(1),value(2),value(3),value(4),value (5),value(6),value(7)]
    DEBUG HEX value(0)^a,TAB,HEX value(1)^a,HEX value(2)^a,HEX value(3)^a,HEX value(4)^a,HEX value(5)^a,HEX value(6)^a,TAB,HEX value(7)^a,CR
    'PAUSE 500
    GOTO sync_byte
    'GOTO start

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

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


    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

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

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


    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.

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

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


    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

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


    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

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

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

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


    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.

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

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


    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.

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


    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

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


    Did you find this post helpful? Yes | No

    Thumbs up up and running

    Larry 676 does not have hs_osc so it would not compile thanks for trying
    BUT:
    I'm up and running (cross fingers)
    remember I said something about adjusting to midpoint of the bit
    well I did 'Command_byte:you had dropped it from104 to 80 to adjust timing
    I dropped to 60 (about half) and bingo it's running (started@ 70 and it ran)
    I think 80 is right on the edge that's why sometime it work and then the next
    it did'n

    and this is with my standard Lanc control board using
    1 pin to read / write no pull up or down 60 ohm resistor in Lanc line
    this basic program just start recording 10 sec. movie then stop wait
    5 sec. and start over. If it will run one command it should run ALL

    it's been running for about 2 hr. with out missing abeat
    Now the bad news the next few days are full full full . not sure it I will have time to eat much less to play I mean work on this
    I would be interested to know how it looks on the scope
    grounded




    Code:
    '****************************************************************
    '*  Name    : pbplanc_T_1833.BAS                                   
    '*  Author  : GROUNDED                                     
    '*  Notice  : Copyright (c) 2009    
    '*          : All Rights Reserved                              
    '*  Date    : 9/25/2009                                       
    '*  Version : 1.0                                             
    '*  Notes   : testing pbp lanc  basic just record and stop                    
    ' 
         
    '****************************************************************
       pic16F676
    @ __config _XT_OSC & _WDT_ON & _MCLRE_OFF & _CP_OFF
    PAUSE 5000
    CMCON = 7                  
    VRCON = 0                   
    TRISA = %00001000           
    TRISC = %00000000		    
    ANSEL = %00000000 	
    OPTION_REG=%01000000         
    WPUA = %00000000            
    
    HIGH PORTC.0  :PAUSE 3000 :LOW  PORTC.0     'POWER UP LED
    
     PAUSE 1000
    
     command_bit var bit
     syncbit var byte
     syncbyte var word
     counter var byte
     value var byte
     Bits 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:     '00011000   SEND 18   
     gosub sync_byte
     pauseus 60   'CHANGED FROM 80 TO 60 (LITTLE OVER HALF OF 104) TIMING ADJUST                    
     input PORTC.4                        
     pauseus 312  '000
     low PORTC.4
     pauseus 208  '11
     input PORTC.4
     pauseus 312  '000
      input PORTC.4 'Stop bits set high
     Return
     START:                       
    Record_on:           '11001100   SEND 33
     gosub Command_byte
     gosub Sync_bit
     
     low PORTC.4                                                          
     pauseus 208   '11                           
     input PORTC.4
     pauseus 208   '00
     low PORTC.4
     pauseus 208   '11
     input PORTC.4
     pauseus 208   '00
     input PORTC.4 'Stop bits set high
     counter = counter +1
     if counter = 4 then  GOTO  MT
     goto Record_on
     MT:
      COUNTER =0
    PAUSE 10000    '10 SEC. MOVIE
      
      Record_off:           '11001100    SEND 33
     gosub Command_byte
     gosub Sync_bit
     low PORTC.4                                                               
     pauseus 208   '11                            
     input PORTC.4
     pauseus 208   '00
     low PORTC.4
     pauseus 208   '11
     input PORTC.4
     pauseus 208   '00
     input PORTC.4 'Stop bits set high
     counter = counter +1
     if counter =4 then GOTO OVER
     goto Record_OFF
    
     OVER:
    
     PAUSE 5000 
    GOTO START
    " 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

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


    Did you find this post helpful? Yes | No

    Default Sony Lanc

    Grounded
    I tested using 60mS and yes it worked for me also, I also tested not using the power on command and issuing a Record command after a pull-down wakeup it also worked.

    looks as if I was on the edge @ 80 if I can find a 4mhz board around I will test the 80 using it, so if 60 to 80 works maybe lower then the timing is not so critical I guess!

    Thanks for your help in working this out now MANY can enjoy

    You would think I would know how to spell TESLA by now

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


    Did you find this post helpful? Yes | No

    Default full blown camera code

    I dropped the PBP LanC read/write in to some of my generic PBP camera code
    because I was able to read/ write with 1 pin like I do with the assembly code
    I could just drop the PBP version in the 16f676 and the camera is up and running
    thanks
    Code:
    '****************************************************************
    '*  Name    : pbp_sony_n.BAS                                    *
    '*  Author  : R Slaton  AKA Grounded /Ratsnest                  *
    '*  Notice  : Copyright (c) 2009 peek-a-boo wild life systems   *
    '*          : All Rights Reserved                               *
    '*  Date    : 9/23/2009                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : SONY LanC NIGHTTIME ONLY WITH IR LED ARRAY        *
    '*          :DIP 1 ON 60SEC. MOVIE /30 SEC DEFAULT              *
    '*          :DIP 2 ON 60 AFTER MOVIE DELAY /30 DEFAULT
    '*          :PIR TRIPS HIGH/15SEC.TEST MOVIE @ CONTROLLER BOOTUP
    '*     :THANKS TO l_gaminde ON THE BIT BANGING READ WRITE PART
    '****************************************************************
       pic16F676
    @ __config _XT_OSC & _WDT_ON & _MCLRE_OFF & _CP_OFF
    
      
    'DEFINE OSC 4               'EXTERNAL CLOCK SPEED 4MH.
    DEFINE ADC_BITS 10          'ADC 10 BIT #
    DEFINE ADC_CLOCK 3          'ADC SAMPLE CLOCK 
    DEFINE ADC_SAMPLEUS 50	    'SAMPLE EVERY 50 US.				
    Pause 5000                  'DELAY TO LET STABILIZE AFTER POWER UP & MODE 
    CMCON = 7                   'COMPARATOR OFF
    VRCON = 0                   'VOLTAGE REF. DISABLE	
    TRISA = %00001101           'MAKE A.2 & A.3 INPUTS
    TRISC = %00000110		    'MAKE .C.0,C.1 PORTC INPUTS
    ANSEL = %00000001           'PORTA.0 A/D IN,RST DIGITAL
    ADCON0.7 = 1                'RIGHT JUSTIFY FOR 10 BIT 
    OPTION_REG=%01000000        'RAISING EDGE/WEAK PULL UP  
    WPUA = %00000000            'NO WEAK PULLUPS  
    
    SYMBOL ADC  =PORTA.0         'ADCIN
    SYMBOL LDR  =PORTA.1         'PHOTO CELL POWER
    SYMBOL PIR  =PORTA.2         'PIR TRIPS HIGH
    SYMBOL MODE =PORTA.3         'MODE BUTTON
    'SYMBOL XT   =PORTA.4        'XT_OSC
    'SYMBOL XT  =PORTA.5         'XT_OSC
    
    SYMBOL LED =PORTC.0          'LED & DIP SWITCH 
    SYMBOL DIPB =PORTC.1         'DIP SWITCH 2
    SYMBOL DIPA  =PORTC.2        'DIP SWITCH 1
    SYMBOL RL   =PORTC.3         'REMOTE LIGHT
    SYMBOL LANC =PORTC.4         'READ /WRITE LANC
    SYMBOL NA =PORTC.5           'FOR SERVO OPTION
    ADC=0:LDR=0:PIR=0:MODE=0:LED=0:DIPA=0:DIPB=0:LED=0:RL=0:LANC=0:NA=0
      LED=1 :PAUSE 5000 :LED=0
     GOTO TESTMOVIE
    '****************************SET UP VARIBLES***************************
    
    DT VAR BYTE  :DT =30          'AFTER MOVIE DELAY VAR. /30 SEC. DEFAULT
    DAY VAR BYTE :DAY=0           'DIP SWITCH 1 VAR FOR DAY ONLY OR DAY/NIGHT
    ML VAR BYTE :ML=0             'DIP SWITCH 2 VAR FOR VARIBLE MOVIE LENGTH
    RCL VAR BYTE :RCL=0           'RECORD LED VAR 
    NIGHT VAR WORD:NIGHT=0        'LDR/ADCIN VAR FOR LIGHT SENSOR
    command_bit var   bit 
    syncbit     var   byte
    syncbyte    var   word
    counter     var   byte
    value       var   byte
    Bits        var   byte
    Time        var   byte
    
    '***********************DAY/ NIGHT PHOTO CELL CAL MODE*******************
    IF MODE=0 Then GoTo  CAL  'IF MODE BUTTON PUSHED THEN GOTO LRD CAL MODE
    GoTo testmovie                  'SKIP CAL MODE  GO CHECK DIP SWITCHES
    CAL:
    LDR=1:Pause 250           'TURN LDR/ADCIN POWER ON
    
    LED=1:Pause 250:LED=0:Pause 250
    LED=1:Pause 250:LED=0:Pause 1000  ' FLASH YOUR IN CAL MODE
    TEST:
    NIGHT=0
    LED=0
    ADCIN 0,NIGHT          'CHECK AN# READ AN0 & STORE IN NIGHT VAR
     
     IF NIGHT=>550  Then LED=1   'IF LED IS ON THEN NIGHT MOVIE
     Pause 250                   ' IF OFF DAYTIME
     
     IF MODE =0 Then GoTo testmovie    'LEAVE CAL MODE 
     
     GoTo TEST                   'LOOP AND CHECK FOR LIGHT AGAIN
    '*********************************SET UP SUBS****************
         Sync_byte:        'Sync_byte looks for the inter_frame gap  
       syncbyte = 0                        
       while syncbyte < 700
       pulsin portc.4, 1, syncbyte
       wend
       Return
    
          Sync_bit:    'Sync_Bit looks for the start_bit of each frame 
       syncbit = 0                         
       while syncbit < 9
       pulsin portc.4, 0, syncbit
       wend
          Return
       
          Command_byte:    'tell camera that a command is to follow normal commands
          gosub sync_byte
       pauseus 55           'pause for camera's start bit to finish 55= MID OF BIT
       input portc.4          'first byte to send (LSB 1ST)Hex 18 %0001,1000
       pauseus 312    '000
       low portc.4
       pauseus 208    '11
       input portc.4
       pauseus 312    '000
       input portc.4                       'Stop bits set high
             Return
    
         Record_SS:
          gosub Command_byte
          gosub Sync_bit                     
       low portc.4               'USED TO STOP AND Start Recording
       pauseus 208   '11          ' 33 (LSB 1ST) %0011,0011
       input portc.4
       pauseus 208    '00
       low portc.4
       pauseus 208    '11
       input portc.4
       pauseus 208    '00
       input portc.4                       'Stop bits set high
          counter = counter + 1
          if counter = 5 then Return
          goto Record_SS
           
        Power_off:
          gosub Command_byte   
          gosub sync_bit
       input portc.4             'Power off command #5E (LSB 1ST) %0101,1110
       pauseus 104    '0      
       low portc.4
       pauseus 416    '1111
       input portc.4
       pauseus 104    '0
       low portc.4
       pauseus 104    '1
       input portc.4
       pauseus 104    '0
       input portc.4                       'Stop bits set high
          counter = counter + 1
          if counter = 5 then Return              
          goto Power_off             
    '*********************************TESTMOVIE*******
    TESTMOVIE:
    COUNTER=0
    GOSUB RECORD_SS
    PAUSE 15000          '15 SEC. TEST MOVIE
    COUNTER=0
    GOSUB RECORD_SS
    PAUSE 3000
    COUNTER=0
    GOSUB Power_off
    '*********************************DIP CHECK****************
    CKD:
    night=0                     'CLEAR NIGHT VAR
    led=0                       'MAKE SURE LED IS OFF
    Pause 20
    
    LED=1 :Pause 250          'TURN DIP SWITCH POWER ON
    IF DIPA=0 Then ML=30
    IF DIPA=1 Then ML=60
    '***********************SET DELAY**************************  
    IF DIPB=0 Then dt=30 
    IF DIPB=1 Then dt=60      
    Pause 300
    LED=0                      'TURN DIP SWITCH POWER OFF
    
    '****************************** PIR WARM UP & WALKTEST *************
    Sleep 50                        '50 SEC. PIR WARM UP
    LED=1:Pause 350:LED=0:Pause 500   'FLASH LED FOR START OF WALKTEST
    LED=1:Pause 350:LED=0:Pause 500
    LED=1:Pause 350:LED=0:pause 500 
    
    A VAR WORD
    For A= 0 TO 30000         '20 SEC. WALKTEST TIME RESETS WITH pir TRIP
    Pause 1
    IF PIR=1 Then               'IF PIR TRIPS THEN TURN ON LED
    LED=1
    Pause 1000
    LED=0
    Pause 500
    A=0
    EndIF
    Next A
    LED=1 :Pause 500 :LED=0 :Pause 300    'FLASH LED END OF WALKTEST
    LED=1 :Pause 500 :LED=0 :Pause 300 
    
    SLEEP 20 :led=1 :Pause 500 : led=0   '20 SEC TO GET OUT OF THE WAY
    
    '************************ GOTO SLEEP & WAIT FIR INTERUPT **********
    MAIN:
    
    NIGHT =0                     'CLEAR NIGHT VAR TO 0
    ON INTERRUPT GoTo MOVIE      'ON PIR TRIP WAKE UP 
    INTCON=$90                   'ENABLE .2 INTERUPT
    
    Sleep 900                   '15 MIN SLEEP
     
     
    GoTo MAIN                    'GO BACK TO SLEEP AND WAIT ON INTERUPT
    Disable 
    
    '*************************************MAKE MOVIE *************************** 
     MOVIE:
     INTCON=0                       'DISABLE ALL INTERUPTS
     pause 200
      IF PIR =0 then  sleep 60 :goto delay 'DID THE PIR CAUSE THE INTERUPPT
     
      LDR=1                         'POWER UP LIGHT SENSOR
     Pause 20 
     ADCIN 0,NIGHT                 'READ AN1 & STORE IN NIGHT VAR
      PAUSE 250
     IF NIGHT=<550 Then  SLEEP 120 :GOTO DELAY   ' IT'S DAY 
    
     Pause 25
     LDR=0  
     
     Wakeup:             ' WAKE CAM UP FROM POWER SAVING SLEEP MODE
       low portc.4     '
       pause 500
       input portc.4
                        
    pause 3000                  'CAM BOOT UP TIME
    RL=1                        'TURN IR LED ARRAY ON
    counter=0
    gosub record_ss 
     
     SLEEP ML                   'MOVIE LENGHT SET WITH DIP1 30/60
     counter=0
    gosub record_ss
    pause 5000                     'GOTO STANDBY
    counter=0
    gosub power_off                'PUT CAM TO SLEEP
    '******************************BETWEEN MOVIE DELAY *******************
    DELAY:
    INTCON=0                       'DISABLE ALL INTERUPTS
    LDR=0                           'MAKE SURE LDR/ADCIN POWER OFF
    RL=0                            'MAKE SURE REMOTE LIGHT IS OFF
    Sleep DT                        'DELAY SET WITH DIP2 30/60
    
        INTCON.1=0                 'RESET A.2 INTERUPT FLAG
        Disable
        GoTo MAIN              'GO BACK TO SLEEP AND WAIT FOR NEXT INTERUPT
    Enable
    " 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

  24. #24
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    this looks very cool guys!

    I hope I can test drive some of those routines soon.(used the ELM lanc chips in the past).

    I see that it write, but does it read LanC too?


    cheeers!

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


    Did you find this post helpful? Yes | No

    Default sony lanc

    Flipper
    I have read LanC using a basic stamp and 9600 serin command so it could be implemented

    Larry

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 : 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