Displaying data in Serial Monitor

Thanks for your input, PaulS, but I think aarg is correct on the total resistance. :)

Do you guys know why it has to be 100 ohm? I feel like that number should be somewhat flexible, since it's only there as a buffer in case a pin is accidentally set to output, to prevent a direct short to ground. If it's only for that purpose, isn't 100 ohm somewhat arbitrary, as long as it's not too big of a number?

It's too small a value, really. Since the maximum current from a pin should be about 20mA, the smallest resistor value should be 5/0.02 = 250 ohms.

The usual way to read off a ribbon cable is to purchase a couple of shift registers and learn to love them.

There are two types - parallel in/serial out and serial in/parallel out. To read off a ribbon, you want the first one.

The shift register has 8 inputs, one output, and a couple of levers. The first lever makes a chain of flip-flops catch whatever is on the inputs at that point in time. Input 0 appears on the output. The second lever moves all of the bits down by one.

The chips are designed do that you can wire any number of them together in one long chain. Consequently, you only need three wires from your arduino to read any number of parallel input bits.

They are tres cool, and a couple of bucks. Some assembly required, but isn’t that the whole point?

``````word readRibbonCable() {
word result = 0;

digitalWrite(SHIFT_REG_CAPTURE, HIGH);
digitalWrite(SHIFT_REG_CAPTURE, LOW);

word bit  = 1;
for(int i = 0; i<16;i++) {
result |= bit;
}
bit <<= 1;
digitalWrite(SHIFT_REG_SHIFT, HIGH);
digitalWrite(SHIFT_REG_SHIFT, LOW);
}
return result;
}
``````

aarg: It's too small a value, really. Since the maximum current from a pin should be about 20mA, the smallest resistor value should be 5/0.02 = 250 ohms.

This makes a lot of sense, per ohm's law, it should be 250 ohms. I'll proceed with 250 ohm resistors as "current limiting resistors" for each pin.

I am, however, really curious as to why other resources (most of what I've found online), seem to recommend 100 ohms only. Between 5V and ground, a 100 ohm resistor would have a 0.05 amp (50mA) of current, which exceeds a pin's maximum current limits of 40mA (yes, recommended current is 20mA). Am I misunderstanding something or are these resources incorrect at the same time?

http://forum.arduino.cc/index.php?topic=69211.0

http://forum.arduino.cc/index.php?topic=15043.0 (diagram uses 3.3v, but with 3.3v at 20mA, the resistor should be 165 ohms)

PaulMurrayCbr:
The usual way to read off a ribbon cable is to purchase a couple of shift registers and learn to love them.

There are two types - parallel in/serial out and serial in/parallel out. To read off a ribbon, you want the first one.

The shift register has 8 inputs, one output, and a couple of levers. The first lever makes a chain of flip-flops catch whatever is on the inputs at that point in time. Input 0 appears on the output. The second lever moves all of the bits down by one.

The chips are designed do that you can wire any number of them together in one long chain. Consequently, you only need three wires from your arduino to read any number of parallel input bits.

They are tres cool, and a couple of bucks. Some assembly required, but isn’t that the whole point?

``````word readRibbonCable() {
``````

word result = 0;

digitalWrite(SHIFT_REG_CAPTURE, HIGH);
digitalWrite(SHIFT_REG_CAPTURE, LOW);

word bit  = 1;
for(int i = 0; i<16;i++) {
result |= bit;
}
bit <<= 1;
digitalWrite(SHIFT_REG_SHIFT, HIGH);
digitalWrite(SHIFT_REG_SHIFT, LOW);
}
return result;
}

Thanks PaulMurrayCbr! I ended up buying the arduino mega, which has more pins than I need, so my current approach will be to simply get digitalReads for each dedicated pin. I have heard of this approach with shift registers (didn’t really understand it back then), but your example helps! I’ll work your suggestion as a “parallel” effort, in case I find that my current approach doesn’t read it fast enough. May have more questions soon!

Ah, an additional question about the current-limiting resistors. I don't have any 250 ohms resistors available to me; next closest resistors are 360 ohms, and 390 ohms.

At 360 ohms, my current would be 13.9mA; and at 390 ohms, my current would be 12.8mA. I guess since the only purpose of these current-limiting resistors are just in case I accidentally set a pin from INPUT to OUTPUT, the amount doesn't have to be too precise, as long as it's above 250 ohms (and less than 20mA). Is this right?

(I included 390 ohm, even though 360 is closer to 250, because I only have fifteen 360 ohm resistors, when I really need sixteen...)

waynewayne: This makes a lot of sense, per ohm's law, it should be 250 ohms. I'll proceed with 250 ohm resistors as "current limiting resistors" for each pin.

I am, however, really curious as to why other resources (most of what I've found online), seem to recommend 100 ohms only. Between 5V and ground, a 100 ohm resistor would have a 0.05 amp (50mA) of current, which exceeds a pin's maximum current limits of 40mA (yes, recommended current is 20mA). Am I misunderstanding something or are these resources incorrect at the same time?

Here are a few examples of that say 100 ohm: ........

Well, don't get me started :) but in my opinion:

1) There are a lot of people pretending to know more than they actually do. Especially on the internet.

2) There are a lot of people copying each other without fully understanding.

3) It's a precautionary measure, so in many cases such a thing never actually gets exercised.

4) The current spec for the chip has more caveats and conditions than most do, it is tiresome to go through them all and understand the complete picture. So many people stop reading at the 40mA number.

5) In general (again, don't get me started on social analysis, though...) I see more of an attitude that "if it works, don't fix it", or "see, it works, what could possibly go wrong...", and other such lazy thinking, than I am used to seeing in a professional environment (or with people who approach recreational pursuits in a really intellectual way). It isn't just here, it's everywhere.

Also realize that a resistor is not the only way to guarantee that the current is limited. Most circuits get on just fine without it. But it is up to the designer to limit it in some way.

Haha okay fair enough :) thus, I do try to do my own research and put in the work to understand what I can before flipping on the switch

What do you think about my subsequent question on using a 360 ohm or 390 ohm resistor in place of the 250 ohm?

I've used numerous values between 430 and 1000 ohms and still have not had to put the white smoke back into the board.

If it was me, I would not use the resistors (except for pull ups). I would just make sure I didn't ever "accidentally set the inputs to outputs". I don't see that it is so difficult to avoid. For intentional loads, I use the 20mA value. If there were multiple pins, I would reduce it if necessary to meet the aggregate current spec.

I have many boards, one of which is more or less sacrificial. If I goof up and burn an output, I would just replace it (but it has never happened to me!). When I assemble a system and load the previously tested software , I use a brand new board.

Good points, guys..

I think I'll still go with the current-limiting resistor, and just stick a 360 or 390 ohm on it, just for caution's sake. I, too, don't think it's too difficult to avoid, but since I already have these resistors on hand (plus I'm still pretty new to arduino), why not.

My general schematic, per I/O pin, looks like this:

pin(INPUT) ---------- CL resistor ----- signal line | | pull-down resistor (10k ohm) | | ground

I believe that I actually do need a pull-down resistor so that when the signal line has no signal, it'll pull the voltage to ground. But the current-limiting resistor is the one you're suggesting I wouldn't really need to use, not the pull-down resistor, right?

(The reason why I'm using a pull-down, as opposed to a pull-up, is because if I use a pull-up my 0/1's are reversed. I need it such that when the signal line is 0, my arduino puts out 0, and when the signal line is 1, my arduino puts out 1. Pull-down seems to be the way to go here, though I'm sure I can probably just include some code that reverses the 0/1s)

It will work fine with 390 ohms, as you have diagrammed. Pull down is fine. But the device at the other end of the cable has to be high impedance when it is in receive mode so the voltage level won't be reduced by the voltage across the CL resistor.

Sorry, you slightly lost me. Could you elaborate on what you mean by the third sentence? Receive mode, for the arduino pin? And the device at the other end of the cable, being the source of the signal line?

When you are sending data from the Arduino. Is this not a bidirectional cable? When the Arduino is configured for output, the resistor in series will of course increase the driving impedance.

Ah, okay, so the cable has 16 lines which are not bidirectional, and 3 lines that are signal lines (1 is input, 2 is output).

Once the arduino sets each of the 19 lines into inputs/outputs, they will not change anymore. I assume this is what you meant by the bidirectional suggestion?