Microcontroller with GPIO, ADC and DAC Connections
This example shows how to model the interface between a microcontroller unit (MCU) and a physical system. Here the microcontroller's GPIO, ADC and DAC connections are used to control a DC motor and connected load with limited angle travel. Load angle measurement is via a potentiometer sensor. This measurement is calibrated by initially ramping the rotor position until the photodiode detects the zero-angle light pulse from the LED. Once calibrated the MCU commands a 0.1Hz 45 degree amplitude sinusoid.
GPIO 1 Subsystem
Motor Driver Subsystem
Simulation Results from Simscape Logging
The plot below shows the performance of the motor control system. At the start of simulation, the controller spins the motor until it finds a known position of the motor shaft (0 degrees). After that, the controller tracks the reference signal.