Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Library for TM1651 (Oshonsoft Basic).

DogFlu66

Member
Hello,
I've been searching for PCBs that include the TM1651 to carry out practical exercises, but it seems that the only available product is an LED battery level indicator that uses the TM1651.

The TM1651 integrated circuit allows controlling 4-digit 7-segment displays and reading up to 6 keys. Writing the library for this chip has been particularly easy because it is similar to the TM1637. Therefore, I adapted the library I previously wrote for the TM1637 to work with the TM1651.

I removed all the functions related to digit control and key reading, and then implemented specific functions to control the LEDs included on the PCB.

I am sharing all the necessary files to experiment with the TM1651-based battery level indicator for a while.

TM1651 Library:

TM1651_Init()
Initialize the TM1651.
TM1651_OutSeg(Seg As Byte, sBit As Bit)
Outputs data to a specific segment of the display (0 to 6, On/Off bit).
TM1651_Clear()
Clears all segments of the display, turning them off.
TM1651_Full()
Turns on all segments of the display.
TM1651_Bright(Bright As Byte)
Adjusts the brightness of the display (0 to 7).

TM1651 Mini Battery Display.jpg
 

Attachments

  • Test TM1651.bas
    1.9 KB · Views: 12
  • _TM1651Lib.bas
    5.4 KB · Views: 13
  • _Pic18F46K22Lib.bas
    43.4 KB · Views: 13
It seems that they are compatible, but for the TM1651, I have only found a battery level PCB that uses it. On the other hand, for the TM1637, it is possible to find PCBs with different key and digit configurations.
 
It seems that they are compatible, but for the TM1651, I have only found a battery level PCB that uses it. On the other hand, for the TM1637, it is possible to find PCBs with different key and digit configurations.
Well the TM1637 is a larger chip, so has more capabilities, it's probably only worth using the TM1651 for a small application like the battery display. Why not use the 37 instead?, presumably the software is very little different. I've got a couple of different TM1637 boards, and have used them with PIC's using XC8.
 
The TM1637 already has its own thread.

 
They seem to be the same. But I can't prove it 100%.

The initial configuration is the same and the memory address of the first output byte is the same. The brightness has the same levels and memory address, which are the only functions you can test, later I will compare the datasheets in detail.
 
Last edited:
They seem to be the same. But I can't prove it 100%.

The initial configuration is the same and the memory address of the first output byte is the same. The brightness has the same levels and memory address, which are the only functions you can test, later I will compare the datasheets in detail.
Should be easy then to make a library that covers them both?.
 
I don't believe the two chips follow exactly the same protocol. Close to the same but different in exactly how the data is sent.

tumbleweed helped me out with this when I was (trapped) on a cruise ship a couple years ago. A lesson learned was the caps for noise filtering on the data lines on some modules are 10× or more than specied, severely limiting data rate.

The battery module is a neat display.
 
Actually, my above comment applies to the TM1637 and TM1638. Slight brain fade this morning.
 
I have been reviewing the TM1637 and TM1651 integrated circuits in detail and found that they share most of their functions. The TM1637 offers greater control capacity for both digits and keys. Therefore, as long as the common memory addresses are used to access basic functions, a single library can be used for both, since the communication protocol is the same. However, ideally, a dedicated library should be created for each integrated circuit. Nevertheless, having a functional library for one can be easily adapted to the other with minimal modifications.
 
Adding the three functions:

TM1651_OutSeg(Seg As Byte, sBit As Bit)
Outputs data to a specific segment of the display (0 to 6, On/Off bit).
TM1651_Clear()
Clears all segments of the display, turning them off.
TM1651_Full()

The Init and brightness functions are common, for this particular case of the battery level indicator, and for the rest of the functions that the TM1651 allows, it would be convenient to have a PCB with digits and a keyboard to perform a complete test.
 
Last edited:

Latest threads

New Articles From Microcontroller Tips

Back
Top