Compoway/F Omron Counter Serial frame communication Protocol

Hello Paul,
Yeah boneheaded move, sorry about that.
Good news is there is transmission. Trigger single run shows defined steps.

I think it's compoway/F and command frame stuff now.
Thank you,
Kota

Hello Sumguy,
This is probably what I was missing.
So something like
Serial3.write(0x02);
Seria3.write(NodeID)
Serial3.write(Subaddress)
and so on.

I'll give this a crack. changing between hex and ascii, and calculating BCC is a bit of a headache but hoping for the best.
Thank you,
Kota

Hello all,
I reconfigured the commands to be the complete frame, like below.

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

void loop() {
  // put your main code here, to run repeatedly:
    while(!Serial3.available()){//wait for data in serial
Serial3.write(0x02);//STX 02H
Serial3.write(0x58);//node id 00
Serial3.write(0x58);
Serial3.write(0x30);//subaddress 00
Serial3.write(0x30);
Serial3.write(0x30);//Service ID(SID) 0
Serial3.write(0x30);//FINS mini text
Serial3.write(0x38);
Serial3.write(0x30);
Serial3.write(0x31);
Serial3.write(0x30);
Serial3.write(0x30);
Serial3.write(0x03);//ETX 03H
Serial3.write(0x3A);//BCC calculated between Node ID and ETX.
    delay(1);
  }
  
Serial.println(Serial3.read());//print out data in serial, I don't receive anything. 
delay(100);
}

Weird thing, I get incoming data only after I unplug and plug the Tx and Rx pins on the arduino. I'm thinking it has something to do with my arduino code, will mess around with this.

The response I get is the following

13:27:25.941 -> 2 **STX
13:27:26.035 -> 88 **Node ID "XX"
13:27:26.129 -> 88
13:27:26.221 -> 48 **Subaddress "00"
13:27:26.314 -> 48
13:27:26.408 -> 48 **End Code(Response from command, which was echo back "00"
13:27:26.515 -> 48
13:27:26.642 -> 56 **FINS mini text section. This should have 0 behind it, because the command I sent was "0801"
13:27:26.735 -> 48
13:27:26.829 -> 49
13:27:26.922 -> 48 **UNKNOWN part of the response
13:27:27.016 -> 48
13:27:27.110 -> 3 **ETX 03
13:27:27.247 -> 58 **Why is there a ":" here

So I think the code is working, but I'm having a bit of trouble deciphering part of the response. Namely, why are there extra 0's and what the ":" is at the end.

Thank you,
Kota

Perhaps it is the BCC for the transmission?
Paul

Hello Paul,
Ohhh that's the "58" at the end, okay that makes sense.

Still confused about the misplaced/extra 00's after the "0801" command frame. The screenshot below shows the FINS mini text portion of the response frame.



Thank you,
Kota

Im not absolutely sure about these numbers they seem right but I have no module to test it with.

Say you want an echo test and you use 777 as the test data then the frame should be close to the following.

STX 2
Node "00"
Sub Address "00"
SID "0"
FINS mini text "08" "01" "777"
ETX 3
BCC D

In the arduino that would look similar to this, two other things to consider and that is one the delay should be a minimum of 50mS between command frames and two the bcc is calculated in a separate sub routine.

Serial3.write(0x02);//STX 02H
Serial3.write("000000801777");
Serial3.write(0x03);//ETX 03H
Serial3.write(0xD);//BCC calculated between and INCLUDING Node ID and INCLUDING ETX.
delay(500);

The above should make programming easier as all you have to deal with is your command string.

I think the response I was getting was what I wrote into serial3 initially as the command frame.

Hello All,
I finally did it, I finally received the response I was looking for. Below is the code, and the response from the counter. The command and response are different, which tells me the counter is actually responding. All I did was connect the grounds, unplug and replug wires and it worked. Didn't change any wiring configuration, but I did change the settings on the Omron counter to 8bit length, even, stop bit 1. This worked for some reason, if anyone could shed some light on this I would appreciate it.

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

void loop() {
  // put your main code here, to run repeatedly:
    while(!Serial3.available()){//wait for data in serial
      Serial3.write(0x02);//STX 02H
Serial3.write("00000080177");
Serial3.write(0x03);//ETX 03H
Serial3.write(0x3A);//BCC calculated between and INCLUDING Node ID and INCLUDING ETX.
delay(50);
Serial.print("waiting");
  }
  while(Serial3.available()){
Serial.println(Serial3.read());//print out data in serial, I don't receive anything. 
delay(50);
  }
}

16:50:06.426 -> 2
16:50:05.494 -> 48
16:50:05.536 -> 48
16:50:05.589 -> 48
16:50:05.642 -> 48
16:50:05.690 -> 48
16:50:05.739 -> 48
16:50:05.789 -> 48
16:50:05.840 -> 56
16:50:05.894 -> 48
16:50:05.930 -> 49
16:50:05.957 -> 48
16:50:06.078 -> 48
16:50:06.078 -> 48
16:50:06.153 -> 48
16:50:06.170 -> 55
16:50:06.236 -> 55
16:50:06.305 -> 3
16:50:06.376 -> 10

Thank you guys so much for your help,
I will probably be back for more questions later. Ultimately I want to read the number value shown on the omron counter and transmit to arduino.
Kota

That is exactly the response to the echo command that the manual describes.

It was interesting that you decided to modify the default communication settings I thought it might work. I dont understand why the settings in your arduino code (Serial3.begin(9600,SERIAL_8E2) are different to the settings you adjusted in the counter, you say you set them to "8bit length, even, stop bit 1". If it works without error then ok but personally I would want both ends looking the same, I think I would also possibly try using 8bit length, parity none, stop bit 1.

well done.

Hi,
You do have the gnd of both devices connected together?

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

Apparently the software supporting the USART does not do anything with errors reported by the status register. Actually implementing error reporting and recovery is too complicated and to infrequent for most users to understand and code for. So, for utility, parity errors, framing errors and all others are ignored.
Paul

Hello Sumguy,
Actually you're right, I was so excited I didn't even catch that.
I'll change that bit, and see.
Thank you,
Kota

Hello Tom,
I do have both grounds looped together, on the oscilloscope though I get wavy bits when grounded to the counter, but when grounded to the arduino only, it shows me straight DC bit levels. I'm not sure if it's because the counter is grounded to 110ACV and the arduino is powered off my laptop.
Thank you,
Kota