MATLAB: Using matlab support package for arduino with any motor shield

arduinoelectric_motor_controlpower_electronics_control

I have an L298N motor shield that I wish to use to drive a DC motor with the help of the MATLAB support package for arduino (NOT the Simulink support package). Browsing on the internet for an example code, all I've found are examples using the ADAFRUIT MOTOR SHIELD which is not the motor shield I would like to use. So my question is, is it possible to drive a DC motor directly in MATLAB without any DC motor shield on the market other than the ADAFRUIT MOTOR SHIELD ? If yes please help me with an example code.

Best Answer

Hi Derick,
From what I find about this L298N motor shield online, it seems to only need digital IO and PWM signal for direction and speed control. To drive it in MATLAB, simply replace digitalWrite to writeDigitalPin and analogWrite to writePWMVoltage or writePWMFrequency to convert any existing Arduino examples. Please refer to the MATLAB Documentation for correct input parameters to writeDigitalPin/writePWMVoltage/writePWMFrequency.
Hope this helps.
Thanks,
Menghan