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