Simulink connection to Shimmer Sensors
7 views (last 30 days)
Show older comments
Hello,
I recently started using the "Shimmer" wearable sensor plattform. I started using the Shimmer MATLAB Instrument Driver to acquire data from the different sensors. Now I would like to use Simulink Desktop Real-Time to acquire and plot sensor data in realtime in Simulink.
I tried to use a "Matlab Function"-Block in my Simulink Model for the data acquisition.
To Initialize the sensor I used the InitFcn of the "Matlab Function"-Block:
ComPortNo = '11';
shimmer = ShimmerHandleClass(ComPortNo);
SensorMacros = SetEnabledSensorsMacrosClass;
if (shimmer.connect)
disp('Shimmer Connected...')
shimmer.setsamplingrate(512);
shimmer.setinternalboard('9DOF');
shimmer.disableallsensors;
shimmer.setenabledsensors(SensorMacros.MAG,1);
shimmer.setaccelrange(0);
shimmer.setbattlimitwarning(3.4);
if (shimmer.start)
disp('Shimmer Started...')
end
end
As you see the variable "shimmer" is an object-handle.
Now I would like to use this handle within the "Matlab-Function"-Block to use its method
function y = fcn(u)
newData = shimmer.getdata('c');
...
during each Simulation step to get new data from the sensor-buffer. I already tried to make the variable "shimmer" global but I still could not use the handle. I barely used Matlab-Functions within Simulink so i've got no clue what I would have to do.
Maybe anybody can help me with my problem?
thanks in advance Dennis
0 Comments
Answers (0)
See Also
Categories
Find more on Block Libraries in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!