Sure Electronics 1.5" 7 segment Display DE-DP001

So for my next trick (part of my rally computer project) I need to have a display.

Anyone got any experience of interfacing this?

http://www.sureelectronics.net/goods.php?id=133
http://www.sureelectronics.net/pdfs/DE-DP001_Ver1.0_EN.pdf

It says SPI like interface?

James

Here's the sample code I found from the datasheet:

#define Fuc_key  GP3 
#define DIMM  GP2 
#define CLK   GP1 
#define DATA  GP0 
unsigned char disp_data; 
unsigned char key_pressed,last_key_pressed; 
unsigned char Value; 
unsigned char time; 
//The total of cathode 
const unsigned char Digital_TAB[] = 
{0xff,0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6,       
   0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; 
void change(void); 
void LED_data(void);  
void LED_display(void); 
void delay_2ms(void) 
{ 
 unsigned char i, j, k; 
 for(i = 0; i < 5; i++) 
 { 
  for(j = 0; j < 200; j++) 
   k--; 
 } 
} 
void change(void) 
{ 
 key_pressed=Fuc_key; 
 if((key_pressed==0)&(last_key_pressed==1))   
 { 
  delay_2ms(); 
  if(key_pressed==0) 
  { 
   disp_data++;  
   if(disp_data==19)disp_data=0; 
  } 
 }   
 last_key_pressed=key_pressed; 
} 
void LED_data(void)  
{ 
 unsigned char i; 
 for(i = 0; i <19; i++)     
 { 
  if(i==disp_data){Value = Digital_TAB[i];} 
 } 
} 
void LED_display(void) 
{ 
 unsigned char i; 
 unsigned char U; 
 U=Value; 
 for(i = 0;i < 8; i++)    
 { 
  DATA = U & 0x01; 
  CLK = 0; 
  CLK = 1; 
  U = U>>1; 
 } 
 U=Value; 
 for(i = 0;i < 8; i++)    
 { 
  DATA = U & 0x01; 
  CLK = 0; 
  CLK = 1; 
  U = U>>1; 
 } 
 U=Value; 
 for(i = 0;i < 8; i++)    
 { 
  DATA = U & 0x01; 
  CLK = 0; 
  CLK = 1; 
  U = U>>1; 
 } 
 U=Value; 
 for(i = 0;i < 8; i++)    
 { 
  DATA = U & 0x01; 
  CLK = 0; 
  CLK = 1; 
  U = U>>1; 
 } 
} 
void main(void) 
{ 
 OSCCAL=0; 
 TRIS = 0b11111000; 
 OPTION=0b11011111; 
 while(1) 
 { 
  change(); 
  LED_data(); 
  DIMM = 0; 
  LED_display(); 
  DIMM = 1;   //Active–high Output Enable 
  delay_2ms(); 
 } 
}

soooo easy :slight_smile:

int clearPin = 2;
int dataPin = 3;
int clockPin = 4;
byte testData = 252; //change this

void setup() {
  pinMode(clearPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  
  digitalWrite(clearPin, 0);
  shiftOut(dataPin, clockPin, LSBFIRST, testData);
  shiftOut(dataPin, clockPin, LSBFIRST, testData);
  shiftOut(dataPin, clockPin, LSBFIRST, testData);
  shiftOut(dataPin, clockPin, LSBFIRST, testData);
  digitalWrite(clearPin, 1);
}

void loop() {
}

just need to write a library now to take a string and output as the correct bytes.

James

I have created a library that interfaces to that board, however I have not yet documented it, so I haven't announced it formally. It allows display of floating point numbers on the display, with the decimal point any any of the 4 locations, or not present. It also allows display of individual digits in any position, and supports fading in and out of the display. I am still working on it, and plan to document it and put it up on my web site, but you can access it now at
http://docmorbius.net/arduino/SevenSegment.zip.
There is an example in there that may help to explain how to use it.
Good luck

Looks good - I will give it a go later.

Do you have any plans to make it do characters also?

James

Have been playing with your library - a few bugs when the digits get bigger but it works nicely!

FYI I have mapped all the characters you can do on the display...

Those with // are where the upper or lower case has been substituted. Obviously some characters you cannot do - so it's still limited.

    case '0': return 0xfc;
    case '1': return 0x60;
    case '2': return 0xda;
    case '3': return 0xf2;
    case '4': return 0x66;
    case '5': return 0xb6;
    case '6': return 0xbe;
    case '7': return 0xe0;
    case '8': return 0xfe;
    case '9': return 0xf6;
    case 'A': return 0xee;
    case 'a': return 0xfa;
    case 'B': return 0x3e;  //
    case 'b': return 0x3e;
    case 'c': return 0x1a;
    case 'C': return 0x9c;
    case 'D': return 0x7a;  //
    case 'd': return 0x7a;
    case 'e': return 0xde;
    case 'E': return 0x9e;
    case 'F': return 0x8e;
    case 'f': return 0x8e;  //
    case 'G': return 0xf6;  //
    case 'g': return 0xf6;
    case 'H': return 0x6e;
    case 'h': return 0x2e;
    case 'I': return 0x60;
    case 'i': return 0x08;
    case 'J': return 0x70;
    case 'j': return 0x70;  //
    case 'L': return 0x1c;
    case 'l': return 0x0c;
    case 'N': return 0xec;  
    case 'n': return 0x2a;
    case 'O': return 0x3a;  //
    case 'o': return 0x3a;   
    case 'P': return 0xce;
    case 'p': return 0xce;  //
    case 'Q': return 0xe6;  //
    case 'q': return 0xe6;
    case 'R': return 0x0a;  //
    case 'r': return 0x0a;
    case 'S': return 0xb6;
    case 's': return 0xb6;  //
    case 'T': return 0x1e;  //
    case 't': return 0x1e;
    case 'U': return 0x7c;
    case 'u': return 0x38;
    case 'Y': return 0x76;  //
    case 'y': return 0x76;
    case '-': return 0x02;
    case '?': return 0xcb;
    case '=': return 0x12;
    case '"': return 0x44;
    default : return 0x00;

I'm not sure what you mean by "a few bugs when the digits get bigger".
If there are bugs, I'd like to fix them. Can you describe the problem in more detail?

I'll incorporate your character values into the code, if that's OK with you.

I think I tired to make it count up in +0.05 or something - when the numbers got too big for the display it went a bit mental.

Here are some updated character codes:

  case '0': 
    return 0xfc;
  case '1': 
    return 0x60;
  case '2': 
    return 0xda;
  case '3': 
    return 0xf2;
  case '4': 
    return 0x66;
  case '5': 
    return 0xb6;
  case '6': 
    return 0xbe;
  case '7': 
    return 0xe0;
  case '8': 
    return 0xfe;
  case '9': 
    return 0xf6;
  case 'A': 
    return 0xee;
  case 'a': 
    return 0xfa;
  case 'B': 
    return 0x3e;  //
  case 'b': 
    return 0x3e;
  case 'c': 
    return 0x1a;
  case 'C': 
    return 0x9c;
  case 'D': 
    return 0x7a;  //
  case 'd': 
    return 0x7a;
  case 'e': 
    return 0xde;
  case 'E': 
    return 0x9e;
  case 'F': 
    return 0x8e;
  case 'f': 
    return 0x8e;  //
  case 'G': 
    return 0xf6;  //
  case 'g': 
    return 0xf6;
  case 'H': 
    return 0x6e;
  case 'h': 
    return 0x2e;
  case 'I': 
    return 0x60;
  case 'i': 
    return 0x08;
  case 'J': 
    return 0x78;
  case 'j': 
    return 0x70;
  case 'L': 
    return 0x1c;
  case 'l': 
    return 0x0c;
  case 'N': 
    return 0xec;  
  case 'n': 
    return 0x2a;
  case 'O': 
    return 0x3a;  //
  case 'o': 
    return 0x3a;   
  case 'P': 
    return 0xce;
  case 'p': 
    return 0xce;  //
  case 'Q': 
    return 0xe6;  //
  case 'q': 
    return 0xe6;
  case 'R': 
    return 0x0a;  //
  case 'r': 
    return 0x0a;
  case 'S': 
    return 0xb6;
  case 's': 
    return 0xb6;  //
  case 'T': 
    return 0x1e;  //
  case 't': 
    return 0x1e;
  case 'U': 
    return 0x7c;
  case 'u': 
    return 0x38;
  case 'Y': 
    return 0x76;  //
  case 'y': 
    return 0x76;
  case '-': 
    return 0x02;
  case '?': 
    return 0xcb;
  case '=': 
    return 0x12;
  case '"': 
    return 0x44;
  default : 
    return 0x00;

Ok. I have updated the library to fix the bug you mentioned,
and added the ability to display characters, and fixed some other
things. I have also documented it.

The library and the documentation is now at...
http://docmorbius.net/arduino/libraries.html#SevenSegment

Thanks for the update.

I am getting my display showing 101.0 when I use this:

#include <SevenSegment.h>

#define DIM   6          // This pin turns off the display when set LOW
#define CLK   4          // This is the clock pin
#define DATA  3           // This is the data pin
#define MAXDIGITS 4       // number of display digits

SevenSegment seg = SevenSegment(DATA,CLK,DIM,MAXDIGITS);    // Create the SevenSegment Object

double value = 100.0;

void setup() {
  
  seg.displayNum(value,1,0);
}

void loop() {
}

Oops. That's a nasty bug.

I just spent some time debugging and, believe it or not, I found that the pow() function in the C library was returning 99 instead of 100 for 10 to the power of 2, or at least when the floating number returned by pow() was cast to a long that's what was returned. Wow!

I replaced the calls to the C library pow() function with my own private function and the problem seems to be fixed.

Thanks for finding that one!

The library is updated on the web site.

That's a pretty weird bug.

Please make sure you post an entry in the Bugs section.

It's not a bug, it's a feature! That pow function is floating point, and rounding will occur. There was at least one thread about it in April (Google "site:arduino.cc floating point pow function").

Andrew

Ten to the power of 2 is exactly 100, not 99.

I'm trying to use this library/codes with a Sure Electronics DE-DP003 2.3" display but I'm getting weird characters. I'm sure that I'm missing something simple.

http://www.sureelectronics.net/goods.php?id=135

JamesCarruthers

Did you ever finish your Rally Computer?