Why serial plotter is looking like this? How to resolve?

4 件のコメント

Walter Roberson
Walter Roberson 2023 年 1 月 9 日
Please post a link to matlab function you are using. Mathworks does not supply any serial plotter. There are a few serial plotters in the file exchange, but they do not look like that.
Technical
Technical 2023 年 1 月 9 日
int analogPin = A3;
int Rawval ; // variable to store the value read
int Scaleval ;
int RELAY_pin = 10; // Relay is connected to pin D10
void setup()
{
Serial.begin(9600); // setup serial
pinMode(RELAY_pin, OUTPUT);
}
void loop()
{
int Rawval = analogRead(analogPin);
Serial.print("Rawvalue from Analog input =");
Serial.print(Rawval);
// For 3V3 input to read 100%, 3V3 of 5V ref
// = (3.3 / 5) * 1023 = 675
Scaleval = map(Rawval, 0, 675, 0, 20);
Serial.print(" Scaled Value =");
Serial.println(Scaleval);
Technical
Technical 2023 年 1 月 9 日
How to visualize the data using this code?
Walter Roberson
Walter Roberson 2023 年 1 月 9 日
That is not matlab code and does not do any plotting. You asked about a specific serial data plotting routine, but to answer that question we need to know which MATLAB-based plotting routine you are using.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 1 月 10 日

0 投票

After you have created a serialport object and configured it appropriate,
s = readline(PORT);
values = sscanf(S, 'Rawvalue from Analog input =%f Scaled Value =%f');
rawvalue = values(1);
scaledvalue = values(2);
After that you could plot the appropriate value, such as by using animatedline and addpoints

カテゴリ

ヘルプ センター および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

質問済み:

2023 年 1 月 9 日

回答済み:

2023 年 1 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by