Pages: [1] 2   Go Down
Author Topic: Serial communications specifics  (Read 1681 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 I've been using other microcontrollers in a project which communicate with each other through digital pins. The uCs are too slow, so I need to upgrade to Arduinos. The problem is, I can't find specifics anywhere & I've already apparently blown up one of my Nanos.

  First of all, how do I wire them together? Do I pull down to ground on the input, or up to 5v? What size resistor do I use? Do I put a resistor on the output, and what size? Why, when I use resistors, do the other uCs (or the other Arduino) power up with no Vcc hooked up to them?

  Second, what is the exact protocol? Data bits, stop bits, parity, and does the line idle high or low?

  Third, what do I have to do with the code to get it to work? I've read the SoftwareSerial routines on this site, and nothing has worked yet. Also, the Arduino seems to have some weird logical rules, I've got "If" statements that seem to run all the time, regardless of the condition being tested.

   I'm trying to send three-byte data packets from one to the other...
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
... communicate with each other through digital pins ...

This is a bit vague. You could be using async serial, I2C, SPI, or some homebrew protocol.

Assuming for the moment you are using serial, you connect all the grounds together, as a reference point. Then the Tx (transmit) from one goes to Rx (receive) of the other. And vice-versa if you want two-way communication. To daisy-chain is going to get fiddlier. You might want to think about I2C which lets you connect up to 119 devices by simply connecting Gnd, SDA and SCL together (not swapped). Having said that there are some wire-length considerations because of capacitance.

I2C requires a single set of pull-up resistors. A lot of detail is here:

http://www.gammon.com.au/i2c

Quote
What size resistor do I use? Do I put a resistor on the output, and what size? Why, when I use resistors, do the other uCs (or the other Arduino) power up with no Vcc hooked up to them?

I'd have to see your circuit to comment. But with a resistor some current will still flow. It sounds odd they are powering up by just connecting the digital pins. In fact it is probably unwise to apply current to the digital pins if they are not powered in some way. You could just connect all the VCCs together (plus all the GNDs) if you had a power supply that could supply enough current.

If you aren't sure, maybe post a quick sketch (diagram) of what you are proposing to do.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 31345
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Also, the Arduino seems to have some weird logical rules,
No it does not, it is just plane C code

Quote
I've got "If" statements that seem to run all the time, regardless of the condition being tested.
My money is on the fact that you have ended the if statement with a colon.
Logged

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

>My money is on the fact that you have ended the if statement with a colon.

 You lose. I'm using the example code in the "softserial" section on this site.

>In fact it is probably unwise to apply current to the digital pins if they are not powered in some way.

  I don't WANT the other arduino powered. I've tried putting resistors on the digital pins, but it's still powering up, and now I'm getting "sync" errors so I'm pretty sure my Nano is screwed. I have to wait until a new one comes in before I can continue troubleshooting. How can I stop them from powering up?
 
  I've had no problems with serial comm on Basic Stamps, PICAXES or the BX-24. They all talk to each other just fine, but the Arduinos aren't getting any info, and the example routines don't work.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 547
Posts: 45982
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
>My money is on the fact that you have ended the if statement with a colon.

 You lose. I'm using the example code in the "softserial" section on this site.
Whoosh. That was hint to post your code. Went completely over your head, apparently.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 31345
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
>In fact it is probably unwise to apply current to the digital pins if they are not powered in some way.

  I don't WANT the other arduino powered.

Then don't apply signals to them that is probably what knackered your Nano. On the other hand if you WANT what you WANT how about re inventing the laws of physics, preferably in some other universe than here.

You are the one asking for help, I think you need a change in attitude to start with.

That statement:-
Quote
Also, the Arduino seems to have some weird logical rules,
Is total bull and is result of you not understanding what you are doing.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  I don't WANT the other arduino powered. I've tried putting resistors on the digital pins, but it's still powering up, and now I'm getting "sync" errors ...

You don't want the Arduino powered? Wouldn't it be easier to omit it altogether?

Quote
... but the Arduinos aren't getting any info, and the example routines don't work.

Because they are unpowered? Be reasonable and give more information. What example routines anyway?
Logged

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

 I'm sorry, I didn't mean to sound as if I had an attitude.  I simply asked a few questions, and was trying to specify what I was looking for.

  Let me try this again:

  1. What is the serial communications protocol, ie. stop bit, parity, logic inverted or not?

  2. How do I keep the other Arduino from powering up through the digital pins?

 
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The protocol is configurable. Typically you have 8 data bits, 1 stop bit, normal logic, no parity. The baud rate you choose on the Serial.begin() function call.

You could normally connect Tx -> Rx and Rx -> Tx (ie. swap them) and also connect the Ground pins.

The chips aren't really designed to "power up" through the few milliamps that come down the serial pins, however as a general rule you don't pump voltages into a device that is itself powered off. Having said that, it probably won't hurt.

To connect serial ports, I would not be using any resistors at all.

I've documented Arduino serial ports here:

http://www.gammon.com.au/forum/?id=10894
Logged

nr Bundaberg, Australia
Online Online
Tesla Member
***
Karma: 121
Posts: 8433
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How do I keep the other Arduino from powering up through the digital pins?
On the powered Arduino change all connected pins to inputs or drive them LOW.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

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

>I've documented Arduino serial ports here:

>http://www.gammon.com.au/forum/?id=10894

  Wow, thanks a lot. That's exactly what I was looking for & more.

 I should probably say that I need the "regular" serial port for diagnostics, and later it'll most likely be connected to a LCD. I need a single communications port to let the Arduinos talk to each other, and I'm using the SoftSerial library for that. It's possible that the other Arduino might not be on sometimes, and I don't want it powering up through the pins - if inline resistors won't work, is there some way I can isolate the pins so that I won't blow up any more Arduinos?
Logged

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

 I just thought of something after I posted this: what if I add an additional digital line from the possibly unpowered Arduino, a "ready to receive" line? The main uC wouldn't have its output line high until it saw a high on the RTR line. If all output lines were low, it couldn't power up through the pins, right? I guess I'll find out for myself after my new Nano arrives...
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 31345
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
is there some way I can isolate the pins so that I won't blow up any more Arduinos?
You can use an opto isolator and a transistor to turn the signal the right way up again.
Logged

nr Bundaberg, Australia
Online Online
Tesla Member
***
Karma: 121
Posts: 8433
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If all output lines were low, it couldn't power up through the pins, right?
See reply #9.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Wellington, New Zealand
Offline Offline
Sr. Member
****
Karma: 1
Posts: 404
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  Third, what do I have to do with the code to get it to work? I've read the SoftwareSerial routines on this site, and nothing has worked yet. Also, the Arduino seems to have some weird logical rules, I've got "If" statements that seem to run all the time, regardless of the condition being tested.

I'm really curious to see the if statements that run all the time.  Sounds bad.  Can you post your code?
Logged


Pages: [1] 2   Go Up
Jump to: