Prev: Write miniSEED Data
Next: MEX straw poll
From: Thilini on 26 May 2010 10:08 "Ankit Desai" <adesai.nospam(a)mathworks.com> wrote in message <hlm73p$5ss$1(a)fred.mathworks.com>... > "adulfo uy" <adz_1718143(a)yahoo.com> wrote in message <hll66f$et2$1(a)fred.mathworks.com>... > > Hi everyone, I am a new one in MATLAB. We have this project involving a load cell and a temperature sensor. The outputs of this two sensors are to be converted to digital and interface to PC (RS232) using matlab for graphing. > > Now, can someone give me an idea on how to alternately get the two data from the serial port and graph it in MATLAB? > > such code samples can help me much. > > Hi Adulfo, > > I have posted an example of live data plotting on MATLAB Central: http://www.mathworks.com/matlabcentral/fileexchange/25519-collect-and-plot-data-from-an-instrument-in-real-time > > The example shows how to query an instrument. > You might want to tweak the code to best fit your need. > > Hope that helps. > > -Ankit I used your code to plot data coming from a "MEMS accelerometer " to a serial port. then I got a error as follows " In an assignment A(I) = B, the number of elements in B and I must be the same. Error in ==> real at 81 voltage(count) = fscanf(serialObject,'%f'); %#ok<SAGROW>" Please help me. Further I get about 300 data samples per second , when tested with hyper terminal ( serial watcher). I need to draw the output for at least for 5mins.
From: Thilini on 26 May 2010 10:09 "Ankit Desai" <adesai.nospam(a)mathworks.com> wrote in message <hlm73p$5ss$1(a)fred.mathworks.com>... > "adulfo uy" <adz_1718143(a)yahoo.com> wrote in message <hll66f$et2$1(a)fred.mathworks.com>... > > Hi everyone, I am a new one in MATLAB. We have this project involving a load cell and a temperature sensor. The outputs of this two sensors are to be converted to digital and interface to PC (RS232) using matlab for graphing. > > Now, can someone give me an idea on how to alternately get the two data from the serial port and graph it in MATLAB? > > such code samples can help me much. > > Hi Adulfo, > > I have posted an example of live data plotting on MATLAB Central: http://www.mathworks.com/matlabcentral/fileexchange/25519-collect-and-plot-data-from-an-instrument-in-real-time > > The example shows how to query an instrument. > You might want to tweak the code to best fit your need. > > Hope that helps. > > -Ankit I used your code to plot data coming from a "MEMS accelerometer " to a serial port. then I got a error as follows " In an assignment A(I) = B, the number of elements in B and I must be the same. Error in ==> real at 81 voltage(count) = fscanf(serialObject,'%f'); %#ok<SAGROW>" Please help me. Further I get about 300 data samples per second , when tested with hyper terminal ( serial watcher). I need to draw the output for at least for 5mins.
From: Ankit Desai on 26 May 2010 14:44 "Thilini " <thivijaya(a)gmail.com> wrote in message <htja20$808$1(a)fred.mathworks.com>... > "Ankit Desai" <adesai.nospam(a)mathworks.com> wrote in message <hlm73p$5ss$1(a)fred.mathworks.com>... > > "adulfo uy" <adz_1718143(a)yahoo.com> wrote in message <hll66f$et2$1(a)fred.mathworks.com>... > > > Hi everyone, I am a new one in MATLAB. We have this project involving a load cell and a temperature sensor. The outputs of this two sensors are to be converted to digital and interface to PC (RS232) using matlab for graphing. > > > Now, can someone give me an idea on how to alternately get the two data from the serial port and graph it in MATLAB? > > > such code samples can help me much. > > > > Hi Adulfo, > > > > I have posted an example of live data plotting on MATLAB Central: http://www.mathworks.com/matlabcentral/fileexchange/25519-collect-and-plot-data-from-an-instrument-in-real-time > > > > The example shows how to query an instrument. > > You might want to tweak the code to best fit your need. > > > > Hope that helps. > > > > -Ankit > > > I used your code to plot data coming from a "MEMS accelerometer " to a serial port. then I got a error as follows > " In an assignment A(I) = B, the number of elements in B and > I must be the same. > > Error in ==> real at 81 > voltage(count) = fscanf(serialObject,'%f'); %#ok<SAGROW>" > > Please help me. > > Further I get about 300 data samples per second , when tested with hyper terminal ( serial watcher). I need to draw the output for at least for 5mins. Hi Thilini, The error indicates that you might be getting more than one value in your fscanf call. Check this for example. In MATLAB try the following: >> voltage = 0; >> voltage(1) = [1, 2, 3] ??? In an assignment A(I) = B, the number of elements in B and I must be the same. As you can see the error is the same you are seeing. Since the demo initializes the voltage value to 0, you cannot assign an array to voltage(n). The demo is written such that each call to fscanf will return one floating point value, and hence a %f flag to fscanf. You might want to configure the device to send you one value at a time. Hope this helps, -Ankit
From: Thilini on 27 May 2010 08:38 "Ankit Desai" <adesai.nospam(a)mathworks.com> wrote in message <htjq5m$4ee$1(a)fred.mathworks.com>... > "Thilini " <thivijaya(a)gmail.com> wrote in message <htja20$808$1(a)fred.mathworks.com>... > > "Ankit Desai" <adesai.nospam(a)mathworks.com> wrote in message <hlm73p$5ss$1(a)fred.mathworks.com>... > > > "adulfo uy" <adz_1718143(a)yahoo.com> wrote in message <hll66f$et2$1(a)fred.mathworks.com>... > > > > Hi everyone, I am a new one in MATLAB. We have this project involving a load cell and a temperature sensor. The outputs of this two sensors are to be converted to digital and interface to PC (RS232) using matlab for graphing. > > > > Now, can someone give me an idea on how to alternately get the two data from the serial port and graph it in MATLAB? > > > > such code samples can help me much. > > > > > > Hi Adulfo, > > > > > > I have posted an example of live data plotting on MATLAB Central: http://www.mathworks.com/matlabcentral/fileexchange/25519-collect-and-plot-data-from-an-instrument-in-real-time > > > > > > The example shows how to query an instrument. > > > You might want to tweak the code to best fit your need. > > > > > > Hope that helps. > > > > > > -Ankit > > > > > > I used your code to plot data coming from a "MEMS accelerometer " to a serial port. then I got a error as follows > > " In an assignment A(I) = B, the number of elements in B and > > I must be the same. > > > > Error in ==> real at 81 > > voltage(count) = fscanf(serialObject,'%f'); %#ok<SAGROW>" > > > > Please help me. > > > > Further I get about 300 data samples per second , when tested with hyper terminal ( serial watcher). I need to draw the output for at least for 5mins. > > Hi Thilini, > > The error indicates that you might be getting more than one value in your fscanf call. > Check this for example. In MATLAB try the following: > > >> voltage = 0; > >> voltage(1) = [1, 2, 3] > ??? In an assignment A(I) = B, the number of elements in B and > I must be the same. > > As you can see the error is the same you are seeing. Since the demo initializes the voltage value to 0, you cannot assign an array to voltage(n). > > The demo is written such that each call to fscanf will return one floating point value, and hence a %f flag to fscanf. > > You might want to configure the device to send you one value at a time. > > Hope this helps, > > -Ankit Thanks for the reply. I cannot configure the hardware to get less than 1500 bytes per second. If there is a way to handle this data rate pls let me know.
From: Ankit Desai on 29 May 2010 18:05 "Thilini " <thivijaya(a)gmail.com> wrote in message <htlp3d$f94$1(a)fred.mathworks.com>... > "Ankit Desai" <adesai.nospam(a)mathworks.com> wrote in message <htjq5m$4ee$1(a)fred.mathworks.com>... > > "Thilini " <thivijaya(a)gmail.com> wrote in message <htja20$808$1(a)fred.mathworks.com>... > > > "Ankit Desai" <adesai.nospam(a)mathworks.com> wrote in message <hlm73p$5ss$1(a)fred.mathworks.com>... > > > > "adulfo uy" <adz_1718143(a)yahoo.com> wrote in message <hll66f$et2$1(a)fred.mathworks.com>... > > > > > Hi everyone, I am a new one in MATLAB. We have this project involving a load cell and a temperature sensor. The outputs of this two sensors are to be converted to digital and interface to PC (RS232) using matlab for graphing. > > > > > Now, can someone give me an idea on how to alternately get the two data from the serial port and graph it in MATLAB? > > > > > such code samples can help me much. > > > > > > > > Hi Adulfo, > > > > > > > > I have posted an example of live data plotting on MATLAB Central: http://www.mathworks.com/matlabcentral/fileexchange/25519-collect-and-plot-data-from-an-instrument-in-real-time > > > > > > > > The example shows how to query an instrument. > > > > You might want to tweak the code to best fit your need. > > > > > > > > Hope that helps. > > > > > > > > -Ankit > > > > > > > > > I used your code to plot data coming from a "MEMS accelerometer " to a serial port. then I got a error as follows > > > " In an assignment A(I) = B, the number of elements in B and > > > I must be the same. > > > > > > Error in ==> real at 81 > > > voltage(count) = fscanf(serialObject,'%f'); %#ok<SAGROW>" > > > > > > Please help me. > > > > > > Further I get about 300 data samples per second , when tested with hyper terminal ( serial watcher). I need to draw the output for at least for 5mins. > > > > Hi Thilini, > > > > The error indicates that you might be getting more than one value in your fscanf call. > > Check this for example. In MATLAB try the following: > > > > >> voltage = 0; > > >> voltage(1) = [1, 2, 3] > > ??? In an assignment A(I) = B, the number of elements in B and > > I must be the same. > > > > As you can see the error is the same you are seeing. Since the demo initializes the voltage value to 0, you cannot assign an array to voltage(n). > > > > The demo is written such that each call to fscanf will return one floating point value, and hence a %f flag to fscanf. > > > > You might want to configure the device to send you one value at a time. > > > > Hope this helps, > > > > -Ankit > > > Thanks for the reply. > I cannot configure the hardware to get less than 1500 bytes per second. If there is a way to handle this data rate pls let me know. Hi Thilini, You can initialize the variable with a size of 1500 and with each iteration read 1500 bytes using the bytesavailablefcn. Check this demo: http://www.mathworks.com/matlabcentral/fileexchange/27290-collect-and-plot-data-from-a-tcpip-server-in-real-time You can use a similar logic. Hope this helps -Ankit
|
Pages: 1 Prev: Write miniSEED Data Next: MEX straw poll |