Lessons learned, Lessons reviewed
Well, its definitely been an eventful week. I completed all of the hardware portion of the project. I learned many lessons about the project and about prototyping circuits in general that I would like to share with you.
1)Pretty is not as good as functional.
The sensing leads for the current sensing amplifier must be mounted directly across the resistor/fuse and keep them very short . I originally tried to clean up the look of my circuit by routing the Vs+ wire (sensing wire of the current sensing amplifiers) to a 12V rail on the breadboard instead of wiring them directly to the positive side of the individual fuses on the relay board. My understanding was there would be no difference because the 12V on the breadboard was at the exact same potential as the fused 12V bus on the relay board. This allowed me to reduce the required number of wires to the relay board and keep it clean. Also, I had ran wires from the Vs- (sensing wire of the current sensing amplifiers) from the breakout board directly to the negative side of each individual current sensing resistor. There was no way I could have done it any other way because each load circuit is individual and at different potentials. This did not look too pretty, but it was necessary. Well as you might realize this idea of keeping it tidy looking created a functionality problem in the circuit.
This was due to the way the current sensing amplifier operates. The current sensing amplifier (CSA) measures the voltage drop across a very low resistance high wattage resistor. This assumes that the Vs+ terminal of the CSA will always be at a higher potential than the Vs- terminal. This only makes sense and indicates the correct direction of current flow. This was not the case with my original “pretty” layout. The problem was I did not account for the combined added resistance that all of the wire routing on the relay board, the terminals on the relay board, the long length of wire from the relay board to the breadboard, the terminals on the breadboard, the wire jumpers on the breadboard, and the resistance of the breadboard strips themselves. This extra resistance between the 12V bus on the relay board and the 12V rail on the breadboard caused the 12Vrail on the breadboard to be at a slightly lower potential than the 12V bus on the relay board. Not only that but due to that extra resistance and my “pretty” wiring scheme the Vs+ terminal of the CSAs were actually at a lower potential than the Vs- terminals. This was because the resistance between the Vs- terminal and the 12V bus on the relay board is only .005Ω, and the resistance between the 12V bus of the relay board and the 12V rail of the breadboard was closer to 3Ω. This looked to the current sensing amplifier like the current was flowing in the opposite direction and it caused the output of those amplifiers to go negative. Not the result I was looking for and highly inaccurate representation of the reality of the circuits operation. Of course the solution was simple if not “pretty”: I just had to wire the Vs+ terminals of the CSAs directly from the breakout board to the 12V bus of th relay board to eliminate any ohmic losses. Once that was completed the CSAs worked flawlessly and reported the correct current readings.
2)Quit working when you get tired.
This is probably the most important lesson of all, and the one I guarantee you will not follow. Working when its late and you are tired is STUPID. Ever knows that you make mistakes when you are tired and I am no exception. Case in point, I completed all of the final hardware changes to the circuit Saturday night and was happily turning on and off load circuits. I even wired up a 12V Car headlight bulb to act as a typical load. I was getting tired and was about to call it a night when I thought it would probably be neat to check out the operation of the included firmware of the chip. I installed the required drivers and setup Putty to allow me to do simple serial communication to the device. Everything was working really well. I was able to turn on and off the 12V load using the serial console on the computer. Then after sometime it stopped working. I am not sure if this was due to a mistyped command or an improper setup, but it didn't work. I was pretty tired and should have come back to it fresh the next day, but I decided to press on(Just like you always see on those damn reality shows!). Next thing you know I am poking wires into the circuit and then it happens. You guessed it, I let the smoke genie out. I totally fried something on my development board. I am hoping it is only part of the built in voltage regulator, but honestly I suspect I fried the MCU. Only after watching the pretty smoke did I decide that maybe I was a little too tired and I called it a night. I will be looking into on Monday.
3)It doesn't make any sense to breadboard complicated circuits anymore
I eluded to this in an early post, but I will reinforce my stance on this issue. It does not make any sense financial or time wise to breadboard complicated circuits. It would seem that breadboarding circuits would be cheaper and faster than sending out for custom PCBs. This is a fallacy. The cost of custom one-off PCBs has dropped so dramatically that breadboarding has become the more expensive option. This is because breadboarding carries many hidden costs. Those costs include: The higher price for DIP packaged chips, the need for breakoutboards for chips not offered in dip packaging, the cost of wire and discrete components like resistors, capacitors, etc that won't be used in the final design, the cost of labor to design something twice. It usually becomes necessary to design the circuit layout twice. Once to design it using a component selection that will work with the limitations imposed by breadboarding, and a second time to redesign it using components that meet your operating conditions and can be used on production quality PCBs. Another redesign is usually in the software department. Most of the time constants are needed in your code to compensate for the variations in component's actual values to their rated specs. These constant are going to have to be recalculated when switching from the breadboard to PCB due to the many differences in the layout, components, and ohmic values if traces versus wires. The cost of designing a circuit twice also costs you time, which supposedly is the reason to breadboard in the first place. Now the argument can be made that breadboarding allows you to quickly alter your circuit design if need be and PCBs do not. i would say that is a poor argument. With the advent of advanced circuit simulators, most circuits should be thoroughly debugged before a single wire is ran or component is soldered. Also, I have found that the quick design changes are usually needed because your circuit schematic needs to be altered to work around some size limitation, or induced noise, or ohmic losses directly created by the use of a breadboard and not due to some oversight on the engineers part.
4)Lastly, don't overlook the little things; They can cause big problems.
On my way driving home this Sunday morning I got into a car accident and totaled my beloved Nissan Altima. It was a very bright morning at around 7:30AM and it had snowed the previous evening. I started out the morning by starting up my car and checking to see if I needed to use the snow scraper. I did not though, because I had cleared the car of snow last night after the snow had finished falling. I proceeded to drive off and made a right onto Rt. 7 going east. I was driving behind what I believe were a couple of pickup trucks spreading salt onto the road using one of those salt spreader things hanging off the back of the pickup. As I was driving some road grime got onto my windshield. I pushed on the windshield washer fluid/wipers to clean my windshield. To my dismay the driverside windshield washer fluid nozzle didn't function correctly. It only squirted a small stream of fluid onto the lower edge of my windshield. At the same time the wipers activated and unfortunately smeared a combination of salt and road grime directly across my field of view. Combined with the bright sun, the large amount of grime blocked my view and I was temporarily unable to see absolutely anything out of my windshield. I pressed the washer fluid lever again to be treated with more of the same futile effort. Coincidentally, the traffic light ahead of me was turning from green to red and the salt pickup truck came to a stop. I barely touched the brakes before I rammed into the back of him going 30-40MPH. I am fine and hopefully the driver is too, we both walked away without a scratch(Gotta love airbags), but the car looks like an accordion now. This is extra poor timing due to my planned move in date of my new place being tomorrow., but I guess accidents never happen at a good time.
My point is this, a small insignificant windshield washer fluid nozzle malfunctioning directly lead to the ultimate destruction of my most prized possession and the injury of two people. This same lesson can be applied to electronic projects. A single floating ground or shorted pin or unsafe piece of code could lead to disastrous, even deadly consequences when that product is used in the field. We would be wise to treat the seemingly least important part of our project with the same respect we treat the “most” important part.
I will leave you with a proverb:
For want of a nail the shoe was lost.
For want of a shoe the horse was lost.
For want of a horse the rider was lost.
For want of a rider the battle was lost.
For want of a battle the kingdom was lost.
And all for the want of a horseshoe nail.