Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 15
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
One birthday today, congrats!
Vaxian (17)


Next birthdays
05/21 Dalus (34)
05/21 Kizmo (37)
05/22 Skynet (32)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: Computer Science
« Previous topic | Next topic »   

Weird serial communication problem ...

Move Thread LAN_403
lpfthings
Sun Jun 27 2010, 02:53PM Print
lpfthings Registered Member #1361 Joined: Thu Feb 28 2008, 10:57AM
Location: Cairns, Australia
Posts: 305
I bought a Silicon Chip Web server in a box kit today, and put it together. It has a RS232 output, on a 3 pin header: RX, GND, TX

I connected GND to Arduino GND, TX to Arduino RX, and RX to Arduino TX.

The web GUI for it has the option to send strings, strings with newline, and decimal character code.

I have setup the Arduino to just echo back anything it recieves:
void setup() {
  Serial.begin(115200);
}
void loop() {
  if (Serial.available() > 0) {
  Serial.println(Serial.read());
  }
}

Baudrates on both sides seem fine.

Here is the problem:

Whatever I send, seems to get translated into a bunch of numbers. If I send 1 thru to 10 thru the decimal character code option, it gives me:

127
63
126
31
125
62
124
15
123
61

Sending it 1 - 10 thru string with newline:
103
121
61
179
222
15
102
121
61
89
222
15
101
121
61
178
222
15
100
121
61
172
235
0
99
121
61
103
86
235
0

abcd with string and newline:
79
121
61
167
222
15
78
121
61
83
222
15

If I send string without newline, I only get single values.

1 to 13:
103
51
102
25
101
50
100
12
99
103
6
103
103
103
51
103
102

a - z without newline:
79
39
78
19
77
38
76
9
75
37
74
18
73
36
72
4
71
35
70
17
69
34
68
8
67
33

A - Z (Caps) without newline:

95
47
94
23
93
46
92
11
91
45
90
22
89
44
88
5
87
43
86
21
85
42
84
10
83
41

The numbers seem consistent. Like, if I keep sending it the same value, it keeps giving me the same value, I just don't know what the values mean ... and how they are encoded, really strange!

Cheers,
Dan :)


Back to top
Bjørn
Sun Jun 27 2010, 03:14PM
Bjørn Registered Member #27 Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
If your signal is inverted then the result would be something like what you get so look into that. Have a look here too: Link2
Back to top
lpfthings
Sun Jun 27 2010, 03:23PM
lpfthings Registered Member #1361 Joined: Thu Feb 28 2008, 10:57AM
Location: Cairns, Australia
Posts: 305
Thanks Bjorn, seems like it could be my problem :)

Since the ATMega328 already has direct RS232 input (SInce they use a FTDI chip to generate it), is there any way to invert this signal without having to use another IC?

I'm sorry if this seems ignorant, I really do not understand serial well smile

Heh nevermind, I'll just pick one of these up today: Link2

Cheers,
Dan
Back to top
klugesmith
Mon Jun 28 2010, 05:36PM
klugesmith Registered Member #2099 Joined: Wed Apr 29 2009, 12:22AM
Location: Los Altos, California
Posts: 1714
Hi Dan.
Since your data are repeatable, I'm sure you can resolve your problem by studying the reported 1's and 0's with respect to an ASCII character table, and looking for the pattern.

Things to pay attention to:
1) Voltage levels.
1A) RS-232 is a bipolar standard, where "Mark" voltage (data=1 or idle line) is negative, commonly about -10 volts, and "Space" voltage (data=0) is positive, commonly +10V.
1B) "RS-232 compatible" serial Tx and Rx on microcontrollers, or the logic side of level-translator chips, have TTL voltage levels and the opposite polarity. Mark voltage (idle line or data=1) is > 2 V; Space is < 0.8 V.

2) Parity and stop bit options -- there's no standard, but transmitter and receiver must have the same settings.

3) Bit order: LSB is sent first, right after the Start bit which is the first logic 0 (Space) voltage.

As a baby step, try a loopback configuration with Arduino Tx and Rx pins tied together. Then anything you send to the Tx should appear at the Rx. You might also start with a lower baud setting, like 9600.
Back to top
...
Mon Jul 05 2010, 12:21AM
... Registered Member #56 Joined: Thu Feb 09 2006, 05:02AM
Location: Southern Califorina, USA
Posts: 2445
I am confused as to exactly what you are doing. Keep in mind the arduino TX and RX pins are internally connected to the ftdi usb-serial chip, and any data that appears on the terminal inside the arduino software is present on these pins. Generally when connecting external serial peripherals you will want to use the SoftwareSerial library to create a serial port on 2 unused GPIO pins. My understanding is that it is possible to use these pins to connect to other stuff, but you have to 'fight against' the usb-serial converter so it is not recommended and may be what is causing your problem.

I would recommend starting by connecting the webserver's tx/rx pins together, and making sure that the web interface behaves as you expect it to. After that is working, connect the tx/rx pins to the new software serial port on the arduino, and have it echo received characters from the web server out the arduino debug port (the normal serial.println interface you are using now) and watching what comes out in the terminal in the arduino software. After that is working correctly, then try and send characters from the computer to the arduino, etc.
Back to top

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.