I am afraid you've lost me a bit here. If I have a 12Vs, and I want a bit less than 100mA, say 80mA, going through my ired (I have lots of different ones, but lets use the one with a continuous forward current of 50mA, and a forward voltage of 1.5V), then i need a collector resistor of 130ohm right ((12-1.5)/0.08=131.3)? If I put in a resistor that has a larger value than that, then I won't get as much current, will I?
Yes
Also, could you explain how it is that the 12Vs won't blow the ired, when it's forward voltage rating is 1.5V?
I assume by this you mean that you have tried it and the ired did not blow. It's possible that it might blow or not. It depends on two things:
1- How much current the 12V source can deliver. If the ired can take the maximum current that the voltage source can deliver then it will not blow. What will happen is that the 12V source will drop voltage across its internal resistance and output a lower voltage that the ired can handle.
2- the characteristic curve of the ired. 1.5V is the nominal voltage or knee voltage of the ired. Higher currents will cause a larger voltage drop across it until it eventually reaches its breaking point. But the curve is basically exponential so a small voltage increase requires a large current increase through the ired.
I suspect the ired would break before 12V ( I could be wrong though ), so likely the 12V source could not supply enough current to kill the ired so for example it could only source 6V at 500mA and at 500mA the ired drops 6V. That would be the Q point of the circuit. Of course the Q point might not be stable because of heat dissipation and might eventually lead to disaster. But this is just an example. In reality, it is somewhat unpredictable, which is why you should always use a series current limiting resistor.
Btw, thanks for alerting me to the fact that the arduino needs a 470ohm resistor on it! But I am confused again, because how can the arduino output 40mA when it has that resistor there? Because if V=IR, then (5/470)=1mA.
First of all, they are being overly cautious because they don't want you to destroy the output pin on your Arduino. Secondly, they cannot assume that you are using 5V. Let's say the Ardiuno is outputting 0V through a resistor which is attached to a 12V source. Now, R=12V/40 mA = 300 ohms. Sourcing is less of a problem unless you use a negative voltage but still they are basically covering their buts so you don't blame them for a faulty product. Thirdly, your calculation is actually
10 mA not 1 mA. In fact, if using 5V you can use 150 ohms and still be under the 40 mA rating. But with 12V you should limit to 330 ohms or more. It is likely a transistor inside the MPU that is rated at 40mA, so if you burn it, essentially you need a new Arduino or at least replace the MPU. So, it is far better to design external circuitry to sink or source more current. That circuitry is easier and cheaper to replace even if you make a mistake in the design.
Ive run some more tests:
I found that the ired seems to have a limiting distance to its transmission. I tested it with 140ohm, then 105ohm, then 70ohm, then 35 ohm resistors on the collector. The final 35ohm resistor would have caused about 330mA to run through the ired, which is about 130mA when you account for a 40% duty cycle. I realise that this is much more than recommended. Nevertheless, the ired still works fine. But the transmission distance only increased marginally (1-2cm).
I think I need to order a high power infrared transmitter. What do you think?
It would appear that you need a larger ired or some way to collimate the infra red signal to the detector. It is not surprising. The distance vs current is probably logarithmic function or similar. Is the photo-detector matched in frequency to the ired? ie are their peek frequencies the same or similar? What is the bandwidth of the frequencies? In other words, improvement might not necessarily be based on more power, but better matching of efficiency between transmitter and receiver.
Another thing, you should try connecting the ired directly to the Arduino, with an appropriate series resistor of course, to compare the distance without the transistor vs the distance with the transistor at similar current levels. It should not matter. But if you test it, then we will know for sure that the decreased distance was a result of less current as opposed to some other problem introduced by the transistor circuit. Then you can determine the logical next step to get more distance out of the transmitter. The key is when something does not seem right, to take measurements and try a few different things so you can see what is actually happening vs what you were expecting to happen. Making a plot of distance vs current was a great example. Now you can extrapolate the graph to estimate how much current will be required for a given distance needed.