Arduino + optocoupler + transistor

I control a simple DC motor speed using PWM from Arduino and a BC547B transistor.
But I want to be super sure that Arduino and DC motor circuit are separated, so I need an optoisolator.

The problem is that I don't know how to connect the optoisolator, because it is more complicated than those described on forum. I'm using 6N138.

Please check, if the schema I drown is correct or not, and please tell what value should the RL resistor take. On page 6 from the 6N138 datasheet I know that it depends on output, but which one is mine?

6N138.pdf (299 KB)

Yes, think that's viable - the device's Vcc is limited to 7V so you need that voltage divider (make it divide to 5V, not 7V, BTW, 7V is the absolute maximum (we don't go there!)). I think a 10k resistor will be fine on the input, it claims 0.5mA drive doesn't it?

MarkT,
you're absolutely right, thanks for the suggestions.

But can you please tell me something about that RL resistor between Vcc and Vo?

Well its limiting the current to the main transistor's base, so it should be appropriate for that I guess.

OK, so now its clear for me :wink:
For those who want to know something about RL: this resistor's value should be appropriate to give enough current to the transistors base. You should choose it carefully, because too much current can damage transistors base!

Today I went to the lab to check the DC motor parameters and to test the circuit.

I wrote down the motor serial numbers - I wasn't able to access the internet to check the parameters, so I assumed that the collector current will be smaller than 1,5A. I used BD135 transistor, with a proper resistor in front of its base. Then I've turned the power supply on and the motor stared rotating, even when there was no signal from the Arduino!

I disconnected the circuit and I've measured the current flowing through the motor in a basic circuit which contained only the motor and power supply - nothing else. The ammeter showed 11,6mA! The power supply voltage was 9,3V, so the power of the motor should be about 0,1W!

I realised that there can be something wrong with the transistor so I've changed it to BC547B which max Ic = 100mA. After that, the PWM control from Arduino worked, but the motor rotated VERY slowly. I've checked the current flowing through the motor and it was only about 4,6mA!

What is wrong?

6N138.pdf (299 KB)

16N28_motor.pdf (261 KB)

projekt_polaczenia_v1.3_bb.jpg