RS232 Shield Help!

My goal is to communicate serially with a GPS unit. using the Arduino with the RS232 shield from CuteDigi (http://www.cutedigi.com/product_info.php?products_id=4329). Schematic found at CuteDigi: (http://www.cutedigi.com/pub/Arduino/arduino_RS232.pdf) Before attaching a GPS device, I decided to test out serial communiation using the RS232 shield.

Here are the steps I've gone through so far and the results:

  1. First, I ran the following script WITHOUT the CuteDigi RS232 shield.
/*
  SoftwareSerial example

  Sample of the SoftwareSerial library.  Listens for serial in on pin 2
  and sends it out again on pin 3.

  by Tom Igoe
  based on examples by David Mellis and Heather Dewey-Hagborg
  written: 6 Jan 2007
*/

// include the SoftwareSerial library so you can use its functions:
#include <SoftwareSerial.h>

#define rxPin 0
#define txPin 1
#define ledPin 13

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
byte pinState = 0;

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
}

void loop() {
  // listen for new serial coming in:
  char someChar = mySerial.read();
  // print out the character:
  mySerial.print(someChar);
  // toggle an LED just so you see the thing's alive.  
  // this LED will go on with every OTHER character received:
  toggle(13);

}

void toggle(int pinNum) {
  // set the LED pin using the pinState variable:
  digitalWrite(pinNum, pinState); 
  // if pinState = 0, set it to 1, and vice versa:
  pinState = !pinState;
}

RESULT 1: everything works great! Characters typed in the Serial Monitor were echoed as designed.

  1. This time I used the same sketch and the RS232 CuteDigi shield attached.

RESULT 2: With the RS232 shield attached, the program encounters problems uploading the sketch with following error code:

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

If I first upload the sketch to the Arduino without the RS232 shield, disconnect the USB cable, attach the RS232 shield, now using the DB9 port of the shield, the program does not work as designed (I'm attempting to communicate in this configuration with the Arduino using TeraTerm Pro).

This is my first attempt at using an RS232 shield, so I'm a newbie in that respect.

Any help/guidance would be greatly appreciated.

Thanks in advace, Gerald (N4PAX)

Now that you have made your first post, you can modify it to add the links that you couldn't add the first time. And, you really need to.

I have tried your code. It does work as you expected using CuteDigi RS232 Shield DB9 port. I am using X-CTU from digi.com.

Thanks, Rocky!

So, perhaps a I have a bad rs-232 shield, since the sketch will not load if it's attached to the Arduino board.

The process of uploading code to the Arduino uses the serial port pins (0 and 1). The shield you are using also uses those pins. Unless there is a jumper you can set while uploading, you will need to remove the shield in order to program the Arduino.

I'm curious why you are using SoftwareSerial on the hardware serial pins. If you are using the hardware serial pins, use the hardware serial class (Serial).

Excellent point! I will try that suggestion.

I continue to find out why I can't get the rs232 shield to work with my Arduino, I found/modified the following program:

/*
  Analog input

 reads keyboard input, prints the value out in a variety of formats.

 created 24 March 2006
 by Tom Igoe
 modified by Gerald Donnelly, 2010
 */

int incomingByte = 0;    // variable to hold the analog value

void setup() {
  // open the serial port at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0) {
            // read the incoming byte:
            incomingByte = Serial.read();

  // print it out in many formats:
  Serial.print("I received: ");
  Serial.println(incomingByte);       // print as an ASCII-encoded decimal
  Serial.println(incomingByte, DEC);  // print as an ASCII-encoded decimal
  Serial.println(incomingByte, HEX);  // print as an ASCII-encoded hexadecimal
  Serial.println(incomingByte, OCT);  // print as an ASCII-encoded octal
  Serial.println(incomingByte, BIN);  // print as an ASCII-encoded binary
  Serial.println(incomingByte, BYTE); // print as a raw byte value

  // delay 10 milliseconds before the next reading:
  delay(10);
  }
}

WITHOUT the CuteDigi rs232 shield attached, the output monitor shows the following when I type "k" on the keyboard:

I received: 107
107
6B
153
1101011
k

The program works perfectly.

When I disconnect power and mount the CuteDigi shield on to the Arduino board, attached db9/rs232 cable to CuteDigi shield, repower and repeatedly type "k" on keyboard, here's what I get echoed in TeraTerm Pro:

Ãkí
Ãkí
kí
Ãkí
Ãkí


Ãkï
Ãkí
Ãkí



Any hints as to what is happening?

Thanks,
Gerald

First thing I'd want to test is whether the shield BY ITSELF was the source of the problem. So, disconnect the serial cable, and connect the USB cable.

Can you communicate with the Arduino correctly when the shield is connected but is not the source of the serial data?

Paul,

No: With the rs232 shield attached, the sketch will not load into the Arduino using the usb cable as I indicated above.

Also, if I remove the shield, upload the sketch to the Arduino, and then power/off, install the shield, power/on, the sketch will not run.

Gerald

I tried your new code on cutedigi RS232 shield. It also works.

You are right. I need to load the code without the RS232 shield. After that, I plug in RS232 shield. DB9 of RS232 shield works same as the USB port when RS232 shield in not on.

Contact support@cutedigi.com for a new RS232 shield. They are responsible and nice.

Thanks, Rocky! Will do. You ALL have been very helpful!

It's Amazing! Within less than an hour, I have received email confirming shipment of a replacement board from www.CuteDigi.com!

Thanks, again, to all who replied.

I'll update a reply when the replacement board arrives.

Here's the latest with respect to getting the CuteDigi RS232 shield to work with the Arduino:

  1. using the sketch I uploaded on 8/8/2010 (see that post), I, too am now able to get the RS232 port on the Cute Digi RS232 shield to work. That is, with the Arduino being powered by the USB cable, the RS232 shield attached, and the RS232 cable attached to the RS232 shield, I can use TeraTerm Pro to echo the characters I type to the PC monitor as programmed in the sketch.

HOWEVER, If I remove the USB cable and power up the Arduino with a 9-v battery plugged in, the program does not work. Instead I get the same garbage characters echoed as I posted above.

So, why won't the Arduino work with RS-232 shield using the 9-v battery source alone (i.e., USB cable detached)?

Thanks,
Gerald

The most simple explanation is that your tiny 9V battery is exhausted. Those 9V batteries have a very low capacity and the current will soon drop beyond usability. Note that the extra shield will need more power than the Arduino alone!

Thanks! I actually think the battery is fresh but what you're pointing out is that it may not be supply enough current to get both the Ard. and the shield to work properly. How much power can I safely appy to the Arduino's power input? Or what other options do I have if I want to use the hardware setup in battery-powered or external power supply situation (non-USB)?

The USB connection provides up to 500mA. Any battery capable of providing that amount of current should suffice. You need not worry about providing too much current, since current is pulled, not pushed.

Thanks, Paul.... That's good to know about current!

Gerald

9V batteries are one of the most efficient and most expensive ways to spoil energy.

The best of them contain 500mAh, their internal resistance is around 50 Ohms, which means they will hardly deliver 150mA, as the terminal voltage drops down to around 7.5V which is just enough to satisfy a non-low-drop 5V regulator.

The ethernet shield will suck more than 100mA alone....

Thanks! It's great to know all this useful information!