I'm trying to upload this code and it works properly but I can't see anything on my serial plotter
const int AnalogIn_Pin0= A0;
const int AnalogIn_Pin1=A1;
const int Pwmout_PIN=11;
float AnalogIn_Val0=0;
float AnalogIn_Val1=0;
int Pwmout_Val=0;
float Error=0;
float ErrorInteg=0;
float Control=0;
float ControlFilt=0;
float kp=0.2;
float Pole =-10;
float Ki =0.01;
int deltaT=0.01;
int deltaT_ms=(int)deltaT*1000;
void setup() {
pinMode (Pwmout_PIN,OUTPUT);
Serial.begin (9600);
}
void loop() {
AnalogIn_Val0=(float)constrain (analogRead(AnalogIn_Pin0),0,600);
AnalogIn_Val1=0.97*AnalogIn_Val1+0.03*(float)analogRead(AnalogIn_Pin1);
Error= (AnalogIn_Val0-AnalogIn_Val1);
ErrorInteg=ErrorInteg+Error*deltaT;
ControlFilt=kp*Error+Ki *ErrorInteg;
Pwmout_Val= constrain (map ((int)ControlFilt,0,1023,0,255),0,220);
analogWrite (Pwmout_PIN,Pwmout_Val);
Serial.print(AnalogIn_Val0);
Serial.print("");
Serial.print(AnalogIn_Val1);
Serial.print("");
Serial.print( Pwmout_Val);
delay (deltaT_ms);
}
jsotola
1,5342 gold badges12 silver badges20 bronze badges
1 Answer 1
You must have each set of data point (or points) on a separate line and if you are plotting more that one value you need a space or a tab between each value.
So to have 3 lines on your plot, I think you want this:
Serial.print(AnalogIn_Val0);
Serial.print(' ');
Serial.print(AnalogIn_Val1);
Serial.print(' ');
Serial.println(Pwmout_Val);
The output in the serial monitor should be something like this:
123 456 789
234 567 901
...
answered Oct 15, 2018 at 19:21
lang-cpp
works properly
... then why did you post your question?5678298549328756238746524983759823462938746238974692387463298574369587234658723468734629375605237643724123046503453948765...
. How is anything supposed to make sense of the data?