동네의 부품샵을 구경하다 우연히 구하게 된 부품이다. 저렴한 가격($1.99)때문에 메뉴얼 여부에 관계 없이 일단 구입하여 버렸다. 물론 '구글신'을 믿고 있었기 때문이지만...

부품 명칭은 PD2437로 OSRAM에서 나온 4-character 5x7 dot matrix alphanumeric programmable display with built-in CMOS control functions 이다. DIL 패키지 안에 5x7 매트릭스가 4개 들어있고 디스플레이 컨트롤러를 내장하고 있다.
이 부품을 사용하기 위해 구글의 도움으로 유저메뉴얼과 어플리케이션 노트를 찾아내었다.
일반적인 메모리같이 8-bit bidirectional data bus를 사용해서 마이크로컨트롤러와 데이터를 교환하고 ASCII 코드를 입력받아 그에 해당하는 문자를 표시하게 되어 있었다.
Arduino에 연결하려고 하는데 8-bit data bus를 모두 digital i/o에 연결해 버리면 arduino에 다른 주변기기를 붙일 수 없을거 같아 74LS164(8-Bit Parallel-Out Serial-In Shift Registers)를 같이 사용하기로 하였다.
이를 토대로 구성한 회로는 다음과 같다.

Arduino의 D2-D9까지를 사용하였다.
실제 기판에 만들기 전에 먼저 브레드보드에서 프로토타입으로 확인을 해 보았다.

큰 문제 없이 원하는 글자를 표시해 주었다. 테스트에 사용한 코드는 다음과 같다.
      View source code
  /*
 * PD2437 Test
 */
/*
 - Addressing 
  0xx : control word
  100 : digit 0 (rightmost)
  101 : digit 1
  110 : digit 2
  111 : digit 3 (leftmost)
 - Control Word
  b7 : clear
       0 standard operation
       1 clear entire display
  b6 : lamp test
       0 standard operation
       1 display all dots at 50% brightness
  b5 : blink
       0 blink attribute disabled
       1 blink entire display
  b4 : attribute enable
       0 disable above attributes
       1 enable above attributes
  b3,b2: attributes
       00 display cursor instead of character
       01 blink character
       10 display blinking cursor instead of character
       11 alternate character with cursor
  b1,b0: brightness
       00 0% (black)
       01 25%
       10 50%
       11 100%
       
  -----------------------------------------------------
  how to load information into the display
  
    SET BRIGHTNESS
  1. set brightness level of the entire display to your preference, (000) <- 0x02 (50%)
    
    LOAD FOUR CHARACTERS
  2. load "S" in the left hand digit, (111) <- 'S'
  3. load "T" in the next digit, (110) <- 'T'
  4. load "O" in the next digit, (101) <- 'O'
  5. load "P" in the right hand digit, (100) <- 'P'
  
    BLINK A SINGLE CHARACTER
  6. into the digit, second from the right, load the hex code 0xcf, which is the code for an 'O' with the d7 bit added as a control bit, (101) <- 0xcf
  7. load enabled blinking character into the control word register. the display should show "STOP" with a flashing "O", (000) <- 0x17
  
    ADD ANOTHER BLINKING CHARACTER
  8. into the left hand digit, load the he code 0xd3 which gives an 'S' with d7 bit added as a control bit, (111) <- 0xd3
  
    ALTERNATE CHARACTER/CURSOR ENABLE
  9. load enable alternate character/cursor into the control word register. the display now should show "STOP" with the 'O' and the 'S' alternating between the letter and cursor. (000) <- 1f
  
    INITIATE FOUR CHARACTER BLINKING
  10. load enable display blinking. the display now should show the entire word "STOP" blinking, (000) <- 0x23
*/
// Connected to LS164
int DATA = 2;    // LS164 Din  (pin 1&2)
int CLK = 3;     // LS164 Clk  (pin 8)
// Connected to PD2437
int A0 = 6;   // Address 0 (pin 7)
int A1 = 5;   // Address 1 (pin 8)
int A2 = 4;   // Address 2 (pin 9)
int WR = 7;   // Write (pin 11)
int CE = 8;   // Chip Enable (NEG, pin 6)
int RST = 9;  // Reset (NEG, pin 4)
void setup()                    // run once, when the sketch starts
{
  Serial.begin(38400);
  
  // pins for LS164
  pinMode(DATA, OUTPUT);      // sets the digital pin as output
  pinMode(CLK, OUTPUT);      // sets the digital pin as output
  
  // pins for PD2437
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(WR, OUTPUT);
  pinMode(CE, OUTPUT);
  pinMode(RST, OUTPUT);
  
  // Reset PD2437
  digitalWrite(CE, HIGH);
  digitalWrite(WR, HIGH);
  digitalWrite(RST, LOW);
  digitalWrite(RST, HIGH); 
}
void loop()                     // run over and over again
{
  putChar(0, 0x83);
  delay(100);
  putChar(7,'S');
  delay(100);
  putChar(6,'T');
  delay(100);
  putChar(5,'O');
  delay(100);
  putChar(4,'P');
  delay(100);
  
  putChar(4, 'P' | 0x80);    // 'P' w/ MSB
  delay(100);
  putChar(0, 0x17);
  delay(100);
  putChar(7, 'S' | 0x80);    // 'S' w/ MSB
  delay(100);
  putChar(0, 0x1f);
  delay(100);
  putChar(0, 0x23);
  
  delay(1000);  
}
//
// Subroutine for LS164
//
// Send byte to LS164
void sendByte(int d)
{
  shiftOut(DATA, CLK, MSBFIRST, d);
}
//
// Subroutine for PD2437
//
// set address for PD2437
void setAddr(int adr)
{
  digitalWrite(A0, (adr&0x1));
  digitalWrite(A1, (adr&0x2));
  digitalWrite(A2, (adr&0x4));
}  
void putChar(int pos, int ch)
{
  digitalWrite(CE, LOW);
  setAddr(pos);
  sendByte(ch);
  digitalWrite(WR, LOW);
  digitalWrite(WR, HIGH);  
  digitalWrite(CE, HIGH);
}
PD2437은 매우 쉽게 여러개를 cascading이 가능하기 때문에 현재 총 10개의 PD2437을 연결하여 20x2 LED display를 만들어 볼까 생각중이다. LCD에 비해 직접 발광을 하기 때문에 시야각 문제도 없고 시중에서 구할 수 있는 20x2 LCD보다 크기도 크기 때문에 야간에도 글자를 정확하게 확인할 수 있기 때문에 signboard로 적합할 거 같다.
 
댓글 없음:
댓글 쓰기