Mega reading Tx output of the LC100-A Capacitor meter

I have a LC100-A Inductance/Capacitor meter: https://www.mpja.com/download/33374te%20users%20manual.pdf
that serially transmits the measurements that is also sent to the attached display. I am trying to read the value from the meter with a Mega2560. There is no information regarding the serial interface on the LC100 in its manual, and I have not been able to find any info beyond that.

I run the following sketch that results in the meter value being displayed in the Serial Monitor one character at a time (in reverse order, but I can figure out how to fix that), but the problem is that it catches a number of random characters and spaces before and after (see attached image of Serial Monitor display).

#include <SPI.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial3.begin(57600);
  
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial3.available()) {
    char inByte = Serial3.read();
    Serial.println(inByte);
  }
}

Attached is pic of Serial Monitor. The data I am needing is the 17107.

I tried the sketches from the “Serial Input Basics” both receiving with end markers and receiving with start and end markers, neither works.

Any suggestions. Thank you.

Those 'random' characters are likely non-printable framing characters such as STX and ETX. Try printing the values as hex or binary and let's have a look a what they really are.

I printed to Serial monitor as Serial.println(inByte,BIN); and Serial.println(inByte,HEX); and just got BIN and HEX equivalents to ASCII.

I did analyze a pattern while printing to Serial Monitor in char (see attached pic of Serial Monitor screen shot). The “0000017126” is the data I am looking for (the measurement from the Capacitor meter is displaying 171.26 pF. There is apparently leading zeros that are not displayed on the unit.

Then there is all of the ransom characters before and after. As I scroll the Serial Monitor this pattern repeats every approximately 95-105 characters (not exactly consistent).

Does this help any? Thank you.

I see the manual and I see several schematics of the meter, but I only see a USB connection to the outside world. How are you connecting the meter to the Arduino?

Paul

I wanted to see the binary/hex.

To Paul,
I have soldered into the Tx and GND labeled through holes (J5) on the LC100-A connecting Tx to RX3 (pin 15) on Mega and GND to GND. See attachment pic.

Roger

LC100A.pdf (124 KB)

Here is the BIN and HEX prints of what I am getting (see attached for Serial Monitor screenshots).
This is the sketch…

#include <SPI.h>

int count = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial3.begin(57600);

}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial3.available()) {
    char inByte = Serial3.read();
   Serial.print("    ...read # ");
   Serial.println(count);
    count ++;
  
    Serial.print("char...");
    Serial.println(inByte);
    Serial.print("Bin...");
    Serial.println(inByte,BIN);
    Serial.print("HEX...");
    Serial.println(inByte,HEX);
    Serial.println("next...");
  }
}

Thank you
Roger

I still find NO documentation for the connections for J5. Do you have them somewhere?

Paul

Paul, That is my problem, I do not find any reference to this J5 serial interface on the LC100-A but I know that it is functional for two reasons:

  1. By reading one character at a time (see sketch above) I eventually get the correct values from the LC100-A that is being displayed on the meter. But I get a lot of other characters around it that I cannot sync.
  2. In December of 2017 a forum post discussed this same issue (Topic: getting a value from pin Rx and use it in the program). The poster stated he eventually got the data he needed (just in reverse order). I am using the same sketch he posted and also get the correct data (in reverse) but, again, with random characters also.
    Thank you
    Roger

Attached is another Serial Monitor of the serial stream with the “char” followed by “DEC” of the character.

The numerous backward question mark is various negative numbers in decimal. I don’t understand.

Attached is another Serial Monitor of the serial stream

Please do NOT post pictures of text. Just copy and paste the TEXT here.

The output in that picture does not match the code you posted.

Sorry,
Here is code that generated previous attachment of Serial Monitor. (I do not see how to copy/paste; I highlight lines of output and it pastes only first line)

#include <SPI.h>

void setup() {

  Serial.begin(9600);
  Serial3.begin(57600);
  
}

void loop() {

  if (Serial3.available()) {
    char inByte = Serial3.read();
    Serial.println(inByte);
    Serial.println(inByte,DEC);

  }
}
    Serial.println(inByte);
    Serial.println(inByte,DEC);

I REALLY hate anonymous printing. Some numbers appear on the serial monitor, but you have no clue what value is what.

   Serial.print("inByte (which is NOT a byte) = ");
   Serial.print(inByte);
   Serial.print(" (");
   Serial.print(inByte, DEC);
   Serial.println(")");

Sure, it takes longer to type, but you learn a LOT more.

It is not indicative of the sharpest crayon in the box to use a type in a variable name that is not the type OF the variable.

I was able to make it work…

The following sketch will effectively read the LC100-A L/C meter serial output.

/* Read serial output of LC100-A L/C Meter
 * 
 */
 
 #include <SPI.h>

unsigned char capbfr1[10]; // ASCII string from each cap meter
int capval1;
unsigned char c;
int i1;
int i;

void setup() {
  Serial.begin(9600);
  Serial3.begin(57600);
    
  Serial.println("Arduino Ready");
}

void loop() {
        if (Serial3.available()) {
            while(Serial3.available()) {
                c = Serial3.read();  
                if (c <= 13) { i1 = 0; continue; }
                if (i1 < 10) capbfr1[9 - i1] = c - '0';
                i1++;
                if (i1 == 10)
                {
                    capval1 = 0;
                    for (i = 4; i <= 8; i++)
                    {
                        capval1 += capbfr1[i];
                        capval1 *= 10;
                    }
                    capval1 += 5;
                    capval1 /= 10;

Serial.println(capval1);   
                 }
           }
        }

}

Thanks for all of the help.