Home › Forums › UM7 Product Support › Matlab Communication
This topic contains 8 replies, has 2 voices, and was last updated by Daniel Piedrahita 1 year, 4 months ago.
-
AuthorPosts
-
June 8, 2015 at 8:54 am #758
ThomasHi,
I want to read data from the UM7 from Matlab. I used the example code and just tried to run the init.m, this is what i get in Matlab2014:
Undefined function or variable “got_temperature_data”.
Error in DUT_callback (line 73)
if got_temperature_data && got_gyro_dataError in instrcb (line 36)
feval(val{1}, obj, eventStruct, val{2:end});Warning: The BytesAvailableFcn is being disabled. To enable the callback property
either connect to the hardware with FOPEN or set the BytesAvailableFcn property.What can I do to make it work? Unfortunately I don’t have any experience in serial communication with Matlab yet. Thanks in advance!
-
August 15, 2015 at 8:47 pm #838
Manish MittalI also have exactly the same query. Please reply as it is very necessary for my thesis work that I am doing.
-
August 17, 2015 at 12:51 pm #842
The Matlab script that can be downloaded from the site is a snippet designed to illustrate how to use serial port callbacks to read and parse data for the UM7, from within Matlab. You can delete the references to got_temperature_data and got_gyro_data.
Basically, the serial callback function reads bytes in from the serial port and parses them. When a packet is received, you can check the packet type and address bytes to see if it is the data that you are interested in. If it is, you can log it, or set a flag (like got_temperature_data), or whatever you want to do with it.
-
August 23, 2015 at 8:48 pm #862
Manish MittalCan you please write an example code to get the euler angel from the orientation sensor? It would be really helpful.
-
August 23, 2015 at 9:13 pm #863
Manish MittalI got to communicate with UM6 using MATLAB. Can you please tell me the address for the Euler angle data packet?
-
August 24, 2015 at 9:31 am #864
Sure, the Euler Angle data begins in register 112 (0x70). You can find that information in the datasheet, here: http://www.chrobotics.com/docs/UM7_Datasheet.pdf
-
November 7, 2015 at 9:50 pm #983
Manish MittalHi Caleb,
I was able to get the Euler Angle Data from the sensor using the MATLAB example code written by you. Now I want to store it in a variable matrix so that I can use it for further calculations. I used the Userdata attribute of the callback. function object to store the data. I did something like:
gyro_x = typecast( flipud(uint8(packet.data(1:2))), ‘int16’ )/100;
gyro_y = typecast( flipud(uint8(packet.data(3:4))), ‘int16’ )/100;
gyro_z = typecast( flipud(uint8(packet.data(5:6))), ‘int16’ )/100;h1 = [gyro_x, gyro_y, gyro_z];
h = [h; h1; h1]
obj.Userdata = h;I thought that it would return an ever-increasing (number of rows will continuously increase storing the real time data) matrix with the gyro_x, gyro_y, gyro_z values. But the Userdata matrix has just one row which contains the latest values of the three variables. Its like its just updating the last row after each loop run. I am not sure if I am doing anything wrong. Can you please tell me know if there is anything wrong or if there is any other way to store the real time data from the callback function in the base workspace for later usage.
-
November 7, 2015 at 9:52 pm #984
Manish MittalActually it is just
h = [h; h1]; (and not h = [h; h1; h1];)
Please suggest.
-
November 28, 2016 at 8:27 pm #1722
Daniel PiedrahitaHi Manish,
You mentioned that you were able to get the Euler Angle Data from the sensor into Matlab. Would you mind sharing your code? I am working on a similar problem now. Any help would be much appreciated.
Thanks,
Daniel
-
-
AuthorPosts
You must be logged in to reply to this topic.