32 bit data displaying on LCD


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by rlampus
    Could you please give one example of actual pic basic code.
    As I have said in the past, there has got to be an easier way....but this might get your ball rolling. I worked it assuming you have no WORD variables and only BYTES. (i.e., I assumed you had a 16 bit number composed of two 8 bit variables instead of your 32 bit number composed of two 16 bit words. Expanding the below to DOUBLE WORDS is similar, just a lot more lines.) (Yes, I know we have WORDS in PBP – I am just demonstrating a process). -THIS IS UNTRIED IN ACTUAL CODE BUT WORKS ON PAPER-

    Background
    bit 1 = 1
    bit 2 = 2
    bit 3 = 4
    bit 4 = 8
    bit 5 = 16
    bit 6 = 32
    bit 7 = 64
    bit 8 = 128
    ----------------
    bit 9 = 256
    bit 10 = 512
    bit 11 = 1024
    bit 12 = 2048
    bit 13 = 4096
    bit 14 = 8192
    bit 15 = 16384
    bit 16 = 32768

    Code:
    ' Example: Dig 12345 (assuming WORDS not available)
    HiByte VAR BYTE
    LoByte VAR BYTE
    Digit VAR byte[5]
    HiByte = $30	' high byte of 12345 ($30 = 00110000)
    LoByte = $39 ' low byte of 12345
    
    Digit[0] = LoByte Dig 0	' = 7
    Digit[1] = LoByte Dig 1	' = 5
    Digit[2] = LoByte Dig 2	' = 0
    Digit[3] =  0	' no need to dig because byte 3 decimal places max
    Digit[4] =  0	' no need to dig because byte 3 decimal places max
    
    If HiByte.0 = 1 then
    	Digit[0] = Digit[0] +6	
    	Digit[1] = Digit[1] +5	
    	Digit[2] = Digit[2] +2	
    If HiByte.1 = 1 then
    	Digit[0] = Digit[0] +2
    	Digit[1] = Digit[1] +1
    	Digit[2] = Digit[2] +5
    	
    If HiByte.2 = 1 then
    	Digit[0] = Digit[0] +4
    	Digit[1] = Digit[1] +2
    	Digit[3] = Digit[3] +1
    	
    If HiByte.3 = 1 then
    	Digit[0] = Digit[0] +8	
    	Digit[1] = Digit[1] +4		
    	Digit[3] = Digit[3] +2	
    	
    If HiByte.4 = 1 then
    	Digit[0] = Digit[0] +6	'=13
    	Digit[1] = Digit[1] +9	'=14
    	Digit[3] = Digit[3] +4	'=4
    	
    If HiByte.5 = 1 then
    	Digit[0] = Digit[0] +2	'=15
    	Digit[1] = Digit[1] +9	'=23
    	Digit[2] = Digit[2] +1	'=1
    	Digit[3] = Digit[3] +8	'=12
    	
    If HiByte.6 = 1 then
    	Digit[0] = Digit[0] +4
    	Digit[1] = Digit[1] +8
    	Digit[2] = Digit[2] +3
    	Digit[3] = Digit[3] +6
    	Digit[4] = Digit[4] +1
    
    If HiByte.7 = 1 then
    	Digit[0] = Digit[0] +8
    	Digit[1] = Digit[1] +6
    	Digit[2] = Digit[2] +7
    	Digit[3] = Digit[3] +2
    	Digit[4] = Digit[4] +3
    
    Digit[1] = Digit[1] + Digit[0] Dig 1		'=24
    Digit[0] = Digit[0] Dig 0			'=5  DIGIT0
    Digit[2] = Digit[2] + Digit[1] Dig 1		'=3
    Digit[1] = Digit[1] Dig 0			'=4  DIGIT1
    Digit[3] = Digit[3] + Digit[2] Dig 1		'=12
    Digit[2] = Digit[2] Dig 0			'=3  DIGIT2
    Digit[4] = Digit[4] + Digit[3] Dig 1		'=1 DIGIT4
    Digit[3] = Digit[3] Dig 0			'=2  DIGIT3
    Good Luck
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  2. #2
    rlampus's Avatar
    rlampus Guest


    Did you find this post helpful? Yes | No

    Default Thankyou.

    Quote Originally Posted by paul borgmeier
    As I have said in the past, there has got to be an easier way....but this might get your ball rolling. I worked it assuming you have no WORD variables and only BYTES. (i.e., I assumed you had a 16 bit number composed of two 8 bit variables instead of your 32 bit number composed of two 16 bit words. Expanding the below to DOUBLE WORDS is similar, just a lot more lines.) (Yes, I know we have WORDS in PBP – I am just demonstrating a process). -THIS IS UNTRIED IN ACTUAL CODE BUT WORKS ON PAPER-

    Background
    bit 1 = 1
    bit 2 = 2
    bit 3 = 4
    bit 4 = 8
    bit 5 = 16
    bit 6 = 32
    bit 7 = 64
    bit 8 = 128
    ----------------
    bit 9 = 256
    bit 10 = 512
    bit 11 = 1024
    bit 12 = 2048
    bit 13 = 4096
    bit 14 = 8192
    bit 15 = 16384
    bit 16 = 32768

    Code:
    ' Example: Dig 12345 (assuming WORDS not available)
    HiByte VAR BYTE
    LoByte VAR BYTE
    Digit VAR byte[5]
    HiByte = $30	' high byte of 12345 ($30 = 00110000)
    LoByte = $39 ' low byte of 12345
    
    Digit[0] = LoByte Dig 0	' = 7
    Digit[1] = LoByte Dig 1	' = 5
    Digit[2] = LoByte Dig 2	' = 0
    Digit[3] =  0	' no need to dig because byte 3 decimal places max
    Digit[4] =  0	' no need to dig because byte 3 decimal places max
    
    If HiByte.0 = 1 then
    	Digit[0] = Digit[0] +6	
    	Digit[1] = Digit[1] +5	
    	Digit[2] = Digit[2] +2	
    If HiByte.1 = 1 then
    	Digit[0] = Digit[0] +2
    	Digit[1] = Digit[1] +1
    	Digit[2] = Digit[2] +5
    	
    If HiByte.2 = 1 then
    	Digit[0] = Digit[0] +4
    	Digit[1] = Digit[1] +2
    	Digit[3] = Digit[3] +1
    	
    If HiByte.3 = 1 then
    	Digit[0] = Digit[0] +8	
    	Digit[1] = Digit[1] +4		
    	Digit[3] = Digit[3] +2	
    	
    If HiByte.4 = 1 then
    	Digit[0] = Digit[0] +6	'=13
    	Digit[1] = Digit[1] +9	'=14
    	Digit[3] = Digit[3] +4	'=4
    	
    If HiByte.5 = 1 then
    	Digit[0] = Digit[0] +2	'=15
    	Digit[1] = Digit[1] +9	'=23
    	Digit[2] = Digit[2] +1	'=1
    	Digit[3] = Digit[3] +8	'=12
    	
    If HiByte.6 = 1 then
    	Digit[0] = Digit[0] +4
    	Digit[1] = Digit[1] +8
    	Digit[2] = Digit[2] +3
    	Digit[3] = Digit[3] +6
    	Digit[4] = Digit[4] +1
    
    If HiByte.7 = 1 then
    	Digit[0] = Digit[0] +8
    	Digit[1] = Digit[1] +6
    	Digit[2] = Digit[2] +7
    	Digit[3] = Digit[3] +2
    	Digit[4] = Digit[4] +3
    
    Digit[1] = Digit[1] + Digit[0] Dig 1		'=24
    Digit[0] = Digit[0] Dig 0			'=5  DIGIT0
    Digit[2] = Digit[2] + Digit[1] Dig 1		'=3
    Digit[1] = Digit[1] Dig 0			'=4  DIGIT1
    Digit[3] = Digit[3] + Digit[2] Dig 1		'=12
    Digit[2] = Digit[2] Dig 0			'=3  DIGIT2
    Digit[4] = Digit[4] + Digit[3] Dig 1		'=1 DIGIT4
    Digit[3] = Digit[3] Dig 0			'=2  DIGIT3
    Good Luck

    Thankyou. This is very helpful.

    R Lampus

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You might also want to take a look at this thread http://www.picbasic.co.uk/forum/showthread.php?t=1942
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 05:47
  2. Nokia 3310 display text
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 04:39
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 03:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 15:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 29th November 2004, 00:56

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