isolating the arduino output via optocopler

Hello I'm developing a project to school which I want to activate a motor via PWM signal but I want isolate the arduino output with a optocopler just in case of preventing a possible damage to arduino board. Does anyone have a circuit with a optocopler and a relay or a transistor?

Relays and PWM don’t normally work together… they do make nice sounds before breaking though. :slight_smile:

Optocouplers can be a problem depending on the frequency you choose to control your motor. Normally PWM frequencies for motors tend to be somewhat high, whilst commuting frequencies for optos (the cheaper kind) aren’t. Not that it is impossible, it is more expensive and maybe difficult to locate the parts.

So, you could control the motor with a power driver L298, 293, something like that, or go with transistors. Both of which have plenty of schematics around the internet.

Here's an opto that's pretty quick. Drive the input side by bringing the cathode low (so that the transistor is off when the arduino starts up). Be sure to use a series current limit resistor to avoid arduino pin damage. Use the Collector to drive a motor drive transistor for some real current flow.

Did you think 4N26 will do the job? I found on ebay for a nice price

Did you think 4N26 will do the job?

What job you haven't given any details of what you want to do and what circuit you want to use it in.

I want isolate the arduino pins(digital for motor or pwm to more small things)to prevent a possible damage , since I want to control some real motor 230V. the circuit is a simple resistor conected to an optocopler, and on the other side I want connect a relay to activate the motor.Of course I wont connect the relay directly to the opto transistor output since the relay will destroy it.I was thinking make a stage with another transistor to deal the current of the relay and the base of this transistor conected to the output of the optocopler, but this is the main idea. Did you think this is ok? will the 4N26 works?

You said:-

I want to activate a motor via PWM signal

You can't control a mains motor with PWM.

If you are using a relay you don't need an opto isolator.

If you are having to ask these questions you are not ready to play with mains.

do you just want to turn a motor on or off ? Or do you want to do some sort of speed control ? You project is a little confusing. Yes that opto isolator will be OK for use in a circuit that simply switches a motor on or off. No it wont be any good to use with a PWM signal then a relay to speed control a motor as speed control, mainly due to the relay.