Go Down

Topic: send command via rs232 (Read 4891 times) previous topic - next topic

amjlopez

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.

Grumpy_Mike

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.

amjlopez

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

AWOL

"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.

amjlopez

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

dxw00d

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?

Grumpy_Mike

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.

amjlopez

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.

AWOL

Quote
Do you know what is it wrong?

No.
Where's the code?
"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.

Grumpy_Mike

Quote
the connections are right

Connected the ground?
Have you tried swapping over TX & RX?
If so post your code.

zoomkat

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.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

amjlopez

Thanks again.
this is my new code:

#include <NewSoftSerial.h>

NewSoftSerial mySerial(7, 8)

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.

Grumpy_Mike

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 )

amjlopez

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

AWOL

"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.

Go Up