Intro to CAD

From Class Wiki
Jump to navigation Jump to search

This page is for the Intro to Engineering ENGR 122 EE/CPE Section

Two Dimensional CAD

Persistence of Vision Bike Light Project

This project will use a 3.3 volt Arduino Pro Mini clone that you will design the circuit board, housing, and software for. Persistence of vision is a psychological effect that allows you to see two dimensional images that were created by one dimensional flashing LEDs. Here are some similar projects:

We will have an MMA8452 accelerometer that communicates via a serial I2C interface. The accelerometer will measure the angular acceleration, which will allow the velocity of the bike wheel to be calculated. This will make it possible to flash LEDs at the proper time intervals to spell words, draw pictures, etc., as you ride your bike down the road at night.

The power source for your POV device can be two or three AA, or AAA batteries. You need to design the packaging. Some suggestions that you can consider are:

Kicad Libraries

Footprints for CVPCB and PCBNew

EESchema Checklist

  • ATMEGA328P
  • MMA8452Q
  • MIC5205
  • Do you really want an LED to tell you the device is on? (I'm guessing probably not, so make sure you didn't put one in if you don't.)
  • Batteries
  • Programming cable connector
  • LEDs
  • Are the LEDs distributed over Ports B, C and D?
  • No errors in the design check?
  • Do you have the DOC linked to the datasheet for each important part?
  • Do you have the datasheet URL in the datasheet field for each important part?
  • Does your schematic look need and tidy?
  • Do you have pull up resistors on the I2C bus lines SCL, SDA, and SA0?
  • Did you include a programming header for the bootloader?

Example Schematics & Footprints

  • This is an example schematic. It has provision using jumpers K1 and P3 to select either two or three batteries and a voltage regulator, or two batteries without a regulator. You don't need to do this. I am doing it, so I can have a board that can be configured either way for debugging possible issues. I recommend picking one or the other power supply method.
  • Example Footprint Selection You need to select the Aerodyne_v2.pretty in the Preferences->Library Tables in CVPCB in order to find the special footprints.

Parts Ordered By Ralph

This is Ralph's parts order.

Kicad Videos and Other Information

Engineering_Electronics

Getting Started with Kicad

Setting Up the Environment and Getting Started

  • Some environment variables should be set such as the two below. Put them in your ~/.profile file at the end.
export KIGITHUB='https://github.com/KiCAD'
export KISYS3DMOD='/usr/local/share/kicad/modules/packages3d'
  • In order for them to be activated, you need to logout and login again, or if you don't want to do than right now you can also paste the two lines above into a terminal and start kicad from that.
  • Some environment variables should be set such as the two below. Put them in your ~/.profile file at the end.
export KIGITHUB='https://github.com/KiCAD'
export KISYS3DMOD='/usr/local/share/kicad/modules/packages3d'
kicad
  • If you want the 3D viewer to know about your Aerodyne_v2 parts, you need to put a symbolic link to the 3D parts in the /usr/local/share/kicad/modules/packages3d/ directory, by doing this from the directory containing the KiCadLib-master directory.
$ sudo ln -s /KiCadLib-master/3D /usr/local/share/kicad/modules/packages3d/3D

Make the Schematic in EESchema

You should have done this already.

CVPCB, Associating Footprint Patterns with Parts

  • Start CVPCB from EESchema after completing the design rules check and creating a netlist.
  • Make sure to point the library tables to your Aerodyne_v2.pretty directory, and select the library type as kicad. You find the tables in CVPCB under Preferences->Library Tables, and you can add a line in the project specific tables. The ${KIPRJMOD} environment variable expansion is the directory of your project.

Project Files Screenshot

  • Now you should be able to find the parts you need to associate in PCBNew.

PCBNew, Designing your Circuit Board

  • Read the The Ten Best Practices of PCB Design.
  • After saving in PCBNew, go back to EESchema and start PCBNew.
  • Import your board outline using File->Import->DXF File, and place it in the middle.
  • In the Design Rules, change the clearance and track width to 0.008 inches under Net Classes Editor, and set the minimum trace width to 0.008 inches in the Global Design Rules. Design Rules Screenshot
  • Using the tool on the right of the toolbar for fast access to the web based router, export your Spectra Design file and open it in the web based Free Router. This may take a minute.
  • In the Free Router, under Parameter->Autoroute click the Detail Parameter, and set the via costs to 8. Hit return and close the windows for parameters. FreeRouter Screenshot
  • Hit the autorouter button and watch it route your board.
  • You may have some violations because the pitch of the accelerometer is smaller than we have allowed somewhere. You can ignore this.
  • Make sure everything went well and your board was able to complete routing.
  • Save the Spectra Session .ses file, and import it back into PCBNew.
  • Run a Design Rules Check in PCBNew, and fix any problems.
  • Put ground plane on both layers.
  • Put your name on the front silk screen layer.
  • Plot the Gerbers, being sure to check the boxes for all the ones we need. Plot Gerbers Screenshot
  • Run FreeDFM Check.
  • Compress your directory, and upload it to D2L.

Arduino Programming

This section describes how to program your Arduino. We will start out with your Pro Mini.

Tool Chain Setup

You can program Arduinos from a PC, Mac or Linux. On OS X and Windows, you need to download the software:

  • The download page is here.
  • On Windows and OS X, you need to install the driver for the PL2303 usb to serial port device used for programming the arduino.
    • On Windows you need to force this driver version by going to device manager, choose update driver from right click into prolific adapter, the choose "browse my computer for driver software", then "let me pick...". On the next window, it should show you different versions of the driver, and you need to choose ver 3.3.2.102. Here is a link to the driver.
    • On Windows 8, you will need a special driver from here. Then you will need to follow these instructions.
    • On OS X, here is the driver download site.
  • On Ubuntu you can load it with Synaptic Package Manager (synaptic), and it should already be there on the virtual machines we set up.
  • Use Codeblocks as Your Arduino IDE on Ubuntu

Here is a video showing how to setup the Arduino IDE for your Pro Mini 3.3V ATMEGA328P device.

Programming Hardware Connections

The Pro Mini requires a USB to serial TTL device to program it. The ones we purchased don't have the DTR line, so you have to push the reset button on the arduino, then hit the upload button on your computer, and wait until it says "uploading," and then release the reset button on the arduino. The serial connections are shown in the photo.

Arduino-serial.jpg

The color code for the wires is:

  • Black is GND which connects to the arduino GND.
  • Red is +5 volts which connects to the arduino VCC.
  • Green is TXO which connects to the arduino RXI
  • White is RXI which connects to the arduino TXO

Note: The serial communications protocol is kind of like whispering secrets. You put your lips up to the other person's ear. (TXO -> RXI) T stands for transmit, and R for receive.

Building the Accelerometer Library

You can use C++ to make Arduino libraries. Here is a tutorial on how. There is a library already made for the MMA8452Q here. There is a tutorial on installing an Arduino library here. And here is the zip file for the library. Download it; don't extract it. Go to the Arduino IDE and select Sketch->Import Library->Add Library. In the file selection dialog that comes up, select the MMA8452Q.zip. It will unzip it into your sketchbook/libraries directory. Then to use it, read the source code on the library. There is an example sketch in the files there that will help you figure out how to read the accelerometer.

Bootloader Programming

The bootloader is a program that needs to be loaded into the ATMEGA328P before you can program your Arduino with the USB/serial programmer.

We really should have provided a programming header for that as well as the one for the USB/serial programmer, but since we didn't, the professor will program your ATMEGA328P units using the information on this web page.

I put the Bootloader Programming procedures here so I will know what I did later.