Confounding Serial Output

To begin, I have been scouring the internet for over a day. No dice. Anyways...

I have a magnetic stripe reader that uses RS-232 serial, baud rate of 9600, 8 data bits, 1 stop bit, and no parity according to the manual:
http://www.idtechproducts.com/download/swipe-readers/doc_download/67-user-manual.html

PIN SIGNAL
2 TXD
3 RXD
4 DSR (Supply Voltage in)
5 GND

Anyways, every variation of code I have tried has either given me bizarre characters or numbers that correlate with weird ASCII characters. When I try the reader on PC it outputs like a charm. When I connect it to the arduino and attempt to view its output on the arduino serial monitor I get craziness. I have tried running at other baud rates too. I have searched the web for other variations on code to get it to work like...

It should output

;682107718698421?

It doesn't...

I have tried (among many other things)

/*
   Software serial multple serial test
  
  Receives from the hardware serial, sends to software serial.
  Receives from software serial, sends to hardware serial.
  
  The circuit: 
  * RX is digital pin 10 (connect to TX of other device)
  * TX is digital pin 11 (connect to RX of other device)

  */
#include <SoftwareSerial.h>

 SoftwareSerial mySerial(10, 11); // RX, TX

void setup()  
{
   // Open serial communications and wait for port to open:
   Serial.begin(9600);

   Serial.println("Goodnight moon!");

   // set the data rate for the SoftwareSerial port
   mySerial.begin(9600);
   mySerial.println("Hello, world?");
}

void loop() // run over and over
{
   if (mySerial.available())
     Serial.write(mySerial.read());
   if (Serial.available())
     mySerial.write(Serial.read());
}

which yields (plugged into pin 10 and 11)

Goodnight moon!
(giberish)

and

int next;
String output = "";

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

void loop()
{
  
  if (Serial.available() > 0)
  {
    next = Serial.read();
    Serial.print(next);
    Serial.print('\n');
    output = output + next;
    
  }
}

which yields (plugged into pins 0 and 1)

0
190
189
239
223
251
255
166
127
187
204
191
255
246
127
219
183
157
155
255

So... help? I am relatively new to Arduino... I have a Uno.

The RS232 output is not electrically compatible with the Arduino input. It would probably be +/- 12V whereas the Arduino expects 0 to 5V. Also the RS232 signal is inverted.

You need to run it through an adapter or chip like the MAX232 to convert the electrical signal. Don't keep trying, you will damage the input pin. (Measure the output of the gadget with a meter to confirm this).

This sort of adapter, for example:

I appreciate the response! I placed an order for the aforementioned part and will update when I get it. Hopefully Friday.

So... I ordered the part without really thinking this through. I have it now and wired it up how I presumed it worked, but obviously not how it works... I've begin to search for info/advice, but figured you all would be more knowledgeable. The pictures have my set-up. You can probably tell I'm sorta clueless.

Whoa, those 2 Mb pictures are a bit hard to download, and even then they don't show a lot. How about resizing them? A few hundred K should be plenty.

The Arduino Basic Connections book shows how to connect DB9 connectors (page 21).

I can't tell if you have done it right or not.

Some rs232/TTL setups.

http://www.scienceprog.com/alternatives-of-max232-in-low-budget-projects/

Uh, why don't you plug the device into the converter? Is the gender wrong? Can't you get a gender-bender?

Can't you get a gender-bender?

Gender changer?

Whoops, that must be what I meant. :slight_smile:

The device is port powered and the converter doesn't seem to supply power. I do have a gardener changer and have tried that. I've skimmed the links (going to keep looking at them right now) but haven't figured out what could be the issue yet.

So, I'll put what I have into words to hopefully make my error(s) clearer.

I have a Port Powered Serial card reader http://www.idtechproducts.com/download/swipe-readers/doc_download/67-user-manual.html
When I power the device with the +5v from an arduino board (and ground to Arduino and the PC) and connect pins 2,3 and 5 (ground) to the PC I can read the data fine with a serial reader.

When I instead put the RX and TX pins into the arduino 1 and 0 pins (also tried digital reader in 10 and 11) I get gibberish. I have tried switching the TX and RX around just to be sure also.

I don't fully understand the Arduino's reading capabilities, so it is possible there is a reason right then and there that the PC can read it and the Arduino can't.

Nick suggested I buy an adapter (Product Page: SparkFun RS232 Shifter - SMD - PRT-00449 - SparkFun Electronics Schematic: https://www.sparkfun.com/datasheets/Prototyping/RS232-Shifter-SMD.pdf) of sorts that I believe converts RS-232 to TTL (which I don't really know much about either) as that is what the Arduino can read. It is possible I misinterpreted what he was saying, of course.

Wiring up this adapter with that is my best guess (probably not very good) as to what should happen gives me no results. I occasionally get 0s and the occasional 255, but this only seems to happen when the card reader loses and regains power. When I read with the PC I get letters, symbols, numbers, etc...

I posted pictures of my setup at this point previously. Going to keep trying things...

The cardreader PDF states it uses DSR, fixed HIGH for power.
I think that's supposed to be at least +5.
So, you'll have to run D-sub pin 4 to Arduino +5, PDF says it runs 8mA or something so that should be OK.

How good is the contact between the sparkfun board and the header pins you're like stuffing through them? Dubious.
That should have header pins in it or wires soldered to and patch the jumper-headers into your breadboard or into the Arduino header, what have you.

I agree the connections are dubious at best. The replacement tip for my soldering iron isn't coming until Wednesday so I've had to resort to this. Going to try and make sure the connections are better for the time being though.

So, at present, is the cardreader's green (power OK) LED coming On then?

Yea. I've gotten the card reader to work completely on the PC serial link by powering it with the Arduino and linking the TX and RX and ground to the PC. I've gotten it to spit (somewhat consistent) gibberish to the Arduino (as viewed by Arduino serial monitor) by putting the RX and TX in the Arduino pins. Now, with the adapter in place I have a connection to the 5v+ to the adapter and the card reader pin 4; ground to the adapter, the card reader, and the adapter 5 pin; the adapter connected to the Arduino TX and RX pins; and the 2 and 3 pins in the device to the 2 and 3 pins in the adapter.

I see that you are trying to receive a byte from the cardreader and then immediately outputting that to Serial Monitor.
I think that you should collect the cardreader's datastream into an array and once it's all in then output that lot to Serial Monitor (but not one by one as it looks like you are.)

jsawy3r:
I do have a gardener changer ...

We seem to agree we aren't sure what to call the damn thing. :wink:

I'll try an array. If I want it to output ASCII characters, what should I be saving the data as? Also, it seems as thought the adapter isn't reading the card reader. When I put some current to the adapter's DB-9 receive pin the TX light turns on, but when I instead put it from the card reader's output pin to the adapter's receive pin I get no light or data.