The MathWorks File Exchange entry called " Getting Started AUVSI " has examples showing how to run MATLAB and Simulink on a PC in soft real-time.
- In MATLAB, you would use timer objects which execute callback functions at user specified rates.
- In Simulink, the "Real-Time Synchronization" in Windows with Real-Time Windows Target will make Simulink models run in soft real-time.
To acquire video from a USB camera, use the Image Acquisition Toolbox's imaq.VideoDevice method in MATLAB and the "From Video Device" block in Simulink.
vidobj = imaq.VideoDevice('winvideo', 1);
function mytimercallback(~,~)
frame = step(vidobj);
// perform image processing on frame
end
-
To communicate using Serial/UDP/TCPIP to other hardware, you can use the Instrument Control Toolbox's communication methods and blocks.
s = serial('COM26'); // initialize serial object buffer
fread(s,1); // read 1 byte from the serial port buffer
fwrite(s,22); // transmit 1 byte, 22, to the serial port
-
For more information, feel free to reply to this post or take a look at the following resources: