Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Welcome to the UW Midnight Sun Hardware team! Joining the team is definitely a rewarding experience, but requires time and effort in order to learn and apply many hardware engineering concepts required to building a solar car! This Hardware 101 does not require a strong knowledge in electrical circuits, but does require patience, and a desire to learn and understand how circuits work. So no matter your knowledge level, you can finish this project and learn a lot on the way.

Since it may be a bit overwhelming to jump straight into an active project for the car, it's best to start things off at a much simpler scale in order to properly grasp the design process for a board, as well as get used to the software tools for development and testing. We will be accomplishing these goals through a tutorial board that will have you ready for working on active and future board for the car.

General Description

The purpose of this exercise is to get you familiar with the following:

  • Using Altium for schematic and PCB layout
  • Using Jira for task tracking and Git for version control 
  • Reading datasheets and creating basic circuits 

You will be doing this through an introductory project that is the basis of a real Midnight Sun board design used in the car.

Problem Statement:

  • Control LEDs with corresponding buttons through a microcontroller  → Similar to driver controls where we use buttons to control various functions of the car 
  • Adjust the brightness of LEDs by turning a potentiometer → Similar to reading any analog sensor data and doing something with it 

IO’s:

  • 2 buttons (digital input)
  • 1 potentiometer (analog input)
  • 2 LEDs (digital output)

Requirements:

  • Buttons need to be debounced 
  • Use our microcontroller (STM32F072CBT6) (Controller Board Interface) 
    • Use appropriate GPIOs


Starting the Project

Before we get into making any circuits or PCBs, let's first make sure we understand what we need to accomplish. By reading the above description, we know we need to design a PCB that has two buttons, a potentiometer, and two LEDs. We also know that the functionality of the board is as follows: when a button is pressed, a corresponding LED should turn on. Great! 

But this sounds so simple... the first google search can tell us exactly how to do wire a circuit that does this:

Image result for circuit with button and led

It's true, the underlying concept of turning on an LED with a button is simple, but we have added some requirements to this project in order to make it more applicable to our design process and to incorporate ideas that will help with design of future boards. If you remember under the requirements heading, it said "Buttons need to be debounced", and "Use our microcontroller (STM32F072CBT6)..." - Let's try to understand these requirements one by one while building a block diagram for what our circuit will look like (This block diagram will be useful when we begin to use Altium).


Creating the Block Diagram

So far we know our inputs and outputs. If we put them on a block diagram we have something that looks like:

Let's now use our requirements to complete this circuit.

Requirement 1: Debouncing buttons:

A quick google search on what button debouncing is can give you a good understanding of the theory behind why we need to 'debounce' buttons and switches. Generally, a button (the one we use for this project) is comprised of two metal contacts that complete a circuit when pressed. Unfortunately, this metal contact created by a human press is never perfect, and can create a ripple in the signal, which if not treated can result in undesirable behaviour from your circuit. This 'unwanted ripple' looks something like:

Do you see the first chunk of the signal? It goes high (on) and low (off) multiple times before stabilizing at the on position. Now, our car uses a push-to-start button; imagine that effect happening on a button like that! It's definitely undesirable, and our goal in this tutorial is to show you a couple of ways to debounce a button and obtain a clean signal from a button press.


Method 1: Low Pass Filter (LPF)

Image result for rc lpf

Before we understand what a low pass filter does, let's make sure we understand the concept of AC voltage/current. If you do not know the difference between the two, this link should help you. Now, notice what the unwanted voltage ripple looks like when the button is pressed: it's oscillating, which we can think of as AC voltage.



Another thing we need to understand is what a Capacitor is, and how it behaves under DC and AC. In essence, a capacitor behaves as an open circuit under DC operation, and a short circuit under high frequency AC operation (with varying degrees over a frequency range). Since our unwanted ripple voltage resembles an AC voltage at some frequency, we can use the capacitor's properties to try and mitigate this noise. 

But how does this circuit shown above get rid of high frequency noise? Well, think about it - if the input signal is DC, a capacitor behaves as an open circuit, and so the bottom branch (which has the cap) will render obsolete, and Vin = Vout. However, if the input signal is a high frequency AC, the capacitor behaves as a short circuit, and now we've created a short circuit to ground, so Vout = 0. We can characterize this behaviour using a 'frequency response' plot (gain vs frequency):

Image result for rc lpf

Another property of a capacitor is that is takes some time to charge up under AC operation (this time depends on the value of the capacitance); and we can use this to create a 'delay' between the button press, and the signal output. This delay can also be characterized using an 'impulse response' plot (voltage vs time):

Image result for rc lpf impulse response

Generally, for buttons, the provided datasheet for the button will include a 'bounce time'. This is the time that the button will take in order to produce a clean, stable signal when pressed (after the noise settles). In the case of the buttons we want to use for this tutorial, the bounce time is 10ms. We can use the impulse response of a LPF to 'ignore' the first 10 or more milliseconds of the button press. In other worse, t1 should be at least 10ms.

So how do we choose the values of C and R in order to obtain a t1 of 10ms? There is a decent amount of math and deeper understanding of circuits required that's beyond the scope of this tutorial. So instead, we'll use a cool online tool that allows us to enter different values for R and C, and shows us the impulse response and frequency response of that LPF: http://sim.okawa-denshi.jp/en/CRtool.php

By inputting different value of R and C, we can see how the cutoff frequency changes, but more importantly, how the rise time changes. So play around until we obtain a value of t that's around 10ms. The values I chose are R = 10 kOhm, and C = 4.7 uF, which yield a t of about 10.82ms.

Perfect! we now have a Low pass filter that will allow us to 'ignore' the bounce time of the button, and give the output a clean, stable signal!


Method 2: Schmitt Trigger

The Schmitt trigger is another circuit we can use to create a clean, noise-free output from a noisy input. Since the circuit of a Schmitt trigger is much more complex than that of a LPF, I'll let you read more about it yourself: https://howtomechatronics.com/how-it-works/electrical-engineering/schmitt-trigger/

What we do need to understand is that a Schmitt trigger can create the following effect:

Image result for schmitt trigger for debounce

which serves the exact purpose we want of mitigating the unwanted noise from the imperfect metal contact in the button press.


For this tutorial, we will implement button debouncing using both methods, first a LPF, then a Schmitt trigger (the part will be provided).

Now, our block diagram becomes:



Requirement 2: Use our micro controller (STM32F072CBT6)

If you've never played around with an Arduino or something similar before, you may not be familiar with what a micro controller is. Please take the time to read about what a micro controller is and come back to the tutorial. 

I'm now going to explain how to incorporate our micro controller into this board, and use it to turn on the LEDs when the buttons are pressed.

Here's an overly simplified explanations of how we use micro controllers: In the car, many PCBs placed in various places in the vehicle, need to communicate with one another. In order for this communication to occur, we need to use micro controllers on these boards. Now, instead of having to add the same micro controller to every board (can be very tedious during board development), we created a 'Controller Board'. This is a generic board that includes our micro controller (and does a couple other things) that we attach on all of the boards that require an MCU (micro controller unit). What this means is that we can make many of the same 'controller board', and attach them to different 'Carrier boards' in order to add an MCU to that carrier board. 

We call it a carrier board because it carries our controller board. An example looks like:

The highlighted greed board is the 'Controller board' and the blue board is the 'Carrier board' (it's our Center Console board). It literally sits on top of our board, and makes electrical connections to the controller board (we'll see more of how this works when we begin the PCB layout).

So, we want to use this MCU in order to take in the button signals as inputs, and have the LEDs as outputs. Then we add some code onto the MCU like if(b1 == 1) then led1 = 1; basically we read the signal that the button gives, and if we sense that it went high, then we give power to the LED which will turn it on. For this tutorial, we simply need to create the electrical connections for this to work - we won't worry about code. So, your task is to learn more about our MCU by reading the datasheet and choosing appropriate GPIOs (General Purpose Input/Outputs) to route the buttons and LEDs to.

(If you're having trouble understanding the datasheet, and knowing which pins to choose, please ask one of our core members, and they'll help you out!)

Great! So now we can fill our block diagram even more:


Awesome! We're almost done. The only thing remaining is that we need to limit the current that goes through the LEDs. Have you ever directly connected an LED to a battery? If you haven't, the LED will likely blow up! This is because there is a large rush of current going through the LED. Since LEDs are rated for a maximum current input, we need to limit the current and voltage going through the LED. A simple google search of "How to pick a resistor for an LED" can tell you exactly how to pick the value of the resistor required in series before the LED. All you need is some information from the LED datasheet. In particular, pay attention to the forward current and forward voltage of the LED.


Finally, our block diagram looks like:


Now that we understand the board requirements, and we have a block diagram for our circuit, we can begin the PCB layout process using Altium Designer.






  • No labels