How do I pass Sensor Data to a GUI?

4 visualizzazioni (ultimi 30 giorni)
Martin Velasquez
Martin Velasquez il 18 Mar 2019
Modificato: Akshay Khadse il 27 Mar 2019
I'm trying to create a GUI that simply plots , or shows in a gauge, what the speed of a Dc motor is. My only problem is that I don't exactly know how to pass it to a GUI function.
So I've created these objects for arduino, the shield library and the dcmotor.
I can set/read the speed, as well as plot it by using a while loop that goes on from 1 -1000, setting axis auto and the drawnow feature.
Now my problem is just doing this in the appdesigner. Now of course a "ValueChangingFcn" should be used, my only problem is passing these parameters to the app designer.
Should I set a property? make a function with the code shown below? start from scratch (i.e uicontrol, uislider..etc..)?
%taken from another post, but works well for me
while (t<interv)
axis auto
grid on
drawnow limitrate

Risposte (1)

Akshay Khadse
Akshay Khadse il 27 Mar 2019
Modificato: Akshay Khadse il 27 Mar 2019
You could directly set the Value property of the Gauge in a MATLAB App. In my opinion, this is the simplest way to pass the data to a GUI designed using MATLAB App Designer.
Assuming that you have a variable named motorSpeed, you can create a simple GUI using MATLAB App Designer named myApp.mlapp as shown below:
This app only has a Guage inside it. The Value property for this Guage is a public property. You just need to have the handle for the app when it is started. Following steps should get you started:
1) Open the app from script or command line using the following command
>> handleApp = myApp
2) Change the Guage Value
>> handleApp.Guage.Value = motorSpeed;
You could do this update whenever you have a new motorSpeed Value.
Please refer the following link to more about sharing data within apps:


Scopri di più su App Building in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by