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

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

  3. #3
    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!

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


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