Are my calculations correct for the resistors attached to this opto-isolator?
You need to start from the load you're trying to drive, then work backwards to what you need to take from the source, then adjust your results for the min/max limits of any of your components.

You don't specify your particular STM32F4 microcontroller (MCU), nor the maximum current you can take from your 12 V.

The load on your circuit is the input leakage current of an I/O pin when configured as an input. You need to find this in your MCU data sheet. A typical figure for these devices is +/- 1 uA. Your inputs need 0.7 x Vdd to Vdd to detect a logic high and GND to 0.3 x Vdd to detect logic low, again typical figures and being 0..1 V for a good low and 2.3..3.3 V for a good high. 

You must also allow for the leakage current down the photo-transistor in your TLP290-4 opto-isolator when it's off, which you will find in the datasheet to be 0.1 uA max.

So your pull-up resistor can afford to drop 1 V across itself with 1.1 uA flowing through it and still be detected as logic high. That's about 909 K but with no margin for error and little resilience to noise.

Your Infra-Red LED (IRLED) has a transfer ratio of 50 % worst-case. Your datasheet also specifies the IRLED current, IF, with figures from 100 uA up in the graphs and example figures of 1 mA up in the tables for output saturated, with the max being 50 mA. In a noisy environment such as a car, you should draw a good-sized current from your signal source to be confident it is not triggered by noise. You had accepted 10 mA. Let's use 5 mA. This will drive the IRLED strongly but not hard. Transient overvoltages on your detection input can be almost 10x the normal 12 V before it'll get anywhere near the 50 mA max. so it's a well-protected input circuit.

So the IRLED series resistor is: (12 - 1.2) / 0.005  =  2160   (use 2K2)

With 5 mA through the IRLED, the photo-transistor Ice(max) can be taken as 2.5 mA. So the acceptable current range through the pull-up resistor is 1.1 uA to 2500 uA.

A 10 K resistor draws: (3.3 - 0.4) / 10000  =  290 uA

This is a good choice: a strong pull-up but still only 10%-odd of the maximum.

You can therefore also use the programmable internal pull-up resistors in your MCU, which the datasheet will tell you are equivalent to 30..50 K or 7..14 K.

In your calculations, you found the IRLED current stated as 10 mA in one place, worked out the current transfer ratio then tried to draw the maximum current you could from the output, rather than the current you need.

The other thing you need to observe is that the maximum reverse voltage that the IRLED in an opto-isolator can take is very often tiny by diode standards, something like -2..3 V being common. You would therefore need a diode connected across the IRLED that conducts when the IRLED is reverse-biased to protect it. The TLP290-4 has these built in so there is no need for an external diode.







simulate this circuit &ndash; Schematic created using CircuitLab

So: use R1 = 2K2 for 5 mA IRLED current and R2 = 10K and you'll be fine with your microcontroller input pins.

You can invert the active state of the signal in your software for free, as well as get the pull-up resistors in your software for free.