Labs / Electronic modules

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.4 · License: CC BY 4.0 · Driver code (motor_drivers/opto_mos_driver): MIT License

Contents
GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)
GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

I. Module Introduction

Optocoupler-isolated MOSFET single-motor drive module uses the optocoupler EL817S to realize electrical isolation between the control signal and the power circuit, and drives a single motor with the help of MOS FET IRFR9024N; the module is equipped with VIN power input and VOUT power output interfaces, the CONTROL pin receives the control signal, and after optocoupler isolation, it controls the on-off of the MOS FET to drive the motor;It is also equipped with an indicator light composed of + 5V power supply, a resistor R5 and LED1 to display the working status; the power supply stability is ensured by filter capacitors (such as C2, C3), which not only enhances the anti-interference capability between the control circuit and the motor drive circuit, but also protects the front-end control equipment, making it suitable for safe drive scenarios of a single motor.

For this module, the VIN maximum voltage is recommended to be ≤55V (limited by the withstand voltage of the MOS tube), and the maximum continuous current is recommended to be ≤6.8A (limited by the current-carrying capacity and heat dissipation conditions of the MOS tube).

II. Introduction to Main Chips

The core chip of this module is EL817S optocoupler.

2.1 Chip Overview

EL817S The optocoupler is a transistor-output photoelectric coupler in 4-pin DIP/SMD packages, composed of an infrared light-emitting diode and a photosensitive transistor optocoupler. It features an input-output isolation voltage of up to 5000Vrms, a creepage distance >7.62mm, a current transfer ratio (CTR) ranging from 50% to 600%(at IF= 5mA, VCE= 5V), an operating temperature range of -55°C to + 110°C, and complies with RoHS as well as certifications including UL and VDE.It can realize isolated signal transmission between circuits with different potentials/impedances, and is suitable for scenarios such as programmable controllers, measuring instruments, and household appliances.

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

2.2 Pin Definition

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)
Pin numberNameDirectionFunction description
1AInputOptocoupler LED anode, connected to the control signal through current-limiting resistor R3.
2CInputOptocoupler LED cathode, connected to PGND.
3EOutputPhototransistor emitter, connected to system GND.
4COutputPhototransistor collector, connected to the MOSFET gate voltage divider network.

2.3 Functional Block Diagram

EL817S The internal functional block diagram is as follows:

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

2.4 Performance Parameters

2.4.1 Absolute Parameters

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

This table presents the absolute maximum ratings for the EL817S optocoupler at an ambient temperature of 25°C, which specify the limiting operating conditions for all dimensions of the device, as interpreted below:

When designing an application, the actual operating parameters must be strictly lower than these rated values; otherwise, device damage or reduced reliability may result.

2.4.2 Photoelectric Characteristic Parameters

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

The electro-optical characteristic parameters of EL817S optocoupler at ambient temperature of 25 ℃ are classified and interpreted as follows:

These parameters directly determine the device's drive matching, signal transmission efficiency and safe Scope of Work, and serve as the core reference for ensuring performance and reliability in circuit design.

2.4.3 Conversion Characteristics

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

EL817S The transmission characteristic parameters of the optocoupler at an ambient temperature of 25°C can be interpreted from the dimensions of "current transfer, saturation voltage drop, isolation performance, high-frequency characteristics, switching speed", etc. :

These parameters define the transmission characteristics of optocouplers in terms of aspects such as "energy conversion efficiency", "electrical isolation capability", and "high-frequency/switching performance", serving as the core basis for matching signal rate, power consumption and isolation requirements in circuit design.

2.4.4 Photoelectric Characteristic Curve

These characteristic curves, from the dimensions of temperature, current, and load and other aspects, reveal the performance variation law of the EL817 optocoupler, which has important guiding significance for circuit design:

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)
GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)
GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)
GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

These curves quantify the variations of the "electro-optical conversion - signal transmission - switching characteristics" of the EL817 with external conditions, and serve as the core basis for "matching driving parameters, estimating temperature influence, and optimizing switching speed" in circuit design.

2.5 Reference Circuit

None.

2.6 Chip Configuration

None.

None.

2.8 PCB Routing Precautions

None.

III. Circuit Engineering

3.1 Circuit Source Engineering

To obtain the circuit source project, please follow the official account [Freak Embedded]

3.2 Module Usage Instructions

The schematic diagram of this module is shown below:

SCH_Optocoupler-Isolated MOSFET Single Motor Driver Module_v1.1_2025-10-10.pdf 2.1 MB

This module uses digital input DOUT for control: when the input is high, the Light Emitting Diode inside the EL817S optocoupler is turned on to emit light, so that the side of the photosensitive transistor is turned on, and then the gate of the MOS tube IRFR9024NTRPBF provides a driving current, so that the MOS tube is turned on, and a path is formed between VIN and VOUT to power the motor and other loads; when the input is low, the optocoupler stops working, and the MOS tube is turned off because the gate has no driving current, cutting off the power supply circuit from VIN to VOUT .

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

From the perspective of schematic analysis, the circuit can be divided into the core driving and isolation section, the auxiliary function section. In the core section, the optocoupler U2 realizes electrical isolation between the control signal and the power loop, preventing interference from the power side from entering the control side;the MOS transistor Q1, acting as a power switch, is responsible for switching on and off the power supply from VIN to VOUT;the SS34 diode provides freewheeling protection for inductive loads (such as motors), while R1 and R2 respectively provide pull-up and drive current limiting for the gate of the MOS transistor.

In the auxiliary section, the power input interface U4 and output interface U3 complete the connection and output of the power supply; the control signal interface U5 together with the filter capacitor C1 ensures the stable input of the external DOUT control signal; the indicator light LED1 realizes visualization of the working state through current limiting via R5; the filter circuit composed of C2 and C3 filters out the ripple of the + 5V power supply;R4 is a 0Ω resistor used to connect PGND and GND to eliminate ground potential difference interference and unify the ground potential of the circuit.The overall design not only achieves the safety of electrical isolation through optocouplers, but also realizes high-efficiency switching driving for the load by means of MOS tubes.

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and connect the optocoupler-isolated MOSFET single-motor drive module to communicate with the main controller via the DIO interface.

Here, we first use the HY2.0-4P connection cable to connect the module to the GraftPort-RP2040 development board's DIO0 interface:

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

The module connections are shown in the following table:

development board pins

Module Pins

Description

Pin 6

DOUT

MCU outputs PWM waveforms

Pin 7

NC

-

-

VIN Terminal +

Power Supply +

-

VIN Terminal -

Power Supply -

-

VOUT terminal

motor

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

Enter opto_mos_driver to search, and the following will be displayed:

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

Click to copy the local installation command:

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

Here, we can import the module driver library code via the mip tool. Below are the usage commands for the mpremote tool:

mpremote mip install github:FreakStudioCN/GraftSense-Drivers-MicroPython/motor_drivers/opto_mos_driver

After importing the optocoupler-isolated MOSFET single-motor driver module - MicroPython driver code, copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2025/8/22 9:42 AM
# @Author  : 缪贵成
# @File    : main.py
# @Description : Optocoupler-isolated MOS single motor driver test file

# ======================================== Import Modules =========================================

import time
from machine import Pin, PWM
from opto_mos_simple import OptoMosSimple

# ======================================== Global Variables =============================================

# ======================================== Functions =============================================

# ======================================== Custom Classes =============================================

# ======================================== Initialization configuration ===========================================

#Power-on delay
time.sleep(3)
print("FreakStudio:  OptoMosSimple Test Start ")
# Create a PWM object, output on GPIO6
pwm = PWM(Pin(6))
# Set PWM frequency to 1kHz
pwm.freq(1000)
print("PWM object created on Pin 6 with 1kHz frequency.")

# Create driver instance
driver = OptoMosSimple(pwm)
print("Driver object created.")

# Initialize the driver
driver.init()
print("[init] Initialized ->", driver.get_status())

# ======================================== Main Program ===============================================

# Test the set_duty method
print("[set_duty] Set duty=10000")
driver.set_duty(10000)
print("Status:", driver.get_status())

print("[set_duty] Set duty=70000 (out of range, auto clipped)")
driver.set_duty(70000)
print("Status:", driver.get_status())

# Test the set_percent method
print("[set_percent] Set 25% duty cycle")
driver.set_percent(25.0)
print("Status:", driver.get_status())

print("[set_percent] Set 150% duty cycle (out of range, auto clipped)")
driver.set_percent(150.0)
print("Status:", driver.get_status())

# Test the full_on method
print("[full_on] Full ON")
driver.full_on()
print("Status:", driver.get_status())
time.sleep(5)

# Test the off method
print("[off] Turn OFF")
driver.off()
print("Status:", driver.get_status())
time.sleep(10)

# Test inverted mode (create a new PWM object)
print("[inverted] Testing inverted mode")
pwm_inv = PWM(Pin(16))  # Use a different GPIO to avoid conflict with the driver
pwm_inv.freq(1000)
driver_inv = OptoMosSimple(pwm_inv, inverted=True)
driver_inv.init()
driver_inv.set_percent(30.0)
print("Inverted 30% ->", driver_inv.get_status())
driver_inv.full_on()
print("Inverted full_on ->", driver_inv.get_status())
driver_inv.off()
print("Inverted off ->", driver_inv.get_status())

# Release the resource
print("[deinit] Release resources")
driver.deinit()
driver_inv.deinit()
print("PWM released.")

print("=== OptoMosSimple Test End ===")

To flash the code, open a terminal and use the mpremote tool to connect to the main controller; the output is as follows:

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)

The microcontroller sends a control signal to the module, which triggers after optocoupler isolation MOS tube to turn on; after the motor is powered on and runs for 5 seconds, MOS tube turns off, and the motor stops immediately.

IV. Drivers

opto_mos_driver.zip 9 KB

None.

VI. Revision History

Document Version

Revision Date

Modifier

Revised Content

v1.0

2025-08-31

Xing Gao

Initialize Document

v1.1

2025-09-21

Li Zisheng

Added 2.8 PCB routing precautions

Revised Section 3, Instructions for Circuit Source Project and Module Usage, and added a secondary heading:

3.1 Circuit Source Engineering, 3.2 Module Usage Instructions, 3.3 Application Experiments

The BOM sheet has not been finally checked, the driver has not been re-verified, and the 3.3 application experiment

Not yet specified.

v1.2

2025-12-29

Li Zisheng

Added application experiments and production files

v1.3

2025-12-31

Sin Ruili

Create an open version of the document based on the internal document version v1.2.

v1.4

2026-03-29

Sin Ruili

Modified the application experiment section

VII. Relevant Materials

7.1 Chip Datasheet

EL817S1(C)(TU)-G Datasheet.pdf 1.1 MB

7.2 PCB Silkscreen Specific Icons

GraftSense - Optocoupler Isolated MOSFET Single Motor Driver Module (Open Version)