DealExtreme 7 Segment (plus) Display

IronJungle

Senior Member
P.S. Is DealExtreme a reputable site? I have thought about buying there but always thought it looked dodgy...
I have ordered from DE many times and never had a issue. Leadtimes are looooong, (3-4 weeks) so be aware of that. The prices are way cheap. Shipping always free.

Quality varies from very good to "WTH were they thinking". Read the user comments before you order an item and you will get a good feel for the product. As far as I can tell DE does not moderate negative, but legit comments.
 

IronJungle

Senior Member
$6.99 and free global shipping? That's a bargain!
That what I thought. Even if I just pull off the 7 segments, tactical buttons, and LEDs. But, I really don't plan to destroy it. I would rather come up with some idea that would make use of it.
 

hippy

Technical Support
Staff member
Is there any evidence/documentation of this being connected to a PICAXE?
I think there should be, somewhere on the forum. I recall it being commented on that the IDC sockets looked to have been put on the wrong side of the board. And voila ...

http://www.picaxeforum.co.uk/showthread.php?18788-Worth-a-punt

Not sure if Boriz or anyone ever tried it, or headed off to a Chinese restaurant seeking a translation service. Might be best to wait until the New Year is over before hassling hard pressed staff though :)
 

westaust55

Moderator
From a quick search, some help is available in the comments on the Deal Extreme website.
See here:
http://club.dealextreme.com/forums/Forums.dx/threadid.936370

and in particular a Googled translation of the TM1638 datasheet here:
https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B84N2SrJaybwZTgxYjM4ZmEtY2EyZi00YjVjLWIzOTctYTlhMjJkM2MxMTBl&hl=en_US

Also, a schematic from another supplier (not Deal Extreme) for a seemingly identical board that may be useful:
http://www.geekonfire.com/index.php?main_page=product_info&products_id=43
 
Last edited:

inglewoodpete

Senior Member
$6.99 and free global shipping? That's a bargain!
It's only a bargain if....
a) it does what you want or
b) it can be made to do what you want in a cost-effective way
I've seen the DX advert before. I wondered who would design such a device, with the connectors on the top of the board. I didn't buy one. 'Nuff said.
 

BeanieBots

Moderator
It's only a bargain if....
a) it does what you want or
b) it can be made to do what you want in a cost-effective way
I've seen the DX advert before. I wondered who would design such a device, with the connectors on the top of the board. I didn't buy one. 'Nuff said.
My thoughts too.
I'd guess that was NOT designed to have the connectors on top but a manufacturing error caused what is seen.
That probably also explains the lack of documention. IMHO it's not a product but a large surplus of incorrectly manufactured displays that are not cost effective to rework.
 

mjy58

Member
Working DealExtreme 7 segment module

Thought the following may be useful for others. Using the translated datasheet found by Westaust55, I have managed to get the module to do something useful;).

The attached program, allows control of all the 7 segment displays and LEDs. It also reads all the switches and put them in variables. As an example I have used it to display temperature from a DS18B20 and mimic the switches onto the LEDS.

The switches are a bit sluggish as everything is going in and out serially. I am sure others will be able to improve on the code, but at least this proves they can be used successfully with a PICAXE.

For under a fiver, the IO you can get from an 08M2 with one of these makes them superb value.

The next step is to attack the mounting of the unit!

(The code seems a bit long for a forum reply, is there a better place to put it?)

Code:
;;Driver for JY-LKM1638
;Allows control of 7 segment display and LEDs.  Will read all the switch values into
;variables
;
;DS18B20 				---> pin 3 08M2
;
;LKM1638 Input pin 3 (CLK)  	---> pin 7 08M2
;LKM1638 Input pin 4 (DIO)  	---> pin 6 08M2
;LKM1638 Input pin 5 (STB0) 	---> pin 5 08M2
;
;The LKM1638 uses 3 pins to control 8 seven segment displays, 8 bicolour LEDs and read
;the values form 8 pushbuttons.
;This allows a 08M2 to have these all these inputs and outputs available with pins still spare
;
;The LKM1638 module has four basic command types
;1) Write to the display in fixed address format
;2) Write to the display in auto increment address format
;3) Set the display brightness
;4) Read the pushbuttons
;
;These four modes are used in the program below
;The main program performs two activities:
;a)High resolution temperature is read from a DS18B20 and displayed both on the lower and 
;upper blocks of 4 digits.
;b)The individual switch positions are read and displayed on the respective LEDs (The LEDs
;display red in this instance as the switch output (1) is merely sent to the LED.
;To display green, the value 2 would have to be sent)
;
;
;
#picaxe 08m2
#no_data
dirsc = %00010111	;c0, c1, c2, c4 as output
symbol clock	= c.0	;Clock output pin
symbol dio		= c.1	;Data input output pin
symbol strobe	= c.2	;Strobe output pin
symbol tempture	= c.4 ;DS18B20 io
symbol s1		= bit16 ;b2
symbol s2		= bit17 ;b2
symbol s3		= bit18 ;b2
symbol s4		= bit19 ;b2
symbol s5		= bit20 ;b2
symbol s6		= bit21 ;b2
symbol s7		= bit22 ;b2
symbol s8		= bit23 ;b2
symbol dataio	= b0 ;w0 and bit 0 to bit 7
symbol pad		= b1 ;w0 and bit 8 to bit 15
symbol iobuf	= w0 ;b0, b1
symbol keys		= b2 ;bit16 to bit 23
symbol fixaddr	= b3 ;display start address
symbol deci		= b4 ;w2
symbol huns 	= b5 ;w2
symbol tens		= b6 ;w3
symbol units	= b7 ;w3
symbol hrtemp	= w4 ;b8 / b9
symbol sign       = b10;w5
symbol whole	= b11;w5
symbol char		= b12;w6
symbol bank		= b13;w7
symbol tmpry 	= b14;w7
symbol dispbrit	= b15;w8
symbol autoaddr	= b16;w8
symbol readmode	= b17;w9
symbol tmpry2	= b18;w9
fixaddr		= $c0
dispbrit		= $88
autoaddr		= $40
readmode 		= $42
;
init:
high strobe			;Ensure strobe is initially high
call clearchar		;Clear all characters
;--------------------------------------------------------
main:
readtemp12 tempture,hrtemp	;Read raw value into hrtemp, lower 11 bits have temp, upper 5 have sign
call gethrtemp
bank = 0			;First block of digits
call convdigit		;Display temperature on first block
call display
bank = 8			;Second block of 4 digits
call convdigit		;Display temperature on second block
call display
;
call getkeys		;Read the keys state
;
for tmpry2 = 0 to 7			;Cycle through each LED address
	dataio = tmpry2*2 + fixaddr + 1 	;LEDs are at odd addresses 1 to 15
	low strobe
	call sendchar
	lookup tmpry2,(s1,s2,s3,s4,s5,s6,s7,s8),dataio ;Write switch value to respective LED
	call sendchar
	high strobe
	;
	dataio	= dispbrit		;Display control on, brightness level
	low strobe 				;Strobe low
	call sendchar
	high strobe				;Strobe high
next
;
goto main
end
;--------------------------------------------------------
convdigit:	;Convert the whole and decimal parts or temperature into digits for 7 seg display
	huns = whole /100
	tens = whole //100 /10
	units = whole //100 //10 	;Need to append DP to this digit
return
;--------------------------------------------------------
display:	;Displays data on the 7 seg displays, using 2 blocks of 4 digits
		;Note: not measuring above 99 deg so do not display hundreds digit
	dataio	= fixaddr + bank + 0 ;Set sign write address
	low strobe 		;Strobe low
	call sendchar
	char = sign		;Lookup the display code for sign
	call lookupchar
	call sendchar
	high strobe		;End of data - Strobe high
	;
	dataio	= fixaddr + bank + 2 ;Set tens write address
	low strobe 		;Strobe low
	call sendchar
	char = tens		;Lookup the display code for tens digit
	call lookupchar
	call sendchar
	high strobe		; End of data - Strobe high
	;
	dataio	= fixaddr + bank + 4 ;Set units write address
	low strobe 		; Strobe low
	call sendchar
	char = units	;Lookup the display code for units digit
	call lookupchar
	dataio = dataio or $80	;Append dec pnt to this digit
	call sendchar
	high strobe		; End of data - Strobe high
	;
	dataio	= fixaddr + bank + 6 ;Set decimal write address
	low strobe 		; Strobe low
	call sendchar
	char = deci		;Lookup the display code for decimal digit
	call lookupchar
	call sendchar
	high strobe		; End of data - Strobe high
	;
	dataio	= dispbrit ;Display brightness level
	low strobe 		; Strobe low
	call sendchar
	high strobe		; Strobe high
return
;--------------------------------------------------------
clearchar:			;Clear LEDs and 7 seg displays
	dataio	= autoaddr ; Data mode auto increment
	low strobe 		; Strobe low
	call sendchar
	high strobe		; Strobe high
	;
	low strobe 		; Strobe low
	dataio	= fixaddr ; Set start address
	call sendchar
	for tmpry = 1 to $0f	;LEDs and 7 seg displays
		dataio = 0		;Zero blanks the  display
		call sendchar
	next
	high strobe		; Strobe high, keep low to end of data
return
;--------------------------------------------------------
sendchar:	;Fundamental routine to send all characters to LKM1638 module serially
	pad		= $ff	;Set counter
	high clock		;Ensure clock is high for pulseout
	do
	  pinc.1 = bit0	;Make c.1 the value in bit0
	  iobuf = iobuf/2	;Shift right
	  pulsout clock,1 '10us clock pulse
	loop Until pad = 0
return
;--------------------------------------------------------
getkeys:	;Reads the input keys in and places them in bits16 to bits23
dataio	= readmode	; Data mode read
low strobe
call sendchar
input c.1			;set c.1 as input
high clock			;Ensure clock is high for pulseout
for tmpry = 1 to 16	;Read in bits 0-15
	bit0 = pinc.1	;Make bit0 the value on c.1. Need to use c.1 as it is both in & out
	iobuf = iobuf*2	;Shift bit left
	pulsout clock,1	;10us clock pulse, read next bit
next
s6 = bit3			;Move 1st word switch values out of buffer
s2 = bit7
s5 = bit11
s1 = bit15
for tmpry = 1 to 16	;Read in bits 16-31
	bit0 = pinc.1	;Make bit0 the value on b.0. Need to use c.1 as it is both in & out
	iobuf = iobuf*2	;Shift bit left
	pulsout clock,1	;10us clock pulse, read next bit
next
s8 = bit3			;Move 2nd word switch values out of buffer
s4 = bit7
s7 = bit11
s3 = bit15	
output c.1			;Return c.1 to output
high strobe
return
;--------------------------------------------------------
lookupchar:	;Looks up the code to display the digit in 'char' on the 7 seg display
	;character 	( 0 , 1, 2 , 3 , 4 , 5 , 6 , 7, 8 , 9 , A , b , C , d , E , F , . , - ,  )
	lookup char,($3f,$6,$5b,$4f,$66,$6d,$7d,$7,$7f,$6f,$77,$7c,$39,$5e,$79,$71,$80,$40,$0),dataio
return
;--------------------------------------------------------
gethrtemp:	;Converts the DS18B20 temperature in + and -ve temperatures to 0.1 deg
	sign= 18 ; 18 is lookup offset for 'blank', i.e. +ve temp
	IF hrtemp>= $800 THEN ; bit 12 is set so below zero
		sign= 17 ; 17 is lookup offset for '-'
		hrtemp= NOT hrtemp ;Invert each bit (TWO's complement)
		hrtemp= hrtemp AND $fff + 1 ;mask off top 4 bits,add 1 for correction (TWO's complement)
	ENDIF	
	hrtemp= hrtemp*10 / 16 ; x10 = 1 decimal(0.1) resolution
	whole= hrtemp / 10
	deci = hrtemp // 10
return
;--------------------------------------------------------
IMAG0128[1].jpg LKM1638 Temperature.JPG
 
Last edited:

IronJungle

Senior Member
Thanks for doing this. I was the thread starter, but other projects have kept me from doing anything with the display.
I look forward to sorting through the code to understand it.

Could you please post a simple schematic?

Thanks again!
 

IronJungle

Senior Member
@mjy58:

I am sorting through your code now. A quick cut/paste download (without a DS18B20) tells me that it works, but I be damn if I *really* understand what is going on right now. Not your fault; mine. Thanks for all the 'REMs!!!!

I have been looking for a serial / EEPROM project as a learning platform and think I am going to build a clock/four letter word display.
4 digits show time. 4 digits show a random four letter word that changes.
 

mjy58

Member
Finished project

Glad you got the code working.

I have posted my finished thermostat project here.

I think I made some improvements from the original code entered in this thread, together with lots more REMs (I need them to remember what it is all about:rolleyes:). It may make it easier to follow what is going on?

Malcolm
 

IronJungle

Senior Member
@Malcolm... Thanks. I appreciate that. Right now I'm just trying to figure out how to display any digit I want onto any 7seg display.
Not real clear on the sendchar and clearchar subs work, but I will get through that.

However... can you comment of what the "for tmpry2 = 0 to 7" loop is doing?

Again, heaps of thanks for doing a great deal of the heavy lifting!
 

westaust55

Moderator
The line:
For tempry2 = 0 to 7

Is a loop that executes 8 times with the index variable set as 0, 1, 2, .... 7
For each of the 8 passes, data is sent to one of the 7seg displays and the
corresponding switch data is sent to the corresponding (one of the 8) LEDs
 

IronJungle

Senior Member
Thanks, westy. Making progress....
See attached pic that is "suppose" to read PICAXE. I am having difficultly controlling the "C". I figured out how to remove the decimal point in your routine, but it appears something else is going on.

For some reason I can control every segment reliably except the one with the DP. Any advise?
2012-08-08 08.19.10.jpg
 

John West

Senior Member
I've been known to pull/pry off such plastic connectors, then de-solder and pull each pin, then clean out the holes with either a solder-sucker or solder wick so I could replace the connector, (typically because it was put on the wrong bd side, by me.) It's unimportant that the connector is trashed if you have replacement connectors or you will be hard-wiring that end of the cables. It's all a slow, tedious process, but it has been known to work.

A heat gun with a pointed tip and a good bit of care might also work to remove the connectors. I'd only suggest this to those with some previous experience with heat-gun component removal.
 

mjy58

Member
Just came to answer the "for tmpry2...." question but Westy beat me to it, probably with a better explanation too!

Glad you have got the display performing as required.

Having just looked at the code in this thread, I realised how early a version it is.

I would certainly recommend looking at my code in the finished thermostat project. I think I have made it much more structured (IMO!) such that you could more easily take bits out for your own use.

@ John West
Having tried both the heat gun and the 'pliers and iron' approaches. My conclusion, to minimise solder pad damage, is one pin at a time with a soldering iron on the pad, pulling out through the connector with pliers. The challenge is to get the pin hot enough to allow the connector to release it easily without putting too much heat into the solder pad to lift it. Took me four connectors to leave all solder pads intact!! Pins and connector definitely trashed.

Unfortunately I have also now had experience at replacing the chip on these boards as well - incorrect polarity after removing connector:(

Malcolm
 

IronJungle

Senior Member
Malcolm sets the display brightness with hex88. The "manual" states eight brightness levels, however, if I use anything other than hex88 the display goes black.

Btw, how the heck Malcolm got this display working with the little documentation I have found is amazing to me.
 

mjy58

Member
Display Brightness

I have to agree, the documentation available leaves a bit to be desired :rolleyes:

The display brightness value has to be between $88 (min) and $8f (max).

This is a copy of the code used in the final project View attachment TM1638 thermostat basic code.pdf

Here you will see the range of values for brightness and that I use one of the switches to change it.

In my current version of the software, I actually limit the value of the brightness to $8c to cap the current consumption of the display.

Malcolm
 

mjy58

Member
Display Brightness

Yes, unfortunately that is all I could find as documentation too.

It was largely experimentation after I had got something to initially display. Table 7.3 is the key, 'Display Control'. It was then thinking outside the box with the Chinese translation.

'Number of extinction' took me a while - eventually concluded 'display brightness':confused:
Pulse Width I translate to mark/space for the display - so higher ratio = brighter display (note the non linear increment)
Display switch = turn display on and off

So then from table 7.3
%10001000 = Display control, Display on, min brightness = $88
%10001111 = Display control, Display on, max brightness = $8f
%10000xxx = Display control, Display off = $80
 

IronJungle

Senior Member
Thanks for all the help. I looked at the later version of your code and it is much better as you suggested. However, I have customized most of your routines so may stick with what I have. No way I would have gotten this far without your example.

What is interesting is that the display is so bright at the min setting ($88), during my experiments I counted *down*. I should have counted up.
Damn, this thing is really really bright on max brightness.

My next questions (if I have any)on my project (clock + 4 letter word) will be EEPROM related. I may start a new thread for those if needed?
 

IronJungle

Senior Member
Project update from the OP:
Early status. Short vid below.

I have time displayed on the LEFT segments. One of >1,000 four letter words on the RIGHT segments.
I am storing the >1,000 four letter words in a 24LC256 EEPROM.

 
Top