Communication between Matlab API and Simulink

X-Series and R-Series Actuators
Post Reply
User avatar
QiangPITT
Posts: 9
Joined: Thu Oct 01, 2020 9:41 am

Communication between Matlab API and Simulink

Post by QiangPITT » Thu Oct 01, 2020 10:28 am

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.
User avatar
dave_rollinson
HEBI Official
Posts: 41
Joined: Tue Dec 31, 2019 11:58 am

Re: Communication between Matlab API and Simulink

Post by dave_rollinson » Thu Oct 01, 2020 8:35 pm

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
User avatar
QiangPITT
Posts: 9
Joined: Thu Oct 01, 2020 9:41 am

Re: Communication between Matlab API and Simulink

Post by QiangPITT » Tue Oct 06, 2020 7:59 pm

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.
User avatar
florian_enner
HEBI Official
Posts: 33
Joined: Wed Mar 25, 2020 11:31 am
Location: Austria

Re: Communication between Matlab API and Simulink

Post by florian_enner » Fri Oct 09, 2020 6:07 am

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.
Post Reply