Go Down

Topic: Arduino RS485 Device (Read 33 times) previous topic - next topic

yuanzhi90

Hi Gurus,

I have a new project I wish to embark on but am having a bit of difficulty understanding what I am missing. I will try my best to describe my project and if possible would like to seek your help in solving the issues.

Background
I wish to use an arduino to communicate with a RS485 devices. However I have problems communicating even with just 1 device. I have using an RS485-USB adapter and it works well with hyper terminal. For this example, I would like to use the Gradasoft PP1600 (1660) to receive commands from an Arduino.

Equipment
Arduino - (Uno, Leonardo, Mega)

MAX485 TTL to RS485 Adapter Module
Link- http://www.dx.com/p/max485-ttl-to-rs485-adapter-module-for-singlechip-red-203318#.VEW28_mSzfI
English Manual/Spec- http://m5.img.dxcdn.com/CDDriver/CD/sku.201318.rar
Data Sheet for Chip- http://datasheets.maximintegrated.com/en/ds/MAX1487-MAX491.pdf

Gradasoft PP1660
Data Sheet- http://www.gardasoft.com/images/btnViewDownload.png
Manual- http://www.gardasoft.com/images/btnViewDownload.png
Communication- (Using an DB9 to RS485 adapter) 115Kbaud, no parity, 8 data bits and 1 stop bit.

Setup
*Arduino would require to transmit only
*Gradasoft PP1660 would require to receive only
*Example Command to send is "CL" without the "".

DI (data in) to pin 11
RO (receive out) to pin 10
DE (data enable) and RE (receive enable) jumpered together and to pin 3
Vcc to 5V
Gnd to Gnd
A and B : RS485 pair

Code: [Select]
#include <SoftwareSerial.h>
#define SSerialRX        10  //Serial Receive pin
#define SSerialTX        11  //Serial Transmit pin
#define SSerialTxControl 3   //RS485 Direction control
#define RS485Transmit    HIGH
#define RS485Receive     LOW
#define Pin13LED         13
SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX
void setup()  
{
  pinMode(SSerialTxControl, OUTPUT);    
  digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver  
  RS485Serial.begin(115000);   // set the data rate
}
void loop()  
{
    digitalWrite(SSerialTxControl, RS485Transmit);  // Enable RS485 Transmit  
    RS485Serial.write("CL");    //Sends CL command      
    delay(10000);
    }



knut_ny

is this correct?: RS485Serial.write("CL"); 
..or: .print ??
Ny

Go Up