|
Advice page for lab 3b
Attaching the cables to the cube
Plan where your connections will go before you start soldering. Then, cut your
wires to length. Hint: your wires will almost certainly not all be the same
length, they probably have different distances to go to get to their
connection points!
The hardest soldering was last week, but this job still matters so keep up
your awesome, now much-more-practiced skills for this week! Make sure your
solder completely covers the joint, but don’t use so much solder that it
bulges out from the joint.
Ethernet cables (which we are not using for Ethernet, but rather to connect
your breadboard circuit to your cube) have eight wires in them, which is
perfect if you did the LED cube. Use one cable for anodes and one cable for
cathodes (unless you have a good reason for some other method).
Breadboard
With so many pins, wires and transistors, laying out the breadboard neatly can
be hard, but it’s still worth doing right. You might need some over-the-top
jumpers, but minimize them by strategically selecting which pins you use and
where you put your PMOS transistors. Remember, you can always change your pin
numbers in your code.
A reminder: Avoid pins 0 and 1. Pin 13 has an onboard LED attached to it, so
it can be used as an output, but not as an input.
Coding
If you feel like your programming background's a little shy, the
slides from the programming review on
Monday will be helpful. They cover concepts specific to this lab, as well as
some common pitfalls to help you avoid them, so don't miss them.
We’ve designed the getValue() and display() function structure very
deliberately. If it’s not crystal clear why we need this display()
function, flick through those slides and re-read
section 5 of the lab handout. If it’s still not clear,
discuss it with your friends, ask your TA or come to an office hour.
Understanding the motivation behind these functions’ existence will prove a
huge help when you start writing them.
If you understand bitwise operations or the ternary operator ((c) ? x : y), it’s
possible to write getValue() in just four lines: one to find each of x,
y and z, and one to look up the value in the array. If you don't, you
might need an if statement or two. But if you find yourself with more than a
couple of if statements, think about how you can use arithmetic operators
(+, *, %) to help simplify your code.
Remember that you can order the pins in your anodePins and cathodePins
arrays in any order you like, with zero impact on the hardware layout. You
might like to choose this order strategically to help simplify your mapping
(getValue()) algorithm.
Debugging
A consequence of running the LEDs so fast that you can't tell when individual
LEDs are on and off is, of course, that they're running too fast for you to
debug. One strategy could be to slow the sequence down by increasing the time
in the delay() statement, to give you more visibility into what the LEDs are
doing. It's not foolproof though — some things are only obvious when you run
the LEDs at a fast rate.
Oscilloscopes are very useful for tracing what's happening in your circuit at
a microsecond time scale. There's a bit of a learning curve, but they can
tell you a lot about your circuit that wasn't obvious before.
Do a few LEDs look like they’re always dimly on? Each instruction takes a few
microseconds to execute, so if you (say) put an anode HIGH just before you
put a cathode LOW (or vice versa), then that LED will be on for a couple of
microseconds. Believe or not, this is visible. Our starter code should help
you avoid this, but if you run into something like this, it could be something
to consider.
|