This walkthrough describes the initial construction of the dsPIC33EP128GP502 ("PIC") circuit for Lab 6. It is required for prelab, and you will need to bring your board, parts kit, and tools to Labs 6-10 and the practicum.
A full listing of what you'll need is on the lab page. Make sure your breadboard has power/ground buses, and at least two rows, like this one.
For this walkthrough, you'll need:
The PIC
1 x 10 uF ceramic capacitor
3 x 1 (or 0.1) uF ceramic capacitors
1 x 0.1 uF ceramic capacitor (if available)
LM2937 voltage regulator
500 mA fuse
2x 51 ohm resistors (or 1 x 51 ohm and 1 x 220-910 ohm resistor, if available)
1 x 2.2 k resistor
1 x red LED
1 x green LED
1 x 47 uF electrolytic capacitor
1 x slide switch
1 x pushbutton
1 x right angle header
1 x USB to TTL cable
If you have the parts kit, don't worry if you're not sure exactly what's what. Illustrations of each part will be provided.
DO NOT APPLY POWER TO YOUR BOARD OR PLUG YOUR USB CABLE INTO YOUR COMPUTER UNTIL THE DIRECTIONS TELL YOU TO.
Your breadboard may be different from the one in the illustrations. For instance, your power and ground rails may be swapped. This is fine, just be aware of it and be sure that you are connecting things correctly for your board.
Your parts may look different. You may be missing a part. You may have gotten an incorrect part. This is also fine. We have plenty of spares of everything (except PICs and USB cables) in the lab, and can give them to you for free. Just let a TA know as soon as possible so that it can be resolved before you come to lab.
You should follow the walkthrough exactly. This will ensure that your board works right, that it is easy to fix if it doesn't, and that you have room for the parts that need to be added in later labs.
You will not be marked off from deviations from the walkthrough, but do not expect a TA to help you troubleshoot if your board is laid out in an unusual manner. First, you will be told to make it like everyone else's.
You will be marked off if your board is messy:
wires sticking up off board
untrimmed leads on components
wires running to and fro uselessly
used jumper wires
The color of the wires you use does not matter.
These are jumper wires. Do not use them in the construction of your circuit.
The walkthrough is based on the following schematic, although the wall transformer is no longer used, and the PIC is powered via USB:
Note that the pins on the PIC are not necessarily in these locations. From B.A. Jones, R. Reese, and JW Bruce, Microcontrollers: From Assembly Language to C Using the PIC24 Family, 2nd ed. Cengage Learning, 2015.
First, connect the red (+) rails of your breadboard. This will be referred to as Vcc. If your breadboard has numbers, do this on the high-numbered end.
Next, connect the blue (-) rails. This will be referred to as ground. Do this on the same end of the breadboard as the Vcc connections.
If you have this kind of breadboard, you only need to use 4 wires to make the Vcc and ground connections.
The PIC has a little notch on one end. That's where pins 1 and 28 are located.
From Microchip DS70000657J
Place PIC into the breadboard with the notched end of the PIC facing left. Use the rows of holes closest to the center divider. You may have to gently bend the pins to get it to fit in the breadboard. Be careful that you do not miss the holes with a pin or two and then jam it down - they'll break off! If your breadboard has numbers, put pin 1 of the PIC in row 20. If not, just place it in this approximate location:
Ground PIC pins 8, 19, and 27:
Connect PIC pins 13 and 28 to the Vcc rail:
Left to right: Fuse, 1 uF capacitors, and 10 uF capacitors from Fall 2024 parts kit. Photo courtesy of Tyler Dunn.
Left to right: Fuse, 10 uF capacitor, and 1 uF capacitor from parts kit
Connect a 10 uF cap (test it with a meter if you're not sure) between pin 20 of the PIC and the ground rail:
For Spring 2025, there is no 10uF capacitor so you can use 1uF capacitor instead
You shouldn't have to trim the caps in the parts kit, but if you're using ones with longer leads, then do so.
If you have 0.1 uF caps (possibly marked 104) available, use those where this walkthrough says 1 uF [1].
Connect a 1 uF cap between PIC pins 27 and 28. Use the holes closest to the PIC:
Connect a 1 uF cap between pin 19 of the PIC and the Vcc rail:
Connect a 1 uF cap between pins 8 and 13 of the PIC. Again, use the holes closest to the PIC:
The shorter lead of the LED is negative. That side of the LED is also a little flatter, though with the LEDs in the parts kit, it's hard to tell.
Above: 51 ohm (top), and 2.2 k (bottom) resistors.
Connect the positive (longer) lead of a red LED to PIC pin 26. Connect the negative (shorter) lead of the LED to the ground rail. For the next step, it would be better to use a resistor of 220-910 ohms [2, 3], but there are none in the parts kit. So use a 51 ohm resistor if that's all you have, and you can swap it out in the lab. Connect the resistor between pin 26 of the PIC and the Vcc rail:
Now trim the leads of the resistor and LED that you just placed so that they are more flush to the board. Trim a little at a time so you don’t make them too short. Be careful to keep the LED aligned properly (with the original short lead going into the ground rail):
Connect a 2.2k resistor between pin 1 of the PIC and the Vcc rail. Cut the leads short.
If your pushbutton leads have tabs at the bottoms, snip them off so they will fit into your breadboard:
Before (left) and after (right) snipping
Connect a pushbutton between pin 1 of the PIC and a position two spaces in front of the PIC. This is the reset button. Put it right next to the resistor, but do not shove it all the way in yet:
Connect the other end of the pushbutton to ground:
Trim the leads of the pushbutton and shove it down so that it is flush with the breadboard. This is a crowded area of the board and you will be jabbing this button a lot, so you don't want it wobbling or coming loose:
Stick the longer prongs of the right angle connector into the other row of your breadboard so that the leftmost prong is at #25 on the board. If you don’t have numbers, or they’re not the same, put it so the 3rd prong from the left is lined up with pin 21 of the PIC. Use a (trimmed) wire to connect the 3rd prong from the left to pin 21 of the PIC:
Connect the 2nd prong from the left with pin 22 of the PIC:
These two wires are the pathway for the PIC to communicate with your computer.
Connect the far-right prong of the right angle connector to the ground rail:
Connect the far-left pin of the right angle connector to pin 1 of the PIC. This connection makes a software reset of the PIC possible. If you wired your button as above, there should be one hole between the button and the PIC:
If you have the precut wire kit, a red one will fit perfectly.
Place the LM2937 voltage regulator so that it is 4 rows to the left of the button's ground wire, and its pins are in rows 11-13 on the breadboard:
This is so it lines up with the holes on the Vcc/ground rails, and also keeps it out of the way of the reset button and power switch as much as possible. NOTE THAT THE WRITING IS ON THE FRONT.
Trim the leads of the LM2937 just a little bit so that you can shove it into the breadboard up to where they widen:
Connect pin 2 (center leg) of the LM2937 to the ground rail, and pin 3 (right leg) to the Vcc rail:
Connect the 47 uF capacitor between the Vcc and ground rails right next to the ground wire. Be sure the gray stripe (-) lead is connected to ground. Trim the leads down:
Next, stick the fuse in the breadboard. It's not polarized, so its direction doesn't matter. Connect one lead to pin 1 of the LM2937 (row #11). Leave three spaces in the breadboard and shove the other lead down (row #7). You shouldn't need to trim it:
If you have a 0.1 uF capacitor, connect it between pin 1 of the LM2937 and the ground rail. If you only have the 1 uF and 10 uF capacitors from the parts kit, omit this step. If you do place that 0.1 capacitor, move your fuse a row over from the previous pic (away from the Vcc/ground rails) so that there is room.
The switch has three pins. It is the power switch for the circuit. Place it on the breadboard and be sure that the center pin is in the same row as the left leg of the fuse:
Being off by one is a common mistake that will cause your circuit to not turn on.
Next is the wire that brings 5V from the USB connection to the power switch. Connect the leftmost pin of the switch to pin 4 (3rd from the right) of the right-angle connector:
(Switch temporarily removed for picture clarity.) A precut orange wire from the kit will fit perfectly.
Now for the final components of the startup circuit - the power-on indicator (green) LED and a 51 ohm resistor. Connect the short lead of the LED to the ground rail, and the long lead to a vacant row on the breadboard. Connect one end of the resistor to the same row, and the other end to the Vcc rail. And, of course, trim down both components, remembering which lead of the LED should be connected to ground:
Stick a wire on the right side of the PIC, right up against it. This way, when you remove and replace it, you know exactly where it goes without having to squint and count pins:
You can remove this wire after Lab 6, as it will get in the way of Lab 7 components, and hopefully you won't be taking your PIC in and out of the breadboard anymore.
Rather than trying to jam your USB cable into the right-angle connector while it's stuck in the breadboard, it's easier to leave the connector attached to the cable. Then you can just plug it into the breadboard when you want to connect to your computer. To remind you where it goes, place a small wire on either side:
What else are you going to do with these tiny red wires that come with the kit?
Affix the short prongs of your right-angle connector to your USB cable. Now you are done. Your breadboard hopefully looks similar to this:
Closeup of the pin 15-28 area, which has been the source of many frustrating intermittent failures in the past when the capacitors were not connected correctly, or were swapped.
Remove your PIC from your breadboard. Be gentle, and use IC pullers if you have them. Let me reiterate:
Before applying power for the first time, REMOVE YOUR PIC FROM THE BOARD!
I apologize for shouting, but every semester, someone doesn't listen and manages to apply 5 V, or 12 V, or 120 VAC to the sensitive pins of their PIC, causing its untimely demise. There is a very limited supply of replacement PICs in the lab (and you will have to pay $5). If you are a distance student, you'll have to wait for us to mail you a programmed one, which will severely impede your lab progress.
After checking that your PIC is not in your breadboard, plug the USB cable into your computer (your computer probably needs to be on), and connect the other end to the right-angle connector. (If the right-angle connector is not inserted in your breadboard, insert it.) Be sure the black wire in the cable is connected t
If your power switch is in the ON position, both LEDs should illuminate brightly. (In the OFF position the red LED may glow dimly and/or fade.)
If the switch is on, you should see ~3.3 V on the Vcc rails, ~5-5.2 V on pin 4 of the right-angle connector, and ~0 V on the ground rails. (The black meter probe should be on the ground rail, and your meter should be set to DC volts; hopefully you already knew that, but it's worth checking - we all make mistakes.) If the switch is off, you should still see ~5 V on pin 4 of the right angle connector, but you will likely see 1.4-1.8 V on the Vcc rail. That is fine.
If you're an in-person student, that's all you can do without a programmed PIC.
If you're a distance student, turn off the switch, and unplug the USB cable. You may proceed to Lab 6.
If your lights don't come on when you flip the switch, try the following:
Check pin 4 of the right-angle connector. If it is not ~5V, then you either have a faulty USB cable (not uncommon), or your computer is not providing voltage via that USB port for some reason. Either way, disconnect, replace the PIC and come to lab to have it resolved.
If #1 is ~5V, check that you see 5V on the left leg of your fuse. If not, check the way you connected your switch and the wire connecting the right-angle connector to the switch.
If #2 is ~5V, check the right leg of your fuse. If it is not 5V, then you've got a bad fuse or somehow blew it - disconnect and come to lab for a replacement.
If #3 is 5V, then check the LM2937. Pin 1 should be 5V, pin 2 is ground, and pin 3 should be 3.3 V.
If pin 3 of the LM2937 is 3.3 V, your Vcc rails should also be 3.3 V. Check them all. If some are 3.3 and some aren't, either you didn't tie them together right or you have a crazy breadboard.
Finally, if your Vcc rails are 3.3 V but your LEDs are not coming on, you probably put them in backwards. You can try turning them the other way, but they might be blown. Come to lab and we'll figure it out.
Turn off your switch, unplug your USB, and put your PIC back on your breadboard. When transporting your circuit, do not just throw it into a backpack or tool bag. Put it in a little box, or carry it in your hand, taking care to shield it from rain, fire, small children, and animals.
[1] from Microchip DS70000657J
[2] from Microchip DS70000657J
[3] The above excerpt is from page 261 of B.A. Jones, R. Reese, and JW Bruce, Microcontrollers: From Assembly Language to C Using the PIC24 Family, 2nd ed. Cengage Learning, 2015. R1 and L1 refer to the schematic at the top of the page. A more recent datasheet, [2], shows that RB15 can sink 15 mA, however note that 3.3 V / 51 ohms = 65 mA, which is over 4x the rated maximum. Measurements taken with a 51 ohm resistor in place and the LED removed verify this current. Although there may not be immediate damage to the PIC, students are encouraged to replace this resistor with one between 220-910 ohms before they perform Lab 6.