Can you display on a Lascar DDM 4 with an arduino?

Hello,

I was wondering if you could display value on a Lascar DDM 4 Digital data display. It says you only need 3 pins: Clock, Data In, and Load. If you can use it with an Arduino, where is a good place to learn how?

Thanks,

Alex

Yes, that is pretty simple to use with an Arduino. The datasheet gives all the necessary detail (but just as well you are using the DDM4 module as that datasheet has a very bad error regarding the "degree", "colon" and "point" inputs).

You use hardware or software SPI to shift the required four bytes into the display and latch them,

I am not familiar with SPI. I looked into it a little bit. I am confused on how to get a 3 digit integer into 32 bit and how to send the value?

Also what does "setting Load to Logic 1" mean? What does logic 1 mean?

Thank you

alexpolyanskiy:
Also what does "setting Load to Logic 1" mean? What does logic 1 mean?

"Logic 1" would be 5 V, a logic "HIGH".

32 bits is in this case, four separate bytes. You need a lookup table to convert a single decimal (or hexadecimal) digit into a byte which has the segment pattern for that digit (with binary "1s" in the positions where the segment must show).

You first convert the number you have into your separate digits, then use the lookup table to find the segment pattern for each, line up four patterns (including unused digits which would simply be zeroes) and send those four pattern bytes via hardware (SPI) or software (shiftOut) to the display.

So I wrote a little bit of code. So I transferred 4 byte, one at a time. Is this what you were talking about? Am I missing something that has to do with converting binary to hex?

``````// Segment labelling:
//        A
//       ----
//     F |  | B
//       ---- G
//     E |  | C
//  .DP    ----
//        D

#include <SPI.h>

byte valuetobyte();

int num=0;
int value;
int dig1 = 0;
int dig2 = 0;
int dig3 = 0;
int dig4 = 0;

//G F A B C D E DP
byte zero  = 01111110;
byte one   = 00011000;
byte two   = 10110110;
byte three = 10111100;
byte four  = 11011000;
byte five  = 11101100;
byte six   = 11101110;
byte seven = 00111000;
byte eight = 11111110;
byte nine  = 11111100;
byte dash  = 10000000;
byte blank = 00000000;

void setup() {

digitalWrite(SS, HIGH);
SPI.begin ();
SPI.beginTransaction(SPISettings (1500000, LSBFIRST, SPI_MODE1));

}

void loop()
{

int num;
byte displaydigit1;
byte displaydigit2;
byte displaydigit3;
byte displaydigit4;

dig1 = num / 1000;
num = num - (dig1 * 1000);
dig2 = num / 100;
num = num - (dig2 * 100);
dig3 = num / 10;
dig4 = num - (dig3 *10);

Serial.begin (9600);

displaydigit1 = Serial.println(valuetobyte(dig1), HEX);

displaydigit2 = Serial.println(valuetobyte(dig2), HEX);

displaydigit3 = Serial.println(valuetobyte(dig3), HEX);

displaydigit4 = Serial.println(valuetobyte(dig4), HEX);

digitalWrite(SS, LOW);

SPI.transfer (displaydigit1>>24);
SPI.transfer (displaydigit2>>16);
SPI.transfer (displaydigit3>>8);
SPI.transfer (displaydigit4);

digitalWrite(SS, HIGH);

delay(100);

return(0);

}

byte valuetobyte(int value) {

byte bytevalue;
//int value;

switch (value) {
case 0:
if(value == 0){
bytevalue = zero;
return(bytevalue);
break; }

case 1:
if(value == 1) {
bytevalue = one;
return(bytevalue);
break; }

case 2:
if(value == 2) {
bytevalue = two;
return(bytevalue);
break; }

case 3:
if(value == 3) {
bytevalue = three;
return(bytevalue);
break; }

case 4:
if(value == 4) {
bytevalue = four;
return(bytevalue);
break; }

case 5:
if(value == 5) {
bytevalue = five;
return(bytevalue);
break; }

case 6:
if(value == 6) {
bytevalue = six;
return(bytevalue);
break; }

case 7:
if(value == 7) {
bytevalue = seven;
return(bytevalue);
break; }

case 8:
if(value == 8) {
bytevalue = eight;
return(bytevalue);
break; }

case 9:
if(value == 9) {
bytevalue = nine;
return(bytevalue);
break; }

default:
bytevalue = blank;
return(bytevalue);
break;

}

}
``````