I have just completed construction on my first Arduino project, an electronic dice roller. Before installing a battery and powering up, I thought it would be a good idea to do some basic checks to rule out a short which might blow everything up, so the first thing I did was to check for continuity (hoping to find none) between the ground rail and the 5V power rail. Strangely, what I get is a momentary beep on the meter -- suggesting that somehow there is a short which only exists for a fraction of a second when I first touch the meter probes to one contact or the other. Unlike what I would expect if a connection were shorting out, the beep is not continuous. It does not seem to be related to movement or position.
I have attached a schematic for the beast -- not very professional, but hopefully adequate to give a sense of what is going on. Basically, there are three sets of components:
The Arduino board itself,
A perfboard which contains 17 resistors (15 to limit current to the LEDs and 2 to pull down some of the switches, and
Components which interact with the player (15 LEDs and three switches) mounted on the front panel.
Connections between the panel and the perfboard are made with Molex KK connectors. Connections between the perfboard and the Arduino are made with Molex connectors on the perfboard side, and Polulu connectors (gender changers and female pins/housings) on the Arduino side.
Any suggestions for how I might approach tracking down this odd behavior would be appreciated.
RobRothman:
I have just completed construction on my first Arduino project, an electronic dice roller. Before installing a battery and powering up, I thought it would be a good idea to do some basic checks to rule out a short which might blow everything up, so the first thing I did was to check for continuity (hoping to find none) between the ground rail and the 5V power rail. Strangely, what I get is a momentary beep on the meter -- suggesting that somehow there is a short which only exists for a fraction of a second when I first touch the meter probes to one contact or the other. Unlike what I would expect if a connection were shorting out, the beep is not continuous.
Try the same test with a capacitor...
(be sure to short the capacitor legs together before each test)
Sorry for my ignorance, but I'm new to this: Where would I put the capacitor (across the rails or in series with one of them), and what would this test tell me? Also, any ballpark suggestions for the value of the cap to use?
I also realize that there are two facts which I neglected to mention in my earlier post:
The perfboard contains 2 shift registers in addition to the 17 resistors, and
The strange behavior occurs whether the main power switch is turned on or off.
You will see a momentary low resistance as the caps on the board go from discharged to a charged state from current injected by the meter. I would expect that design would eventually get up towards 10s of Ks of resistance.
CrossRoads:
You will see a momentary low resistance as the caps on the board go from discharged to a charged state from current injected by the meter. I would expect that design would eventually get up towards 10s of Ks of resistance.
You will see a momentary low resistance as the caps on the board go from discharged to a charged state from current injected by the meter. I would expect that design would eventually get up towards 10s of Ks of resistance.
And what would this imply as to why I am getting the momentary continuity without the capacitor? Or would it suggest that the momentary short is not really a problem?
Posted by: CrossRoads
You should also add 0.1uF cap from Vcc pin to Gnd of each shift register.
I had tried this in the breadboard stage. What I found was without the caps, it worked fine; when I added them, thigs started generally behaving very strangely. So I took the "Don't fix it if it ain't broke" approach.
IAnd what would this imply as to why I am getting the momentary continuity without the capacitor? Or would it suggest that the momentary short is not really a problem?
It's NOT a problem. That's the way capacitors work... In series, they tend to "pass" AC and changing voltages and they "block" DC. A "sudden" connection of the Ohmmeter is a "change" and current flows as the capacitor charges-up. If you look-up the formula for inductive reactance (impedance) you'll find it's inversely proportional to frequency.
I had tried this in the breadboard stage. What I found was without the caps, it worked fine; when I added them, thigs started generally behaving very strangely.
Connecting small capacitors between power & ground should never cause a problem... Maybe something was connected wrong or something was shorted?
So I took the "Don't fix it if it ain't broke" approach.
That philosophy is OK to a point, and if your circuit is working you may not need them.. But, the lack of bypass capacitors can often cause random/strange/unpredictable problems. If you go "into production" (or if you just build a 2nd identical circuit) you might find that only half of your boards work, or that 90% of them work, or that 90% of them fail, etc.
...If you remove half of the bypass capacitors on your computer's mother board, it will probably still work fine. But its proper engineering practice to put a bypass capacitor on every chip... Or on every power pin if you have a high density chip with multiple power-pins.
P.S.
It's normal to get an "inrush" of current when you first switch-on a power supply or first connect a circuit with capacitors. It's possible to do something "bad" like connect one of those 1 Farad (1 million microfarad) capacitors that they use with high-power car stereos to a small power supply. In that case you might get too much current for too long and damage the power supply.
I took the plunge and powered the circuit up. The good news is nothing seems to have been fried. The bad news is that it is behaving oddly (and not entirely consistently). Basically, when I first power it up (without hitting the "roll" button), some of the LEDs (not always the same ones) light up. When I then hit the roll button, nothing happens. So it looks like the first thing to try, as per the suggestions that have been made, is to add some capacitors between power and ground of the shift registers. All I have to do is figure out how to fit them onto the board while keeping them pretty near the registers and not accidently having the leads touch something they shouldn't. I guess I would have been better off adding them originally, when I could have planned for them when laying out the board -- but I guess that's why the process is called learning.
Happy to include the code (it's attached to this post), but since it worked fine on the breadboard I'm confident the code is not the explanation.
I didn't see debouncing as an issue, since it shouldn't affect the functioning if a single button press is read as multiple presses -- it just means that it will run the routines for generating random numbers and displaying the appropriate pips multiple times (but the only one that matters is the last one). If anything, that simulates a physical die roll, where the dice bounce around a bit before reaching their final resting position.
There are two shift registers on the board, so, as has been suggested, I will add caps to decouple the power supply to those.
In examining the board to see how I might fit in the capacitors, I realized that I made a much more fundamental error. When I soldered the connections to the sockets for the shift registers consistent (I thought) with the pinout diagram, I was looking at the bottom of the board (where the solder connections are) rather than the top (which is how the diagram is oriented). Thus, every connection to the chips is on the wrong side!
Unfortunately, desoldering all of these connections and redoing them correctly will probably wind up being more difficult than building the board was originally.
RobRothman:
Well, I win the idiot of the year award!
Well, we all knew something was badly wrong with your wiring when you claimed that adding the bypass capacitors caused it to malfunction. Basically, that can never happen, so it really gave the game away.
I rebuilt the board from scratch, using all new components and adding a capacitor between the Vcc pin of each shift register and ground. (It was easier to do it this way than to desolder all of the parts and try to get them off in usable form, and the parts -- resistors, sockets for the shift register chips and connectors -- are all quite inexpensive.) After a bit more work tracking down and fixing problems, the gizmo was working fine -- or so it appeared.
Once it appeared to be working correctly, I proceeded to what I thought would be the final step, namely attaching the Arduino board and the perfboard to the inside of the enclosure. Note that the enclosure is plastic, not metal, and I used plastic standoffs in any event, so the problems (which I am about to describe) are not the result of the enclosure itself causing a short.
When I powered it up after screwing down the boards, the LEDs constituting the first die (what the code calls die(0)) continue to work perfectly. The second set of LEDs, constituting the second die (die(1)), however, are behaving very erratically. Sometimes they don't come on at all, sometimes they come on but in weird patterns that do not match the patterns of a real die (and do not match the binary numbers which the figurePips function uses to represent those locations), and sometimes one or all of those LEDs come on when they shouldn't (e.g., when the system is first started or when S2 is in "Big Julie" mode (where nothing is supposed to light up because ya gotta remember where da spots formerly wuz)).
THIS IS A CONTINUATION OF THE PREVIOUS POST -- Sorry, I accidently must have hit the "post" button before the message was complete).
I have tried the following:
Although I did not change the code between the time when it was working OK and the time when the problem showed up, just to be sure I added a few lines which allowed me to use the serial monitor to see what was going on. The microcontroller appears to be calculating the correct pips to turn on.
I added a second capacitor to the Vcc pin of the shift register controlling the problematic bunch of LEDs (parallel to the existing capacitor). The problem persisted.
On the off chance that somehow the shift register itself got damaged, I swapped it out for a new one. No dice (no pun intended).
Bottom line is I'm now at a loss as to what else I can do to track this down. :~ Any suggestions?