Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

Image Added

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.

...

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 lpfImage Added

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 responseImage Added

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 debounceImage Added

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:

Image Added



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:

Image Added

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:

Image Added


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:

Image Added


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.