Discussion in "8051 Discussion Forum" started by    kekkon    Jul 11, 2009.
Sat Jul 11 2009, 06:17 AM
#1
Hi, i am currently doing a project using lookup table which i am not really familiar with.

The 8051 reads through Port 1 where higher nibbles stand for 1 sets of inputs and the lower nibbles stand for another set,which is total of 2 sets of inputs after every 60seconds.

The question now I am facing is how to use the lookup table to read the 2 different sets of input to compare them whether they are equal, smaller or greater to each other.

Thanks for helping:-)
Sat Jul 11 2009, 05:54 PM
#2
well I understand what you need but i am not able to understand how lookup tables are involved in this.

you said u want to compare two nibbles of P1 so from where this lookup table comes?

or gimme better explanation with example
Tue Jul 14 2009, 05:23 PM
#3
Sorry for the late reply.

The lookup table is register like that store the inputs from P1 nibbles.

Example: first input is 0100 and the second is 0110 then the input data is move to the lookup table.

Then the data in the lookup table is being compare to determine whether they are bigger,equal or smaller.

Thanks :-)
Tue Jul 14 2009, 06:19 PM
#4
The question is why use a lookup table to compare values

You would use the micro's comparison instructions to do that.

A lookup table is normally fixed, pre-set data, used to swap one value
for a different one.


[ Edited Tue Jul 14 2009, 06:30 PM ]
Tue Jul 14 2009, 07:18 PM
#5
Ya, I know. But this is a question given by my lecturer, i have to do what he told me to do :-|
Tue Jul 14 2009, 07:54 PM
#6
i agree with ExperimenterUK
just
mask ---> swap ---> compare
that's it!!!
look up table may not be fixed, they can be set up inside ram location , for this case we don't need either

If this is a question given by your lecture and we are helping you ? then what's the point
without trying how you can learn something ? refer Mazidi for implementation of lookup tables :bye


[ Edited Tue Jul 14 2009, 07:59 PM ]
Tue Jul 14 2009, 08:08 PM
#7
Since this is a pointless exercise it is hard to know what
a good method is
However you could..
Fill an array (table) of 16 bytes with 0s
Get the first nibble, use it as an offset into the table,store 1 at that entry.
Fill all addresses that follow with 2s

To compare,
Use the second nibble as an offset into the table and get the byte at that entry.
If the byte is 0 the second nibble is lower, if 1, it is the same
and if it is 2, it is higher.
(and I get the marks )

Generally I agree with afilash's comment about doing this yourself, but I think
a small pointer is OK just this once.


[ Edited Thu Jul 16 2009, 11:27 AM ]
Wed Jul 15 2009, 12:19 PM
#8
are you using C or assembly?

in assembly lookup table is defined in CODE memory as follows:

LookUp: ;this is a lable
DB: 03H,05H


i stored 03H and 05H in code memory using directive DB (define byte).
to use these values or to read them from lookup table we use MOVC instruction as shown below..

CLR A ;clear A
MOV DPTR,#LookUp ;load address from lable
MOVC A,@A+DPTR ;load data from address pointed by A+DPTR
;remember its good to have A as 0 before reading from lookup table and increment DPTR for next value
Wed Jul 15 2009, 12:20 PM
#9
[Topic moved to 8051 Discussion forum]
Thu Jul 16 2009, 03:31 AM
#10
Thanks for all your help in this topic. :-)

I am using assembly language. (FX8031 kits). :-)

cseg
Start:  CLR     P1.0
        CLR     P0.0
        CLR     A
        MOV     TMOD,#11H
        MOV     TCON,#01H
        MOV     IE,#082H

        MOV     DPTR,#LookUp
        MOVC    A,@A+DPTR
        MOV     R2,A
        INC     DPTR
        MOVC    A,@A+DPTR

        SUBB    A,R2
        JC      BIGGER
        JNC     SMALLER
        SJMP    EQUAL

        CALL    DELAY_20MS
        CLR     P0.0

        ENDS
        END


This is the code that I've tried to write. Is the method I am using correct ?:-)


[ Edited Thu Jul 16 2009, 04:41 AM ]

Get Social

Information

Powered by e107 Forum System

Conversation

rawat742
Fri Aug 18 2017, 11:37 AM
hi @ angel patel i will attach a file i hope it will be helpfull for you
ExperimenterUK
Mon Aug 14 2017, 09:57 PM
@ angel patel... just log in and post your problem
Mon Aug 14 2017, 01:45 PM
angel patel
hey any one help to make the led scrolling display
desuza6
Sat Jul 29 2017, 07:09 AM
I see the code for step motor h l 298 to rotate 45 degree, but all delay time, if I want to input sensor to h the pulses to stepmotor
rammichael
Thu Jul 27 2017, 12:05 PM
okay fine
ExperimenterUK
Wed Jul 26 2017, 07:51 PM
Please post questions in the forum, the chat box is for chat
msd007
Wed Jul 26 2017, 11:27 AM
i need code if any one have aduc706 interfacing lcd 16*2
msd007
Wed Jul 26 2017, 11:26 AM
pl help me how to write code of interfacing ADuc7026 controlleo lcd pl any one help me hoe to initializend configure the direction
rammichael
Wed Jul 26 2017, 06:04 AM
can you explain what is timer and how to use their modes ...
rammichael
Wed Jul 26 2017, 06:03 AM
ExperimenterUk thank you for your quick reply okay

Downloads

Comments

kira113
Sat Aug 19 2017, 08:40 AM
Pirateak
Thu Aug 17 2017, 02:02 PM
sathishksk71
Wed Aug 16 2017, 04:47 AM
rawat742
Sun Aug 13 2017, 05:49 PM
alparslanbagriyanik
Fri Aug 11 2017, 08:10 AM
Thanhquan
Sat Aug 05 2017, 05:17 PM
NAMRATHA
Thu Aug 03 2017, 08:32 AM
Kgj
Tue Aug 01 2017, 12:41 PM

Online

Guests: 90, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37879
Newest member: kira113
Forum Activity
kira113 Avatar
Posted By kira113
Sat Aug 19 2017, 08:52 AM
hello everyone i write a simple program using c la...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Aug 19 2017, 02:47 AM
else x+=0x46; //print as ascill 0x41 to 0x46 A-F ...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 02:58 PM
Dear Sir, I have a another program in which I am a...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:45 AM
LCD SCROLLING MESSAGE PROGRAM CODE AND SIMULATION...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:24 AM
Dear Sir , I am not able to increased value by pre...
rawat742 Avatar
Posted By rawat742
Fri Aug 18 2017, 11:19 AM
Dear Sir, as per your attachment I w...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Aug 17 2017, 10:54 PM
Try this. Attachment ...
rawat742 Avatar
Posted By rawat742
Thu Aug 17 2017, 08:24 PM
Dear Sir , Please help me for stor...
sathishksk71 Avatar
Posted By sathishksk71
Wed Aug 16 2017, 04:53 AM
Hi.. Iam refreshing c language using this useful r...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Aug 14 2017, 10:19 PM
The original 8051 is a primitive device.Over the ...