simple serial issue

Eh. I give up. You answer part of the questions posed to you but not all of them. You assert things which experienced members of the forum question but are unwilling to back up those assertions with measurements to support your assertions. You ignore suggestions and corrections from people trying to help you or, worse, argue with them even when the evidence (ie: your project isn't working) shows you to be wrong.

Good luck. You're going to need it.

I didn't implement the use of Serial.available() but thats because I prefer to see -1 than to see nothing. I perfectly well know that receiving -1 means nothing were there - it doesn't mean that I actually received "-1".
I didn't check the voltage of the TX line because I don't have an analog voltmeter. Other times where I have tried this with my voltmeter, it hasn't been able to measure the full voltage of the line. My voltmeter is way too slow to catch the changing voltage. Also, it's not really necessary, as I have already accepted the proposition that my GPS might be 12v. That's why I started experimenting using my RS232 to TTL converter in between the GPS and the arduino. Theres no reason to make experiments to convince me when I'm already accepting the idea (and my recent use of the RS232 to TTL converter shows this).

Is the above behavior unacceptable, or do you have other reasons to discard my case?

The only text on the GPS is this:
"Model no.:
GPS-601
Made in Taiwan
Tested to comply with FCC standards"

Thats why I can't tell you either manufacturer name or part number. I've tried googling "GPS-601" but it doesn't reveal much.

Your adaptor need to be powered. simply connecting the TX/RX line won't do it. Adaptors like that are useually port powered threw pin 7 (RTS) of the DB9 connector. You might be able to use the +5v from the Arduino to power the adator. If you don't have the specs for the adaptor, open the case and see if you can I dentify where to power it from.

This is the adapter that I am using:
http://awce.com/rs1.htm
That website says: "Pin 1 and 2 require +5V (regulated) and ground." I think they mean pin1 has to have 5v and pin2 has to go to ground - both on the 5v side. Also, thats the names on the pins 1 and 2 on the TTL side, so thats how I have wired it up. The voltage is there and its 5.00 volt.
Referring to this image:
http://www.circuitdb.com/show.php?cid=172
I'm connecting the TX line from the GPS to either pin2 or pin3 on the 12v side. So Im trying all four combinations (pin2 or 3 on the 12v side and crossing or not crossing the two com lines from pin "T" and "R" on the converter to pin0 and 1 on the arduino). I also tried the pin4, just in case I am doing a "mirroring" mistake. The GPS is powered from the power from the power pins from its original cable (a usb to serial converter). This power source works fine, as I managed to get data from the GPS to my PC using them.
All while I'm running this code on the arduino:

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

void loop() {
char hardSerialChar = Serial.read();
Serial.print(hardSerialChar, DEC);
}

I simplified the code a bit. I don't know what baud rate the arduino PC-side software uses for uploading code to the arduino, but I have set the Serial monitor to listen using baud 4800.

As always, the result is a series of "-1" :frowning:

I haven't got hold of a camera yet, but I'm working on it.

Thank you all for your help and patience. I really appreciate it!

Finally got some pictures up:
http://appliedusers.dk/jon/Arduino-GPS/4.JPG
http://appliedusers.dk/jon/Arduino-GPS/5.JPG
http://appliedusers.dk/jon/Arduino-GPS/1.JPG
http://appliedusers.dk/jon/Arduino-GPS/2.JPG
http://appliedusers.dk/jon/Arduino-GPS/3.JPG
http://appliedusers.dk/jon/Arduino-GPS/6.JPG
http://appliedusers.dk/jon/Arduino-GPS/7.JPG
http://appliedusers.dk/jon/Arduino-GPS/8.JPG

Any questions? Just ask. It all makes sense :slight_smile:
The white cable is the USB from the PC to the Arduino. The black is the USB to Serial converter that came with the GPS. Its plugged into the PC as well.
The little black box with round edges on the laptop is the GPS. In between the GPS and the USB to Serial converter is a little homemade breakout device. Two wires goes to get some power from the USB to Serial converter, while the third (TX) is plugged into pin3 on the DB9-jack on the RS232 to TTL converter (sorry, the pin had fallen out on some of the pictures). This breakout-setup has been tested with the PC as the recipient, and it worked 100% - I received loads of NMEA-data.
From the TTL-side of the RS232 to Serial converter goes 4 pins: two to get power from the breadboard (measured at the pins: 5.00volt). The two other ("T" and "R") goes to pin 0 and 1 on the Arduino. My testing involved switching these pins, and trying to insert the TX-pin from the GPS in different holes in the female DB9-jack.
All I got was alot of "-1".. :confused:

Haven't looked them over real hard, but one thing I don't see is a common ground between the Arduino and the GPS. I see that you are powering the Arduino from the USB port of the PC, but does everything share a ground?

Easy thing to try is connect a wire from the Arduino ground to the all the oter grounds. 2 devices being powered from seperate supplies need to share a ground for data. I have done that to my self a few times.

It don't look like your problem is that simple, but you never know.

Okay.

Two main problems.

  1. Already mentioned, there is no common ground. RS232 requires a common ground between all devices. That explains why you got nothing when using SoftwareSerial, and why you wouldn't have gotten anything with hardware serial, if you had been aware of the next point:

  2. Look over to the other side of the Arduino board. See those two other pins labeled 0 and 1, and also RX and TX? I think you know where I'm going with this.

I see someone already caught it, was just looking over the pics again. You aren't connected to the TX and RX pins on the Arduino.

:-[
This is slightly embarrasing..
Now it apparently works. At least I see loads of digits - all of which is something else than "-1". Only issue now is that the Arduino IDE has started freezing 100% when I try to upload new code to my board. It just writes "Uploading to I/O board..." and then its dead. Afte 5 mins I kill it from Windows task manager. That means I cant change:

Serial.print(hardSerialChar, DEC);

into:

Serial.print(hardSerialChar, BYTE);

So I can have a final confirmation that what I see is the NMEA-data (but what could it else be).

But anyway, thank you all for your help. It really was a simple serial issue :wink:

Just add the common ground and go back to the software serial code, you can't upload because pins 0 and 1 are also used for the bootloader. If you attach something to them, it can easily interfere with the upload, that's why we were all skeptical of that method at the beginning. Plus, you would see all the data twice, once when it was sent to the Arduino and PC from the GPS, and then again when the Arduino sent it to the PC.

to macegr:
I guess your comment apply generally to all projects that use the hardware serial port of the arduino? Or is there something in my setup that makes it extra delicate/complicated/unfortunate/risky?
I can't see how use of the hardware serial on the arduino can awoid having the effects you mention.

Most successful hardware serial projects are connecting to only one device at a time. That means disconnecting other devices while downloading code to the Arduino.

It's why the software serial library exists.

I've now added common ground.

I guess one can actually brick a Arduino by writing a program that constantly sends some trivial data (like "A") to the PC

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

void loop() {
Serial.print("A");
}

That would make it impossible to ever write programs to it again, as it will hang, just as mine is doing now, when I upload while my GPS is connected.

WAUW, now it works perfectly :smiley:

I'm using this code:

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

void loop() {
if (Serial.available()) {
char hardSerialChar = Serial.read();
Serial.print(hardSerialChar, BYTE);
}
}

The code without the if Serial.available inserted alot of "-1" in the NMEA-sentenses (hmm, one could actually figure out the cycle-speed of the 'void loop' function by looking at how many "-1" are for each NMEA-letter, and knowing that the baud rate of the GPS is 4800)

I had some issues right up till now. Using the power supply from the breadboard to support my GPS made it not turn on (which I didn't notice). Using the ground from the breadboard and the power line from the original GPS-cable also didn't work - the GPS turned on but couldn't communicate anything. Finally I added a wire from the ground on the breadboard to the ground-jack on the original GPS cable going to the computer. THEN it worked. PHEW!! I was getting really frustrated.

And yes: DON'T let data go into RX when uploading new code to the Arduino.

Good to hear you have it going and nice to see that Serial.available() has finally made it into your code. :wink:

Have fun!

i am not sure if this is where i ask anyway i am new to using arduino.
i am building a miniture dynamometer and i want to send four types of information(voltage,speed,load pressure) to my program (vb) over a serial link. please if anyone can help i would be gratefull
thanks

I guess one can actually brick a Arduino by writing a program that constantly sends some trivial data (like "A") to the PC

Hmmm.... that didn't brick my Arduino.

to mikalhart:
no I figured that myself too. The problem only occurs with stuff going into the RX pin on the Arduino. And that you can aways mitigate by removing the source of that stuff. So no bricking option here :slight_smile: