Having issues with Serial output

I've been pulling my hair out for a few days now, what am I doing wrong?

I've got a usb to rs232 converter with a rs232 female plug wired up so the 2nd pin (TXD) is going to my Arduino Uno pin 0, 3rd pin (RXD) going into pin 1, 5th going i nto ground (changes nothing either way with what i'm getting). Or were the TXD/RXD other way around, can't remember and don't have the board in front of me, I know I'm only getting data from one configuration so I'll assume that is the correct way. Anyway...

Anything I have a logger on the usb end allowing me to see the data as it comes in live. Now the issue is I'm getting different values to what I see in the Serial Monitor, to what the logger is showing.

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.print("Temp");
delay(1000);
}

Is example code I'm using, serial monitor shows Temp fine, debugger (set to 9600, 8, 1, none, none) returns this as HEX "55 53 52 02" or USR with a tiny upside down _| next to the R.

If it was noise causing it, I'd expect to be able to remove Serial.print("Temp") and still see garbage going through, but I'm nto getting anything.

I'm completely new to playing with Arduino's, so have no idea where to go from here to work out what I'm doing wrong.

Edit:
Also I've tried the SoftwareSerial class as well on other pins and am still getting the same output.

I've got a usb to rs232 converter with a rs232 female plug wired up so the 2nd pin (TXD) is going to my Arduino Uno pin 0, 3rd pin (RXD) going into pin 1...

By "rs232 converter" do you mean an actual RS-232 converter or a USB-to-TTL-serial converter?

've got a usb to rs232 converter with a rs232 female plug wired up so the 2nd pin (TXD) is going to my Arduino Uno pin 0, 3rd pin (RXD) going into pin 1,

Can you confirm you've got the TTL level Tx signal from your Uno connected directly to your RS232 Rx?

There's an inversion in RS232, hence your garbage on the serial line.

USB to RS232 DB9 Digitech converter is all it says.

You'll have to forgive me for my lack of knowledge, but what do you mean by TTL level Tx signal? Is that just the D1 pin labelled as TX up arrow? Got it connected via breadboard to a rs232 female connector which i then plug in with the above mentioned adapter.

As reference to I have pin 2 on pic connected to the D1 (TX up arrow labelled) and pin 3connected to the D0 (RX down arrow labelled).

How do you mean inversion, I've read up it sends it right to left, is there something else it does?

Sorry about not replying sooner, my email notifier failed me...

RS232 signalling uses a low signal (actually below zero volts) to signal a logical '1' bit, and a high (above zero volts) to signal a '0' bit.
The signal in and out of the Rx and Tx pins on the Arduino are NOT RS232 compatible.
These voltages may be much higher than is electrically acceptable to the AVR processor.

Hmm ok, so do I need some form of adapter to convert from the TTL(?) the arduino sends to RS232 serial port?

Yes, something like a MAX232

Thanks for the info, now to work out how to use the MAX232. Found some documents and I'll deal with that all tomorrow.

Thanks for all the help, wish I had posted earlier. Would have a few more hairs on my head then.

I ran into the exact issues trying to communicate with a Scott Edwards 4x20 Serial LCD display which uses a true RS232 input. The solution is to install a simple 7404 hex inverter inbetween your serial out and your device. (I have not used this for bi-directional communications though).

That may work for one particular non-compliant device, but those inverter outputs do not go below 0V.

Xanord:
Thanks for the info, now to work out how to use the MAX232.

You could just get a TTL converter.

Ok I've been looking for adapters reasonably locally. And found one here http://www.futurlec.com.au/Mini_RS232_TTL_5V.jsp. Am I right in believing the Uno sends TTL over 5v, and not 3v as they also have a 3v version? And also would I be just using tx0, rx0 for it or probably also requiring a 5V line wired to it for power? No description on it :frowning:

Also I found another adapter, Dual animal tag rfid data logger with SD card storage [RFIDLOG] - $82.00 : Priority 1 Design, Electronics design and manufacturing which looks to be perfect for what I'm wanting, am I right in thinking I can set a pin on the arduino as digitalWrite(#, HIGH) and that will supply the 5V neccessary for this board to operate on? Note*: Will be powering the board by a 8-9V input through VIN. Will that still be enough for the Uno, or would I need to wire in a 2nd power into(can I wire that into the VIN as well)?

Still looking for a local provider :frowning:

I do have a RS232 to TTL board. It simply a MAX232. The Rx pin go to TX pin of the Ardiuno. The Tx pin go to the RX pin of the Ardiuno. Here the site of the board I have. http://www.schmartboard.com/index.asp?page=products_populated&id=84
I got mine at Active Components in Toronto. Pricy little board, BTW. I build a breadboard version using the MAX232. Much cheaper. Just need : D-9 connection, a MAX232 chip or SP232ACP, 4 X 0.1 uF. And follow the schematic in that site.

Or

The old fashion way... with 1488 and 1489 ( line driver and receiver ), but you need a dual power line ( +12 V, -12 V and 5 V )

For the 5V, I'd go right to the 5V pin on the Arduino header. The regulator supplies enough current to run the MAX232.

One thing I found is that putting the MAX232 on pins 0 and 1 interferes with the 8U2/16U2 so you might have errors when trying to upload to the chip.

I got around it by disconnecting those lines when programming.

R/
Jason

Yep already doign the same with disconnecting 0 and 1.

Going to have a go at soldering up my own.

Found this diagram

from societyofrobots.com that I'll be using for it.

I'll report back how I go.

Ok, I have an adapter hooked up to the arduino. Data sending/receiving appears to be fine (rs232-usb) cable connected to adapter with logging software to see what is being received and sending.

Now the device is not responding to the data I'm sending. It's a master/slave setup, the arduino as master tells the device stuff, the device then responds.

First step is device registration.
header (2 byte), source (2 byte), dest (2 byte), control code (1 byte), function code (1 byte), dataLength (1 byte), data (# byte), checksum (2 byte)

Now I've also got the source for the software for the windows machine, so what i'm sending and how it's sending is the same. On both code side, and serial side(through com port logging software).

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  delay(1000);
}

byte data[] = { 0xAA, 0x55, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x10 };
bool sent = false;

void loop() {
  if (!sent) {
    Serial.write(data, sizeof(data));
    Serial.flush();
    sent = true;
  }
  
  if (Serial.available() > 0) {
    digitalWrite(13, HIGH);
  }
}

I'm using the above code to see if I ever get a reply of anything from the device, and the red LED is never lighting up :frowning:

Reading about TTL and RS232, they are both LSB first, the device is 9600 baud, 8 data, no parity, 1 stop bit, no flow control.

Delay timings given are
inter character delay 0~0.2s
Delay before response 0~0.5s
Min interval between commands 0.5s

One strange thing on the protocol sheet is the statement "Note:
When sending the LSB will be firstly transmitted as a packet of word format."

Also the software that does it is c++, so i would've thought it be almost copy paste.

Can anyone see what I'm doing wrong with all this?

try that. You are sending an array. Treat the data as an array. But this code will send the data only once, because the < sent=true; >

void loop()
 {
    if (!sent)
   {
       for (int i=0;i<sizeof(data);i++)
       {
           Serial.write(data[i]);
       }
       Serial.flush();
       sent = true;
    }
  
   if (Serial.available() > 0)
   {
      digitalWrite(13, HIGH);
   }
}

Thought Serial.write supported sending array and len (so says the doc page)? Anyhow I'll try it in a few mins and get back to you.

And yeah sending it once just to see if i get a response without affecting the device, can always hit the reset button on the arduino to send it again.

Ok, no go with that code. Well...it goes, but no little red light :frowning:

I'm wondering if it's from the interface expecting higher voltage then the 5V the arduino can send out. Reading the spec's it is meant to support +-3V upto 15V with handling upto 22V.

Could this also support why one brand of USB-RS232 cable works for the software to the device, but another brand doesn't? I'm waiting on a reply from the manufacturer to find out about the min voltage it supports.

Either way, any other suggestions?

First step is device registration.
header (2 byte), source (2 byte), dest (2 byte), control code (1 byte), function code (1 byte), dataLength (1 byte), data (# byte), checksum (2 byte)

byte data[] = { 0xAA, 0x55, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x10 };

What does your device expect for 'registration' ?
Is the header 0x55AA or 0xAA55?
Is the Checksum correct also (0x1001 or 0x0110)?
Are the 2-byte words sent in the correct order? (LSB least significant byte then MSB)