Read from serial DMM

Need some help to figure out how this works

test sketch

void setup() {
Serial.begin(9600, SERIAL_8N1);		//USB-Prog. Port / Serial Monitor
Serial1.begin(2400, SERIAL_7O1);	//Meter DP802  
Serial1.setTimeout(600);
}

void loop() {
  String myText = Serial1.readString();
  Serial.println(myText);

//convert to binary
  for(int i=0; i<myText.length(); i++){

   char myChar = myText.charAt(i);
  
    for(int i=7; i>=0; i--){
      byte bytes = bitRead(myChar,i);
      Serial.print(bytes);
    }
    Serial.println("");
  }
  Serial.println("");
}

Serial Monitor Output

3RRvlr2^3RRvlr2$
00000000
00110011
01010010
01010010
01110110
00010010
01101100
01110010
00110010
01011110
00011101
00110011
01010010
01010010
01110110
00010010
01101100
01110010
00110010
00100100
00011101

I would expect as long as the display is showing 5.00V the first data packet "range" should be "0110001", however the received serial data varies sometimes even when the display remains unchanged

https://tde-instruments.de/wp-content/uploads/2019/09/TDE-INSTRUMENTS-DPM802-Digital-Multimeter-Panel-Meter-Instruction-Manual.pdf

zu5

tde-instruments-dpm802-tw

Do you have a question ?

value displayed:
4.99V

data to expect in my opinion:

00110001 range
00110000 digit3 -> 0
00110100 digit2 -> 4
00111001 digit1 -> 9
00111001 digit0 -> 9
00111011 function
00110000 status
00110000 option1
00111010 option2
00001101 CR
00001010 LF

actual received data:

00110011
01110010
01010110
00100100
00100100
01101100
01110010
00110010
01011110
00011101

I would start by increasing the baud rate for Serial, you may be spending too much time sending data to the serial monitor and overrunning the receive buffer on Serial1.

The data sheet says

the host can use the RS232 interface to read the data
Have you got some hardware in place to convert the RS232 output of the DMM to the TTL levels of the Arduino ?

I am using a small circuit with an optocoupler

blue is RX1 PIN19 on the due ~(0V to 2V)

yellow is PIN10 on the DPM802 meter ~(-2V to+ 1V)

I think the signal is OK? The arduino due swaps between low and high around +1.4~1.5V according to my trials

tried with 57600, another 2 samples

still 4.99V on the display

3rV$$lr2^
00110011
01110010
01010110
00100100
00100100
01101100
01110010
00110010
01011110
00011101

3rV$$lr$^
00110011
01110010
01010110
00100100
00100100
01101100
01110010
00100100
01011110
00011101

I guess the buffer should be ok as it is relaying Serial1 2400 baud to Serial 9600 baud

Which arduino are you using? Is Serial1 hardware or software serial?

The manual you linked has a somewhat confusing description of the serial signal. It states the serial can be read on an RS-232 interface, than also states the +V voltage represents a HIGH and -3V a LOW, while an RS-232 signal uses the negative voltage as HIGH and positive as LOW. I would expect an RS-232 interface going to Rx on an arduino to invert the signal, while your pictures shows no inversion.

Do you ever receive correct data, or is it always incorrect? The binary serial output would be a lot easier to read if your sketch also printed the ASCII character afterwards.

Hi,
Can you please post a circuit diagram?
What model Arduino are you using?

Do you have the gnd of the Arduino and the DMM connected together?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Its an Arduino Due and Serial1 is hardware. I am still running the sketch out of my 1st post. It prints ASCII and converts to binary. I will draw a circuit diagram tomorrow. The ground is common for all devices.

I never received plausible data.

@david_2018
I would like to invert the serial input with software

Have you tried reversing pins 2 and 3 on the optocoupler?

There is no output after reversing pins 2 and 3

modifiying USARTClass.h from

Mode_7O1 = US_MR_CHRL_7_BIT | US_MR_PAR_ODD   | US_MR_NBSTOP_1_BIT,

to

Mode_7O1 = US_MR_CHRL_7_BIT | US_MR_PAR_ODD   | US_MR_NBSTOP_1_BIT | US_MR_INVDATA,

helps with inverting the data, however I am guessing I need to invert the whole signal :thinking:

Can you at least temporarily use an inverter to verify that data can be received correctly?

Unfortunately there is no softwareserial in the DUE board package, that generally allows for signal inversion.

it works, of course I had to invert the whole signal after the optocoupler :crazy_face: