Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8051 output voltage problem

Status
Not open for further replies.

niranjan23

Member level 5
Member level 5
Joined
Jan 22, 2012
Messages
94
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Visit site
Activity points
2,109
hiii....I am using at89s51 for two led on-off by a switch

My problem is when I press the switch of pin P1.0.... I get the output only 400mV to 500mV to pin P2.0 on multimeter but LED still ON

I want +5V on P2.0 how can I get it..???

I changed IC to 8052 but problem is still getting

according to datasheet of 8051 Logic high is +5V but I getting low Voltage to output pin P2.0....
the circuit is given below and also assembly code

8051tr.png

Code for above circuit
org 0000h
mov p2,#00h
mov p1,#00h
back:mov a,p1
cjne a,#01h,go2 ; check whether switch 1 is pressed
setb p2.0 ; turn ON the LED
clr p2.0
sjmp back
go2:cjne a,#02h,back ;check whether switch 2 is pressed
setb p2.1 ;turn ON the LED
clr p2.1
sjmp back


Please tell me what is the problem and what I have to do for that..???
 

There is no way, repeat, NO WAY that your LED will turn on with 500mV coming out on P2.0. You are either measuring improperly or you circuit is not wired as shown in your schematic.

Update:

Upon further review, your software is wrong. You set the bit, and then immediately clear it on the next instruction. That won't do. The reason you are seeing 500mV is that you've actually got an ac signal on the pin.
 

so what I do...????

and what is mean by ac signal on pin:???:..??? don't understand...!!!:-|
 

Did you ever read the 89S51 datasheet chapter about IO ports? That would be probably the first step, then you'll know how to correct your circuit.

Both P1 and P2 are open drain ports with weak pull-up.
 
  • Like
Reactions: tpetar

    tpetar

    Points: 2
    Helpful Answer Positive Rating
Did you ever read the 89S51 datasheet chapter about IO ports? That would be probably the first step, then you'll know how to correct your circuit.

Both P1 and P2 are open drain ports with weak pull-up.

Further, P2 can't source much current, and it can only sink about 1.5mA.

But your software is still wrong.
 

well ok ...

Actually I want to connect LDR to 8051 and operate SPDT relay....and for LDR I am using simple One transistor circuit to give microcontroller High and low logic

becoz of this relay is not operating ...that is transistor which is I used as switch to relay is not working...do you know what I want say...???

Please give me solution on it...:-:)-?
 

Instead of showing us a picture of a circuit with a switch and LEDS, when in reality you have a transistor and a relay, WHY DON'T YOU SHOW US WHAT YOU ACTUALLY HAVE??????

How can you show us a picture of one circuit, and expect us to tell you why a TOTALLY DIFFERENT circuit doesn't work?
 

ohh I am sorry for that I don't want to confuse you ...

I am also confused why output voltage is getting low...I don't have solution for that...

here is the circuit...

8051new.jpg

I am Sorry again...!! Please give me solution on it...!!!
 

As mentioned you have to remove the instruction CLR 2.0. Datasheet says When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. Maybe when you are making P2.0 pin high it is acting as an input pin. Try P3.0 and see if that works for you.
 

@jayanth.devarayanadurga

I tried on Port 3

when remove CLR 2.0 ...it's not work..!!!

but it work with CLR 2.0

also o/p is still low...
 

Maybe your compiler is creating wrong hex file. Post your project files I will check in Proteus. Mention the MCU you are using.

Try this. If it still doesn't work you have to use debounce delays for the switches.


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
org 0000h
        mov p2,#00h
        mov p1,#00h
back:mov a,p1
        cjne a,#00h,on
        clr P2.2
        clr p2.3
on:cjne a,#01h,go2              ;check whether switch 1 is pressed
        setb p2.2                               ;turn ON the LED
        sjmp back
go2:cjne a,#02h,back    ;check whether switch 2 is pressed
        setb p2.3                               ;turn ON the LED
        sjmp back
        end

 

Attachments

  • at89c51_led.rar
    49.5 KB · Views: 68
Last edited:

Yes..... your given hex file is working but you did port 2 as output and excluding P2.3 other pins are high

I am getting 4.6V at P2.3 your program is working

But i have one technical problem the relay is connected to P2.0 is not activating...the circuit and my project file attached below......

View attachment 8051asm.rar
 

I have used AT89C51 and it is working fine. What is your MCU?

Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
org 0000h
        mov p2,#00h
        mov p1,#00h
        mov p3,#00h
back:mov a,p1
        cjne a,#00h,on
        clr P2.0
        clr p2.1
on:cjne a,#01h,go2              ;check whether switch 1 is pressed
        setb p2.0                               ;turn ON the LED
        sjmp back
go2:cjne a,#02h,back    ;check whether switch 2 is pressed
        setb p2.1                               ;turn ON the LED
        sjmp back
        end

 

Attachments

  • at89c51_led v2.rar
    49.5 KB · Views: 67

You really need to read your specifications:

1) The nominal current out of P2 is 60 microamps.
2) The transistor has an hFE of about 100=> collector current=.06*100=6mA.
3) Your relay requires about 60 mA to turn on.

The transistor needs well over 1 mA to drive it into saturation, you are nowhere near that.
 

You could just use a discrete darlington, or a logic-level MOSFET (unless you have need for the other transistors in that ULN2003.)
 
Please consider that guaranteed IOH output current of 60 µA is not sufficient to drive an ULN2003/2803. The typical curent will work, but it's not realiable.
 
@jayanth.devarayanadurga

can you tell me which compiler you use for converting .asm to .hex file..../???
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top