TM1637 code


+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: TM1637 code95 days old

  1. #1
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,366
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default TM1637 code

    Hi,
    I have written some code for TM1637 modules, it does not do the DP/Colon or key scan as I only wanted it for a revcounter for a lathe.
    They are 4 (or 6 digit) 7 segment displays on 2 data lines. https://www.ebay.co.uk/sch/i.html?_nkw=tm1637 display

    Regards,
    Bob

    Code:
    '****************************************************************
    '*  Name    : TM1637.BAS                                        *
    '*  Author  : RGV250                                            *
    '*  Notice  : Copyright (c) 2020 Bobby Garrett                  *
    '*          : All Rights Reserved                               *
    '*  Date    : 29/02/2020                                        *
    '*  Version : 5.0                                               *
    '*  Notes   : Procedures based on I2C code from Les             *
    '*          : Key scan not used.                                *
    '****************************************************************
          Include "Amicus18.inc"               'Setup the program to run on an Amicus18 board(PIC18F25K20 at 64MHz)
        
    'Setup the default pins for SDA and SCL
    $define TM1637_SDA_Pin PORTC.4           'Set the SDA pin 
    $define TM1637_SCL_Pin PORTC.3           'Set the SCL pin 
        
    '----------------------------------------------------------------------------------------------
    'Delay a fixed number of microseconds
    '
    $define TM1637_hDelay() DelayUS 100      'It worked At 2 in ISIS VSM but didn't work at 50 on real hardware.
                                             'Unsure why it did not work but this is fast enough.
    '----------------------------------------------------------------------------------------------    
    'Variables
        Dim TestData As Word
        TestData = 0
    '----------------------------------------------------------------------------------------------
    'Send a start condition
    'Input     : None
    'Output    : None
    'Notes     : A Start condition is high to low of SDA when SCL is high
    '
    Proc TM1637_Start()
        Input TM1637_SDA_Pin                 'Make the SDA pin an Input (High)
        Input TM1637_SCL_Pin                 'Make the SCL pin an Input (High)
        TM1637_hDelay()
        Output TM1637_SDA_Pin                'Make the SDA pin an Output (Low)
        TM1637_hDelay()
        Output TM1637_SCL_Pin                'Make the SCL pin an Output (Low)
    EndProc
    
    '----------------------------------------------------------------------------------------------
    'Initiate an acknowledge
    'Input     : None
    'Output    : None
    'Notes     : None
    '
    Proc TM1637_Ack()
        Output TM1637_SDA_Pin                'Make the SDA pin an Output (Low)
        Input TM1637_SCL_Pin                 'Make the SCL pin an Input (High)
        TM1637_hDelay()
        Output TM1637_SCL_Pin                'Make the SCL pin an Output (Low)
        DelayUS 5                            'After the falling edge of the eighth clock delay for 5us.
        Input TM1637_SDA_Pin                 'Make the SDA pin an Input (High)
    EndProc
    
    '----------------------------------------------------------------------------------------------
    'Send a stop condition
    'Input     : None
    'Output    : None
    'Notes     : A Stop condition is low to high of SDA when SCL is high
    '
    Proc TM1637_Stop()
        Output TM1637_SDA_Pin                'Make the SDA pin an Output (Low)
        TM1637_hDelay()
        Input TM1637_SCL_Pin                 'Make the SCL pin an Input (High)
        TM1637_hDelay()
        Input TM1637_SDA_Pin                 'Make the SDA pin an Input (High)
        TM1637_hDelay()
    EndProc
    
    '----------------------------------------------------------------------------------------------
    'Send single bytes to the TM1637 module.
    'Input     : pData holds the byte to write
    'Output    : None
    'Notes     : LSB first
    '
    Proc TM1637_WriteByte(pData As Byte)
    
        Dim bIndex As Byte = 8
        Repeat                               'Create a loop for the 8-bits
            If pData.0 = 1 Then
                Input TM1637_SDA_Pin         'Make the SDA pin an Input (High)
            Else
                Output TM1637_SDA_Pin        'Make the SDA pin an Output (Low)
            EndIf
            TM1637_hDelay()
            Input TM1637_SCL_Pin             'Make the SCL pin an Input (High)
            TM1637_hDelay()
            Output TM1637_SCL_Pin            'Make the SCL pin an Output (Low)
            TM1637_hDelay()
            pData = pData >> 1
            Dec bIndex
        Until bIndex = 0
    
    EndProc
    
    '----------------------------------------------------------------------------------------------    
    'Set brightness
    'Send a single byte to the TM1637 module for the brightness.
    'Input     : pData1 holds the brightness data, pData2 is the "On/Off" control.
    'Output    : None
    'Notes     :     
    'Values > 7 will turn display off.
    'Address bits b7 / b6 = 10
    'b5 / b4 don't care, fill with 0
    'b3 On / Off control - 1 = On / 0 = Off
    'b2 - b0 is the data
    '000 = 1/16
    '001 = 2/16 
    '010 = 4/16
    '011 = 10/16 
    '100 = 11/16 
    '101 = 12/16
    '110 = 13/16 
    '111 = 14/16 
    Proc SetBrightness(pData1 As Byte, pData2 As Byte)  
    Dim DataByte As Byte
    Dim ControlBit As Byte
    DataByte = pData1
    Controlbit = pData2
    
    'Check if the display should be On or Off.
        If ControlBit = 1 Then 
        DataByte = Databyte | 001000  
        Else
        DataByte = 000000
        EndIf
    'Send the data    
        TM1637_Start() 
        TM1637_WriteByte(DataByte)         
        TM1637_Ack() 
        TM1637_Stop() 
    EndProc
    
    '---------------------------------------------------------------------------------------------
    Proc UpdateDisplay(pData As Word)        'Write display register 
        Dim index As Byte
        Dim BitPattern As Byte
        Dim TempArray[4] As Byte             'Create a temporary array for individual characters
    
    'Split the value into individual numbers for writing to display. 
        If Dig pData,3 = 0 Then
        TempArray#3 = 0
        Else
        TempArray#3 = Dig pData,3
        EndIf
        
        If Dig pData,2 = 0 Then
        TempArray#2 = 0
        Else
        TempArray#2 = Dig pData,2
        EndIf    
        
        If Dig pData,1 = 0 Then
        TempArray#1 = 0
        Else
        TempArray#1 = Dig pData,1
        EndIf    
        
        If Dig pData,0 = 0 Then
        TempArray#0 = 0
        Else
        TempArray#0 = Dig pData,0
        EndIf
        
    'Set data command mode.
    '40H is automatic increment by 1.
    '44H is fixed address.
        TM1637_Start() 
        TM1637_WriteByte(0x40)  
        TM1637_Ack() 
        TM1637_Stop() 
    'Set the first address    
        TM1637_Start() 
        TM1637_WriteByte(0xc0)  
        TM1637_Ack()
    'Send the data    
        For Index = 3 To 0 Step -1           'Will need to modify if using displays with more than 4 digits.
            BitPattern = LRead SegmentData + TempArray[Index]
            TM1637_WriteByte(BitPattern)  
            TM1637_Ack() 
        Next index
        
        TM1637_Stop() 
    EndProc    
    
    '---------------------------------------------------------------------------------------------
    'Start    
        Low TM1637_SDA_Pin                   'Make the TM1637 SDA pin an output low
        Low TM1637_SCL_Pin                   'Make the TM1637 SCL pin an output low
    
    'Zero the display at the start.
    'Send data to the TM1637 module    
        UpdateDisplay(TestData)         
            
    '---------------------------------------------------------------------------------------------
    Main:  
        SetBrightness(4,1)                   'Set the brightness 0 - 7, 1 = On, 0 = Off.
        
    'Send data to the TM1637 module    
        UpdateDisplay(TestData)         
        
        DelayMS 10
        Inc TestData
        
        If TestData > 2222 Then              'Rollover to test the preceeding zeroes
        TestData = 0
        EndIf
        
        GoTo Main                            'Do forever.
        
    '---------------------------------------------------------------------------------------------    
       
    'Bit patterns for numbers 0 - 9
    'Some of my TM1637 modules do not have a DP but have a colon, I will not be using either 
    'so I have not done the code for that at the moment.
    'This was copied from some other code somewhere.
    '       __A__
    '      |     |
    '      F     B
    '      |__G__|
    '      |     |
    '      E     C
    '      |__D__| X
    '      
    'XGFEDCBA             0          1          2          3          4          5          6          7         8           9
    SegmentData:
        LData As Byte 111111, 000110, 011011, 001111, 100110, 101101, 111101, 000111, 111111, 101111

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,560
    Thumbs Up
    Received: 76
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default Re: TM1637 code

    Thanks Bob for this contribution. If I may, I would suggest to promote it to an article so it does not get lost in the forum.
    Regards

    Joseph

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,596
    Thumbs Up
    Received: 341
    Given: 162
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: TM1637 code

    Nice one Bob. :-)

    It's excellent to see procedures used in an 8-bit microcontroller program. They add a whole new methodology to the Proton language, making it even easier to use and a whole lot more powerful. I just wish it would promote sales of zero :-(

    Many thanks for sharing your code with the users on this forum as well, it is very much appreciated.

    I bought a 7-Segment display board with a keypad on it and the TMS1637 device, but never go taround to using it because my injury happened just after it arrived, and it has laid in a box with my other stuff for a few years now. :-( For what you get on the PCB, they are an excellent price and really useful as a display.

    I'm going to be selling a lot of my boards and components on Ebay in the next few weeks to try to help pay for our house move back to our beloved North Norfolk later in the year when we have saved up enough, and that board will be one of them, along with many other boards bought from ebay over the years. I'm already selling some of my beloved 8-bit computers on ebay, sadly, but I will never sell my lovely Bernard's and Babani books, of which I have over a hundred of them collected over the years. :-)

    You never quite know what you miss until it is not there anymore. :-(

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,366
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: TM1637 code

    Hi Joseph,
    I will have to read up the "How to" first and see how it goes from there.

    Regards,
    Bob.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,366
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: TM1637 code

    Hmm, that did not go too well, I copied and pasted the code and it is in one single line. If any moderator sees this could you have a look to see what I have done wrong.
    It is in Example code / LED Display.

    Regards,
    Bob

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,560
    Thumbs Up
    Received: 76
    Given: 33
    Total Downloaded
    6.56 GB

    0 Not allowed!

    Default Re: TM1637 code

    Quote Originally Posted by RGV250 View Post
    Hmm, that did not go too well, I copied and pasted the code and it is in one single line. If any moderator sees this could you have a look to see what I have done wrong.
    It is in Example code / LED Display.

    Regards,
    Bob
    I would have gladly tried to correct it if I, (we), still had the ability to correct forum entries. I will have a look and give you suggestions what to do.
    Regards

    Joseph

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,322
    Thumbs Up
    Received: 19
    Given: 0
    Total Downloaded
    1.01 GB

    0 Not allowed!

    Default Re: TM1637 code

    WOW! That was good timing , I just ordered a couple of the 4 digit modules from EBAY then came back to the forum to see if anyone had posted any code. Thanks Bob.
    My RAM is failing

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,366
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: TM1637 code

    Hi,
    It is quite basic as I only needed a speed readout for a lathe. Are you likely to need decimal places, if so I will have a look as it should not be too difficult.
    The code above has got the issue with binary numbers IE losing %etc. PM me if you want me to send you the proper file.
    I forgot to put in the comments that the blue ones and possibly another one need 5V so Amicus18 will not drive it directly at 3.3v.

    Regards,
    Bob

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,354
    Thumbs Up
    Received: 83
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: TM1637 code

    I find that if I post code with binary data and don't subsequently edit it, it displays ok. I'd like to try you code, perhaps you could repost?
    George.

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,366
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: TM1637 code

    Hi,
    This should be the same but with a couple of comments added.

    Regards,
    Bob

    Code:
    '****************************************************************
    '*  Name    : TM1637.BAS                                        *
    '*  Author  : RGV250                                            *
    '*  Notice  : Copyright (c) 2020 Bobby Garrett                  *
    '*          : All Rights Reserved                               *
    '*  Date    : 15/03/2020                                        *
    '*  Version : 5.1                                              *
    '*  Notes   : Procedures based on I2C code from Les             *
    '*          : Key scan not used.                                *
    '*          : Min voltage for Red, Yellow LED is 3.3 volts      *
    '*          : Min voltage For Green, Blue LED is 5.0 volts      *
    '*          :                                                   *
    '****************************************************************
    
    ' 5.1 Min voltage comment added
    ' 5.0 Original version
    
        Include "Amicus18.inc"               'Setup the program to run on an Amicus18 board(PIC18F25K20 at 64MHz)
        
    'Setup the default pins for SDA and SCL
    $define TM1637_SDA_Pin PORTC.4           'Set the SDA pin 
    $define TM1637_SCL_Pin PORTC.3           'Set the SCL pin 
        
    '----------------------------------------------------------------------------------------------
    'Delay a fixed number of microseconds
    '
    $define TM1637_hDelay() DelayUS 100      'It worked At 2 in ISIS VSM but didn't work at 50 on real hardware.
                                             'Unsure why it did not work but this is fast enough.
    '----------------------------------------------------------------------------------------------    
    'Variables
        Dim TestData As Word
        TestData = 0
    '----------------------------------------------------------------------------------------------
    'Send a start condition
    'Input     : None
    'Output    : None
    'Notes     : A Start condition is high to low of SDA when SCL is high
    '
    Proc TM1637_Start()
        Input TM1637_SDA_Pin                 'Make the SDA pin an Input (High)
        Input TM1637_SCL_Pin                 'Make the SCL pin an Input (High)
        TM1637_hDelay()
        Output TM1637_SDA_Pin                'Make the SDA pin an Output (Low)
        TM1637_hDelay()
        Output TM1637_SCL_Pin                'Make the SCL pin an Output (Low)
    EndProc
    
    '----------------------------------------------------------------------------------------------
    'Initiate an acknowledge
    'Input     : None
    'Output    : None
    'Notes     : None
    '
    Proc TM1637_Ack()
        Output TM1637_SDA_Pin                'Make the SDA pin an Output (Low)
        Input TM1637_SCL_Pin                 'Make the SCL pin an Input (High)
        TM1637_hDelay()
        Output TM1637_SCL_Pin                'Make the SCL pin an Output (Low)
        DelayUS 5                            'After the falling edge of the eighth clock delay for 5us.
        Input TM1637_SDA_Pin                 'Make the SDA pin an Input (High)
    EndProc
    
    '----------------------------------------------------------------------------------------------
    'Send a stop condition
    'Input     : None
    'Output    : None
    'Notes     : A Stop condition is low to high of SDA when SCL is high
    '
    Proc TM1637_Stop()
        Output TM1637_SDA_Pin                'Make the SDA pin an Output (Low)
        TM1637_hDelay()
        Input TM1637_SCL_Pin                 'Make the SCL pin an Input (High)
        TM1637_hDelay()
        Input TM1637_SDA_Pin                 'Make the SDA pin an Input (High)
        TM1637_hDelay()
    EndProc
    
    '----------------------------------------------------------------------------------------------
    'Send single bytes to the TM1637 module.
    'Input     : pData holds the byte to write
    'Output    : None
    'Notes     : LSB first
    '
    Proc TM1637_WriteByte(pData As Byte)
    
        Dim bIndex As Byte = 8
        Repeat                               'Create a loop for the 8-bits
            If pData.0 = 1 Then
                Input TM1637_SDA_Pin         'Make the SDA pin an Input (High)
            Else
                Output TM1637_SDA_Pin        'Make the SDA pin an Output (Low)
            EndIf
            TM1637_hDelay()
            Input TM1637_SCL_Pin             'Make the SCL pin an Input (High)
            TM1637_hDelay()
            Output TM1637_SCL_Pin            'Make the SCL pin an Output (Low)
            TM1637_hDelay()
            pData = pData >> 1
            Dec bIndex
        Until bIndex = 0
    
    EndProc
    
    '----------------------------------------------------------------------------------------------    
    'Set brightness
    'Send a single byte to the TM1637 module for the brightness.
    'Input     : pData1 holds the brightness data, pData2 is the "On/Off" control.
    'Output    : None
    'Notes     :     
    'Values > 7 will turn display off.
    'Address bits b7 / b6 = 10
    'b5 / b4 don't care, fill with 0
    'b3 On / Off control - 1 = On / 0 = Off
    'b2 - b0 is the data
    '000 = 1/16
    '001 = 2/16 
    '010 = 4/16
    '011 = 10/16 
    '100 = 11/16 
    '101 = 12/16
    '110 = 13/16 
    '111 = 14/16 
    Proc SetBrightness(pData1 As Byte, pData2 As Byte)  
    Dim DataByte As Byte
    Dim ControlBit As Byte
    DataByte = pData1
    Controlbit = pData2
    
    'Check if the display should be On or Off.
        If ControlBit = 1 Then 
        DataByte = Databyte | %10001000  
        Else
        DataByte = %10000000
        EndIf
    'Send the data    
        TM1637_Start() 
        TM1637_WriteByte(DataByte)         
        TM1637_Ack() 
        TM1637_Stop() 
    EndProc
    
    '---------------------------------------------------------------------------------------------
    Proc UpdateDisplay(pData As Word)        'Write display register 
        Dim index As Byte
        Dim BitPattern As Byte
        Dim TempArray[4] As Byte             'Create a temporary array for individual characters
    
    'Split the value into individual numbers for writing to display. 
        If Dig pData,3 = 0 Then
        TempArray#3 = 0
        Else
        TempArray#3 = Dig pData,3
        EndIf
        
        If Dig pData,2 = 0 Then
        TempArray#2 = 0
        Else
        TempArray#2 = Dig pData,2
        EndIf    
        
        If Dig pData,1 = 0 Then
        TempArray#1 = 0
        Else
        TempArray#1 = Dig pData,1
        EndIf    
        
        If Dig pData,0 = 0 Then
        TempArray#0 = 0
        Else
        TempArray#0 = Dig pData,0
        EndIf
        
    'Set data command mode.
    '40H is automatic increment by 1.
    '44H is fixed address.
        TM1637_Start() 
        TM1637_WriteByte(0x40)  
        TM1637_Ack() 
        TM1637_Stop() 
    'Set the first address    
        TM1637_Start() 
        TM1637_WriteByte(0xc0)  
        TM1637_Ack()
    'Send the data    
        For Index = 3 To 0 Step -1           'Will need to modify if using displays with more than 4 digits.
            BitPattern = LRead SegmentData + TempArray[Index]
            TM1637_WriteByte(BitPattern)  
            TM1637_Ack() 
        Next index
        
        TM1637_Stop() 
    EndProc    
    
    '---------------------------------------------------------------------------------------------
    'Start    
        Low TM1637_SDA_Pin                   'Make the TM1637 SDA pin an output low
        Low TM1637_SCL_Pin                   'Make the TM1637 SCL pin an output low
    
    'Zero the display at the start.
    'Send data to the TM1637 module    
        UpdateDisplay(TestData)         
            
    '---------------------------------------------------------------------------------------------
    Main:  
        SetBrightness(4,1)                   'Set the brightness 0 - 7, 1 = On, 0 = Off.
        
    'Send data to the TM1637 module    
        UpdateDisplay(TestData)         
        
        DelayMS 10
        Inc TestData
        
        If TestData > 2222 Then              'Rollover to test the preceeding zeroes
        TestData = 0
        EndIf
        
        GoTo Main                            'Do forever.
        
    '---------------------------------------------------------------------------------------------    
       
    'Bit patterns for numbers 0 - 9
    'Some of my TM1637 modules do not have a DP but have a colon, I will not be using either 
    'so I have not done the code for that at the moment.
    'This was copied from some other code somewhere.
    '       __A__
    '      |     |
    '      F     B
    '      |__G__|
    '      |     |
    '      E     C
    '      |__D__| X
    '      
    'XGFEDCBA             0          1          2          3          4          5          6          7         8           9
    SegmentData:
        LData As Byte %00111111, %00000110, %01011011, %01001111, %01100110, %01101101, %01111101, %00000111, %01111111, %01101111

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #11
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,322
    Thumbs Up
    Received: 19
    Given: 0
    Total Downloaded
    1.01 GB

    0 Not allowed!

    Default Re: TM1637 code

    Thanks Bob,

    I had already copied the code from the first post when the displays arrived but the code did not work for me. I first checked the clock and data wave forms on the 'scope and they were more like saw tooth than square wave. After some research on the net I removed C3 and C4 from the display. The wave form was then square but still it did not work.

    Coming back to the forum I copied your second code and that works fine.

    Of course it was the pesky %x removal that caused the problem.
    Last edited by See_Mos; 7th April 2020 at 19:41.
    My RAM is failing

  22. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #12
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,366
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: TM1637 code

    Hi,
    I have not had to remove the caps from my modules.

    Thank George for the tip on how to post code, it does seem strange but it appears to work.

    Regards,
    Bob

  24. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  25. #13
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,322
    Thumbs Up
    Received: 19
    Given: 0
    Total Downloaded
    1.01 GB

    0 Not allowed!

    Default Re: TM1637 code

    Research shows that not all modules use the same value capacitors so that might explain why Bobs worked, but why it did not work at higher speeds

    To look at it the 0.56 display that I bought it has both decimal points and a colon for clock displays but that is misleading as only the colon is available on this one, it all depends on which display is fitted.

    In my case it is CLS 5463BB. I found very little information about the actual display but from what I discovered if you need decimal points then look out for modules with a CLS 5461 display.

    I see that a lot of different LED displays fitted to the various modules available so you might need to confirm that you get the correct one for your needs.
    My RAM is failing

  26. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  27. #14
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,322
    Thumbs Up
    Received: 19
    Given: 0
    Total Downloaded
    1.01 GB

    0 Not allowed!

    Default Re: TM1637 code

    I ordered two more modules that hopefully will have decimal point LED's

    There are thousands of suppliers on EBAY but the pictures and descriptions are totally random and should not be relied upon! Some show a CL3642BH9 display which would be good as that display has all of the extra LED's but that has 16 pins (?) and the photo of the associated modules show 12 pin displays.

    I did eventually find a data sheet for the CL5641BB, blue, display but when I went to the XLITX site the display is not listed.

    I had a look at RS Components to see if I could find a suitable replacement LED display but their data sheets do not match their component descriptions so I gave up. Farnell and CPC had nothing suitable in stock either.
    Last edited by See_Mos; 8th April 2020 at 15:48.
    My RAM is failing

  28. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  29. #15
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,354
    Thumbs Up
    Received: 83
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: TM1637 code

    I have one of these modules but the ony text on the display is KYX-3462BS. The text on the PCB is "4-bit LED Digital Tube Module", I got it on ebay via the slow boat.
    Last edited by towlerg; 9th April 2020 at 14:34.
    George.

  30. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Delay time not used in source code - pse read code for mistake
    By scdhome in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 8th October 2012, 17:55
  2. [SOLVED !] convert Basic stamp 2 code to PDS code
    By billyminor in forum Proton Plus Compiler v3
    Replies: 31
    Last Post: 24th June 2007, 20:07
  3. CODE CHALLENGE: SCP1000 Barometric Sensor Code
    By ohararp in forum Proton Plus Compiler v3
    Replies: 23
    Last Post: 26th April 2007, 00:32
  4. Self modifying code / Writing to code memory
    By geraintwalesuk in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 16th September 2006, 00:34
  5. Device Code/button Code
    By insury in forum Proton-IR
    Replies: 3
    Last Post: 14th December 2004, 21:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts