Debugging Techniquesx

Download Report

Transcript Debugging Techniquesx

DEBUGGING
TECHNIQUES
Wiring
• Type of wire to use
• Solid core for breadboard
• Multiple-strand for flying leads and connections to power supply unit (PSU)
• Be consistent with colour coding of wires, especially power supply
signal to differentiate different levels.
• Suggested colours of red for +5V and orange for +3V
• Being consistent as is easier to help debug each other’s circuits and reduces the
chance of accidentally applying wrong voltages.
• Be consistent with colour coding signal for scope channels as we easily confuse
the written colours with the channel colour. This helps when looking at the
images collected from the scope later.
• Known the Stroop effect
Circuits
• Know what the expected voltages are at intermediate points in
the circuit.
• This is what circuit simulation and hand calculations provide you.
• Begin with simple measurements.
• Is there power to all of the components in the circuit?
• Are all of your grounds connected to one another?
• Start at the very beginning of the circuit.
• Does the input signal exist?
• Move from one circuit to the next to make sure that the data
flow is correct.
• Where possible, disconnect subcircuits and inject known input signals in
and measure output.
• For example, disconnect the amplifier from the optical sensor and make sure that
the amplifier works properly with a known input signal.
• This is why we breadboard a circuit before soldering the components on to a PCB.
• Feel (carefully) if the major components in the subcircuit are hot, but not too hot.
• Record your measurements!
• Other members of your team may want to look at them – Use their help.
mbed
• Electrical
• Make sure that the voltage supplied to power the mbed is the
correct voltage, particularly when the other components in the
circuit are consuming power.
• Voltage droop
• Suggestion:
• Connect the mbed into the pulse meter circuit after you have
determined that all of the other subcircuits work properly.
• There are few replacement mbed available and none are free!
mbed
• Software
• Be neat and structured
• Split the code into small understandable sections
• Comments need to be accurate
• Ideally, there is a comment with every line of code to explain what that line does.
• Industry standard is that a software engineer writes about 10 lines of good code per day.
• Naming variables, functions, and subroutines be consistent
• There are some cases where a decision may be made whether hardware or
software should be used to perform certain functions. Identifying the blocks of
code that act like a hardware block allows others to insert or remove the software.
• Debugging Without a Debugger
• Toggle a pin and note whether there was a reaction to an input – switch between
features or modes on a serial port
• Save old versions of your code
• Have a naming convention that allows you to determine which code is the latest
one.
• Other suggestions on debugging are posted at
http://developer.mbed.org/handbook/Debugging
Debugging on a PCB
• Put test points at appropriate places on the PCB
• Test points are places where there is an a pin (or an exposed metal
run, but this is not really good practice) at an input or output
terminal of a component so that you can measure the voltage at
these points.
• Test points can also be used to inject known input signals into
subcircuits when disconnected from the rest of the circuit.
• Construct circuit on PCB in blocks
• Build the subcircuit that caused the most problems on the
breadboard first.
• Characterise it with a known signal injected at a test point and power
supplied to the ICs.
• Once it is working, continuing building the rest of the circuit. Stop to
verify that the subsequent blocks function properly.
Header pins
http://www.rapidonline.com
http://www.robotroom.com/SandwichPCB/SPCBTestPoints.jpg
Use IC sockets
• Only solder an IC directly on to your PCB if:
• You are exceptional at soldering and won’t
• overheat the component
• accidently solder two pins together
• solder the part in backwards
• and will never damage the part while testing the circuit.
• Otherwise, use an IC socket
IC socket for mbed
• Two female header strips 1x20
• You will have to layout the holes for the header strips correctly so
that the two rows of pins on the mbed line up with the two header
strips.
• You will also have to solder the two header strips in well so that
they are perpendicular to the PCB and will not flex when the mbed
is pushed in place.
1x10 female header strip as an example
http://www.technobotsonline.com/female-pcb-header-1x10.html
Label Component Locations
• Use your PCB as more than a way to run metal wires from
one component to another.
• Put your names on it.
• Label the locations of the components
• With the full name of the component if possible or a code that you give
to the component.
• Number the holes for pins or location of notch to remember how the IC
and electrolytic capacitors should be placed on the board.
http://www.robotroom.com/SandwichPCB.htm l
If you are frustrated
• STOP!!!
• Bad things happen to good circuits when the person debugging is
ticked off.
• Same is true if you are rushing because you have other things
that you must do
• Friday evening tend to be poor time to debug circuits if your friends are
waiting for you somewhere else.
• Don’t wait until the end of the semester to get this project done,
time pressures make for bad decision making and major errors.
• Also, you and your teammates will not get a good grade as there will
be due dates for sections of the project throughout the semester.
• Debug with someone else on your team.
• Discussing what is observed can help you both think through the
problem and find a solution.
This is a team project
• Figure out how to keep your teammates informed about the
status of the project.
• It is a waste of time if you debug the software, find the errors, and fix it
and then a teammate repeats the same process using the original
code.
• Store the components, breadboards, PCBs, and software in
places where the other team members can access them.
• It is not an acceptable excuse to say that your teammate took the
circuit home over the weekend to show the parents and then forgot to
bring it back to school.
• When there is a problem and/or a solution, everyone on the
team should be aware of it.
• There should be note of this in the minutes from team meetings
recorded by the scribe (stapled in each lab notebook) or a hand written
note/copy of an email in each team member’s lab notebook.