0
\$\begingroup\$

I made a circuit which selects one of 4 sensors and determines if a valid data stream is present on that sensor and counts the number of times data is valid. I narrowed my problems to hardware.

In the original circuit, I did not include the LED and 100 ohm resistor in series (see thick wire in schematic) because I thought I didn't need it. Then I started adding it temporarily and everything seems to run more smoothly with it in.

So at this point with the resistor and LED in, I can detect light status on any sensor of my choice at a rate of 1 every 2 ms. Ideally, I want to detect at a rate of 1 every 125 us.

I believe my problem exists because of some delay caused by the math resulting from the internal resistor on the micro's RXD pin plus the 1k resistor plus a capacitor somewhere in any of the IC's?

The reason I added the 1k resistor is because if by fat chance I ground the RXD pin via software and output W is high and I didn't have any resistor then I'd have a short circuit which I do not want.

But what baffles me is that I get success with the diode and LED circuit even though output W would return a high or low since the part is a 151 not a 251 or does that chip output still have a resistor in series?

My other thought is to replace the AT89C2051 with an AT89LP4051 but that's asking for more money and another programmer.

Anyways, other than my thoughts, Can I configure this setup hardware wise to allow a signal to pass through from the photo transistor to the micro via a multiplexer at a rate of 1 bit per 125us? (like change resistor values and/or add/remove resistors)? etc.

Currently I have the entire circuit minus the LED+resistor in series mounted on a PCB with tracks at least 12 mils wide and power tracks at least 40 mils wide.

The supply voltage averages at 4.8V.

Circuit

UPDATE

I have tried all of the following without success:

  1. Replaced the series LED+resistor combo in original circuit with just a 1K resistor and used 220 ohm for series resistor

  2. Removed the series LED+resistor combo and instead connected the GPIO pin to ground via 22K resistor and again used the 220 ohm for series resistor

Now I haven't gone as low as 75 ohms for series resistance that someone pointed in their diagram but I'm still a little fuzzy. Maybe there's an entry in a datasheet I need.

Now I'm curious, considering this micro has (based on literature I read) GPIO pins in open drain format only, could I get away with removing the resistors and LED and replacing the series resistor with only one reverse-based diode (so anode connects to GPIO and cathode connects to multiplexer output)? If so, can I get away with a standard 1n4148/1n914 diode?

\$\endgroup\$
9
  • \$\begingroup\$ 1. 125uS. 2. Raw 8-bits. currently I'm setting the valid data to 11000011 in binary. and 3. 8 bits are sampled before data is checked for validity. If after 8 scans (125uS wait period per scan), the data is 1, 1, 0, 0, 0, 0, 1, 1 then its valid. \$\endgroup\$ Commented Jan 27, 2019 at 4:30
  • 1
    \$\begingroup\$ Feeding a phototransistor into a digital input isn't going to work, period. You need to be modulating the data onto a subcarrier itself modulating the IR radiation, otherwise you are not going to be able to distinguish it from background. And you need a receiver designed for that - if you want to use a bare phototransistor instead, you'll need an analog input and to do software subcarrier detection. Most TV remote type receivers are low bandwidth, tuned for a subcarrier around 38 KHz; there are higher bandwidth data communication parts for IRDA etc but they get harder to find. \$\endgroup\$ Commented Jan 27, 2019 at 5:09
  • \$\begingroup\$ It might help if I explained I'm doing this for lazer tag. The reason why I'm using an 8-bit data format to detect a lazer on a photo-transistor instead of just 1 bit is because I don't want someone to shine a flashlight to confuse the system into thinking the incoming light counts as a shot. So yes Chris, that's my way of modulation... creating an 8-bit data signal to define that a light went on and off in a timely manner. \$\endgroup\$ Commented Jan 27, 2019 at 16:45
  • \$\begingroup\$ @jsotola technically 125uS is a measure of conductivity. Mike probably meant 125μs. \$\endgroup\$
    – Hearth
    Commented Jan 27, 2019 at 16:58
  • \$\begingroup\$ i meant speed. 125 microseconds per bit detection \$\endgroup\$ Commented Jan 27, 2019 at 17:12

2 Answers 2

0
\$\begingroup\$

It's not entirely clear what you're asking, but I think you're trying to receive short pulses from the W output of IC2 into the P3.0-RXD pin of IC1, and you're discovering that 2ms pulses are detected at IC1, but 125uS pulses aren't.

the 1K resistor is far too large, especially since it's having to work against the LED and its 100 ohm current limiting resistor.

The simplest thing to do to fix your circuit is to connect the LED and the 100 ohm resistor between the Y (pin 5) output of IC2 and ground (noting the polarity will be different). Change the 100 ohm resistor for something bigger (for a red led you probably want something more like 330 ohms).

With that modification you won't be loading the output excessively.

Next reduce the 1K resistor. The ratings for the 74HC151 give maximum source or sink current as 25mA, and the AT89C2051P lists a maximum source or sink current of 25mA as well. With a 5V supply, 25mA gives you a limit of 200 ohms, so swap the 1K resistor for a 330 ohm one.

\$\endgroup\$
5
  • \$\begingroup\$ The entire scheme isn't going to work, for reasons far beyond those. \$\endgroup\$ Commented Jan 27, 2019 at 5:08
  • \$\begingroup\$ @ChrisStratton you've clearly been able to parse more than I could, I think the OP's trying to make a multi input IrDA style serial-over-ir receiver, in which case switching the BPX81 for a decent IrDA receiver with an AGC would probably be enough \$\endgroup\$
    – james
    Commented Jan 27, 2019 at 15:59
  • \$\begingroup\$ Ultimately I want the microcontroller to detect the signals. I was only using the add-on LED and resistor in series to test if the signals are getting through (which they are). So I'm guessing by your answer that the signal current from the 151's output isn't strong enough for the micro to recognize it with the 1K in series? \$\endgroup\$ Commented Jan 27, 2019 at 16:41
  • \$\begingroup\$ Please check my question. I added an idea that might work but need confirmation. \$\endgroup\$ Commented Jan 27, 2019 at 17:21
  • \$\begingroup\$ You can't have the led on the same wire as the input (RXD) of IC2. However IC1 gives you two outputs, so you can use one for the AT89 and one for the LED. Connect IC1 W to IC2 P3.0-RXD with a resistor no larger than 330Ohms and do not connect it to anything else. Connect your LED to IC2 Y as I explained. Open Drain applies to outputs only, RXD is an input. \$\endgroup\$
    – james
    Commented Jan 27, 2019 at 18:11
0
\$\begingroup\$

If anything the LED pullup ought be 1k with no series R to expect good margin for Vol.

If you need an LED indicator with 100 ohms, use another inverter like the 'HC14 so as not to apply this much pullup current.

The opto slow rise time will delay the output due to the 50% hysteresis by 4~5us due to 8pF=Cout * 500k

schematic

simulate this circuit – Schematic created using CircuitLab

This optical design needs to use a path loss analysis with more precise Rx gain than a phototransistor such as a PD with an OpAmp for gain.

There are also far better solutions using Sharp/Vishay IRDA Tx Rx IC's. Optical gain is done by using narrow-angle beamwidth.

This is what I mean up to 115.2 kbit/s (SIR) at 1m or 8 kb/s @ 12m range @ 0 deg https://www.vishay.com/docs/81965/tfdu4301.pdf

There are better ways if you define range and beamwidth.

\$\endgroup\$
8
  • \$\begingroup\$ Ok, its now clear to me that I must reduce the series resistor, but wouldn't my microcontroller malfunction if the multiplexer output feeding it directly is high and the GPIO pin its connected to is set to logic low by software? I mean personally I "think" I could get away with 220 ohms since that's under 25mA current used. but I'm trying to understand. hmm... \$\endgroup\$ Commented Jan 27, 2019 at 16:49
  • \$\begingroup\$ Vol/Iol=Rs @ 15mA \$\endgroup\$
    – D.A.S.
    Commented Jan 27, 2019 at 16:55
  • \$\begingroup\$ Please check my question. I added an idea that might work but need confirmation. \$\endgroup\$ Commented Jan 27, 2019 at 17:21
  • \$\begingroup\$ @Sunnyskyguy, Did you notice IC1 has two outputs? So the OP can use one for the LED and one for the uP \$\endgroup\$
    – james
    Commented Jan 27, 2019 at 18:11
  • \$\begingroup\$ I agree W= not Y ( inverted) and High side RdsOn is only slightly higher than low side 33 to 66 Ohms (typ to max) ( I showed Rs=75 ohm as a worst case) but Rol is usually 50 Ohms nom for 74HC 5V logic \$\endgroup\$
    – D.A.S.
    Commented Jan 27, 2019 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.