Pages: 1 2 [3]   Go Down
Author Topic: simple serial issue  (Read 1810 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
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".. :/
Logged

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 415
MEGA_Stick_II is here
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

SF Bay Area
Offline Offline
Edison Member
*
Karma: 10
Posts: 1235
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

0
Offline Offline
Sr. Member
****
Karma: 1
Posts: 415
MEGA_Stick_II is here
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 :-[
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 smiley-wink
« Last Edit: January 26, 2009, 04:20:23 am by loldrup » Logged

SF Bay Area
Offline Offline
Edison Member
*
Karma: 10
Posts: 1235
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

SF Bay Area
Offline Offline
Edison Member
*
Karma: 10
Posts: 1235
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

WAUW, now it works perfectly smiley-grin

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.
Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Have fun!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
« Last Edit: January 27, 2009, 03:41:27 am by loldrup » Logged

Pages: 1 2 [3]   Go Up
Jump to: