PDA

View Full Version : 32 bit data displaying on LCD



selahattin
- 12th January 2004, 17:23
Dear developers

I 'm developing an operating panel (LCD and keypad included)
for Matsushita PLCs.

I have to display decimal 32 bit full range data (up to 4.294.967.295) on LCD and handle 32 bit data from LCD entered by the user.

Displaying and retrieving LCD is no problem.

But How can I display 32 bit decimal data to LCD and calculate new 32 bit data from LCD

Thank you for your help right now

Selahattin Aslan
ASM Electronics Ltd

rlampus
- 10th September 2006, 22:54
Dear developers

I 'm developing an operating panel (LCD and keypad included)
for Teksco USA.

I have to display decimal 32 bit full range data (up to 4.294.967.295) on LCD and handle 32 bit data from LCD entered by the user.

Displaying and retrieving LCD is no problem.

But How can I display 32 bit decimal data to LCD and calculate new 32 bit data from LCD

Thank you for your help right now

Randy Lumpus
Teksco,USA

mister_e
- 10th September 2006, 23:51
Duh... what i don't understand here...


Displaying and retrieving LCD is no problem.

But How can I display 32 bit decimal data to LCD and calculate new 32 bit data from LCD
More about the calculation?

blainecf
- 13th September 2006, 16:56
When I take my shoes off, I can see my toes, so I can count to 20.

When I count to 5, I only need to see one hand, but to 10, I need to see both hands.

Therefore, if a word variable is 16 bits, two word variables is 32 bits. That means, if I declare a 2 element word array, I'll have 32 bits. So I'd just need a simple algorithm to refer to the array and treat it like one 32bit variable.

You could use assembler, or use any of the bit functions (>> << or var.bit) to handle it.

bcf

sayzer
- 13th September 2006, 17:06
When I take my shoes off, I can see my toes, so I can count to 20.

When I count to 5, I only need to see one hand, but to 10, I need to see both hands....

bcf


Hi blainecf,

I wonder what would you take off if you needed to count to 40? :)

keithdoxey
- 13th September 2006, 19:36
Hi blainecf,

I wonder what would you take off if you needed to count to 40? :)

LOL

I'm still confused how you get beyond 23 :)

rlampus
- 14th September 2006, 03:25
When I take my shoes off, I can see my toes, so I can count to 20.

When I count to 5, I only need to see one hand, but to 10, I need to see both hands.

Therefore, if a word variable is 16 bits, two word variables is 32 bits. That means, if I declare a 2 element word array, I'll have 32 bits. So I'd just need a simple algorithm to refer to the array and treat it like one 32bit variable.

You could use assembler, or use any of the bit functions (>> << or var.bit) to handle it.

bcf

This is very helpful, Thankyou. Could you please give one example of actual pic basic code.

r lampus

paul borgmeier
- 14th September 2006, 08:35
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



' 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

Archangel
- 14th September 2006, 08:56
When I take my shoes off, I can see my toes, so I can count to 20.

When I count to 5, I only need to see one hand, but to 10, I need to see both hands.



I can only count to 10, toes are too far to count, belly too big to reach!

rlampus
- 15th September 2006, 03:50
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



' 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

Bruce
- 15th September 2006, 14:33
You might also want to take a look at this thread http://www.picbasic.co.uk/forum/showthread.php?t=1942