12월 042011
 

지난 번에 테스트삼아 만든 아두이노 프로그램을 좀 더 손을 봐서,  본격적으로 NX마운트에서 올라오는 3번핀의 CMD를 안정적으로 추출하도록 했습니다.

이 프로그램으로 NX10 바디가 전원을 켰을 때나, 렌즈가 마운트 되었을 때, 안정적으로 바디의 CMD를 수신할 수 있는 것도 확인했습니다. 상당한 성과입니다.

아래는 이 프로그램을 심은 아두이노로 추출한 NX10이 30mm 렌즈를 장착한 상태로 전원을 켰을 때 추출된 CMD의 값들입니다.

 03 AA 55
 03 10 01
 FF FF FF FF 80 A9 A6 D4 80 90
 3B 07 00 A6 00 00 00 00 00 00 00 00 00 88 00 00 00 89 00 00 00 8A 00 00 00 8B 00 00
 05 10 06 50 01
 05 10 06 50 02
 05 10 06 50 03
 05 10 06 50 07
 05 10 06 50 08
 05 10 06 50 09
 06 10 08 50 01 01

그리고 아래는 AF 동작시 추출된 바디의 CMD 신호의 값들입니다.

 07 11 01 40 0C 05 05
 07 11 01 40 14 05 05
 07 11 01 40 0C 01 C6
 07 11 01 50 FF 02 71
 07 11 01 80 FF 00 00

모두 로직 애널라이저로 확인해 본 결과 일치하는 값들이었습니다.

 

아래는 아두이노의 스케치 소스코드입니다.

#include 
 
#define CMD_PIN  11    // MOSI --> NX Mount Pin 3
#define DAT_PIN  12    // MISO --> NX Mount Pin 2
#define CLK_PIN  13    // SCK --> NX Mount Pin 1
 
#define CMDBUFFSIZE 1024
 
volatile byte cmd_buf[CMDBUFFSIZE];
volatile int pos;
volatile int disp_pos;
 
// --------------------------------------------------------------------------
// Setup SPI
// --------------------------------------------------------------------------
void setup (void)
{
  Serial.begin (9600);
  Serial.println ("Begin");
 
  // get ready for an interrupt
  pos = 0;   // buffer empty
  disp_pos = 0;
 
  pinMode(CMD_PIN, INPUT);
  pinMode(DAT_PIN, OUTPUT);
 
  //| 7    | 6    | 5    | 4    | 3    | 2    | 1    | 0    |
  //| SPIE | SPE  | DORD | MSTR | CPOL | CPHA | SPR1 | SPR0 |  
 
  // SPI interrupt mode, SPI Enabled, MSB First mode, Slave Mode
  SPCR = B11001100;  //SPIE=1,SPE=1,DORD=0,MSTR=0,CPOL=1,CPHA=1,SPR=00
}
 
// --------------------------------------------------------------------------
// SPI interrupt routine
// --------------------------------------------------------------------------
ISR (SPI_STC_vect)
{
  cmd_buf [pos++] = SPDR;
 
  if (pos > 1023) {
    pos = 0;
  }
}
 
// --------------------------------------------------------------------------
// main
// --------------------------------------------------------------------------
void loop (void)
{
  int currentPos = pos;
  int gap = abs(disp_pos - currentPos);
 
  while (disp_pos != currentPos) {
    Serial.print (" ");
    Serial.print ((byte)cmd_buf[disp_pos++], HEX);
    if (disp_pos > 1023) {
      disp_pos = 0;
    }
  }
  if (gap > 0) {
    Serial.println(" ");
  }
  disp_pos = currentPos;
}

  3 Responses to “아두이노: NX 마운트 커맨드 추출기”

  1. Hello!!!

    I have a Samsung NX 11 camera.
    Actually i’m using a micro nikkor 55 mm AI-S f2.8 manual lens.

    I am tryng to make your circuit with stm32f103rbt6 LC STUDIO pcb board and CooCox ARM Cortex MCU Development Tools.

    This is the comunication between camera and my stm32 board :

    Begin:
    03 AA 55 00_
    00 03 10 01 00 00_
    05 10 06 50 01 00_
    05 10 06 50 02 00_
    05 10 06 50 03 00 05 10 06 50 07 00_
    05 10 06 50 08 00 05 10 06 50 09 00 05 10 06 50 0D 00 05 10 06 50 0E 00_
    06 10 08 50 01 00 00 00 00 00 00 00 00 00 00 06 10 08 50 01 01_
    06 10 08 50 01 01_

    but i have a response problem with 06 10 08 50 01 cmd.

    when i receive 6 10 08 50 01 from camera, i send the sequence 3 20 01 04 70 02 03 but the camera not respond.

    Could you help me ?

    Best Regards

    Luca Pellati, Italy.

    Great respect for yours job !!!!!!

    i have dump data from 20 mm f2.8 samsung lens:

    ======================= DAT_NX to STM32 ==================================
    03 AA 55_
    cmd: 00 00 00
    B1 20 01 00 64 00 00 00 00 00 00 00 00_
    06 00 00 00 0B 10 01 10 05 10 06 10 07 10 08 10 09 10 0C 10 0D 10 10 11 01 11 02 00 00 00 03 40 01 40 02 40 03 00 00 00 08 50 01 50 02 50 03 50 07 50 08 50 09 50 0D 50 0E 00 00 00 1B 60 01 60 02 60 03 60 04 60 05 60 06 60 07 60 08 60 09 60 0A 60 0B 60 0C 60 0D 60 0E 60 0F 60 10 60 12 60 13 60 14 60 16 60 17 60 18 60 1A 60 1B 60 19 60 1C 60 1D 00 00 00 02 70 01 70 02 05 53 44 49 43 00 07 58 4C 31 30_
    31 36 00 0C 30 31 2E 31 30 5F 30 31 2E 31 30 00 0D 32 33 38 31 30 30 31 37 35 38 38 33

    cmd: 00 00 00 00 00 00
    0F 20 01 00 02 01 00 00 02 00 04 00 01 02 03

    cmd: 00 00 00 00 00
    0D 20 01 00 02 01 01 01 02 00 02 00 01

    cmd: 00 00 00 00 00
    0D 20 01 00 02 01 00 00 02 00 02 00 01

    cmd: 00 00 00 00 00
    11 20 01 00 04 20 00 15 00 15 01 00 6E 02 34 00 01

    cmd: 00 00 00 00 00
    0C 20 01 00 02 00 01 01 01 01 01 01

    cmd: 00 00 00 00 00
    0C 20 01 00 02 20 01 01 01 01 1C 01

    cmd: 00 00 00 00 00
    0F 20 01 00 02 01 01 01 02 00 04 00 01 10 11

    cmd: 00 00 00 00 00
    12 20 01 00 02 01 00 00 02 00 07 00 01 02 03 05 0A 1E

    cmd: 00 00 00 00 00 00 ( 6 10 50 8 1 <——– nx10 no answer at DAT below——–)
    03 20 01 04 70 02 03_

    cmd: 00 00 00 00 00 00
    03 20 01_

    00 00 00 00 00_
    05 20 01 00 6A_
    06 70 01 03 00 9C_
    00 00 00 00 00 00_
    03 20 01_
    00 00 00 00 00_
    05 20 01 00 9A_
    07 40 01 00 9A 03 03_
    07 40 01 00 9A 03 03_
    00 00 00 00 00 00 00_
    04 20 01 00_
    07 40 01 00 9C 20 03_
    06 70 01 21 00 9D_
    07 40 01 00 A4 21 03_
    07 40 01 00 AE 21 03_
    00 00 00 00 00 00 00_
    04 20 01 01_
    07 40 01 00 B8 21 03_
    07 40 01 00 C7 21_
    03 07 40 01 00 DE 21 03_
    00 00 00 00 00 00 00_
    04 20 01 01_
    07 40 01 00 F2 21 03_
    07 40 01 01 07 21 03_
    07 40 01 01 26 21 03_
    07 40 01 01 46 21 03_
    07 40 01 01 66 21 03_
    07 40 01 01 85 21 03_
    00 00 00 00 00 00 00_
    04 20 01 01 07 40 01 01 A0 22 03_
    06 70 01 03 01 A1_
    00 00 00 00 00 00_
    03 20 01_
    00 00 00 00 00 00_
    03 20 01_
    00 00 00 00 00 00 00_
    04 20 01 00_
    06 70 01 03 00 1F_

    ======= CMD NX to STM32 =======================================================

    03 AA 55_
    00 00 00_
    03 10 01 00 00 00 00 00 00 00 00 00 00 00 00 00_
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF 80 A9 A4 68 80 8D FD D3 00 AE 00 00_
    00 00 00 00 00 00 00 88 00 00 00 89 00 00 00 8A 00 00 00 8B 00 00 00 8C 00 00 00 8E 00 00 05 10 06 50 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 10 06 50 02 00 00 00 00 00 00 00 00 00 00 00 00 00 05 10 06 50 03 00 00 00 00 00 00 00 00 00 00 00 00 00 05 10 06 50 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 10 06 50 08 00 00 00 00 00 00 00 00 00 00 00 00 05 10 06 50 09 00 00 00 00 00 00 00 00 00 00 00 00 05 10 06 50 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 10 06 50 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 10 08 50 01 01 00 00 00 FF FF FF FF_
    06 10 08 50 0D 10 FF FF FF_
    05 10 07 50 07_
    FF FF FF FF FF_
    FF FF FF FF FF FF_
    06 10 08 50 0D 11_
    FF FF FF_
    05 10 07 50 07_
    FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 06 02 34_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 0E 02 34_
    FF FF FF FF_
    FF FF FF FF FF FF_
    FF FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 13 02 34_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 60 00 00 6E_
    FF FF FF FF FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    06 10 08 50 0D 10_
    FF FF FF_
    06 10 08 50 0D 11_
    FF FF FF_
    05 10 07 50 07_
    FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 60 00 00 6E_
    FF FF FF FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 06 02 34_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 0E 02 34_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 13 00 6E_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01_
    60 00 00 6E FF FF FF_
    FF FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    06 10 08 50 0D 10_
    FF FF FF_
    06 10 08 50 0D 11_
    FF FF FF_
    05 10 07 50 07_
    FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 60 00 00 6E_
    FF FF FF FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 06 02 34_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 0E 02 34_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 13 00 6E_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    07 11 01 30 FF 00 B6_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF_
    FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    07 11 01 40 13 02 34_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    FF FF FF FF FF FF_
    07 11 01 50 FF 00 A6_
    FF FF FF FF_
    FF FF FF FF FF FF FF_
    05 10 07 50 07_
    FF FF FF FF FF_
    FF FF FF FF FF FF FF_
    06 10 08 50 0D 10_
    FF FF FF_
    FF FF FF FF FF FF_

    • Luca,

      Thank you for your visiting my blog. I have to take a look your code dump and I need to remind the logic what is going on. 🙂

      Please allow me some time to recall my memory. I will get back to you soon.

  2. Thank you very much !!!!

    Bye

Leave a Reply to 자작쟁이 Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)