Arduinoで、SONY LANCプロトコルを調べる

LANC端子は、主にソニーのビデオカメラについている、カメラを制御する端子です。赤外線リモコンでは制御できない細かい制御ができますので、重宝するのですが、仕様が公開されておらず、カメラによって使える機能が違うなど、なかなか一筋縄で行かない規格でもあります。
LANCのプロトコルについては、解析したThe SONY LANC protocolが有名ですが、全てを網羅しているわけではないので自分のカメラがどのLANCコントロールに対応しているか解析するために、Arduinoと簡単な回路とプログラム作ってみました。
ハードウェアの説明
Arduino互換機のダ・ヴィンチ32Uを使用しています。ビデオカメラは、HDR-CX270です。
出典:Serial to LANC (Control-L) – Arduino Project Hub
LANC端子は、2.5mmステレオジャックが使われる事が多いですが、手持ちのカメラは、A/Vリモート端子の形状をしていましたので、変換ケーブルを嚙ましています。
プログラムの説明
LANCプロトコルは、8bitの8Byteが一括りとなって通信します。
0Byte目は、リモートコントロールする機器の種類の番号、1Byte目は、命令の番号という事のようです。ビデオカメラへ信号を送るだけだと、0Byte目と1Byte目の2Byteだけで、事足ります。
このプログラムは、変数 cmdByte0 に0Byte目をいれ、zoomOutButtonボタン・zoomInButtonボタンで1Byte目を変更して、recButtonボタンでコマンドを送り出す事が出来ます。
cmdByteの0Byte目は、 0x18と0x28の2種類だけでよさそうです。1Byte目は、0x00~0xFFまで調べます。
シリアルモニタで、どの信号が送られているか、表示されます。
#define lancWritePin 7 #define lancReadPin 11 #define recButton 6 #define zoomOutButton 5 #define zoomInButton 4 #define focusNearButton 3 #define focusFarButton 2 byte cmdByte0 = 0x18; //command preset. byte RECSTARTSTOP[] = {0x18 ,0x33}; byte STILL[] = {0x18 ,0x2B}; // byte comm = 0x00; int bitDuration = 104; void setup() { pinMode(lancReadPin, INPUT); pinMode(lancWritePin, OUTPUT); pinMode(recButton, INPUT); digitalWrite(recButton, HIGH); pinMode(zoomOutButton, INPUT); digitalWrite(zoomOutButton, HIGH); pinMode(zoomInButton, INPUT); digitalWrite(zoomInButton, HIGH); pinMode(focusNearButton, INPUT); digitalWrite(focusNearButton, HIGH); pinMode(focusFarButton, INPUT); digitalWrite(focusFarButton, HIGH); digitalWrite(lancWritePin, LOW); delay(5000); bitDuration = bitDuration - 8; Serial.begin(9600); } void loop() { if (!digitalRead(recButton)) { byte tmp[] = {cmdByte0 , comm}; lancCommand(tmp); Serial.print("RUN = "); Serial.println(comm,HEX); } if (!digitalRead(zoomOutButton)) { comm++; Serial.print("command = "); Serial.println(comm,HEX); delay(50); while (!digitalRead(zoomOutButton)) {} delay(50); } if (!digitalRead(zoomInButton)) { comm--; Serial.print("command = "); Serial.println(comm,HEX); delay(50); while (!digitalRead(zoomInButton)) {} delay(50); } if (!digitalRead(focusNearButton)){ lancCommand( RECSTARTSTOP ); } if (!digitalRead(focusFarButton)){ lancCommand( STILL ); } } void lancCommand(byte lanc[]){ byte tmp = 0; while (pulseIn(lancReadPin, HIGH) < 5000){} delayMicroseconds(bitDuration); tmp = lanc[0]; for (int i=0; i<8; i++) { if((tmp & 1) == 1){ digitalWrite(lancWritePin, HIGH); }else{ digitalWrite(lancWritePin, LOW); } tmp = tmp >> 1; delayMicroseconds(bitDuration); } digitalWrite(lancWritePin, LOW); delayMicroseconds(10); while (digitalRead(lancReadPin)) {} delayMicroseconds(bitDuration); tmp = lanc[1]; for (int i=0; i<8; i++) { if((tmp & 1) == 1){ digitalWrite(lancWritePin, HIGH); }else{ digitalWrite(lancWritePin, LOW); } tmp = tmp >> 1; delayMicroseconds(bitDuration); } digitalWrite(lancWritePin, LOW); }
HDR-CX270のLANCコマンド
このプログラムで、地道に調べたHDR-CX270のコマンドが以下です。
0Byte目 0x18
1Byte目 | action |
2A | スチル・ビデオ切り替え |
2B | スチル撮影 |
33 | ビデオ撮影・停止 |
39 | スチルピント合わせ |
3A | ビデオ撮影 |
5E | 電源OFF |
84 | メニューアップ |
86 | メニューダウン |
9A | メニュー表示 |
A2 | メニュー選択 |
B4 | ステータス表示 |
C2 | メニューライト |
C4 | メニューレフト |
0Byte目 0x28
1Byte目 | action |
00 | variable speed zoom Tele: slowest speed |
02 | variable speed zoom Tele: faster than 00 |
04 | variable speed zoom Tele: faster than 02 |
06 | variable speed zoom Tele: faster than 04 |
08 | variable speed zoom Tele: faster than 06 |
0A | variable speed zoom Tele: faster than 08 |
0C | variable speed zoom Tele: faster than 0A |
0E | variable speed zoom Tele: fastest speed |
10 | variable speed zoom Wide: slowest speed |
12 | variable speed zoom Wide: faster than 10 |
14 | variable speed zoom Wide: faster than 12 |
16 | variable speed zoom Wide: faster than 14 |
18 | variable speed zoom Wide: faster than 16 |
1A | variable speed zoom Wide: faster than 18 |
1C | variable speed zoom Wide: faster than 1A |
1E | variable speed zoom Wide: fastest speed |
21 | テレフレ・グリッド表示 |
45 | Focus manual far |
47 | Focus manual near |
E1 | Focus manual far : slowest speed |
E3 | Focus manual far : faster than 00 |
E5 | Focus manual far : faster than 02 |
E7 | Focus manual far : faster than 04 |
E9 | Focus manual far : faster than 06 |
EB | Focus manual far : faster than 08 |
ED | Focus manual far : faster than 0A |
EF | Focus manual far : fastest speed |
F1 | Focus manual near : slowest speed |
F3 | Focus manual near : faster than 00 |
F5 | Focus manual near : faster than 02 |
F7 | Focus manual near : faster than 04 |
F9 | Focus manual near : faster than 06 |
FB | Focus manual near : faster than 08 |
FD | Focus manual near : faster than 0A |
FF | Focus manual near : fastest speed |
※Focus manualは、カメラの設定で、フォーカスをマニュアルにしていないと使用できない
まとめ
メニュー関係のコマンドと、Focusの速さが何段階かあるというのを見つけたのが、今回の収穫です。もしかすると、他にもコマンドがあるかもしれませんが、今回の調査は、これで終わりです。
欲を言えば、フォーカスのオート・マニュアルの切り替えを行うコマンドと、明るさをマニュアルで変更できるコマンドを見つけたかったのですが、無いのでしょうか?どなたか発見したら教えてください。
ソニーのLANCリモコンにはFocus MANU/AUTOがあるようなので、コマンドは存在してるようですね。
http://www.sony.jp/handycam/products/RM-95/
やはり、コマンド的にはあるんですね!
フォーカスを動かすのに対応しているのに、MANU/AUTOの切り替えが対応していないとは。。。。中途半端な!
[…] Arduinoで、SONY LANCプロトコルを調べる http://ichirowo.com/2017/10/arduinosony-lanc/ […]
修理時に設定したりとかにも使うのですが、非公開なんですよね。