TM1640 (16 digit display) with PicBAsic Pro, possible is? How?


Closed Thread
Results 1 to 36 of 36

Hybrid View

  1. #1
    Join Date
    Oct 2011
    Posts
    54


    Did you find this post helpful? Yes | No

    Default Re: TM1640 (16 digit display) with PicBAsic Pro, possible is? How?

    Hi jefrem
    New improved code. Pauses not required. Address set command now works. If you don't write to all 16 displays some segments of displays not written to turn on when they shouldn't, therefore it is best to write to all 16 displays and over-write these segments.
    Phil

    Code:
    'PIC18F2550 @ 48mHz, USB bootloader, JY-LM1640 16 x 7 seg display
    
    DEFINE OSC 48
    DEFINE RESET_ORG 1000h 
    
        dat_com_inc VAR BYTE        'Display command for auto inc address
        dat_com_fix VAR BYTE        'Display command for fixed address
        dis_com_off VAR BYTE        'Display command OFF
        dis_com_on  VAR BYTE        'Display command ON
        address     VAR BYTE        'Display address ($00 - $0F)
        brightness  VAR BYTE        'Brightness value (0 - 7)
        dat         VAR BYTE        'Data to send to TM1640
        digit       VAR BYTE        '7 seg display (0 - 15)
        n           VAR BYTE        'Counter
        
        dat_com_inc = %01000000     'Data command ADDRESS auto + 1
        dat_com_fix = %01000100     'Data command FIXED address
        dis_com_off = %10000000     'Switch display OFF
        dis_com_on  = %10001000     'Switch display ON
        brightness  = %00000011     'Display brightness (0 = MIN 7 = MAX)
        address     = %11000000     'Display ADDRESS $00
    
        din        VAR LATB.7	
        sclk       VAR LATB.6
        
        TRISC = %00111000
        LATC = 0
        TRISB = %00111111
    	
        din  = 1                    'Data pin HIGH to start
        sclk = 1                    'Clock pin HIGH to start
        PAUSE 500
        
    '---------- Start of program ------------------------------------
        FOR digit = 0 TO 4          'Scroll to right, increase brightness
            GOSUB PRINT:
        NEXT
        FOR digit = 3 TO 0 STEP -1  'Scroll to left, decrease brightness
            GOSUB PRINT:
        NEXT
        END
    '---------- Print to display ------------------------------------    
    PRINT: 
        dat = dat_com_inc           'Data command setting
        GOSUB COMMAND:
        dat = address + digit       'Set address
        din = 0 : sclk = 0          'Start transmission process    
        SHIFTOUT din,sclk,0,[dat]   'LSB first, clock idles low
        FOR n = 0 TO 15             'Print 16 characters
            LOOKUP n,[0,115,6,57,6,127,113,91,109,109,63,0,64,64,64,64],dat	
    	SHIFTOUT din,sclk,0,[dat]   'Print message
        NEXT
        sclk = 1 : din = 1          'End transmission process
        dat = dis_com_on + digit    'Set brightness
        GOSUB COMMAND:
        PAUSE 1000
        RETURN
    '----------------------------------------------------------------
    COMMAND:
        din = 0 : sclk = 0          'Start transmission process 
        SHIFTOUT din,sclk,0,[dat]   'LSB first, clock idles low
        sclk = 1 : din = 1          'End transmission process
        RETURN
    '----------------------------------------------------------------

  2. #2
    Join Date
    Aug 2011
    Location
    Manaus - Brazil
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: TM1640 (16 digit display) with PicBAsic Pro, possible is? How?

    Hi Phil,

    This last code is perfect!!!

    Thank you again for your attention and partnership my friend. If I can help, please contact me.

    Name:  IMG_1273.jpg
Views: 4012
Size:  326.6 KB

    Regards,

Similar Threads

  1. HSEROUT full 3 digit display of variable howto ?
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th October 2008, 14:53
  2. Replies: 2
    Last Post: - 14th July 2008, 23:11
  3. Replies: 2
    Last Post: - 22nd January 2008, 15:25
  4. How to display dot on 7-seg , 4 digit
    By chai98a in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 19th January 2007, 19:17
  5. SMART Serial 4 Digit LCD Display (SMARD4)
    By paul borgmeier in forum Adverts
    Replies: 0
    Last Post: - 5th January 2005, 06:50

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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