The Make It Last Build Series Newsletter, Build #3, Dispatch #2
Welcome to the third project of the Make It Last Build Series, sponsored by Microchip and Energizer.
The goal of this newsletter installment is to make sure we have the PIC toolchain installed and working, and to prototype the basics of a controller for our Drawbot wall drawing machine.
There will be prizes at the end of the build process. To be eligible, all you have to do is post your photos to the MAKE Flickr pool and tag them "makeitlast".
As always, see the Build Series landing page for full info, prize details, and info about the first two builds in the series.
Cheers,
Shawn Wallace
back to top Building the Drawbot Controller
As discussed in the first post, the Drawbot is a rig for drawing algorithmic designs on a wall. The mechanism is made up of two motorized spools holding monofilament, which is connected to a marker; the two motors tug on the marker, and graivity tensions the line. The friction between the marker tip and the wall holds the marker to the wall. By turning the motorized spools clockwise and counterclockwise we can precisely control where the marker goes (with a little math).
back to top A Block Diagram
The project can be broken down into the three components, shown in this diagram: power, controller, and driver.
Power distribution is a major consideration in the design of any circuit, especially when driving higher current loads such as motors. The motors speced in our project operate at 5V, but often you will find motors that run at 9V, 12V, or 24V. The controller runs at 3.3V or 5V, so we will have to distribute power to the controller and the motor drivers separately.
Because the pins on the microcontroller can only source a few milliamps (not nearly enough to driver a motor directly), we'll need a separate driver circuit to provide enough current to the motors. The motors we are using are stepper motors, which can be precisely controlled by pulsing its four control lines in a particular order. The motor driver circuit we'll be using will reduce the number of control lines from four to two.
We'll be discussing the motor operation and building the motor driver next week; for now we will concentrate on the controller, which will have two control lines for each motor as outputs. Our goal this week is to set up a working prototype controller and program it to blink four LEDs, one for each control line.
back to top Breadboard the Prototype
The schematic for the controller is almost exactly like the one used in the two previous builds, with the addition of four LEDs on lines RA0-RA3, which will eventually be used to control the two motorized spools. Follow the schematic to get all the components on a breadboard. If you've never used a breadboard, start with the blog post from Project #1 that describes Hello World blinky light on a PIC.
Start with the PIC18LF25K22 microcontroller and connect the other components to the microcontroller, following the directions for the Hello World project. Be sure to connect all of the power and ground pins to the microcontroller. Also connect the ground rails on the breadboard to each other, and the power rails to each other. Finally, add an LED between each of pins RA0 through RA3. The long lead goes toward the pin, and the short lead connects to GND.
back to top Programming the Controller
The finished prototype should look something like the one above. We'll be using the PICKit3 programmer to compile and upload code (you can also use the PicKit 2, as described in the forums).
As in previous builds, we'll use the MPLAB environment to compile and upload code. If you haven't installed MPLAB yet, follow the instructions from Project #1. The device definitions and include files for the microporcessor we are using (the PIC18LF25K22) are included in the latest distribution of MPLAB; if you have an older version you may have to upgrade or update your device definitions.
The PIC will run at voltages up to 5V; for now we'll run the circuit at 3.3V so we don't have to add current-limiting resistors to the LEDs. As a convenience, the PICKit3 can power the circuit. Before attaching the programmer to the circuit, open MPLAB and change the settings under Programmer—>Power to power the circuit at 3.3V. Then connect the programmer to the six pin header with pin 1 in the proper orientation (it's marked with a white arrow).
Download the sample code to test the prototype controller. Create a new project and add the main.c file to it. If all the connections are made properly, you should be able to connect to the microcontroller, select Build All, and upload the code with the "Program" command. A working circuit will blink each LED in turn. Please follow and post to the Make It Last forum for troubleshooting help.
Next week we will build a stepper motor driver circuit and connect it to the controller in place of the LEDs.
back to top Parts List Update
Please note that this project will use the 16MHz internal resonator; the parts list in the first post incorrectly listed a 32.768 kHz crystal (Digi-Key 631-1205-ND) and two 22pf capacitors, which were from a previous project.
For next week we'll need 4 switches that will be used to control the motors manually. I'm using simple momentary switches from Digi-Key (part #450-1650-ND), but you can use any switch that is single throw and typically open. If you don't know how the pins of the switch are connected, test them with a multimeter in the open and closed position.
Next week we'll need the following parts:
* 5x 1k resistor 1/4W (Digi-Key P1.0KBACT-ND)
* 2x H-Bridge SN754410 (Digi-Key 296-9911-5-ND)
* 4x 100uF capacitor (Digi-Key P5123-ND)
* 1x MCP1702 regulator (Digi-Key MCP1702-3302E/TO-ND)
* 4x Switching transistor (Digi-Key PN2222AD26ZCT-ND)
* 1x AC/DC power supply, 5V, 2.5A (Jameco 252736)
* 2x Stepper motors, 400 steps/revolution (Jameco 1581231)
and another breadboard.
back to top Microchip Discount Code
Want to pick up a PIC programmer or development kit? As part of this series, Microchip is offering a 20% discount on the following development tools:
* PICkit3
* PICkit3 Debug Express
* ICD3 In-Circuit Debugger
* XLP 16-bit Development Board
* F1 Evaluation Platform
* F1 Evaluation Kit
If you've been thinking about getting started with PIC programming, this could be a great opportunity to get a good deal on a programmer. To request a discount code, send an email to makeitlast@makezine.com.
back to top |