CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Two PWMs driving the same opto

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

Two PWMs driving the same opto
PostPosted: Thu Sep 08, 2005 1:06 pm     Reply with quote

I have two independent PWM pins (CCP1 and ECCP) connected to an optocoupler as shown below. If I want CCP1 to be the PWM source, my plan is to make ECCP1/P1A as an INPUT (thus High Impedance?). Similiarly, when ECCP1 is firing its PWM pulse, I would then configure CCP1 as an INPUT (high impedance?).

My dad's telling me that i need diodes to make something like a wired-OR, but I insist that the circuit is sufficient as long as at least ONE of the pins is an INPUT at all times. A pin enabled as an input is essentially an open circuit (or more exactly, a high impedance) and won't load the circuit down, would it?

newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Thu Sep 08, 2005 1:11 pm     Reply with quote

I'd be inclined to agree with you. You'd only need the wired OR if you were driving both PWMs at the same time.
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Thu Sep 08, 2005 3:35 pm     Reply with quote

When whichever is an output is high, the input will see 5 volts. When the ouput is low, the input will be at 5 volts, less the voltage drop of the LED, (which can be surprisingly big), less the voltage drop across R3.

Careful about input impedance. I don't think the impedance on the PIC is that great. Let's say its 10K, for giggles. Now, you've got almost as much current going across R3 and R1, and assuming a 2 volt drop across the LED, you're looking at about 0.07V-- seems OK, with plenty of headroom.
Now, consider a high PWM signal. Assuming 10K input impedence, you'll have about 4.8 Volts at the junction of the three resistors (a voltage divider across the 220 ohm and the parallel combo of the 10K resistor and the 10K input impedance, ignoring the second 220 ohm). This should be enough to guarantee that the diode is off, but you might want to make sure to avoid surprises.

Let's look at what's going on at the PWM pin when its a low output. Assuming, worst case, a 1 volt drop across the diode, the PWM pin would need to sink 18 mA all on its very own. I know the maximum for the 4431 is 25mA. Keep in mind that just about all of that current is sourced through the diode, so you need to look up that maximum rating, too. I think 18 mA is a tad more than I would design for (from the PIC point of view), especially if the PWM can be 0% for any length of time. The bigger the voltage drop for the diode, the better the number would be (and dramatically so), so you might be OK. If not, you might consider raising R2 and R3, and lowering R1, and redoing the analysis to make sure that a high is still sufficient to turn off the diode.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 08, 2005 3:45 pm     Reply with quote

Quote:
I don't think the impedance on the PIC is that great

The 18F4431 data sheet says the Input Leakage Current is +/- 1 ua
max for any pin voltage between Vss and Vdd. (Section 25.3,
parameter D060). So for a Vdd of 5 volts, this gives an input
impedance of at least 5 Meg ohms.
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Thu Sep 08, 2005 4:57 pm     Reply with quote

PCM programmer wrote:
Quote:
I don't think the impedance on the PIC is that great

The 18F4431 data sheet says the Input Leakage Current is +/- 1 ua
max for any pin voltage between Vss and Vdd. (Section 25.3,
parameter D060). So for a Vdd of 5 volts, this gives an input
impedance of at least 5 Meg ohms.


Live and learn. I think the number buzzing around my head had more to do with the analog inputs and the maximum recommended value for source impedance of 2.5K, which made me think input impedance was bad in general. Of course, why would that be when a simple FET brings it to megohms. In fact, the 2.5K probably has more to do with settling time than input impedance anyway.

Scott
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Thu Sep 08, 2005 5:24 pm     Reply with quote

Okay, thanks guys --- so the consensus is:

R = V/I = 5V / 1uA = 5 Mohm

I guess tomorrow i'll be soldering some resistors onto my board to make sure it indeed works.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: Two PWMs driving the same opto
PostPosted: Thu Sep 08, 2005 6:42 pm     Reply with quote

MikeValencia wrote:
I have two independent PWM pins (CCP1 and ECCP) connected to an optocoupler as shown below. If I want CCP1 to be the PWM source, my plan is to make ECCP1/P1A as an INPUT (thus High Impedance?). Similiarly, when ECCP1 is firing its PWM pulse, I would then configure CCP1 as an INPUT (high impedance?).

My dad's telling me that i need diodes to make something like a wired-OR, but I insist that the circuit is sufficient as long as at least ONE of the pins is an INPUT at all times. A pin enabled as an input is essentially an open circuit (or more exactly, a high impedance) and won't load the circuit down, would it?



You can do this simpler than this. You do not need the 10K pullup. You only need a single 220R resistor connected between the anode of the optocoupler (pin 1) and +5v. The cathode goes to CCP1 and ECCP. This is a completely valid configuration assuming that you never configure both devices as outputs simultaneously.

You are driving the optocoupler too hard. According to the datasheet the maximum current required to switch the output over the life of the optocoupler is around 1.8ma. You are driving it with 3.5volt / 220R = 15.9mA. I suggest dropping the drive current to around 3mA in which case you can bump up the 220 resistor to 1K.

Having said you only need a single resistor, the advantage of using two resistors (R2 and R3) is that if you do make a mistake in software and drive both lines simultaneously then you will not cause excessive current consumption. In which case I would get rid of R1 as discussed and increase R2 and R3 to 1K
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: Two PWMs driving the same opto
PostPosted: Thu Sep 08, 2005 6:44 pm     Reply with quote

MikeValencia wrote:
I have two independent PWM pins (CCP1 and ECCP) connected to an optocoupler as shown below. If I want CCP1 to be the PWM source, my plan is to make ECCP1/P1A as an INPUT (thus High Impedance?). Similiarly, when ECCP1 is firing its PWM pulse, I would then configure CCP1 as an INPUT (high impedance?).

My dad's telling me that i need diodes to make something like a wired-OR, but I insist that the circuit is sufficient as long as at least ONE of the pins is an INPUT at all times. A pin enabled as an input is essentially an open circuit (or more exactly, a high impedance) and won't load the circuit down, would it?



You can do this simpler than this. You do not need the 10K pullup. You only need a single 220R resistor connected between the anode of the optocoupler (pin 1) and +5v. The cathode goes to CCP1 and ECCP. This is a completely valid configuration assuming that you never configure both devices as outputs simultaneously.

You are driving the optocoupler too hard. According to the datasheet the maximum current required to switch the output over the life of the optocoupler is around 1.8ma. You are driving it with 3.5volt / 220R = 15.9mA. I suggest dropping the drive current to around 3mA in which case you can bump up the 220 resistor to 1K.

Having said you only need a single resistor, the advantage of using two resistors (R2 and R3) is that if you do make a mistake in software and drive both lines simultaneously then you will not cause excessive current consumption. In which case I would get rid of R1 as discussed and increase R2 and R3 to 1K
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group