Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Serial monitor erratic separation issue

  1. #1

    Serial monitor erratic separation issue

    Hello,

    I have a sketch running on a Teensy 3.2 and sending data to the USB port (used in serial mode). I check the data on the Arduino IDE with the serial monitor / serial tracer.

    My data are basically 12-bit ADC measurements from sliders with a bit of filtering. So I do not expect values outside the 0-4095 range.

    Here's the code:

    Code:
    #include "MeanFilterLib.h"
    
    int filtered[12];
    int raw[12];
    int inputs[] = {A9, A8, A6, A5, A4, A3, A2, A1, A10, A11, A14, A0};
    #define LED_PIN 6
    
    MeanFilter<long> meanFilter[13](200);
    
    void setup() {
     analogReadResolution(12);
     Serial.begin(115200);
     analogWrite(LED_PIN,1);
    }
    
    void loop() {
      for (int i = 0; i < 12; i++) {
        raw[i] = analogRead(inputs[i]);
        filtered[i] = meanFilter[i].AddValue((long)(raw[i]));
        Serial.print(raw[i]);
        Serial.print(",");
        Serial.print(filtered[i]);
      }
      Serial.println();
    }

    However I have much bigger values, as if most separating commas are lost at some point and most values are merged together two by two. I don't understand what causes this issue.

    Click image for larger version. 

Name:	serial_issue.jpg 
Views:	8 
Size:	57.0 KB 
ID:	16698

  2. #2
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,112
    You're printing two values but only one comma with each loop.

  3. #3
    Quote Originally Posted by oddson View Post
    You're printing two values but only one comma with each loop.
    How stupid I am. Thanks a lot oddson!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •