Pages: [1] 2 3   Go Down
Author Topic: send command via rs232  (Read 4086 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello:
When I write in serial monitor number 3, I need to send this command=  3! to a device connected to arduino with Tx and Rx. and when I write in serial monitor 8,  I need to send this command  8! .
Can you tell me how to do it Please?
thank you very much.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33311
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I need to send this command=  3! to a device connected to arduino with Tx and Rx.
First off what do you mean by 3!

The serial monitor uses the UART on the arduino so unless you have a Mega you have to do further serial communication with a UART simulator like new software serial.

Then if this device is RS232 you need to change the TTL voltages into RS232 voltages with a converter or a chip like the MAX202.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much:
The device that I use is an Extron switcher, one of its command is 2! , this command select the input 2 in the switcher through RS232.

I have an Arduino Uno and I have bought http://www.electronshik.ru/pdf/DFROBOT/DFR0077.pdf, it is connected to TX pin 6 and RX pin 7, VCC 5v and Gnd. I think the problem is the code that I don´t know how to send 2! to the device.

Can you help me please?
many thanks
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 289
Posts: 25699
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
Serial.print("2!");
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you:
with this command I send it to the Serial Monitor but not on the external device.
many thanks
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Then your description of how the device is connected,
Quote
device connected to arduino with Tx and Rx
, is misleading. Tx and Rx are generally accepted to mean the hardware serial pins.

How is it connected to the Arduino?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33311
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you have connected that device through pins 6 & 7 then you need software to make those pins into a serial port. There is a libary called new software serial that will do that. It allows you to create other pins to talk serial to. Then you just print it, see the examples that come with it.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you.
I have just tried NewSoftSerial Library, the connections are right and does not work. I haven't error compiling the code.
NewSoftSerial Library works for Arduino UNO?
Do you know what is it wrong?
many thanks.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 289
Posts: 25699
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you know what is it wrong?
No.
Where's the code?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33311
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the connections are right
Connected the ground?
Have you tried swapping over TX & RX?
If so post your code.
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The device that I use is an Extron switcher, one of its command is 2! , this command select the input 2 in the switcher through RS232.

Did you pay any attention to the below? New soft serial may be able to invert the arduino output.

Quote
Then if this device is RS232 you need to change the TTL voltages into RS232 voltages with a converter or a chip like the MAX202.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks again.
this is my new code:

#include <NewSoftSerial.h>

NewSoftSerial mySerial(7, smiley-cool

void setup() 
{
  Serial.begin(9600);
   // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
 }

void loop()
{
  switch(Serial.read())
  {
    case '4':
    mySerial.print("4!");
    break;
    case '5':
    mySerial.print("5!");
    break;
    default :
    //
    break;
   }
}
Like I said  I use http://www.electronshik.ru/pdf/DFROBOT/DFR0077.pdf, it is connected to TX pin 7 and RX pin 8, VCC 5v and Gnd. Do I need another TTL voltage converter?

I have changed also pins 7 & 8 but does not work.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 597
Posts: 33311
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do I need another TTL voltage converter?
No

Do a loop back test, connect your TX and RX together on the RS232 side. Then send a byte out on the TX and see if it returns on the RX. ( you need to write some code to do this )
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't understand you.
loop back test,  I have made
void loop()
{
}

connect your TX and RX together...?

can you send me some code please?
many thanks
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 289
Posts: 25699
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Loop-back tx to rx.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1] 2 3   Go Up
Jump to: