TM1637 problem

354 views
Skip to first unread message

adrian....@gmail.com

unread,
Dec 7, 2022, 1:35:29 PM12/7/22
to jallist
Hi!
I try to use the tm1637 library on simple 4 led display without keyboard and nothing seems to work. I write a simple program to light the display , but nothing happen . This library work on simple 4 digit display board please?
Thank you!

rob...@hotmail.com

unread,
Dec 7, 2022, 1:41:06 PM12/7/22
to jallist
Hi Adrian,

You should provide us with more information about what you are doing. Did you use a board or did you make one yourself? If so has it been connected as given in the data sheet? Did you one of the sample programs for testing it first before making your own software?

The demo of the sample program can be seen here: https://youtu.be/9_aQ2CmVYC4

Kind regards,

Rob


Op woensdag 7 december 2022 om 19:35:29 UTC+1 schreef adrian....@gmail.com:

adrian....@gmail.com

unread,
Dec 8, 2022, 4:36:49 AM12/8/22
to jallist
Hi Rob!
I buy a simple 4 digit board with TM1637 ,board without switches, I make correct connection with board, and i use this simple program:
enable_digital_io()                -- make all pins digital I/O
include delay
--------------------------------------------------------------------------------
--TM1637 Setup
alias tm1637_clk is pin_C4           -- To CLK of the TM1637
alias tm1637_clk_direction is pin_C4_direction
alias tm1637_dio  is pin_C5          -- To DIO of the TM1637
alias tm1637_dio_direction  is pin_C5_direction

include tm1637
tm1637_init()

tm1637_display_on()

tm1637_set_brightness(4)

--------------------------------------------------------------------------------
forever loop

tm1637_display_word_hex(1234, 4)

delay_1s(1)
tm1637_display_update()

end loop

and nothing on display
I believe I make a mistake somewhere!

Best regards,
Adrian    

Rob CJ

unread,
Dec 8, 2022, 12:57:40 PM12/8/22
to jal...@googlegroups.com
Hi Adrian,

Some suggestions:
  • Since you are using 4 displays instead of the default 6 you must set the following: const byte TM1637_WIDTH = 4
  • You are using this: tm1637_display_word_hex(1234, 4) but the first display starts with 0, so try: tm1637_display_word_hex(1234, 0)
  • The following function is not needed since it is called by the previous function so please remove: tm1637_display_update() so please remove it.
Can you let me know if it solved your problem? Which PIC are you using, there may also be another issue but I only know that if I know which PIC you are using.
Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens adrian....@gmail.com <adrian....@gmail.com>
Verzonden: donderdag 8 december 2022 10:36
Aan: jallist <jal...@googlegroups.com>
Onderwerp: [jallist] Re: TM1637 problem
 
--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallist/9e5f27a2-a6a7-44f4-94ef-a40526a94879n%40googlegroups.com.

adrian....@gmail.com

unread,
Dec 10, 2022, 11:39:42 AM12/10/22
to jallist
Hi Rob,
Thank you for your kind response!
I resolved communication between pic and TM1637 with 2 pullup resistor on clk and dio pin ,but I have another problem :
display show correct number and position ,but very short time (not se the digit all time), if number is with 2 digit i see alternating between 2 number very short period. I use different delay time but no improvement ,if i use 1 sec ,nothing on display, i use another display and problem persist, I test every procedures , no improvement 
  
This is test code:
include 16f876a                    -- target PICmicro

-- This program assumes that a 20 MHz resonator or crystal
-- is connected to pins OSC1 and OSC2.
-- (unspecified configuration bits may cause a different frequency!)

pragma target clock 20_000_000     -- oscillator frequency

-- configuration memory settings (fuses)
pragma target OSC      HS               -- HS crystal or resonator
pragma target WDT      disabled     -- no watchdog
pragma target DEBUG    disabled     -- no debugging
pragma target LVP      disabled     -- no Low Voltage Programming
-- These configuration bit settings are only a selection, sufficient for
-- this program, but other programs may need more or different settings.
--

enable_digital_io()                -- make all pins digital I/O
include delay
--------------------------------------------------------------------------------
--TM1637 Setup
alias tm1637_clk is pin_C4           -- To CLK of the TM1637
alias tm1637_clk_direction is pin_C4_direction
alias tm1637_dio  is pin_C5          -- To DIO of the TM1637
alias tm1637_dio_direction  is pin_C5_direction

include tm1637
tm1637_init()

--delay_1s(1)
tm1637_set_brightness(4)
var byte num = 0
--------------------------------------------------------------------------------
forever loop
        tm1637_display_byte_hex(num, 1)
        delay_1ms(500)
        num = num +1
end loop


Kind regards,
Adrian

Rob CJ

unread,
Dec 11, 2022, 4:39:54 AM12/11/22
to jallist
Hi Adrian,

Did you see this suggestion in the sample file: 
--          Note that modules with 7-segement displays often have capacitors on
--          the clk and dio line. These should be removed.

Since you are using a 20 MHz clock and a standard module, it might be that the capacitors on the board are disturbing the clock line or data line.  The fact that something is happening when adding pull-up resistors (which are I think already present on your board) may indicate that too.

So if your board has capacitors on the clock and data line please remove them. You also find these in the data sheet, see screenshot below. But as said the disturb the operation, especially at higher rates.


Since you are using 4 displays instead of the default 6 that the library assumes please add const byte TM1637_WIDTH = 4 before you include the tm1637 library otherwise it will not work correctly. Your code should then be as follows.


--TM1637 Setup
alias tm1637_clk is pin_C4           -- To CLK of the TM1637
alias tm1637_clk_direction is pin_C4_direction
alias tm1637_dio  is pin_C5          -- To DIO of the TM1637
alias tm1637_dio_direction  is pin_C5_direction

const byte TM1637_WIDTH = 4

include tm1637
tm1637_init()

If you use a library always have a look at the sample file since they often explain additional features. 

Thanks

Kind regards,

Rob





Verzonden: zaterdag 10 december 2022 17:39
Aan: jallist <jal...@googlegroups.com>
Onderwerp: Re: [jallist] Re: TM1637 problem
 

Patrick FROUCHT

unread,
Dec 11, 2022, 5:34:21 AM12/11/22
to jal...@googlegroups.com
Hi Adrian

I may be wrong but in your main program,

forever loop
        tm1637_display_byte_hex(num, 1)
        delay_1ms(500)
        num = num +1
end loop

Once you get your 4 7led display, you'll go back to them after 253 loop about 120 secondes meanwhile they are off!

add at the end of your program something like:

If m>= 4 then m = 0 end if


Patrick




adrian....@gmail.com

unread,
Dec 13, 2022, 1:46:03 PM12/13/22
to jallist
Hi!
I removed 2 capacitor from board(attached on clk and dio)  to  but nothing happen ! Some problem!
const byte TM1637_WIDTH = 4 - I modified this in the library before
 
If I removed pullup resistor  who I  add , nothing on display
Essential problem is digit light very short time, is in correct position, show correct number or character, but very brief time, not stay on . I put different delay on every line of code but no result
I believe this library don't work  with simple TM1637  4 digit display board!
 
Patrick, - I make this:
forever loop
        tm1637_display_byte_hex(num, 1)
             delay_1ms(500)
                   forever loop
                    end loop
end loop

only one time command  
No change 

Thank You all!

Best regards,
Adrian

Rob CJ

unread,
Dec 14, 2022, 2:34:56 AM12/14/22
to jal...@googlegroups.com
Hi Adrian,

You need the pull-up resistors but not the capacitors. Can you send your complete program that has the problem?

Thanks

Met vriendelijke groet,
Rob Jansen

From: jal...@googlegroups.com <jal...@googlegroups.com> on behalf of adrian....@gmail.com <adrian....@gmail.com>
Sent: Tuesday, December 13, 2022 7:46:03 PM
To: jallist <jal...@googlegroups.com>
Subject: Re: [jallist] Re: TM1637 problem
 
Hi!
I removed 2 capacitor from board(attached on clk and dio)  to  but nothing happen ! Some problem!
const byte TM1637_WIDTH = 4 - I modified this in the library before
 
If I removed pullup resistor  who I  add , nothing on display
Essential problem is digit light very short time, is in correct position, show correct number or character, but very brief time, not stay on . I put different delay on every line of code but no result
I believe this library don't work  with simple TM1637  4 digit display board!
 
Patrick, - I make this:
forever loop
        tm1637_display_byte_hex(num, 1)
             delay_1ms(500)
                   forever loop
                    end loop
end loop

only one time command  
No change 

Thank You all!

Best regards,
Adrian

Adrian Pipa

unread,
Dec 14, 2022, 3:09:29 AM12/14/22
to jal...@googlegroups.com
Hi Patrick!
I put 2 pullup resistor and i removed 2 capacitor from clk and dio pin , if this simple code don't work , no other code work. Tm1637 show correct digit and position but, brief period of time. This is the problem. My board is simple, only display and ic, no push button. Anyone use this board? I am curious , I want to try low crystal frequency 
Thank you!
Best regards!
Adrian 

Rob CJ

unread,
Dec 14, 2022, 4:04:29 AM12/14/22
to jal...@googlegroups.com
Hi Adrian,

The program may be simple but the error could also be somewhere else (like when using a PIC that has a PPS feature and the pins do not work like you expect) so that's why I am asking for the complete program not only a part since the problem could be in the part you are not showing.

It is sufficient to send a program that has the error, it does not have to be your final program.

And indeed (but that can only be determined if you send the program) there may be something in the clock speed.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Adrian Pipa <adrian....@gmail.com>
Verzonden: woensdag 14 december 2022 09:09
Aan: jal...@googlegroups.com <jal...@googlegroups.com>

adrian....@gmail.com

unread,
Dec 14, 2022, 6:44:00 AM12/14/22
to jallist
Hi Rob,
Only i tested the library, to use in a diy spot welder,  
I haven't included  code in the program, nothing to show,I wanted to test first but no result. 
Thank you for yours kind response!
Best regards,
Adrian 

Rob CJ

unread,
Dec 14, 2022, 9:01:09 AM12/14/22
to jal...@googlegroups.com
Hi Adrian,

Just a thought. The maximum clock speed of the TM1637 is 250 kHz. In the library tm1637.jal you find the following procedure at the end of the library:

-- Lower the clock to the TM1673.
procedure _tm1673_clock_delay() is

   _usec_delay(3)

end procedure

Can you give it a try to see what happens if you change this library and make it 4 or 5 us (or 10 us to test) and see if that helps? 

If that works, I need to adapt the library for the Jallib release.

Thanks.

Kind regards,

Rob


Verzonden: woensdag 14 december 2022 12:44

adrian....@gmail.com

unread,
Dec 14, 2022, 10:31:47 AM12/14/22
to jallist
Hi, Rob,
I lower the clock on tm1637 but nothing good happen unfortunately 
I have a theory: I believe communication  between micro and works good, but is an error in the library, because  display light correct number  at correct position, no problem here, problem is display show digit brief period of time,  not light continuously, because, I believe , micro send another command to display , and make digit to go off 

Compiler give a warning all the time , from beginning :
Compilation started at :12/14/2022 5:13:14 PM
jal jalv25r6 (compiled Oct 29 2021)
[Warning] (lib/tm1637.jal) [Line 345]  assignment to smaller type; truncation possible
[Warning] (lib/tm1637.jal) [Line 346]  assignment to smaller type; truncation possible
[Warning] (lib/tm1637.jal) [Line 429]  signed/unsigned mismatch
55 branches checked, 0 errors
114 data accesses checked, 0 errors
12 skips checked, 0 errors
[Warning] (lib/tm1637.jal) [Line 345]  assignment to smaller type; truncation possible
[Warning] (lib/tm1637.jal) [Line 346]  assignment to smaller type; truncation possible
[Warning] (lib/tm1637.jal) [Line 429]  signed/unsigned mismatch
Compiler CommandLine:  C:\JALLIB~1\compiler\jalv2.exe "E:\Electronica\Proiecte\16F876a\16f876A test tm1637.jal" -s "C:\JALLIB~1\lib" -no-variable-reuse  

Errors :0       Warnings :3
Code   :274/8192    Data:33/368  Hardware Stack : 4/8  Software Stack :96

Thank You very much! I appreciate your help!
Kind regards,
Adrian

Rob CJ

unread,
Dec 14, 2022, 11:56:55 AM12/14/22
to jallist
 Hi Adrian,

Well found, I need to fixt that but I think this does not cause a problem. It was not handy of me to disable the warining in the sample program. I saw that I also made a sample program for 4 displays and found that the order is then different when using the default of six (the order is then 3,4,5,0,1,2). So I used these settings for 4 displays. Can you give this a try?

-- You can change the display width (default is 6 when not defined).
const byte TM1637_WIDTH = 4
-- Set the display order, rightmost is 0, leftmost is TM1637_WIDTH - 1.
const byte TM1637_DISPLAY_ORDER[TM1637_WIDTH] = {0,1,2,3}

I attached the update of this 4 display sample program and an update of the library without the warning. I was not able to test it yet.

Can you run the sample program on your hardware (I assume you are using another PIC so change the top part of the sample program). If it works I will also add this sample program to Jallib.

Thanks.

Kind regards,

Rob


Verzonden: woensdag 14 december 2022 16:31
16f1823_tm1637_test_4_displays.jal
tm1637.jal

adrian....@gmail.com

unread,
Dec 14, 2022, 12:48:58 PM12/14/22
to jallist
Hi Rob,
I make th change and post a video on Youtube :

Thanks!
Kind regards,
Adrian

Rob CJ

unread,
Dec 14, 2022, 1:40:19 PM12/14/22
to jal...@googlegroups.com
Hi Adrian,

I see it flickering but strange that this happens. Is this the sample program running that I sent you?

I need to build a set-up on a breadboard and test it to see what is happening. I will give it a try with 4 displays and no keys so the same setup that you have.

Currently I am not at home so maybe I am able to do something this weekend.

Thanks for the info.

Kind regards,

Rob



Verzonden: woensdag 14 december 2022 18:48

Rob CJ

unread,
Dec 14, 2022, 1:51:03 PM12/14/22
to jal...@googlegroups.com
Hi Adrian,

I have one remaining question which I need to know for comparison.

  1. Which IPIC are you using?
  2. What is the target clock?
  3. Which pins are used for clock and data?
  4. How big are the pull-up resistors?
Thanks.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Rob CJ <rob...@hotmail.com>
Verzonden: woensdag 14 december 2022 19:40

adrian....@gmail.com

unread,
Dec 14, 2022, 2:15:29 PM12/14/22
to jallist
Hi Rob, 
I use 16f876a at 20Mhz,pin C4 and C5 with 4k7 pull-up resistor
Thanks!
Kind regards,
Adrian

Rob CJ

unread,
Dec 16, 2022, 9:20:43 AM12/16/22
to jallist
Hi Adrian,

I did a test with a PIC16F1823 running at 32 MHz using 4k7 pull-up resistors and no capacitors on the clock and data line using 4 displays.

The only change I made in the sample program is the order in which the displays are addressed using the following settings:

const byte TM1637_WIDTH = 4
const byte TM1637_DISPLAY_ORDER[TM1637_WIDTH] = {3,2,1,0}

In the following video you see the result. I only had displays in sets of 3 so you see 6 but only 4 are connected. 

The left display was connected to GRID1 (see datasheet of the TM1637) end the fourth to GRID4.  GRID5 and GRID6 where not connected. 

The first text that is shown says 'Four'. Video: https://youtu.be/Oq6e-y_Mtls

So the library seems to work OK. I attached the library and the 4 display sample program (not using the keyboard). 

The onlly thing I can think of is that in your module they connected GRID6 to GRID3 so maybe it then should be addressed as if it where 6 displays. If so you can change the settings mentioned above.

Since I made a small change to the library itself (removing the warnings) I uploaded it (and this sample file) to GitHub so they will be in the next bee-package.

Kind regards,

Rob


Verzonden: woensdag 14 december 2022 20:15
16f1823_tm1637_4_displays_no_keyboard.jal
tm1637.jal

Rob CJ

unread,
Dec 16, 2022, 10:30:42 AM12/16/22
to jallist
Hi Adrian,

Als did a test with a PIC16F876a running at 20 MHz, using the same pins as you defined.

It works the same as shown in the video.

See attached program.

Kind regards,

Rob


Verzonden: vrijdag 16 december 2022 15:20
16f876a_tm1637_4_displays_no_keyboard.jal

Rob CJ

unread,
Dec 16, 2022, 2:04:38 PM12/16/22
to jal...@googlegroups.com
Hi Adrian,

And a small fix for the text, the "F" was not displayed as an "F".

Let me know if you can get it working.

Kind regards,

Rob


Verzonden: vrijdag 16 december 2022 16:30
16f876a_tm1637_4_displays_no_keyboard.jal
Message has been deleted

adrian....@gmail.com

unread,
Dec 16, 2022, 3:47:52 PM12/16/22
to jallist
Hi Rob,
I test the board with your program, i put two 330ohm pullup resistor and I see an big improvement. If I keep 4k7 pullup,  display not working . The problem is in my   board construction; board already have 10k pullup resistor, and no decimal point on digit, but a 2 point colon . Now seems to work properly! 

Thank you very much Rob! I am grateful to you!

Kind regards,
Adrian

Rob CJ

unread,
Dec 17, 2022, 3:31:53 AM12/17/22
to jal...@googlegroups.com
Hi Adrian,

You're welcome and thanks for the feedback. 

Good to see that it works. I do wonder why you somtimes see the flickering on the screen when values change. I did not notice that and I cannot explain or is it the camera?

Good luck with your project.

Kind regards,

Rob


Verzonden: vrijdag 16 december 2022 21:47

adrian....@gmail.com

unread,
Dec 17, 2022, 12:42:29 PM12/17/22
to jallist
Hi Rob,
Flickering is real, when digit change rapid is some flickering, and first digit on the left appear to be more luminous,   but I am ok , I have to make some experiment with different  pullup resistor, another pic and frequency. I change different port on  clk and dio and everything is ok.   

Thank you very much with your help!
Kind regards,
Adrian

Reply all
Reply to author
Forward
0 new messages