diff --git a/README.md b/README.md index 1e07ddada3850a19a46085f37e1b0e525cd8693d..49bc48a64c4cdca4851dd154b10712a703feeb54 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ # e7020e_2021_hw -Hardware lab assignment for E7020E 2021 \ No newline at end of file +## Lab 1 (Schematics) + +The main topic of this lab is to give you a good understanding on how touse the information inDatasheetsto draw components and connect them inthe schematic view. This lab should be done in your assignedgroup. Topassthis lab assignment you have to show the lab-assistant your work and get anapproval from him/her. If you are not able to pass the lab before the deadline,you will have to write a short report on your work.Read the whole lab instruction before you start.1 TaskDesign and connect all necessary components to the microcontroller (MCU).Some of the components can’t be found in the standard libraries so you have todraw some of them by yourself and extract the necessary information throughdatasheets.The work flow of KiCad: Add components and draw the schematic of yourdesign→Assign a footprint to your schematic components→Generate a net-file→Layout(Lab2)1.1 Adding the microcontrollerStart ”KiCad” and follow the instructions:•Make a new project.•Open the schematic. (double-click on the *.sch-file)•Click on Preferences/Manage symbols libraries. Check the library MCUSTSTM32F4is active in your project.•Click on the ”Place symbol”-button to the right and then click on thesheet where you want the component to be placed.•Find your microcontroller in the stm32-library. (STM32F411RETx)You have now added the microcontroller to your project. It needs additionalcomponents to make it run, eg. a crystal, decoupling capacitors, power and aSWD (Serial Wire Debug) connector to program it.1 +1.2 Decoupling capacitorsTo stabilize the voltage at the pins to the MCU, decoupling capacitors areused. When assigning decoupling capacitors for a microcontroller running ataround 100MHz, 100nF ceramic capacitors are usually suitable for each power-pin. However, this microcontroller needs additional decoupling capacitors forits internal voltage regulator and analog peripherals, you can find the datasheetby searching on internet. Hint: ”STM32F411 datasheet”•Open the datasheet and look at the figure in section 6.1.6.•Add capacitors to the power pins as the figure shows. (Place component-button, click on sheet, device/C)•Hoover over the capacitor, press ”V” and give the capacitor its value eg.100n.•Connect them to the microcontroller using the ”wire” button. (W key)You should have at least 8 capacitors connected to the microcontroller.1.3 Adding supply symbolsVDD should be connected to +3.3V and VSS should be connected to ground.These nets are often used in a schematic, so to avoid drawing nets across thewhole schematic you can add power ports. All power ports are global in yourdesign, which means that all power ports of the same kind is connected to eachother.•Click on the Place power port button.•Select ”+3.3V”.•Add power ports on appropriate places and connect them to the pins andcapacitors that should have 3.3 volt.•Do the same thing with GND.Note that the VCAP1 pin shouldNOTbe connected to +3.3V.1.4 Pull-up resistor to NRST (reset)The reset pin NRST turns off the microcontroller when its low (0). An uncon-nected input may take an undefined value (0 or 1), hence to avoid restartingour MCU we will define this pin to 1 by applying a pull-up resistor. More inforegarding the NRST-pin can be found in the datasheet for the MCU at section6.3.17. For more info on what a pull-up resistor is, search the internets for”Pull-up resistor”.•Click on the place component button.•Find a resistor, device/R.•Add it close to the NRST pin on the microcontroller.•Change the resistors value to 10k.2 +•Connect it to the microcontroller by using the ”wire” button.•Add one more ”+3V3” port and connect that to the other end of theresistor. Hence pulling it up to 3.3 volt (1).1.5 Pull-down resistor to BOOT0 (boot mode)The microcontroller can boot in different modes, similar to how you can enterthe BIOS when booting your PC by pressing the F2-key (or other F-key). Thiscan save you in tricky situations, for example if you are playing with the mainclock or with sleep modes and it crashes, making you unable to upload a newbinary to the microcontroller. You can then boot it in ’safe mode’ by pullingthis pin high (solder an external temporary wire) so it does not run you code onstartup. This enables you to boot it and wait for you to upload a new binary.•Add a 10k pull-downresistor to the BOOT0 pin.1.6 CrystalThe crystal will resonate at a specified frequency. Its waveform will be used asan input to the PLL that will multiply the crystal’s frequency. This is the crystalthat will be used:https://www.elfa.se/en/quartz-hc49us-mhz-auris-000000m-hc49ussmd-f3030d20/p/17452820•Click on the Place component button.•Find the device/Crystal.•Place it close to PH0 and PH1, pin 5 and 6 (RCCOSCIN and RCCOSCOUT).•Connect the component with wires to the mentioned pins. Value 8.0MHz.•Connect one 18p capacitor to each pin on the crystal and connect theother end of the capacitor to GND.1.7 Serial Wire Debug (SWD) connectorTo program and debug the MCU we will use a SWD connector (6 pin header).Sometimes it can be tricky to find all the information in the datasheet and usermanual for the microcontroller, all the information you need is there, it will justtake time to find it. However, it can then be useful to follow proven exampleseg. your Nucleo board. This is the connector that will be used:https://www.elfa.se/en/pin-header-6p-wuerth-elektronik-61300611121/p/30024526•Add one conn/CONN01X06 (male).•Search for the Nucleo boards datasheet.•In this datasheet search for the table that explains the connector ”CN4”pinout. You can also investigate how they have connected the target MCUto these pins in the schematic below in the datasheet.•You can connect pins without wires going everywhere. Use ”net labels”(button to the right) to name one wire. It will connect all wires with thesame name in the local sheet.3 +•VDDTARGET→+3.3V. GND→GND. NRST→NRST. SWCLK→SWCLK (PA14). SWDIO→SWDIO (PA13). SWO→SWO (PB3)1.8 Power SupplyThe MCU needs a stable voltage. Depending on your projects voltage andcurrent requirement, the voltage regulator might have to be changed later on.However, for now you shoulddrawa voltage regulator called LM1117 with ad-justable output voltage.https://www.elfa.se/en/ldo-voltage-regulator-25-13-sot-223-texas-instruments-lm1117imp-adj-nopb/p/30019193For some components there might not exist a library, so you will now learnhow to draw your own component.1.9 New component•Click on Tools/ Symbol Library Editor.•Create a new library for your project and click on Create New symbol inthe new library).•Component name ”LM1117ADJ”. OK.•Add pins and name them to your liking, is good if the names have someresemblance to the datasheet of the LM1117. Remember to assign thecorrect pin number as well.•Make sure to set the ”Electrical type” ononeoutput pin to Power output.•Save by clicking on the ”Save current component to new library”-button,can be found at the top. This is only done for the first component, youcan add several components to the same lib later.•Do the things the pop-up said you had to do. Same thing as with thestm32 lib but with your newly saved lib.•Add the voltage reg to your schematic.Hint! Name the pins by the pin description in the datasheet. Hint nr. 2. Never,never ever, change the grid settings when placing the pins in the symbol. It canlook something like this when you are done:4 +1.10 Power from USBOne easy way to get power to your project is through USB. It can deliver up to100mA without any negotiations.•Add a ”USBOTG” connector to your schematic.•Find the USB pinout. (wiki)•Connect the USB connector to the voltage reg.•Assign appropriate smoothing capacitors 10uF and decoupling capacitors100nF on both sides of the reg.•Use the ports ”+5V”, ”+3.3V” and ”GND”.•Build a resistor netfrom the E12 seriesthat adjusts the output voltageto 3.3V and connect that to the adjust pin on the reg. The equation forthe output voltage can be found in the datasheet for LM1117.Hint: A good rule of thump is one 100nF ceramic capacitor to each power-pin.Hint2: The smoothing capacitor should be an electrolytic capacitor, hence po-larized.1.11 FootprintIt isvery importantthat the pin numbering on your component is correct tothe footprint in the library! Always double check with the datasheet.You will now associate each component to a footprint.•Annotate all the components, this will give your components a name.•Click on the ”Assign PCB footprints to schematic symbols” to associatecomponents and footprints”-button at the top.•Click on the View selected footprint button at the top, it will display thefootprint in question.•We recommend you to use 0805-size capacitors and resistors. Associateall the res. and ceramic caps. to 0805 respectively, Handsoldering. (Ca-pacitorsSMD and ResistorsSMD)•The 10uF caps should have an electrolytic footprint. Search Elfa, Farnellor digikey for appropriate size for the capacitor.•Read in the datasheet or on the link for the voltage regulator and selectthe correct footprint.•Repeat for the crystal and SWD connector.•MCU = HousingsQFP:LQFP-6410x10mmPitch0.5mm.•USBOTG = Connect:USBMini-B•Don’t forget to save!Hint: Check that the numbering of the pins are correct! Hint 2: When you areworking with your project later, you will probably not find all footprints in thestandard library. There are good tutorials on youtube on how to draw your ownfootprints.5 +1.12 Electric Rule Check (ERC)ERC is a check that detects if you have any ”lose ends”, meaning that it willgive you a warning if you have a net with only one connection. It will also giveyou a warning if you have drawn a net to a component but the net and thecomponent haven’t connected. To get the ERC to work as intended, you haveto mark all the unused pins with a Not-connected flag, found to the right.1. ”Perform electrical rules check” button (Ladybug button).2. Do a ERC.3. Fix errors.4. Repeat point 1 until errors == 0 && warnings == 3.The GND net is not connected to a Power output, the 5 voltage neither and thecapacitor connected to VCAP1 is not connected to a power output. Show thelab-assistant that you have done the lab.It should look something like this when you are done:6