Looking for LANC power OFF and power ON comands (Arduino project)

Hi,

I am looking for the LANC power OFF and power ON commands.

I have:

00111010 Power on
01111010 Power off

but they don’t seem to be working. I am using this code to start/stop recording and it is working great. But when I tried to modify it to power off the camera, it is not working. :~

/*
Send a Start/Sop Recording command to the LANC port of a video camera.
Tested with a Canon XF300 camcorder
This code requires a simple interface see http://micro.arocholl.com
Feel free to use this code in any way you want.

Comprehensive LANC info: www.boehmel.de/lanc.htm

"LANC" is a registered trademark of SONY.
CANON calls their LANC compatible port "REMOTE".

2011, Martin Koch
http://controlyourcamera.blogspot.com/2011/02/arduino-controlled-video-recording-over.html
*/

#define cmdPin 7 
#define lancPin 11
#define recButton 2
int cmdRepeatCount;
int bitDuration = 104; //Duration of one LANC bit in microseconds. 

void setup() {

pinMode(lancPin, INPUT); //listens to the LANC line
pinMode(cmdPin, OUTPUT); //writes to the LANC line
pinMode(recButton, INPUT); //start-stop recording button
digitalWrite(recButton, HIGH); //turn on an internal pull up resistor
digitalWrite(cmdPin, LOW); //set LANC line to +5V
delay(5000); //Wait for camera to power up completly
bitDuration = bitDuration - 8; //Writing to the digital port takes about 8 microseconds so only 96 microseconds are left till the end of each bit
}

void loop() {
if (!digitalRead(recButton)) {
REC(); //send REC command to camera
delay(1000); //debounce button
}
}



void REC() {

cmdRepeatCount = 0;

while (cmdRepeatCount < 5) {  //repeat 5 times to make sure the camera accepts the command

                while (pulseIn(lancPin, HIGH) < 5000) {   
                  //"pulseIn, HIGH" catches any 0V TO +5V TRANSITION and waits until the LANC line goes back to 0V 
                  //"pulseIn" also returns the pulse duration so we can check if the previous +5V duration was long enough (>5ms) to be the pause before a new 8 byte data packet
//Loop till pulse duration is >5ms
}

//LOW after long pause means the START bit of Byte 0 is here
delayMicroseconds(bitDuration);  //wait START bit duration

//Write the 8 bits of byte 0 
//"18hex" or “00011000”  tells the camera that there will be a normal command to camera in the next byte
//Note that the command bits have to be put out in reverse order with the least significant, right-most bit (bit 0) first
digitalWrite(cmdPin, LOW);  //Write bit 0. 
delayMicroseconds(bitDuration); 
digitalWrite(cmdPin, LOW);  //Write bit 1 
delayMicroseconds(bitDuration);  
digitalWrite(cmdPin, LOW);  //Write bit 2
delayMicroseconds(bitDuration); 
digitalWrite(cmdPin, HIGH);  //Write bit 3
delayMicroseconds(bitDuration);  
digitalWrite(cmdPin, HIGH);  //Write bit 4
delayMicroseconds(bitDuration);
digitalWrite(cmdPin, LOW);  //Write bit 5 
delayMicroseconds(bitDuration);
digitalWrite(cmdPin, LOW);  //Write bit 6
delayMicroseconds(bitDuration); 
digitalWrite(cmdPin, LOW);  //Write bit 7
delayMicroseconds(bitDuration);
//Byte 0 is written now put LANC line back to +5V
digitalWrite(cmdPin, LOW);
delayMicroseconds(10); //make sure to be in the stop bit before byte 1

while (digitalRead(lancPin)) { 
//Loop as long as the LANC line is +5V during the stop bit
}

//0V after the previous stop bit means the START bit of Byte 1 is here
delayMicroseconds(bitDuration);  //wait START bit duration

//Write the 8 bits of Byte 1
//"33hex" or “00110011” sends the  Record Start/Stop command
//Note that the command bits have to be put out in reverse order with the least significant, right-most bit (bit 0) first
digitalWrite(cmdPin, HIGH);  //Write bit 0 
delayMicroseconds(bitDuration);
digitalWrite(cmdPin, HIGH);  //Write bit 1 
delayMicroseconds(bitDuration); 
digitalWrite(cmdPin, LOW);  //Write bit 2
delayMicroseconds(bitDuration); 
digitalWrite(cmdPin, LOW);  //Write bit 3
delayMicroseconds(bitDuration);
digitalWrite(cmdPin, HIGH);  //Write bit 4 
delayMicroseconds(bitDuration); 
digitalWrite(cmdPin, HIGH);  //Write bit 5
delayMicroseconds(bitDuration);
digitalWrite(cmdPin, LOW);  //Write bit 6
delayMicroseconds(bitDuration);
digitalWrite(cmdPin, LOW);  //Write bit 7
delayMicroseconds(bitDuration);
//Byte 1 is written now put LANC line back to +5V
digitalWrite(cmdPin, LOW); 

cmdRepeatCount++;  //increase repeat count by 1

/*Control bytes 0 and 1 are written, now don’t care what happens in Bytes 2 to 7
and just wait for the next start bit after a long pause to send the first two command bytes again.*/


}//While cmdRepeatCount < 5
}

Hi,

Thank you for taking the time to reply. Yes, I have been all over the web looking for the codes for my camera. It is a Sony HXR-MC1. No luck so far. I was hoping that the Sony commands are standardized. The start/stop recording command is working well.

I was also hoping that I might find someone on the forum who has some experience with this type of project and the Sony commands. I should have mentioned the camera model, thanks for pointing that out.

:slight_smile:

Partially solved.

For my camera, Sony HXR-MC1, "01011110" is Power Off. It is working well.

Still looking for Power On.

:)

to power on, you need to connect GND and LANC Signal wires together for >140ms. I'm doing that with a relay switch, can't think of a different option at the moment.

There used to be someone out there that built a PIC (if I remember correctly) processor to do basically what you want - if it is like the older Sony cameras that I worked with in the past, basically, you need to “bit-bang” the serial data because you need to monitor the frames the camera is sending as a “master” then at the correct bit time, you need to feed in the command (using an open collector transistor) at 9600 baud. I have some information I have collected over the years on the LANC stuff - pm me if you want it. Here is the link to the one I was thinking of that was a RS-232 to LANC converter chip.
http://www.elmelectronics.com/thehome.html

mikey

amertahir: to power on, you need to connect GND and LANC Signal wires together for >140ms. I'm doing that with a relay switch, can't think of a different option at the moment.

Works beautifully, implement it in software, and use it with a soft power button camera such as the Canon Vixia HF G20.

// define your lancPin to whatever your Arduino hardware is connected to
#define lancPin 7
void setup()
{
  pinMode(lancPin, OUTPUT); // Change pin function to power up a camera via LANC
  digitalWrite(lancPin, LOW);
  delay(165); // needs to be greater than 140ms
  digitalWrite(lancPin, HIGH); // change back to listen
}
void loop() 
{
//your code
}