how to test if lcd is working

I recently bought a KTM-S1201 lcd module for the purpose of making myself learn how to use it with arduino. I wrote some code that I think should work for it, but I'm getting nothing on the display. I'm wondering if it's actually broken or something like that. Is there a way to test it to verify that it's working without having working code? Any help would be appreciated. Here are some links to some stuff that might be helpful.

some notes on using the ktm-s1201 module

this is the data sheet for the controller on the module ([ch956]PD7225)
http://www2.renesas.com/maps_download/pdf/S14308EJ6V1DS00.pdf

this guy made some programs to work with the ktm-s1201 that i was trying to learn some stuff from
http://www.qsl.net/ve3lny/ktms1201.html

Since I'm sure somebody will ask, here is the code and wiring diagram. If you see any problems here, let me know. I'm not even sure this code should work.

const int BUSY = 8; // variables are what the pins are called on the lcd module
const int SCK = 9; // the numbers are the arduino pins they are connected to
const int SI = 10;
const int CD = 11;
const int RESET = 12;
const int CS = 13;

const int MODE = 0x40;
const int UNSYNCHRONIZED = 0x30;
const int BLINKOFF = 0x18;
const int DISPLAYON = 0x11;
const int SEGMENTDECODERON = 0x15;
const int CLEARDATAANDPOINTER = 0x20;
const int NUM1 = 0x01;
const int NUM2 = 0x02;
const int NUM3 = 0x03;



void setup() {
  
  
  
  pinMode(BUSY, INPUT); // BUSY is the only input. When low, lcd module is processing data
  // and can't recieve. When high, lcd module is ready to accept data.
  pinMode(SCK, OUTPUT); // SCK is clock pin. When it goes high, it stores the state (bit) from
  // SI. It will wait for it to go high again to store the next one. After 8 pulses, the lcd module 
  // will lock out until CS goes high.
  pinMode(SI, OUTPUT); // This is where the data bits go for serial communication
  pinMode(CD, OUTPUT); // If this is high, it will register info from SI as a command. If it's low 
  // it will register as data.
  pinMode(RESET, OUTPUT); // Resets lcd module when it goes low.
  pinMode(CS, OUTPUT); // Hold this low the whole time while transferring a byte. Return it high when
  // done so it stores the info.
  
  // initial setup of lcd module
  digitalWrite(RESET, LOW); // reset module
  delay(1000); // wait 1000 ms to make sure it's done resetting 
  
  
  digitalWrite(CD, HIGH); // this will be a command to change settings
  digitalWrite(CS, LOW); // this tells it we are going to send some data
  while(digitalRead(BUSY) == 0){ // makes sure BUSY is high. if low, lcd module is busy, and
  // it waits 1 ms before checking again
    delay(1);
  }
  shiftOut(SI, SCK, MSBFIRST, MODE); // setting up the controller
  shiftOut(SI, SCK, MSBFIRST, UNSYNCHRONIZED);
  shiftOut(SI, SCK, MSBFIRST, BLINKOFF);
  shiftOut(SI, SCK, MSBFIRST, DISPLAYON);
  shiftOut(SI, SCK, MSBFIRST, SEGMENTDECODERON);
  shiftOut(SI, SCK, MSBFIRST, CLEARDATAANDPOINTER);
  digitalWrite(CS, HIGH);
  
  digitalWrite(CD, LOW);
  digitalWrite(CS, LOW);
  while(digitalRead(BUSY) == 0){ 
    delay(1);
  }
  shiftOut(SI, SCK, MSBFIRST, NUM3); // should hopefully make it display 123 on the screen
  shiftOut(SI, SCK, MSBFIRST, NUM2);
  shiftOut(SI, SCK, MSBFIRST, NUM1);
  digitalWrite(CS, HIGH);
  
}



void loop(){
  delay(1);
}

If the picture isn't showing up, find it here.
http://www.freeimagehosting.net/image.php?70a1fc8349.png

Any help is appreciated.

Has anybody else tried to use one of these?

Hi!
I have ordered one on eBay - waiting to receive it. The guy has sent me the documentation, but I have yet to read it. I'll be following the thread with interest...

Well, I just found one problem with my code. I set the reset pin low to reset the lcd, but never set it high again. It's just resetting constantly the way the code is now. I'll test it with this change when I have the time.

I added a line to send the reset pin high again to stop resetting, and now the display turns on. By adjusting the contrast potentiometer, I can see the segments appear. It's not displaying anything useful yet, though. With my code, I see "8.8.8.8.8.8.8.8.8.8.8.8.". Not sure why, but I know it's not broken at least.

I found out a few more things and got the code working to display 123 on the lcd.

  1. When sending commands cs has to go high after each byte, but when sending data to display cs needs to stay low while you send all the bytes then high at the end.
  2. By inserting a bunch of Serial.println() commands I was able to figure out that the busy pin was never going high. I don't know why this is, but if you just ignore the busy pin and instead put a delay(1) after each time you change the cs pin it will work.
  3. When you are sending several bytes of data at once, it can mess up and not pick up all the data. If you put a delay(1) in between bytes of a sequence, it will register them correctly.

Here is my new code

const int BUSY = 8; // variables are what the pins are called on the lcd module
const int SCK = 9; // the numbers are the arduino pins they are connected to
const int SI = 10;
const int CD = 11;
const int RESET = 12;
const int CS = 13;

const int MODE = 0x40;
const int UNSYNCHRONIZED = 0x30;
const int BLINKOFF = 0x18;
const int DISPLAYON = 0x11;
const int SEGMENTDECODERON = 0x15;
const int CLEARDATAANDPOINTER = 0x20;
const int NUM1 = 0x01;
const int NUM2 = 0x02;
const int NUM3 = 0x03;



void setup() {
  
  Serial.begin(9600);
  
  pinMode(BUSY, INPUT); // BUSY is the only input. When low, lcd module is processing data
  // and can't recieve. When high, lcd module is ready to accept data.
  pinMode(SCK, OUTPUT); // SCK is clock pin. When it goes high, it stores the state (bit) from
  // SI. It will wait for it to go high again to store the next one. After 8 pulses, the lcd module 
  // will lock out until CS goes high.
  pinMode(SI, OUTPUT); // This is where the data bits go for serial communication
  pinMode(CD, OUTPUT); // If this is high, it will register info from SI as a command. If it's low 
  // it will register as data.
  pinMode(RESET, OUTPUT); // Resets lcd module when it goes low.
  pinMode(CS, OUTPUT); // Hold this low the whole time while transferring a byte. Return it high when
  // done so it stores the info.
  
  // initial setup of lcd module
  digitalWrite(RESET, LOW); // reset module
  delay(1); // wait 1 ms to make sure it registers 
  digitalWrite(RESET, HIGH); // turn off reset
  delay(1000); // wait 1000 ms to make sure it stops resetting

    
  digitalWrite(CD, HIGH); // this will be a command to change settings
  digitalWrite(CS, LOW); // this tells it we are going to send some data
  delay(1);
  
  shiftOut(SI, SCK, MSBFIRST, MODE); 
  digitalWrite(CS, HIGH);
  delay(1);
 
 digitalWrite(CD, HIGH); // this will be a command to change settings
  digitalWrite(CS, LOW); // this tells it we are going to send some data
  delay(1); 
   
  shiftOut(SI, SCK, MSBFIRST, UNSYNCHRONIZED);
  digitalWrite(CS, HIGH);
  delay(1);
  
  digitalWrite(CD, HIGH); // this will be a command to change settings
  digitalWrite(CS, LOW); // this tells it we are going to send some data
  delay(1);
  
  shiftOut(SI, SCK, MSBFIRST, BLINKOFF);
  digitalWrite(CS, HIGH);
  delay(1);
  
  digitalWrite(CD, HIGH); // this will be a command to change settings
  digitalWrite(CS, LOW); // this tells it we are going to send some data
  delay(1);
  
  shiftOut(SI, SCK, MSBFIRST, DISPLAYON);
  digitalWrite(CS, HIGH);
  delay(1);
  
  digitalWrite(CD, HIGH); // this will be a command to change settings
  digitalWrite(CS, LOW); // this tells it we are going to send some data
  delay(1);
  
  shiftOut(SI, SCK, MSBFIRST, SEGMENTDECODERON);
  digitalWrite(CS, HIGH);
  delay(1);
  
  digitalWrite(CD, HIGH); // this will be a command to change settings
  digitalWrite(CS, LOW); // this tells it we are going to send some data
  delay(1);
  
  shiftOut(SI, SCK, MSBFIRST, CLEARDATAANDPOINTER);
  digitalWrite(CS, HIGH);
  delay(1);
  
      
  digitalWrite(CD, LOW);
  digitalWrite(CS, LOW);
  delay(1);
  
  shiftOut(SI, SCK, MSBFIRST, NUM3);
  delay(1);  
  shiftOut(SI, SCK, MSBFIRST, NUM2);  
  delay(1); 
  shiftOut(SI, SCK, MSBFIRST, NUM1);
  delay(1);
  digitalWrite(CS, HIGH);
  delay(1);
}



void loop(){
  delay(1000);
}
1 Like
void loop(){
  delay(1000);
}

Don't do anything, but wait for a second before you don't do it.

Very useful.

drhoff,

thanks for your testing and explanations. It's very nice to have someone open the road for you. I'll post my findings as soon as I can do something useful.

I guess that delay in the main loop doesn't really do much. What happens if the main loop is blank?

What happens if the main loop is blank?

It would do nothing right away.

This display is on ebay, see "ARDUINO 12 DIGIT 7 SEG LCD Display" ($1.57). You will find out that the shiftOut command inverts one of the pins I think it is the Clock pin. That corrupts the data when "text" is sent (all 8 bites of data). I wrote a function relying heavly on the original shiftOut command that fixes the problem.
void ktmshiftOut(byte val)
{
int i;
for (i=0;i<8;i++)
{
digitalWrite(LcdSi,!!(val & (1<< (7-i))));
digitalWrite(LcdSck,LOW);
delay(1);
digitalWrite(LcdSck,HIGH);
}
}
I hope this helps. :wink: