PDA

View Full Version : Pic to LanC



grounded
- 20th February 2007, 17:18
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

mister_e
- 20th February 2007, 17:24
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

grounded
- 20th February 2007, 17:38
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

mister_e
- 20th February 2007, 17:43
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!



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

grounded
- 21st February 2007, 17:44
thanks again
I'm reading studying and I figure I'm about a year away from being able to do this. LOL

mister_e
- 21st February 2007, 18:08
Bah, don't give up. If i had a Sony Cam here, i would try.. unfortunately, i don't have any.

Anyways, good luck!

grounded
- 21st May 2008, 00:24
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

mackrackit
- 21st May 2008, 00:50
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.

grounded
- 21st May 2008, 02:00
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

grounded
- 24th June 2008, 00:12
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.



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