Go Down

Topic: Unable to use values received at rx tx (Read 2868 times) previous topic - next topic

Visual_Kol

The schematic is pretty simple. I've attached it, along with the code. And my apologise for not posting this earlier.

Please can you have a look at this
Do you think I should try using this DF1 library, while knowing that there is no standard DF1 library for arduino?

Nick_Pyner

re reply#11, there is no such thing as a software serial monitor, the serial monitor is on hardware serial - no exceptions, and, if you have any peripheral connected to 0,1, you won't be able to upload..
AB Micrologix 1400 PLC has a DB9 port which supports RS232 protocol.
So the Connections are PLC <---> RS232 Cable <---> RS232 to TTL converter <---> Arduino (0,1)(Rx,Tx)Yes but it's because my SoftwareSerial doesn't work!
You are connecting the peripheral to the hardware serial pins, 0,1 which, with Software Serial,  will never work. If you insist on using Software serial, put it on pins 7,8 and use software serial there, then it might work. Indeed anything will do - except pins 0,1.

Nick_Pyner

Your hand drawing does not agree with the pic in the link. You just have to make up your mind which serial method you want and code accordingly, and stop fartarsing about with both.

If AB say hardware, you should understand that is OK, and I assume the serial monitor is not part of the game. Just remember to disconnect the MAX232 when uploading the programme.

If you want to use software serial, it will be OK at 9600.


jremington

#18
Mar 12, 2020, 02:39 am Last Edit: Mar 12, 2020, 02:47 am by jremington
Get rid of the useless delays in the program shown in the .jpg appended to reply #15.

Then bidirectional character transmission should work, but if not, try swapping the wires connected to pins 2 & 3.

However, if you don't use the expected protocol, you will not be able to communicate properly with the box, and it may not respond AT ALL.

Visual_Kol

#19
Mar 12, 2020, 04:23 am Last Edit: Mar 12, 2020, 04:36 am by Visual_Kol
re reply#11, there is no such thing as a software serial monitor.
Sorry to confuse you, but when I was saying about using Rx Tx and Serial Monitor, I was trying to say that my SoftwareSerial method doesn't work, so I have gone back to Hardware Serial, removing SoftwareSerial from the picture.
Your hand drawing does not agree with the pic in the link.
Actually I was asking you, whether I should go with method that they have used in that link, so my drawing is not built according to that.
Get rid of the useless delays in the program shown in the .jpg appended to reply #15.
The delay(50) is because PLC is sending data at every 50 milliseconds. And I send just ONE Character from PLC so ARDUINO should perfectly match with that.
The delay(1000) is because I was getting print statements in loop to quick to understand. So for now it is definitely useless. And I will get rid of them.
Then bidirectional character transmission should work, but if not, try swapping the wires connected to pins 2 & 3.
I did try swapping the pins. I think I'm frustrating you guys by complicating my replies. I'll try to keep it simple onwards.
And I will further be uploading the code after disconnecting the RS232 - TTL converter from Arduino.

6v6gt

Maybe configuring the serial port (stop/start/parity bits) is necessary if these don't match the standard used on the Arduino. See, for example, https://forum.arduino.cc/index.php?topic=479134.0

Nick_Pyner

I have gone back to Hardware Serial, removing SoftwareSerial from the picture.
Good idea.
I can't help but feel that your problems may be at the other end but, since the makers have Arduino code, you should be able to use that verbatim, and the real problem is understanding how to use it. Further, this software serial stuff is just a result of misunderstanding.

jremington

Quote
The delay(50) is because PLC is sending data at every 50 milliseconds. And I send just ONE Character from PLC so ARDUINO should perfectly match with that.
No, you do not need a delay.

The Arduino is always ready to receive a character, and Serial.available will tell you whether one has arrived.

Visual_Kol

No, you do not need a delay.
Actually I was following the Nick_Pyner's suggestions from #2 & #4.
you should be able to use that verbatim, and the real problem is understanding how to use it.
I don't understand this, can you please elaborate on that one?
Maybe configuring the serial port (stop/start/parity bits) is necessary
On plc or arduino? And if on arduino, how to do that?

jremington

#24
Mar 12, 2020, 06:05 pm Last Edit: Mar 12, 2020, 06:11 pm by jremington
Quote
Actually I was following the Nick_Pyner's suggestions from #2 & #4.
You misunderstood Nick's point. You do not need a delay.

Quote
Maybe configuring the serial port (stop/start/parity bits) is necessary
On the Arduino. Consult the Arduino reference guide entry on Serial.begin() for instructions.

This:
Quote
#define DF1baud 9600
#define DF1format SERIAL_8N1
tells you the Baud rate and exact serial port configuration.

Quote
I don't understand this, can you please elaborate on that one?
The word "verbatim" means follow the instructions exactly as written.

Nick_Pyner

I don't understand this, can you please elaborate on that one?
I don't know anything about your PLC. The link you provided had some code from the manufacturer, using hardware serial. Why don't you use it?

Visual_Kol

#26
Mar 14, 2020, 03:52 pm Last Edit: Mar 14, 2020, 03:54 pm by Visual_Kol
The link you provided had some code from the manufacturer, using hardware serial. Why don't you use it?
Tried this today. It's not working. But actually the demonstration given in that link was for Micrologix 1000 which has a single Rs232 communication port, whereas I'm using Micrologix 1400 having 2 such ports. And I'm using the second port. The PLC program given with this demo, doesn't specify any communication channel.
Then I went for a standard Modbus Communication with same circuit and Arduino as master and PLC as slave. Still it also doesn't work.

So finally I think I need to buy a new original uno and test again.

Nick_Pyner

#27
Mar 14, 2020, 04:10 pm Last Edit: Mar 14, 2020, 04:28 pm by Nick_Pyner
So finally I think I need to buy a new original uno and test again.
Unless you have exercised some serious and very specific physical abuse that you are not telling us about, you are probably wasting your time and money. All we are talking about here is hardware serial communication. This involves the on-board uart that is shared between the serial monitor and pins 0,1. The fact that you have never said you are unable to upload a programme rather suggests that it is 100% kosher. As I said, you might look at the other end and, if you want to throw money at the problem, that would be a good place to start.

Further, Arduino has only one serial connection, it only talks to its own port and has no idea what is on the other side. It doesn't care how many serial ports the PLC has, it just needs to be connected to the right one, and in the proper manner.

Go Up