Skip to content
Snippets Groups Projects
Commit 00f13d05 authored by Per Lindgren's avatar Per Lindgren
Browse files

MCU...Power

parent c90a421e
Branches
No related tags found
No related merge requests found
{
"cSpell.ignoreWords": [
"datasheet",
"datasheets",
"microcontroller",
"nrst",
"nucleo",
"pinout"
]
}
\ No newline at end of file
......@@ -47,20 +47,19 @@ Start ”KiCad” and follow the instructions:
- Click on Preferences/Manage symbols libraries.
- Check the library `MCU_ST_STM32F4` is active in your project.
- Click on the ”Place symbol”-button to the right and then click on the sheet where you want the component to be placed.
- Find your microcontroller in the stm32-library. (STM32F411RETx).
- Find your microcontroller (`STM32F411RETx`) in the stm32-library.
- You have now added the microcontroller to your project. It needs additional components to make it run, e.g. a crystal (for stable USB clocking), decoupling capacitors, power and a SWD (Serial Wire Debug) connector to program it.
### Decoupling Capacitors
To stabilize the voltage at the pins to the MCU, decoupling capacitors are used. When assigning decoupling capacitors for a microcontroller running at 50-100MHz, 100nF ceramic capacitors are usually suitable for each power-pin.
However, this microcontroller needs additional decoupling capacitors for its internal voltage regulator and analog peripherals, you can find the datasheet by searching on internet. Hint: ”STM32F411 datasheet”
However, this microcontroller needs additional decoupling capacitors for its internal voltage regulator and analog peripherals, you can find the datasheet by 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.
- Hoover over the capacitor, press ”V” and give the capacitor its value e.g.,100n.
- Connect them to the microcontroller using the ”wire” button. (W key)
You should have at least 8 capacitors connected to the microcontroller.
......@@ -71,22 +70,68 @@ VDD should be connected to +3.3V and VSS should be connected to ground. These ne
- Click on the Place power port button.
- Select ”+3.3V”.
- Add power ports on appropriate places and connect them to the pins and capacitors that should have 3.3 volt.
- Add power ports on appropriate places and connect them to the pins and capacitors that should have 3.3 volt.
- Do the same thing with GND.
- Note that the VCAP1 pin should NOT be connected to +3.3V.
### Power on reset
### NRST Reset pin
The NRST pin is an active low (0) input used to reset the MCU.
There is an internal pull-up resistor keeping the pin high (allowing the MCU to run). For more info on what a pull-up resistor is, search the internet for ”Pull-up resistor”.
Later we will add a Reset Button, so that you can force reset even when the MCU is powered and running.
### Pull-down resistor to BOOT0 (boot mode)
The NRST pin is an active low (0) input used to reset the MCU. An unconnected input may take an undefined value (0 or 1), hence to avoid arbitrary resets, we will define this pin to 1 by applying a pull-up resistor. More info regarding the NRST-pin can be found in the datasheet for the MCU in section 6.3.17. For more info on what a pull-up resistor is, search the internet for ”Pull-up resistor”.
The microcontroller can boot in different modes, similar to how you can enter the BIOS when booting your PC by pressing the F2-key (or other F-key). This can save you in tricky situations, for example if you are playing with the main clock or with sleep modes and it crashes, making you unable to upload (flash) a new binary to the microcontroller. You can boot in "safe mode" by pulling this pin high (so it does not run you code on startup) allowing you to upload a new binary even if your code would otherwise brick your MCU.
- Add a 10k pull-down resistor to the BOOT0 pin.
- Add a 2-pin header (*HA, var hittar de dessa i kickad enklast*) to BOOT0 and +3.3v, so that you can easily boot into "safe mode" by shorting the header using a "jumper".
### Crystal
The crystal will resonate at a specified frequency. Its waveform will be used as an input to the PLL (Phase Locked Loop) that will multiply the crystal’s frequency. This is the crystal that will be used:https://www.elfa.se/en/quartz-hc49us-mhz-auris-000000m-hc49ussmd-f3030d20/p/17452820
- 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.
- Connect it to the microcontroller by using the ”wire” button.- Add one more ”+3V3” port and connect that to the other end of the resistor. Hence pulling it up to 3.3 volt (1).
- (Later we will add a Reset Button, so that you can force reset even when the MCU is powered.
- Click on the Place component button.
- Find the device/Crystal.
- Place it close to `PH0` and `PH1`, pin 5 and 6 (`RCC_OS_CIN` and `RCC_OSC_OUT`).
- Connect the component with wires to the mentioned pins. Value 8.0MHz.
- Connect one 18p capacitor to each pin on the crystal and connect the other end of the capacitor to GND.
### 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
### Serial Wire Debug (SWD) connector
To 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 user manual for the microcontroller, all the information you need is there, it will just take time to find it. However, it can then be useful to follow proven examples like 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 the same name in the local sheet.
- VDDTARGET→+3.3V. GND→GND. NRST→NRST. SWCLK→SWCLK (PA14). SWDIO→SWDIO (PA13). SWO→SWO (PB3)
### Power from USB
One easy way to get power to your project is through USB. It can deliver up to 100mA without any negotiations.
- Add a ”USBOTG” connector to your schematic. Already here you can think about how you should connect your mouse and use a suitable connector (mini, micro or even usb-c).
- Find the USB pinout for your connector.
### Power Supply
The MCU needs a stable voltage. To this end we will use a fixed LDO (low dropout) regulator, with a 5v input (powered from the USB connector) and 3.3v output. We will use the (*HA*)
Look in the datasheet for reference values for decoupling. Later we will design the power supply for the PWM3389 sensor, which is a bit trickier.
For some components there might not exist a library, so you will now learn how 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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment