rx tx problem arduino uno

hello everyone. i have some problem with serial communication............please help me

i want to send ascii data from PLC SERIAL port to arduino serial port. I have connected serial cable from plc to rs232 to ttl converter. TTL ouput of converter is connected to arduino rx tx pin correctly. i uploaded a blank sketch to arduino.some of the observation i point out below.

  1. when i send ascii character from plc to arduino it is receving correctly which i can see in serial monitor. 2.the tx light of converter which is connected to rx of arduino is blinking also. 3.when i remove the usb from pc and connect to external power supply and ascii data sent from PLC can be assumed by blinking led of converter.
  2. but when i write code Serial.begin(9600) in arduino sketch and trnsmit data from PLC then no light is blinking .i.e communication drops.

i am unable to findout the solution...pl help plc is set to 9600, 8bit, N, 1 and in arduino only serial.begin(9600)

Please upload the sketch.

fnb111: Please upload the sketch.

fnb111: Please upload the sketch.

it is blank sketch. but when serial.begin(9600) is added in setup no communication occur

I'm not sure how the serial buffer works, if it causes receipt to stop when it's full. It's only 64 bytes, so perhaps that arrived in a blink and then got stopped.

Try perhaps with this code from the reference page but with the Serial.print() commented out then it should keep reading from the buffer and doing nothing with what it gets.

(Just a guess on my part, really)

int incomingByte = 0; // for incoming serial data

void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {
  // reply only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    //Serial.print("I received: ");
    //Serial.println(incomingByte, DEC);
  }
}

Maybe you should bring the PLC in via soft serial, and leave pin 0 and 1 and the usb alone for uploading code, and debug messages. (Or use a Mega with more hardware serials.)

neiklot: I'm not sure how the serial buffer works, if it causes receipt to stop when it's full. It's only 64 bytes, so perhaps that arrived in a blink and then got stopped.

Try perhaps with this code from the reference page but with the Serial.print() commented out then it should keep reading from the buffer and doing nothing with what it gets.

(Just a guess on my part, really)

int incomingByte = 0; // for incoming serial data

void setup() {   Serial.begin(9600); // opens serial port, sets data rate to 9600 bps }

void loop() {   // reply only when you receive data:   if (Serial.available() > 0) {     // read the incoming byte:     incomingByte = Serial.read();

    // say what you got:     //Serial.print("I received: ");     //Serial.println(incomingByte, DEC);   } }




Maybe you should bring the PLC in via [soft serial](https://www.arduino.cc/en/Reference/SoftwareSerial), and leave pin 0 and 1 and the usb alone for uploading code, and debug messages. (Or use a Mega with more hardware serials.)

i have already tried this .... serial.begin causing the problem

amubgr: I have connected serial cable from plc to rs232 to ttl converter. TTL ouput of converter is connected to arduino rx tx pin correctly. i uploaded a blank sketch to arduino.some of the observation i point out below.

  1. when i send ascii character from plc to arduino it is receving correctly which i can see in serial monitor.

This sounds as if you are trying to use the Tx and Rx pins for two separate purposes so everything is getting confused.

Use SoftwareSerial to create a separate serial port on two other pins and connect your converter to them. Leave Pins 0 and 1 for communication with the PC.

...R Serial Input Basics - simple reliable ways to receive data.

Robin2: This sounds as if you are trying to use the Tx and Rx pins for two separate purposes so everything is getting confused.

Use SoftwareSerial to create a separate serial port on two other pins and connect your converter to them. Leave Pins 0 and 1 for communication with the PC.

...R Serial Input Basics - simple reliable ways to receive data.

it is working.....actually i wanted to use ab df1 arduino driver for plc interface which by default use rx tx pin. is there any possibility to make arduino default rx tx pin to work

amubgr:
i wanted to use ab df1 arduino driver for plc interface which by default use rx tx pin.

Is that the DF1 library? I see various references to it around, but can’t find a download link.

Surely it will have a line where you can override the defaults, or in the worst case edit the source?

Maybe there’s a DF1.begin() kind of line, which may take the pins as arguments, just like software serial does?

Nobody in their right minds would have written Arduino code that forces you to use pin 0 and 1 for serial comms, that’s crazy.

I dis some simple digging around into the DF1 library, and with some advice from PaulS, think you could try this, if it is the DF1 library you’re using:

#include <SoftwareSerial.h>

SoftwareSerial DF1_Serial(10, 11);

void setup()
{
..
DF1_configure(&DF1_Serial, DF1baud, DF1format, DF1timeout, DF1packets, DF1TOTAL_NO_OF_PACKETS);
..
}

neiklot:
I dis some simple digging around into the DF1 library, and with some advice from PaulS, think you could try this, if it is the DF1 library you’re using:

#include <SoftwareSerial.h>

SoftwareSerial DF1_Serial(10, 11);

void setup()
{

DF1_configure(&DF1_Serial, DF1baud, DF1format, DF1timeout, DF1packets, DF1TOTAL_NO_OF_PACKETS);

}

thanks … tommorow i will try and let u know.

neiklot:
I dis some simple digging around into the DF1 library, and with some advice from PaulS, think you could try this, if it is the DF1 library you’re using:

#include <SoftwareSerial.h>

SoftwareSerial DF1_Serial(10, 11);

void setup()
{

DF1_configure(&DF1_Serial, DF1baud, DF1format, DF1timeout, DF1packets, DF1TOTAL_NO_OF_PACKETS);

}

added the code…but it is not working…default serial port is still active

Well it was just an idea..

If it's the DF1 library you're using, perhaps you would be better off contacting the creator of the library?

(BTW, do you have a link to the DF1 library? I followed some links and ended up in a complicated blog page and couldn't find a download button.)

neiklot: Well it was just an idea..

If it's the DF1 library you're using, perhaps you would be better off contacting the creator of the library?

(BTW, do you have a link to the DF1 library? I followed some links and ended up in a complicated blog page and couldn't find a download button.)

https://program-plc.blogspot.com/p/project-file-for-allen-bradley-plc.html?m=1 after loading the download link will come. after clicking download link after 20 sec download will start

Thanks, I was on that page and thought that button was one of those "should I really click this or not" pretend downloads.

neiklot: Is that the DF1 library? I see various references to it around, but can't find a download link.

Surely it will have a line where you can override the defaults, or in the worst case edit the source?

Maybe there's a DF1.begin() kind of line, which may take the pins as arguments, just like software serial does?

Nobody in their right minds would have written Arduino code that forces you to use pin 0 and 1 for serial comms, that's crazy.

i googled the different project of the creator of library and finally got the solution. i can use mega and configure for serial1.it is working.communication is established. but the data i need from plc data table not received to arduino. i am trying to contact the creator of library but not responding. i dont understand the c++ code of library. i need to contact a allenbradly plc expert

any further luck on this please, i’m also stuck with DF1 Arduino library with similar problem. I’m able to write data to N7 with arduino UNO but unable to read data. In my case i’m not connected to PLC yet, but using a simulator software.

Would you mind sharing the code which worked on mega?