The paper is focused on the modeling of a digital twin (DT) through a circuit simulation and artificial intelligence (AI) analysis to determine the effects of disturbances and noise in optocoupler devices integrated into programmable logic controller (PLC) systems. Specifically, the DT analyzes the parametric and the predicted simulations about the sensitivity of the optocouplers versus noise and interference to provide possible corrective actions, compensating for the distortion of the output signal. The model is structured into two main data processing steps: the first is based on the circuit simulation of the optocoupler noise coupling by highlighting the time-domain sensitivity aspects and the frequency behavior of the coupled signals; the second one estimates the predicted disturbed signal by means of supervised random forest (RF) and unsupervised K-Means algorithms to provide further elements to prevent corrective solutions by means of risk maps. This work is suitable for Industry 5.0 scenarios involving machine control supported by AI-based DT platforms. The innovative elements of the proposed model are the DT features of scalability and modularity; the spatial multidimensionality, able to couple the effects of different undesired signals; and the possibility to simulate the whole PLC system, including its control circuits.