@@ -38,7 +38,7 @@ Design and connect all necessary components to the microcontroller (MCU
- Generate a net-file
- Layout (Lab2)
### Adding the microcontroller
### 1) Adding the microcontroller
Start ”KiCad” and follow the instructions:
...
...
@@ -50,7 +50,7 @@ Start ”KiCad” and follow the instructions:
- 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
### 2) 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.
...
...
@@ -64,7 +64,7 @@ However, this microcontroller needs additional decoupling capacitors for its int
You should have at least 8 capacitors connected to the microcontroller.
### Adding supply symbols
### 3) Adding supply symbols
VDD 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 the whole schematic you can add power ports. All power ports are global in your design, which means that all power ports of the same kind is connected to each other.
...
...
@@ -74,21 +74,21 @@ VDD should be connected to +3.3V and VSS should be connected to ground. These ne
- Do the same thing with GND.
- Note that the VCAP1 pin should NOT be connected to +3.3V.
### NRST Reset pin
### 4) 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)
### 5) Pull-down resistor to BOOT0 (boot mode)
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
### 6) 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
...
...
@@ -98,7 +98,7 @@ The crystal will resonate at a specified frequency. Its waveform will be used a
- 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.
### Serial Wire Debug (SWD) connector
### 7) 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).
...
...
@@ -107,31 +107,118 @@ To program and debug the MCU we will use a SWD connector (6 pin header). Sometim
- 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.
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
### 9) 3.3v 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*)
The MCU needs a stable voltage. A common for digital components is 3.3v. 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.
### 10) PWM3389DM-T3QU Schematic Symbol
Download the general [datasheet](https://www.pixart.com/products-detail/4/PMW3389DM-T3QU), and look at section 3. There you will find a reference schematic.
For some components (like the PMW3389DM-T3QU) there might not exist a pre-made library, so you will now learn how to draw your own 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 ”PMW3389”. OK.
- Add pins and name them according to the datasheet. Remember to assign the correct pin number as well.
- Make sure to set the ”Electrical type” on each pin according to usage (signal in/out, power in/out etc.) `X` marks a non connected pin. In our setting we don't use `GPO` so you can set it `X`.
- Save by clicking on the ”Save current component to new library”-button (found at the top). This is only done for the first component, you can add several components to the same lib later.
- Add the newly created component to your schematic.
Hint. Never, never ever, change the grid settings when placing the pins in the symbol.
### 11) 1.9v Power Supply
As you see in the PWM3389DM-T3QU datasheet and reference schematics, the sensor requires a 1.9v power supply. This is much less common voltage (try finding one from Elfa or rs-online) and you will likely fail.
To that end, you can use an adjustable regulator (*HA*).
The equation for the output voltage can be found in the datasheet for (*HA*).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 polarized.
Once you have added the 1.9v power supply you can add a new power net, and connect that to your PMW3389 component.
### 12) Reset button
Now add a reset button. Suitable value for capacitor is found in the MCU data sheet.
### 13) Power LEDs and probing pins
In order to see that your system is correctly powered, it is common to add both probing pins/pads and LEDs. You can use (*HA*) and a [led caluclator](https://ohmslawcalculator.com/led-resistor-calculator) to design suitable current limiter. Use values from the E12 series.
### 14) SPI
SPI (Serial Peripheral Interface) is a common way to interconnect components synchronized with a clock signal. In our case the STM32F401/F411 will be the Master and the PMW3389 will be the slave (so all communication is driven by the MCU).
In order to allocate pins to peripherals there is a nice tool [STM32CubeMX](https://www.st.com/en/development-tools/stm32cubemx.html). Install STM32CubeMX (either using the link, or your package manager), select the target (smt32f401, e.g.) and find suitable (unused pins for) SPI communication. E.g., using SPI2 you can assign.
``` shell
// Configure SPI
// spi2
// sck - pb10,
// miso - pc2,
// mosi - pc3,
// ncs - pb4,
```
Decide on which pins you want to use, and connect the PMW3389 to your MCU. You can connect the `Motion` signal to a free GPIO (its used to generate an interrupt when the sensor detects a motion event, for allowing wake from sleep mode). Likely you don't need this but you can add it in any case.
### 15) USB Data
Until now you have used the USB only to power the system, but you will need to add data lines +D/-D as well for communication. Check the data sheet for specifics.
You may also want to protect your system from ESD (Electrostatic discharge). To that end you may optionally add protection circuitry (*HA*).
### 16) Assign Footprint
It is very important that the pin numbering on your component is correct to the 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 associate components and footprints”-button at the top.
- Click on the View selected footprint button at the top, it will display the footprint in question.
- We recommend you to use 0805-size capacitors and resistors. Associate all the res. and ceramic caps. to 0805 respectively, Handsoldering. (Ca-pacitorsSMD and ResistorsSMD)
- The 10uF caps should have an electrolytic footprint. Search Elfa, rs-online first. If they don't have the components, check Farnellor digikey for appropriate size for the capacitor.
- Read in the datasheet or on the link for the voltage regulator and select the correct footprint. Make sure that all components are in stock for immediate delivery.
- Repeat for the crystal and SWD connector.
- MCU = HousingsQFP:LQFP-6410x10mmPitch0.5mm.
- USBOTG = Connect:USBMini-B (or to your liking)
- Don’t forget to save!
Hint: Check that the numbering of the pins are correct! Hint 2: When you are working with your project later, you will probably not find all footprints in the standard library. There are good tutorials on youtube on how to draw your ownfootprints.
### 17) Electric Rule Check (ERC)
ERC is a check that detects if you have any ”lose ends”, meaning that it will give you a warning if you have a net with only one connection. It will also give you a warning if you have drawn a net to a component but the net and the component haven’t connected. To get the ERC to work as intended, you have to mark all the unused pins with a Not-connected flag, found to the right.
- 4) Repeat point 1 until errors == 0 && warnings == 3. The GND net is not connected to a Power output, the 5 voltage neither and the capacitor connected to VCAP1 is not connected to a power output.
## First Submission
In Canvas look for Lab1-First Submission, and submit a link to your repo there before the deadline.
## Review
You will be assigned two repositories to review. Clone the repositories and compare to your solution.
For some components there might not exist a library, so you will now learn how to draw your own component.1.9
Check each that each of the 17 steps has been correctly conducted and that the calculated values for generating 1.9v makes sense, and that the LED selection/current limitation is within specs.
Make an issue in each repository that you review with detailed comments to the author/repo owner. Later follow up on those comments and close them when your issues have been addressed to your satisfaction.
In Canvas look for Lab1-Review, and submit links to the repositories you have reviewed before the corresponding deadline.
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
## Final
Address the raised issues, and commit your fixes. This is an iterative process, where you help each other coming up with a working solution by leading questions, hints etc. (Just giving the answer directly is not particularly fruitful, its a learning process right.)
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
Once you have addressed all issues, look in Canvas for Lab1-Final, and submit a link to your repository.