• Home
  • Exercises 02
  • MILO MCU and power board schematic capture
  • MILO MCU and power board schematic capture

    The questions below are due on Thursday February 23, 2023; 10:00:00 AM.
     
    You are not logged in.

    Please Log In for full access to the web site.
    Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

    Desiging the MILO system other boards

    As you know, this is the first offering of this course, so we're still tweaking the labs and exercises. Our goal is to teach you, not frustrate you, so if this exercise is taking you longer than an hour or two ask for help on Piazza or come to office hours! You're also welcome (and encouraged) to work together on the paper schematic design.

    Learning Objectives

    With your first schematic drawn and reviewed, it's now time to perform schematic capture for the rest of the MILO hardware node (aka the box).

    From our MILO system diagram, we can see that the hardware is broken into three boards.

    Now, in a real product we probably wouldn't break things into three boards, but remember, one of our requirements is that the system should be a useful pedagogical exercise. So that informs the system partition we chose.

    Our intent is that the schematic design should take about an hour, max. But we're not sure, since this is our first time offering this class, and we have students with varying backgrounds. If you are finding that this exercise is taking longer than an hour to create the paper schematic, please reach out.

    Divide and conquer

    We're going to divide the team into two sub-teams: one team will do the power management board, the other will do the MCU board. So your first task is to agree as a team who will do what.

    The MCU and power management board paper designs can be done together, but each individual must draw their own schematic, and lay out their own board (e.g. all team members working on the MCU board will do their own schematic and board layout of the MCU board). Questions will arise during the design and layout that require communication across team members, which is totally fine.

    To help you decide how to divide, let's talk a bit about what goes into each subsystem.

    To reiterate, each team member will create a schematic for EITHER the MCU or the Power Management subsystem, not both

    MCU subsystem

    The MCU subsystem is the brains of the MILO hardware node. We need a central controller to interact with the sensors and to relay that information to the server. That is the MCU subsystem.

    We're going to make life a bit easier, but using a fairly powerful MCU: the ESP32-C3. Even better, we can purchase the ESP32-C3 in a module that includes the WiFi antenna. Better still, the module itself has been FCC certified, so it meets our regulatory spec straight-away.

    There are actually several ESP32-C3 modules we can purchase:

    The main difference is that the MINI has a smaller footprint than the WROOM. But the footprint of the WROOM is amenable to hand-soldering. So we'll go with that, since eventually we'll have to assemble the boards by hand.

    Even once we've picked the WROOM there are multiple sub-variations (yes, this stuff gets detailed!). Go to the datasheet and figure out how many variations there are.

    How many variations of the ESP32-C3-WROOM-02 exist?

    To make our lives easier, we want the one with an integrated antenna, and we don't need a wide temperature range, given our operating temperature spec.

    Based on these specs, which part number should we get? Enter your answer as a Python string (including the quotes, e.g. "ESP32-????")

    Make sure you can find this part in the Altium part search. Ask a staff member if you need help!

    OK, so we have a part, so what else do we need for our schematic? Well, we'll want all the things we had for our sensor board:

    • Connectors for power and data
    • Status LEDs

    Reset Button

    In addition we probably need a way to reset the MCU without having to plug/un-plug. So it's good to have a button for that.

    Section 3.2 of the ESP32-C3-WROOM-02 datasheet lists the function of each pin on the module. We can see the EN pin (pin 2) resets the MCU when it is pulled low. It also says not to leave the pin floating, so we'll need a pull-up resistor between this pin and the 3.3V line to make it default to high. As a rule of thumb, we'll use 10k ohm resistors for our pull-up resistors. We'll also add a button between this pin and ground so that when we press the button, the pin gets pulled strongly to ground resetting the MCU.

    Draw out this button and pull-up resistor on your paper schematic.

    Boot Sequence and Strapping Pins

    Another thing we need to consider is that the MCU needs to be put into a certain state in order to be ready to receive new firmware. This can sometimes be done via software (that's why you can often "flash" new code onto your MCU just via software control), but it's good to have a physical button in case things go awry.

    For example, the first time you upload code to the MCU you may need to manually put it into Download Mode.

    Check out section 3.3 of the ESP32-C3-WROOM-02 datasheet. Here it describes how the ESP32 can be booted into SPI Mode or Download Mode. In SPI mode, it executes any uploaded code as expected. In Download Mode, code may be "flashed" to the MCU.

    We can control which mode the ESP32 boots into by adding pull-up or pull-down resistors to several "strapping pins" defined in section 3.3 of the datasheet and using a button to pull the voltage the other way when it is pressed. We want our system to default to the SPI boot, but we'd like to maintain the option to put it into Download mode via a button press if we need to.

    According to Table 4 in Section 3.3, which two pins should have pull-up resistors ensuring they're always high when the MCU boots? Enter your answer as a python set of two numbers (e.g. {1,2})

    According to the datasheet, which of the strapping pins (3, 8, or 9) determines whether the ESP32 boots into SPI or Download mode based on if the pin is high or low?

    In your paper schematic, add pull-up resistors between the necessary pin(s) and the 3.3V line.

    In the above concept question, we identified a pin that boots the MCU into SPI Mode if it is high and Download Mode if it is low. We'll use a combination of a pull-up resistor and a button to pull the pin high when the button is not pressed, and low when the button is pressed. Add this button to your paper schematic tying the pin to GND when the button is pressed.

    Table 4 says that GPIO9 has an internal pull-up resistor, so we don't need to add one to this pin.

    Beyond that, the MCU schematic will need typical components: some decoupling capacitors, pull-up resistors, and the such.

    We're not going to explicitly tell you everything that should be on this board. But you can look at reference designs, such as on the datasheet, or other similar boards, like the Seeed Studio XIAO ESP32C3](https://www.seeedstudio.com/Seeed-XIAO-ESP32C3-p-5431.html), and so on.

    Power management subsystem

    The power management subsystem has one primary goal: deliver power to the rest of the system. But when we drill down, it gets a bit complicated.

    In order to be portable, we decided to power MILO via a LiPo battery. A single-cell LiPo battery has a nominal voltage of 3.7V (a bit more when fully charged, and decreasing as it discharges). We want to take that voltage and convert it to the 3.3V that the rest of the system needs. In some cases it's not absolutely necessary to do so -- this voltage conversion (with a voltage regulator) takes extra parts and space and thus cost. However, we want to avoid downstream issues that can arise from a varying supplying voltage, so we'll incorporate a 3.3V regulator.

    But eventually the battery will discharge, so we need a way of charging it back up. So we need some sort of integrated circuit to charge the battery. LiPo batteries can be dangerous, so specialized ICs are used to make sure the batteries charge at the right rate and to the right voltage.

    But it gets even more complicated. If we're running off of the battery, and the battery gets too discharged, we'd like to be able to plug the system in, and have the system continue working, while the battery is charging. After all, when you plug your phone in to charge, you expect the phone's battery to charge and the phone to still work.

    So really what we need is some magical IC (or ICs) to manage the power, directing power to/from the battery, to the system, from the wall, and so on. Sounds complicated.

    Luckily, it's complicated but extremely commonly needed, and hence companies have created solutions to do this. These systems go under various interrelated name: battery management system (BMS), power management IC (PMIC), battery chargers, and so on.

    We'll be using the MCP73871. This remarkable little chip (~$2!), includes "load sharing" (aka automatically directing power to the system or the battery), and battery charge management (charge the battery).

    Basically, the system operates in a few different modes:

    Power board functions

    Now, we're mostly done, but the MCP73871 will be more than happy to send 5V to the rest of the system when under USB power, and the raw battery voltage when under battery power. So we will need to insert a regulator at the output of the MCP738731.

    The regulator's job is to take whatever voltage comes in and output 3.3V, with the important caveat that the voltage coming in is >3.3V. There are basically two ways to do this: we could basically burn away the extra power and output 3.3V, or we could somehow transform the input voltage into 3.3V without losing (much) power. The first way is a linear regulator, the second uses a switching regulator. If we really cared about power efficiency, or we wanted to make a smaller voltage into a larger voltage, we could use a switching regulator. In our case, we think we'll have plenty of power for MILO, and the linear regulators are inexpensive, small, and require very few external components.

    So we'll use a linear regulator. To pick one, we need to know the range of input voltages, the desired output voltage, the current that we need to supply, and of course cost constraints, size constraints. We have chosen the AP7361C-33Y5-13. This is one part i nthe AP7361C family. The "33" means it outputs 3.3V. The "Y5" indicates that the package is an SOT89-5 (pretty easy to hand solder). It's inexpensive (~$0.50 at our quantitites), and readily in stock.

    So now we can get a handle on what goes into this board:

    • MCP73871, AP7361C-33Y5-13
    • Some connectors (enough to power the other boards in the system)
    • Some status LEDs, and other external components (resistors, caps)

    The connector to the other subsystem boards should be the same as the one we used for the sensor board (and the MCU board, for whoever designs that). But the connector to the battery needs to be a variant: PH2 JST, which has a 2-mm pin-to-pin spacing (vs. 2.54 mm). A good part for this is B2B-PH-K-S(LF)(SN) in MPS.

    This board uses two nontrivial ICs with datasheets we'll have to reference for the schematic design. The MCP73871 in particular has a lot going on, so we'll break down some of the datasheet here.

    Reference Circuit and Pin Descriptions

    First, take a look at page 2 of the datasheet. It has a typical application circuit giving a reference design for many of the details of the schematic.

    Section 3.0 starting on page 17 has a table of pin functions as well as written explanations of which pin does.

    VPCC and TE For our simple MILO system, there are a couple features of this chip we'll ignore: the voltage proportional charge control (VPCC pin, section 3.3) and the internal safety timer (TE pin, section 3.14). Read those sections of the datasheet to determine how to properly deactivate them.

    SEL Pin The SEL pin (pin 3) determines the maximum output current that the MCP73871 will supply to the system and the battery charger when the board is plugged in to a power source. We'll be powering this board from a micro-USB connector, so we want this maximum current to reflect the USB specificiation.

    CE Pin The CE pin (pin 17) is the "charge enable" pin. When this is high, the IC allows battery charging.

    Status Pins

    The MCP73871 has three output status pins that switch between a high-impedance output and a low voltage depending on the internal state of the IC. Table 5-1 on page 25 has a handy reference for what pin states correspond to the various internal states.

    If no battery is present, what should be the output of the three status pins? Enter you answer as a python list of one the following strings: "high z", "low", "high". Your list should be in the order [STAT1, STAT2, PG]

    For our MILO board, we want to be able to easy tell the state of these pins for easy debugging. In your paper schematic, add status LEDs to each of these pins.

    Thermistor

    According to section 3.15, the MCP73871 expects a 10k negative temperature coefficient (NTC) thermistor to run between pin 5 and GND.

    Thermistors are categorized by how the resistance varies with temperature. In negative temperature coefficient thermistors the resistance gets lower with higher temperature, so a graph of temperature vs. resistance will have a negative slope

    Many LiPo batteries have this thermistor built in and the MCP73871 uses it to monitor battery temperature and stop charging if the battery gets too hot. Our batteries don't have this built in thermistor, so we can add a normal resistor to emulate this.

    Programming Pins

    The MCP73871 has three "programming" pins that adjust different parameters of the battery charging cycle, these pins are creatively named PROG1, PROG2, and PROG3.

    Check out this article if you'd like to learn more about LiPo battery charging. The short version is that the MCP73871 will go through a fast charging cycle which applies a relatively high constant charge current and then switches to a constant charge voltage mode.

    In this IC, PROG1 is used to set the fast charge current. PROG3 is used to set the "charge complete" current. When the charger is in constant voltage mode, the charging current will decrease as the battery voltage approaches the charging voltage. When this charging current falls below a threshold set by PROG3, the IC will halt battery charging.

    When charging from a USB interface, PROG2 sets the maximum current the IC will pull from the USB source. For our MILO boards, go with the higher current draw.

    It can be tricky to parse through the datasheet, so we'll highlight some important sections here:

    • Section 3.8: more details about PROG1
    • Section 3.9: more details about PROG2
    • Section 4.3
    • Section 4.5 and Equation 4-1: how to choose a value for PROG1
    • Section 4.7 and Equation 4-2: how to choose a value for PROG3

    For our MILO system, choose PROG1 such that the fast charge current is 1A and choose PROG3 such that the completion current is 100mA.

    Linear Regulator

    The MCP73871 directly outputs whatever the source voltage is, so if our battery is currently supplying 3.7V, that's what we'll get out of the OUT pin of the MCP73871. The rest of our boards expect a 3.3V supply and this higher voltage might damage them. One solution to this is to add a linear regulator to our board. As mentioned above, we'll be using the AP7361C-33Y5-13.

    This part is quite a bit simpler, take a look at page 11 of the data sheet for an example circuit.

    The AP7361C-33Y5-13 has a constant voltage output and is not adjustable, so you can ignore the ADJ pin

    Add this IC into your paper schematic so that it regulates the output of the MCP73871 down to 3.3V.

    Draw your schematic

    Now that you've seen what's involved in each of these two subsystems, pick which team members will design which boards. Remember, half should do the MCU board, half the power board.

    Then, each sub-team should develop paper schematics by studying the typical application diagrams for their systems. You can talk among subteams, and between subteams, but ultimately each person should have their own design.

    Next, start up a new project in Altium and draw your schematic.

    Submitting your design

    Once you are satisfied with your schematic, click the button below so we know you're finished. You can submit multiple times, we'll use the last submission time.

    Click submit when you're finished. Ignore the box.

    What's next

    In Lab03 we'll do schematic reviews of these two boards.

    Laying Out the Board

    We'll lay out the boards in EX03.