free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
priya123
Tue Apr 15 2008, 06:43PM
 User Offline
Registered Member #7113
Joined: Wed Apr 09 2008, 02:39AM

Posts: 48
Thanked 0 times in 0 posts
i am posting the thread.the logic of the program is that - i want to interface adc and microcontroller and see the output through the ports of microcontroller .say for a voltage of 2volts ,adc is going to read 033h and this data will be displayed through ports of microcontroller . please check the code and correct it so that it works properly.please help,its too urgent.i am using adc0804 with a vref of 1.28 volts.in r3 i am storing the value of the voltage for which adc is going to give the desired output ,like for 2v ,it will display 033h.
CODE:
setb p2.5
 setb p2.6
intr bit p2.7
setb intr
adc_port equ p1
adc_val equ 30h
voltage_val equ r3
back: clr wr
       setb wr
       acall conversion
read:  clr rd
       setb rd
       mov r3,#00h
       acall data_display1
 mov r3,#01h
         acall data_display2
  mov  r3,#02h
         acall data_display3
 mov r3,#03h
          acall data_display4
 mov  r3,#04h
           acall data_display5
 mov r3,#05h
      acall data_display6  
            sjmp back
data_display1: mov a,#00h
conversion:  mov b,#10h
                div ab
                mov r7,b
              mov b,#10h
              div ab
              mov r6,b
              mov r5,a
              mov p1,r7
              acall delay
              mov p1,r6
              acall delay
              mov p1,r5
              acall delay
data_display2:  mov a,#033h
                 mov b,#10h
                 div ab
                 mov r7,b
                 mov b,#10h
                 div ab
                 mov r6,b
                 mov r5,a
                 mov p1,r7
                 acall delay
                 mov p1,r6
                 acall delay
                 mov p1,r5
                 acall delay
data_display3:    mov a,#067h
                  mov b,#10h
                  div ab
                  mov r7,b
                  mov b,#10
                  div ab
                  mov r6,b
                  mov r5,a
                  mov p1,r7
                  acall delay
                  mov p1,r6
                  acall delay
                  mov p1,r5
                  acall delay
data_display4:    mov a,#097h
                  mov b,#10h
                  div ab
                  mov r7,b
                  mov b,#10h
                  div ab
                  mov r6,b
                  mov r5,a
                  mov p1,r7
                  acall delay
                  mov p1,r6
                  acall delay
                  mov p1,r5
                  acall delay
 data_display5:   mov a,#099h
                  mov b,#10h
                  div ab
                  mov r7,b
                  mov b,#10h
                  div ab
                  mov r6,b
                  mov r5,a
                  mov p1,r7
                  acall delay
                  mov p1,r6
                  acall delay
                  mov p1,r5
                  acall delay
  data_display6:   mov a,#0ffh
                    mov b,#10h
                    div ab
                    mov r7,b
                    mov b,#10h
                    div ab
                    mov r6,b
                    mov r5,a
                    mov p1,r7
                    acall delay
                    mov p1,r6
                    acall delay
                    mov p1,r5
                    acall delay
    delay:          mov r4,#200
    here:           djnz r4,here
                         ret
                         end                                                                                                                                    
 

the problem with this code is that it is being emulted but correct result is not displayed, in port1 where i am seing te display its giving all msb first then lsb.suppose for nos.33,67,97, it is reading 3,6,9 then 3,7,7,but it should read 33,67,97. if i add a ret statement after every data_display function then at the last 2 functions(data_display5,data_display6 an error is occuring stating expression out of range) .i want to see the display through leds connected to ports of microcontroller.please help me to sort this out.




[ Edited Fri Apr 25 2008, 03:58AM ]

p
Back to top


shyam
Tue Apr 15 2008, 07:07PM

 User Offline

Registered Member #2984
Joined: Mon Aug 06 2007, 11:33AM

Posts: 723
Thanked 107 times in 103 posts
u must be on a slow internet and the connection might be getting timed out!!!

thats y u r posting multiples/duplicate and we are wasting our time deleting them

do not click on repost data after a connection times out..

restart from the home page .. see if the post has already been posted if not then repost again!!!

for the attatchment give proper time for the files to get atatched


lProgress is not made by early risers or hard workers, but by LAZY people, trying to find easier ways to do the same........
Back to top


sashijoseph
Wed Apr 16 2008, 03:40AM

 User Offline
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 552
Thanked 124 times in 117 posts
Please note
Allowed file types: | .zip | .gz | .jpg | .png | .gif | .rar | .pdf |
Any other file types uploaded will be instantly deleted.
Maximum file size: 2M

@Priya ...Make sure you're complying to ^^

Let there be music........
Back to top


pdi33
Wed Apr 16 2008, 04:02AM

 User Offline
Registered Member #1329
Joined: Mon Jun 04 2007, 09:28AM

Posts: 655
Thanked 144 times in 140 posts
If u r finding trouble in attaching the code , why don't u try and just cut paste it in the main window (if the size is not very large.). try converting to pdf if possible and attach

* inspired to develop,developing to inspire *
Back to top


sashijoseph
Mon Apr 21 2008, 03:26AM

 User Offline
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 552
Thanked 124 times in 117 posts
priya123 wrote ...

i am posting the thread.the logic of the program is that - i want to interface adc and microcontroller and see the output through the ports of microcontroller .say for a voltage of 2volts ,adc is going to read 033h and this data will be displayed through ports of microcontroller . please check the code and correct it so that it works properly.please help,its too urgent


Please give details of which ADC you're using,Vref etc......

In your code you are making subroutine calls(acall data_display1 etc) without using 'ret' at the end of the subroutine.Only the 'delay' subroutine has a proper ret statement.....Correct this.

acall conv

where's the 'conv' routine???

cjne r3,#00h,check1

What does r3 contain?......you haven't put a value in r3 to compare with.

If you're using ADC0804 plz go through this tut and understand the program flow and then adapt it to your requirement...
http://www.8051projects.net/adc-interfacing/adc0804-8051-programming.php

Let there be music........
Back to top


sashijoseph
Fri Apr 25 2008, 12:24AM

 User Offline
Registered Member #5870
Joined: Mon Feb 04 2008, 06:26PM

Posts: 552
Thanked 124 times in 117 posts
Hi Priya.....
First of all whenever you have to write something new,make a new post(in the same thread).Do not edit your original post(unless it's for some correction).
Coming to your code,I would suggest you to go through the tutorial I linked above again and again till you understand it.
Where are you reading the ADC?
What have you done with r3?
acall conversion doesn't have a ret.


As for the display problem you are dividing the value with 10H(ie 16 decimal)...
Use 0AH(dec 10) and see....

[ Edited Fri Apr 25 2008, 12:25AM ]

Let there be music........
Back to top



This post has been thanked 1 time
 priya123 
priya123
Tue Apr 29 2008, 05:27PM
 User Offline
Registered Member #7113
Joined: Wed Apr 09 2008, 02:39AM

Posts: 48
Thanked 0 times in 0 posts
i have another query regarding this project,at first i was getting the display by connecting pins of port1 to leds on my trainer kit but if i want to see the display through a 7-segment display how should i connect 7-segment display with the microcontroller port,the program code will remain the same or i have to change it? please tell me what changes i have to make???please send a quick reply ,its too urgent.

p
Back to top


priya123
Tue Apr 29 2008, 05:28PM
 User Offline
Registered Member #7113
Joined: Wed Apr 09 2008, 02:39AM

Posts: 48
Thanked 0 times in 0 posts
i have another query regarding this project,at first i was getting the display by connecting pins of port1 to leds on my trainer kit but if i want to see the display through a 7-segment display how should i connect 7-segment display with the microcontroller port,the program code will remain the same or i have to change it? please tell me what changes i have to make???please send a quick reply ,its too urgent.

p
Back to top


Arun Kumar V
Tue Apr 29 2008, 06:09PM

 User Offline
Registered Member #426
Joined: Sun Jan 28 2007, 11:50PM

Posts: 445
Thanked 188 times in 158 posts

Girl you are too confusing,

First you haven't answered to Shashijoseph's doubts, full details are missing

Second you fill the entire forum (including chatbox) with your multiple threads,

Third your want solutions to your problems in a jiffy (very desperate)

follow a step by step approach while debugging

Arun
Back to top


 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems