I Need help for AT89c2051 programming.

Thread Starter

Parv Bhavsar

Joined Apr 12, 2016
15
I am doing project in which i will be having two dc sources.
One is Consistent 12v and onther one is fluctuating...
I will be using analoge comparator of AT89C2051,
I am having two problems
1)during using keil 5.0 i use <reg89x51.h> and <at89c2051.h> but after debugging and run messege appears "cant open the file"
2)I want to turn on severel optocouplers PC817 using PORT 1 pins....
Can port 1 pins provide enough voltage and current to drive pc817?
 

Papabravo

Joined Feb 24, 2006
21,157
I don't think the 8051 Port 1 pins can do an adequate job of driving a garden variety optocoupler. The output drivers are not symmetrical; they can source about 400 μA, and sink about 3.2 mA. Depending on the CTR of the optocoupler you might be able to use a low going output to put 3.2 mA through the diode side, but if the CTR is low, 20% for example, the Ic of the output transistor would only be 640 μA. It will also get worse with age, that is why you might want some margin.

You might also want high efficiency LEDs which have acceptable brightness at much lower current levels than standard LEDs. One question -- why can't you read the datasheet for yourself and discover this information on your own?
 

Papabravo

Joined Feb 24, 2006
21,157
AT89C2051 port pins can source or sink 20 ma.
Had to check the datasheet on this one cuz I assumed it was an MCS 8051 compatible part.
Your claim of a symmetrical output stage is demonstrably false. I agree that the Port 1 outputs can sink 20 mA, which is an upgrade from previous 8051 compatible parts, but they cannot source 20 mA by a long shot. 80 μA @ Voh of 2.4 V minimum. Learn to read a datasheet.

So 20 mA is more than enough to drive an opto, even with a poor CTR. Just connect the port pin to the cathode of the diode and pull it low to turn it on. Don't forget the current limiting resistor from the anode to Vcc.
 
Last edited:

Thread Starter

Parv Bhavsar

Joined Apr 12, 2016
15
so as you
Had to check the datasheet on this one cuz I assumed it was an MCS 8051 compatible part.
Your claim of a symmetrical output stage is demonstrably false. I agree that the Port 1 outputs can sink 20 mA, which is an upgrade from previous 8051 compatible parts, but they cannot source 20 mA by a long shot. 80 μA @ Voh of 2.4 V minimum. Learn to read a datasheet.

So 20 mA is more than enough to drive an opto, even with a poor CTR. Just connect the port pin to the cathode of the diode and pull it low to turn it on. Don't forget the current limiting resistor from the anode to Vcc.
so as you said i willconnect port 1 pin to cathode of pc817 and pull the pin low to turn on optocoupler.
And
Please tell tell me all registries that will be needed for at89c2051
 

Papabravo

Joined Feb 24, 2006
21,157
so as you

so as you said i willconnect port 1 pin to cathode of pc817 and pull the pin low to turn on optocoupler.
And
Please tell tell me all registries that will be needed for at89c2051
I'm not sure what you are asking with "tell me all registries that will be needed for AT89C2051"
 

Brevor

Joined Apr 9, 2011
297
Had to check the datasheet on this one cuz I assumed it was an MCS 8051 compatible part.
Your claim of a symmetrical output stage is demonstrably false. I agree that the Port 1 outputs can sink 20 mA, which is an upgrade from previous 8051 compatible parts, but they cannot source 20 mA by a long shot. 80 μA @ Voh of 2.4 V minimum. Learn to read a datasheet.
Thanks, Papabravo for having the diligence to check the datasheet. I was answering from old memories.
 

Thread Starter

Parv Bhavsar

Joined Apr 12, 2016
15
I'm not sure what you are asking with "tell me all registries that will be needed for AT89C2051"
hello
i got my controller working with acs712
by which i will be switching a secondary 12v dc source if primary gives supply to any load...
when i connect load to primary source pin 1.4 and pin 1.3 gives +5V and almost 0mA,
cant figure out how to drive 2N2222 with that voltage..
 

ScottWang

Joined Aug 23, 2012
7,397
Had to check the datasheet on this one cuz I assumed it was an MCS 8051 compatible part.
Your claim of a symmetrical output stage is demonstrably false. I agree that the Port 1 outputs can sink 20 mA, which is an upgrade from previous 8051 compatible parts, but they cannot source 20 mA by a long shot. 80 μA @ Voh of 2.4 V minimum. Learn to read a datasheet.

So 20 mA is more than enough to drive an opto, even with a poor CTR. Just connect the port pin to the cathode of the diode and pull it low to turn it on. Don't forget the current limiting resistor from the anode to Vcc.
PB, you really make mistake this time.

Please see the page 3 for port 1:
The Port 1 output buffers can sink 20 mA and can drive LED displays directly. When 1s are written to Port 1 pins.
AT89C2051.
 

Papabravo

Joined Feb 24, 2006
21,157
PB, you really make mistake this time.

Please see the page 3 for port 1:
The Port 1 output buffers can sink 20 mA and can drive LED displays directly. When 1s are written to Port 1 pins.
AT89C2051.
That is what I said Scott. After checking the datasheet, I realized that the sink capability had been upgraded from the standard 8051 architecture. They still cannot source enough current to drive an LED. That part of the pin architecture is still the same quasi bi-directional port of old.
 

Papabravo

Joined Feb 24, 2006
21,157
hello
i got my controller working with acs712
by which i will be switching a secondary 12v dc source if primary gives supply to any load...
when i connect load to primary source pin 1.4 and pin 1.3 gives +5V and almost 0mA,
cant figure out how to drive 2N2222 with that voltage..
What does your answer have to do with "registries"?
 

ScottWang

Joined Aug 23, 2012
7,397
That is what I said Scott. After checking the datasheet, I realized that the sink capability had been upgraded from the standard 8051 architecture. They still cannot source enough current to drive an LED. That part of the pin architecture is still the same quasi bi-directional port of old.
The port 1 are enough current to output 0 to sink the led as : sink 0 ← led ← R ← +5V
And also enough current to output 1 to drive the led as : output 1 → R → led → Gnd.
 

Papabravo

Joined Feb 24, 2006
21,157
The port 1 are enough current to output 0 to sink the led as : sink 0 ← led ← R ← +5V
And also enough current to output 1 to drive the led as : output 1 → R → led → Gnd.
C'mon Scott I admitted you were right about the ability to sink current. How is 80μA enough source current to drive an LED?
 

ScottWang

Joined Aug 23, 2012
7,397
C'mon Scott I admitted you were right about the ability to sink current. How is 80μA enough source current to drive an LED?
Oh, oh, sorry, this time you are right, I' was wrong, although I said that you was wrong, but I still felt that very strange how can you make a mistake like this, so I went to searched the application circuits, and the output port 1 same with port 0, only used the sink function, no any applications output high, so that was I didn't read the datasheet very carefully, when you replied and I checked it again and I found that I was missed something. (I'm talking with some friends with LINE(smartphone) to discussing the problem of voltage responding speed of ut61e multimeter and some other multimeters right now, and we had been discussed for hours)
 

Papabravo

Joined Feb 24, 2006
21,157
Oh, oh, sorry, this time you are right, I' was wrong, although I said that you was wrong, but I still felt that very strange how can you make a mistake like this, so I went to searched the application circuits, and the output port 1 same with port 0, only used the sink function, no any applications output high, so that was I didn't read the datasheet very carefully, when you replied and I checked it again and I found that I was missed something. (I'm talking with some friends with LINE(smartphone) to discussing the problem of voltage responding speed of ut61e multimeter and some other multimeters right now, and we had been discussed for hours)
No need to apologize, I made the first mistake by assuming that the part (89C2051) was an 8051 "compatible" part. I struggled with the limitations of the AT89C51CC01 & AT89C51CC03 which were otherwise perfect for my purposes except for the limited drive capability of the outputs. We used numerous transistor buffers in those designs.
 

ScottWang

Joined Aug 23, 2012
7,397
No need to apologize, I made the first mistake by assuming that the part (89C2051) was an 8051 "compatible" part. I struggled with the limitations of the AT89C51CC01 & AT89C51CC03 which were otherwise perfect for my purposes except for the limited drive capability of the outputs. We used numerous transistor buffers in those designs.
The hdd of the computer that I usually using was damaged, so I have to use another computer to create a new environment to use, I will be through a hard time.

I'm first times to see the AT89C51CC01 & AT89C51CC03.
 

Papabravo

Joined Feb 24, 2006
21,157
The hdd of the computer that I usually using was damaged, so I have to use another computer to create a new environment to use, I will be through a hard time.

I'm first times to see the AT89C51CC01 & AT89C51CC03.
We used them to build components for factory automation systems. The network was DeviceNet, and we had various combination of Digital Input, Digital Output(High Side and Low Side), Analog Input and Analog Output along with implementations of the required DeviceNet Objects. We used a substantial portion of the onboard flash memory for those devices.
 
Top