[Help]Send commands to device via 485 protocol

Hi all.
I have a device with the following parameters:
Interface Standard: Confirmed to RS-485 of EIA standard.
Baurate : 19,200 BPS
Code: ASCII
11 bit: Start bit |b0|b1|b2|b3|b4|b5|b6|b7|Parity|Stop bit

ENQ Sequence: EOT|SA|UA|ENQ
EOT: Start
SA:Station Address (Device No.(40H~7FH)which is assigned to each device )
UA:Unit Address (41H : Selecting -51H : Polling)
ENQ: Stop
How can I send a polling command to the device with address: 01
I followed the instructions but did not take. Please take me a detailed example.
Thanks.
This is my code:

/ assemble message
byte msg [] = {
52, //4 - EOT
48, // 0
49, // 1
53, // 5
49, // 1
53// 5 -ENQ
};

#define TX_ENABLE_PIN 2 // define the EIA-485 transmit driver pin ( RE + DE pin's modules)
SoftwareSerial rs485(9, 10); // SoftwareSerial rs485(RO, DI); pins name on the module

void setup(){
pinMode(TX_ENABLE_PIN, OUTPUT); // driver output enable
rs485.begin (19200); // vitesse com
Serial.begin(19200);
}

void loop(){
digitalWrite (TX_ENABLE_PIN, HIGH); // enable transmit driver
for (int i = 0; i < 8; i++) {
rs485.write(msg*); *

  • }*
  • delay(16) ;*
    digitalWrite(TX_ENABLE_PIN, LOW); // disable transmit driver
  • if (rs485.available()) *
  • {*
  • Serial.println("polling");*
  • int byteReceived = rs485.read(); *
  • Serial.write(byteReceived); *
  • }*
    }[/quote]
1 Like

A few problems I can see (and probably several I have not)...
Software serial does not support any other protocol apart from 8N1 and you need one that has parity.
You don't mention if the parity is meant to be odd or even.
You seem to be confusing decimal with both hex and ascii.
You don't say if the address your refering to is the station address or the unit address (or both)

Untested your code would look something like

// assemble message
byte msg [] = {
  0x04, //4 - EOT
  0x40, // '@'
  0x41, // 'A'
  0x05//  5 -ENQ
};

#define TX_ENABLE_PIN 2            // define the EIA-485 transmit driver pin ( RE + DE pin's modules)
SoftwareSerial rs485(9, 10); // SoftwareSerial rs485(RO, DI); pins name on the module

void setup(){
  pinMode(TX_ENABLE_PIN, OUTPUT);  // driver output enable
  rs485.begin (19200);              // vitesse com
  Serial.begin(19200);
}

void loop(){
  digitalWrite (TX_ENABLE_PIN, HIGH);     // enable transmit driver 
  for (byte i = 0; i < sizeof(msg); i++) {
    rs485.write(msg[i]);     
  }
  delay(16) ;
  digitalWrite(TX_ENABLE_PIN, LOW);       // disable transmit driver
  if (rs485.available()) 
  {
    Serial.println("polling");
    int byteReceived = rs485.read();   
    Serial.write(byteReceived);         
  }
}

Thank for reply.

Software serial does not support any other protocol apart from 8N1 and you need one that has parity.
--> I used module convert TTL to RS485

You don't mention if the parity is meant to be odd or even.
--> Yes, i don't know. This is the tutorial:
(1) Interface Standard; Confirmed to RS-485 of EIA standard.
(2) Synchronous Method; Asynchronous
(3) Transmission Speed; 19,200 BPS
(4) Transmission Method; Half Duplex
(5) Transmission Procedure; Control Procedure.(polling/selecting method)
( 6 ) Parity Check; Horizontal(even),Vertical(even)Parity Check.
(7) Correction; Automatic.(ACK-NAK Method)
(8) Code; ASCII Code
(9) Composition of One Character; 11 Bit.

You seem to be confusing decimal with both hex and ascii.
--> Yes, i'm not sure
You don't say if the address your refering to is the station address or the unit address (or both)
-->My Pump has Address is 01

Smells like the old NCR(National Cash Register) addressing scheme where they change one bit in the device address to change from polling the device to selecting the device to receive the message. And I think the IBM 3270 bisync did sort of the same. Must be something from the dark ages!

Paul

This is protocol of Tatsuno Pumps (Fuel Dispensers SUNNY-XE). I need communication with Pump for my demo project.

As I said in #1, AFAIK software serial does not support any other protocol other than 8N1 and you need 8E1.
You could use an Arduino Mega, Leonardo or Pro Mini so you can use the Hardware serial port that does support 8E1.

I am currently using Arduino Uno R3. Is there any other way for Uno R3 to communicate with RS485? Or forced me to use Mega to communicate

shinsozach:
I am currently using Arduino Uno R3. Is there any other way for Uno R3 to communicate with RS485? Or forced me to use Mega to communicate

You can use the UNO Serial for the 8E1 protocol over RS485 if you don't connect the UNO to a PC to use Serial commands or maybe try a SoftwareSerial library that has been altered to support parity. Only one I could find is here.

Thanks Riva.
I will test it.

Hi Shincozach,
I read Your Post on this forum.
I am looking to connect to a tatsuno demo dispenser via rs485. Could you please share to me the Communication protocol Tatsuno (command between the pump column and the console).
my email: REMOVED BY MODERATOR
Thank you!