Serial Communication Trouble

I'm having some difficulty getting the RX and TX ports to communicate with a Canon PTZ camera. I'm trying to send RS232 commands via pins 0 and 1 on an Arduino Mega2560 to a Canon VC-C50iR. I normally program Crestron and AMX systems, but I have a special project that spec'd this Arduino board as the main controller. Here is a sample command to the Canon:

($ = hex character)
$FF,$30,$30,$00,$60,$30,$31,$EF

This is an 8 byte string for the "tilt up" command. Here is a sample of the code used to send the string:

Serial.write(255);
Serial.write(48);
Serial.write(48);
Serial.write(0);
Serial.write(96);
Serial.write(48);
Serial.write(49);
Serial.write(239);

I have confirmed through the Serial Monitor while plugged in via USB that the correct commands are being sent. However, the camera was not responding, so I connected my Arduino board to my PC's serial port and opened a console program to read the commands. Instead of the expected string ($FF,$30,$30,$00,$60,$30,$31,$EF), I received this string:

$00,$F6,$F6,$3F,$9F,$9D,$21

I'm not sure why the Serial Monitor says one string, while the actual TX output is another. In fact, it's not even the same number of bytes. Am I missing a setup step for the RS232 interface to work correctly? Is there additional hardware necessary? The only command I can find relating to RS232 setup is "Serial.begin(9600);" in the setup section which is already present in my program. I have also tried using the additional serial ports (changed Serial.write to Serial1.write, Serial2.write, & Serial3.write). Any help would be appreciated.

This is an 8 byte string for the "tilt up" command. Here is a sample of the code used to send the string:

If you know the values in hex, why are you converting them to decimal?

Serial.write(0xFF);
Serial.write(0x30);
Serial.write(0x30);
Serial.write((byte)0x00);
Serial.write(0x60);
Serial.write(0x30);
Serial.write(0x31);
Serial.write(0xEF);

Serial.write() sends binary data. I would not expect to open the serial monitor and see anything useful.

Am I missing a setup step for the RS232 interface to work correctly?

Possibly. If the camera expects RS232, the TTL output of the Arduino is not going to cut it. You need a MAX232 chip between them to convert the TTL output to RS232 levels.

If you know the values in hex, why are you converting them to decimal?

Because this was the format given in the sample on the Reference section of the website.

Serial.write(45); // send a byte with the value 45

Thanks for the info on sending hex values, but changing them to that format still produces the same result.

Serial.write() sends binary data. I would not expect to open the serial monitor and see anything useful.

I realized after posting that the serial monitor was NOT showing the correct values. It showed "ÿ00 `01ï". The middle characters are correct (including the NULL), but the stx and etx chars are not. The "ÿ" char is 0x98 instead of 0xFF and the "ï" char is 0x8B instead of 0xEF. Is this a limitation of the serial monitor or is something in the arduino mis-translating the hex characters?

You need a MAX232 chip between them to convert the TTL output to RS232 levels.

Is this true for the 3 additional serial ports on the Mega 2560? Also, is this hardware info listed somewhere? I searched the website thoroughly before posting. The only information regarding physical serial ports is here: Serial - Arduino Reference. There appears to be a contradiction in paragraph three regarding RS232 connection.
"To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground."
followed immediately by:
"(Don't connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.)"
Do I or don't I connect these pins to the device?

In the words of your own post and the data sheet:
""To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground."
followed immediately by:
"(Don't connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.)"
Do I or don't I connect these pins to the device?"

The first sentence says TTL serial device, not an RS232 device - so no you can't just hook the rx and tx pins to the RS232 device. It will wreck those pins with the negative voltage. You need a TTL to RS232 converter chip like the max232 between the pins and the RS232 device.

I realized after posting that the serial monitor was NOT showing the correct values.

Sure it is. "Correct" and "what you want to see" are not the same thing.

The "ÿ" char is 0x98 instead of 0xFF

According to who? The "ÿ" is most definitely what prints when you send 0xFF (aka -1) to the serial monitor.

Though why you are sending binary data to an ASCII device is a mystery.

Is this a limitation of the serial monitor or is something in the arduino mis-translating the hex characters?

No and no. The Serial Monitor is designed to display ASCII data, not binary data. OK, maybe you could consider that a limitation. I don't. There is no mistranslation going on.

Is this true for the 3 additional serial ports on the Mega 2560?

All the serial ports on every Arduino being produced output TTL levels, not RS232 levels.

And, yes, Duckie58 is right.

I realized after posting that the serial monitor was NOT showing the correct values. It showed "ÿ00 `01ï".

The values you are seeing really are the ascii characters that you'll get when you send the hex data. The ÿ is hex 98 according to most extended ascii charts, but that doesn't mean the font that you happen to be using has that character in that particular place. On windows systems the funny 'y' is in position 255. You're getting mislead by various things and this is simply leading to confusion and frustration.

So, basically, the code you put together is sending the right stuff, but it's hard to tell. This is one link to a table of the extended characters that may help you troubleshoot. The Extended Character Set It may not be perfectly correct for your use, but it will help some, and there are lots of others. Just be sure to use 'windows' in the search string.

Regarding rs232, the folks above are correct, albeit they could use a bit more tact in their replies. Many, many people (myself included) didn't realize that the serial ports on the arduino run at TTL levels until they took a close look at it. But, don't despair, just go to ebay and get one of the cheap convertors and get on with the project.

It's interesting that one of the requirements is to use an arduino on one of those expensive cameras. They trying to save some bucks?