0

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
asked Oct 15, 2018 at 16:14
4
  • works properly ... then why did you post your question? Commented Oct 15, 2018 at 16:24
  • you do not say what you actually see ..... maybe your plotter is defective Commented Oct 15, 2018 at 16:25
  • it's not plotting, the hardware works properly Commented Oct 15, 2018 at 16:49
  • 2
    It looks like that will just output a long string of numbers. No separators between fields, no separators between records (like: 5678298549328756238746524983759823462938746238974692387463298574369587234658723468734629375605237643724123046503453948765.... How is anything supposed to make sense of the data? Commented Oct 15, 2018 at 16:52

1 Answer 1

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.