Page 1 of 1

Communication between Matlab API and Simulink

Posted: Thu Oct 01, 2020 10:28 am
by QiangPITT
Hello!

Could you offer me some suggestions to get other sensor measures into the Matlab API control loop for real-time control? Like how to feedback EMG data to design the X-series motor controller. I know all the X-series motor control and feedback are within the same Matlab code, which is not applicable to collect other sensors data like using DAQ board.
Thanks a lot.

Re: Communication between Matlab API and Simulink

Posted: Thu Oct 01, 2020 8:35 pm
by dave_rollinson
Qiang,

We have done some demos using EMG sensors before, sending the amplified signals to an I/O Board:


In the video above we used the analog voltage input on the I/O board to read the EMG sensor, a MyoWare Muscle Sensor. Based on that analog signal you can design controllers in Matlab of varying complexity. The video above was just a simple velocity control with some thresholding. You could do similar things with torque and I think get some interesting results.

Code: Select all

while true
    fbk = emgSensorGroup.getNextFeedbackIO();
    cmd.velocity = max( emgSensorGain * (fbk.a1-emgSensorOffset), 0 );
    cmdGroup.send(cmd);
end
Hope this helps!
-Dave

Re: Communication between Matlab API and Simulink

Posted: Tue Oct 06, 2020 7:59 pm
by QiangPITT
Thanks a lot. This demo is really interesting and helpful.
Here is one of my another question: I am using the SpeedGoat target machine (running in Simulink) to collect EMG data and joint encoder data, and in order to control the motor in real-time, I need to transfer the live sensor data from Simulink to Matlab API, which is really painful for me. Would you please offer me some suggestions for the data transfer between Simulink and the Matlab API? Or would you please tell me do you have some Simulink API support for the motor control?
I really appreciate your help.

Re: Communication between Matlab API and Simulink

Posted: Fri Oct 09, 2020 6:07 am
by florian_enner
Simulink targets are unfortunately really limited, so it's not possible for us to create a real Simulink API.

If you can't use an I/O board as Dave mentioned, you would need to send the Simulink data to your MATLAB instance via a UDP block.