Still not working, I tried using the software serial same as before with changing the connection. Nothing on the serial monitor. I tried reseting the arduino too.
I also tried the connections you recommend (i.e. on 7,8 pins). Output: Nothing!
Then I removed the serial monitor from the equation, powering arduino from external power supply 7.4v. Removed all serial statements, except those of softwareserial. And connected an led to be turned on or off according to the data received at the rx pin. It's simply not working.
Have you checked the Wiring Rx>TX, Tx>Rx as noted in reply#4?
Note that there is nothing magic about pins 7,8, indeed I only mentioned them because they are very un-magic.
Actually in the first post I told that whatever I send from plc, shows up in my serial monitor, but it's after I reset the arduino, an then the setup statements appear. So I guess no problem with Rs232 to ttl converter.
Guys, something much bizarre has happened today. of course i did not get the output as i wanted but just have a look.
I've attached a copy of the test codes I was conducting today. Please find it attached. I again tested with the Software Serial monitor, it seems to be unable to read any data. So it failed again.
But while I was experimenting with simple serial monitor code, I accidentally deleted the code for printing the received Character. So i further experimented with it. And finally uploaded this code.
So, as you see I haven't read the data arriving in the serial buffer or printed it.
Now I send number '2' from the plc. I didn't get anything as expected. But when i reset the arduino It was as follows.
So it means that the conception that the conflict between Serial monitor and tx rx working at the same time might be the reason to get this effect. But why is this value getting printed? that too before even setup begins the serial communication. and again how to store this value in a variable so that it can be used further.
jremington:
How do you have the PLC wired to the Arduino?
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)
jremington:
It looks like you are still using the serial monitor RX and TX (0 and 1 on an Uno) connections for both, which is not allowed.
Yes but it's because my SoftwareSerial doesn't work!
Same as earlier, it doesn't take anything into the buffer. But for some reason hardware rx tx does (after reset). That's why I was trying to use rx tx and serial monitor parallelly.
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..
Visual_Kol:
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.
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.
Nick_Pyner:
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.
Nick_Pyner:
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.
jremington:
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.
jremington:
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.
Visual_Kol:
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.
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.