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




Bookmarks