Pic to LanC


Closed Thread
Results 1 to 10 of 10

Thread: Pic to LanC

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

    Default Pic to LanC

    I'm playing with a little hobby project I know this has been done but this is way over my head BUT you only learn if you try.
    useing a PIC to talk to a sony video cam though the LanC port on the camera to turn it on and start and stop recording.
    any and all help or ideals welcome
    thanks grounded

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    maybe this should help to start
    http://www.boehmel.de/lanc.htm

    and how about using ELM624 chip in between?
    http://www.elmelectronics.com/DSheets/ELM624DS.pdf

    or use an ASM code...
    http://www.bealecorner.com/trv900/EdGrip/index.html
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    Man your fast
    I read over that stuff last week pretty scarey and Like I said over my head
    I will reread and try to learn
    thanks

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    in the first link
    The master generates the telegram frame, creating 8 startbits, followed each by 8 bits (1 byte) and a (long) stopbit. Then everything starts again. One bit has a duration of 104µs.
    The distance between two startbits can vary between 1200µs and 1400µs depending on the device.
    The distance between two telegrams is 20ms for PAL/625 and 16.6ms for NTSC/525.
    once you understand it an can shift out one bit after the other... it's not going to be really hard!

    Code:
    For BitN=0 to 7
        SerPin=ValueToSend.0[BitN]
        pauseus 104
        next
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Smile

    thanks again
    I'm reading studying and I figure I'm about a year away from being able to do this. LOL

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Bah, don't give up. If i had a Sony Cam here, i would try.. unfortunately, i don't have any.

    Anyways, good luck!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Smile

    Well after over a year I'm back on this little hobby project.
    and I think for my 1st attempt I will try one of the things mister e offered
    the elm624 interface chip which I believe is based on a p12c5xx
    http://www.elmelectronics.com/DSheets/ELM624DS.pdf
    because of the whole final project I would i would like to use a 16f676 to communcate
    to the elm624, which can be communicated with a PC using rs232. would I need to use serin/serout
    for this? any other helpful hint?
    remember I only program for a hobby not everyday for a living so I ask dumb ?'s
    bare with me
    thanks
    grounded

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Not knowing the elm chip...

    The hardware serial (HSERIN/HSEROUT) might be better, it can run in the background(interrupt). Then you can do other things in the mean time.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    thanks mackrackit
    maybe a little more infor on the total project . this is my 1st. communication project.
    the lanc commutication is the meat but just a small part of the total code.

    yes were talking Ok LED
    AND
    with a input (rising edge interrupt) 103A is sent to start recording and after xx time
    1030 is sent to stop recording.

    thanks for all help

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


    Did you find this post helpful? Yes | No

    Default

    Well After 2 years of on and off this project it is up and running!
    I did use the elm624 interface chip between the 16f676 and the Sony recorder
    why:
    because most of what I found on the internet was in assembly and from all
    that I read and was told along with the little tested I did the tight timing
    tolerance of the Lanc protocal Pic Basic pro would not work.
    and yes I did find snippets of code written in basic and proton but no one could tell me that it actually worked for them.
    Now if anybody Has communicated with the lanc buss using PBP I'M ALL EARS
    talk to me. because I would love to do this with out the Elm!
    The attached Code is just the basic of my finish project with out the bells
    and whistles which will be added in the final phase.

    This code has been tested and does work.BUT
    remember I'm just a hobbiest so it is not written like a pro
    but I a'm open to any advice that anyone would offer.

    Code:
     
    '****************************************************************
    '*  Name    : SONY-LD.BAS                                       *
    '*  Author  : Grounded                                          *
    '*  Notice  : Copyright (c) my homemade stuff                   *
    '*          : All Rights Reserved                               *
    '*  Date    : 6/20/2008                                         *
    '*  Version : 1.0  TESTED & WORKING CODE                        *
    '*  Notes   : PIC TO SONY LANC USING  ELM624 INTERFACE, DAY ONLY*
    '*          :INTERNAL CLOCK  VAR DELAY AND MOVIE LENGHT         *
    '****************************************************************
       pic16f676
    '****************** FUSES SET IN INC FILE *****************
    'INTRC_OSC_NOCLKOUT, WDT_ON, MCLR_OFF,
    'CPD_OFF, BOD_OFF, PWRT_ON,PROTECT_OFF
    '**************************************************************
    Define OSCCAL_1K 1          'INTERNAL CLOCK SPEED 4MH.
    				
    Pause 2000                  'DELAY TO LET STABILIZE AFTER POWER UP & MODE 
    CMCON = 7                   'COMPARATOR OFF
    VRCON = 0                   'VOLTAGE REF. DISABLE	
    TRISA = %00001101           'MAKE A.0, A.2 & A.3 INPUTS
    TRISC = %00100011	    'MAKE .C.0,C.1 & C.5 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 
    
    '***********************ADC FOR DAY/NIGHT DEFINES ***********************
            DEFINE ADC_BITS 10          'ADC 10 BIT #
            DEFINE ADC_CLOCK 3          'ADC SAMPLE CLOCK 
            DEFINE ADC_SAMPLEUS 50	    'SAMPLE EVERY 50 US.
        
    '************ DEBUG/COMMUNICATION  DEFINES  TRANSMIT ********************
     
            DEFINE DEBUG_REG PORTC        ' RED ELM PIN 5, BROWN 232 PIN 2 R
    	DEFINE DEBUG_BIT 4
    	DEFINE DEBUG_BAUD 9600
    	DEFINE DEBUG_MODE 1           'FOR DIRECT TO ELM             
     
    '************DEBUGIN /COMMUNICATIONS  DEFINES  RECIEVE *******************
    
    	DEFINE DEBUGIN_REG PORTC      ' BLACK ELM PIN 6 ,RED 232 PIN 3 T
    	DEFINE DEBUGIN_BIT 5
    	DEFINE DEBUGIN_BAUD 9600
    	DEFINE DEBUGIN_MODE 0         'FOR DIRECT TO ELM
    
    '*********************************ALIASES***************************************
    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 SER  =PORTA.4         'N/A FOR OPTIONAL SERVO MOTOR (NIGHTSHOT SWITCH)
    SYMBOL LED  =PORTA.5         'WALKTEST AND POWER LED
    
    SYMBOL DIPB =PORTC.0         'DIP SWITCH 2
    SYMBOL DIPA =PORTC.1         'DIP SWITCH 1
    SYMBOL DPO  =PORTC.2         'DIP SWITCH POWER
    SYMBOL RL   =PORTC.3         'N/A OPTIONAL IR LIGHT  FOR NIGHT VIDEO
    'SYMBOL TX  =PORTC.4         'DEBUG
    'SYMBOL RX  =PORTC.5         'DEBUGIN  
    '********************************TURN EVERYTHING OFF*********************
    ADC=0:LDR=0:PIR=0:MODE=0:SER=0:LED=0:DIPA=0:DIPB=0:DPO=0 
    '****************************SET UP VARIBLES***************************
    
    DL VAR BYTE :DL=0             'DIP SWITCH 1 VAR FOR DELAY 
    ML VAR BYTE :ML=0             'DIP SWITCH 2 VAR FOR VARIBLE MOVIE LENGTH 
    NIGHT VAR WORD:NIGHT=0        'LDR/ADCIN VAR FOR LIGHT SENSOR
    DT VAR WORD :DT=30            'VAR AFTER MOIVE DELAY
    '*****************************POWER UP CHECK**********************************
    LED=1 :PAUSE 4000 : LED=0     'POWER UP OK
    PAUSE 10000                   'DELAY TO TURN ON CAM AFTER ELM POWERS UP
    
     '**************CHECK CAM CONNECTION AND ELM TO CAM SYNC ********************
     LED=1
     LANCHECK:
      BO VAR BYTE :BO=0
        DEBUG "A"  ,13,10       'TELL ELM I'M READY TO SEND, CR ,LF
        PAUSE 1000  
        DEBUG "ATCS" ,13,10     'SEND CHECK SYN COMMAND , CR ,LF 
                 
     
     DEBUGIN [WAIT("S") ,BO]   'DEBUGIN SYNC OK
       
     IF BO="Y" THEN PAUSE 1000 : LED=0 'IF LED GOES OFF THEN PIC TO CAM SYNC OK
     
     '**************PUT CAM TO SLEEP FOR POWER SAVINGS UNTIL INTERRRUPT ***********
    
     
         PAUSE 1000
         DEBUG "A" ,13,10             'TELL ELM I'M READY TO SEND, CR ,LF
         PAUSE 1000 :LED=0
         DEBUG "105E" ,13,10          'GOTO SLEEP COMMAND , CR ,LF
         
    '*************************  SET AFTER MOVIE DELAY  *********************
    DELAYSET:
    DD VAR WORD
    For DD= 0 TO 10000         '
    Pause 1
    IF MODE=0 Then               '
    LED=1 :Pause 2000 :DT=DT+60 :LED=0 :PAUSE 2000  'ADDED 60 SEC.DELAY PER
    
    EndIF
    Next DD
     
    
    '*********************************DIP CHECK****************
    
    DPO=1 :Pause 250          'TURN DIP SWITCH POWER ON
    IF (DIPA=0) AND (DIPB=0) Then ML=30   '30 SEC.MOVIE LENGHT 
    IF (DIPA=1) AND (DIPB=0) Then ML=60   '60 SEC.MOVIE LENGHT
    IF (DIPA=0) AND (DIPB=1) Then ML=120  '2 MIN.MOVIE LENGHT 
    IF (DIPA=1) AND (DIPB=1) Then ML=240  '4 MIN.MOVIE LENGHT     
    
    Pause 300
    DPO=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         '30 SEC. WALKTEST TO CHECK PIR DETECTION RANGE
    Pause 1
    IF PIR=1 Then               'IF PIR TRIPS THEN BLINK LED
    LED=1
    Pause 2000
    LED=0
    Pause 500
    EndIF
    Next A
    LED=1 :Pause 500 :LED=0 :Pause 300    'FLASH LED END OF WALKTEST
    LED=1 :Pause 500 :LED=0 :Pause 300 
    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 FOR INTERUPT **********
    MAIN:
    
    NIGHT =0                         'CLEAR NIGHT VAR TO 0
    ON INTERRUPT GoTo MAKEMOVIE      'ON PIR TRIP WAKE UP 
    INTCON=$90                       'ENABLE .2 INTERUPT
    
    Sleep 7200                        '2HR. SLEEP
     
     GoTo MAIN                         'GO BACK TO SLEEP AND WAIT ON INTERUPT
    Disable 
    '**************************MOVIE TIME******************************************    
        
       MAKEMOVIE:
    '************************** CHECK THAT'S DAYTIME*********************************
       INTCON=0                    'DISABLE INTERRUPTS
       NIGHT=0
       LDR=1:Pause 250           'TURN LDR/ADCIN POWER ON
    ADCIN 0,NIGHT          'CHECK AN# READ AN0 & STORE IN NIGHT VAR
     
     IF NIGHT=>550  Then SLEEP 60 :GOTO DELAY 'TO DARK FOR Day movie  
         
                                  
                DEBUG "A" ,13,10          'TELL ELM I'M READY TO SEND, CR ,LF
                PAUSE 1000
                DEBUG "ATSP" ,13,10       'WAKE UP PULSE
                DEBUG "A" , 13,10         'TELL ELM I'M READY TO SEND, CR ,LF
                PAUSE 1000
                DEBUG "1027" , 13,10      'RECORD COMMAND   ,CR,LF
                LED=0
                SLEEP ML                        'VAR MOVIE LENGHT(SET WITH DIP SWITCH)
                
                DEBUG "A" , 13,10        'TELL ELM I'M READY TO SEND, CR ,LF
                PAUSE 1000
                DEBUG "1029" , 13,10      'STOP RECORD COMMAND ,CR,LF
     
     PAUSE 3000
               DEBUG "A" ,13,10             'TELL ELM I'M READY TO SEND, CR ,LF
               PAUSE 1000 
               DEBUG "105E" ,13,10          'CAM GOTO SLEEP COMMAND , CR ,LF
     DELAY:
            Sleep DT                        'VAR LOCKOUT AFTER MOVIE (SET WITH MODE PB)
     INTCON=1 
         Disable
        GoTo MAIN            
    Enable           'SEND EVERYTHING BACK TO SLEEP AND WAIT ON NEXT INTERRRUPT

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Replies: 67
    Last Post: - 8th December 2009, 02:27
  3. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  4. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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