Skip to content

Week 10: Outputs

Note: I will need until Saturday, April 4th to complete the individual assignment for the week. I've documented what I have done so far below:

Our assignment:

Group Assignment: measure the power consumption of an output device

Individual Assignment: 1. add an output device to a microcontroller board you've designed, and program it to do something


Group Assignment

Find our group assignment documented here and my documented learnings below.

This week, we had the great benefit of having Quentin come by to visit the lab! He and Will gave us some instruction that led to the completion of the group assignment.

quentin!

Quentin visits Fab Lab NODA! We did a deep dive in electronic circuits

We used a breadboard circuit based on some practice I was doing for this week's assignment (see below). We ended up hooking up a 12 V LED strip to the circuit and determined its power consumption by measuring voltage and amperage using a multimeter. We did this with the following equation:

  • Power (in watts) = Voltage x Current (P = V x I)

We were already familiar with how to use the multimeter to measure voltage. We simply placed the negative probe to the ground wire of the LED and the positive probe to the positive wire for the LED.

castor measuring voltage

Castor measuring voltage. It read about 11.84 V which is within range of what is expecte das it is a 12V LED hooked up to 12 V power supply

To use the multimeter to measure current, we had to understand more about how the multimeter actually works. The "multi" actually indicates the multiple things it can measure-- voltage, continuity, resistance, and current, for example. Whereas the voltimeter function we are used to measuring measures in parallel, the current must be measured in series. This meant we would need to rig up another wire to open the circuit and clamp the multimeter (functioning as a amp-meter now) within the circuit.

Lesson about Resistance in Multimeters

We took note of the following formulas:

Rseries = R1 + R2

Rparallel = 1/(1/(R1) + 1/(R2))

In order not to disturb the circuit, a multimeter measuring in parallel (like when we're measuring volts) must include a resistor (R2) that is really BIG (since it can't actually be infinite). This effectively simplifies the parallel resistor equation to the resistance equaling the resistance of the main circuit we're measuring.

Similarly, when measuring a current in series, the resistor value is really SMALL so that the added resistance is negligable.

This was all a long way to explain why we needed to open up the circuit to measure the current.

measuring current LED

Measuring the current of the LED. This came out to about 0.239 amps

Now with the equation P=VI, the power = 11.84 Volts x 0.239 amp = 2.8 watts

Note: Will explained that 1 Volt is 1 joule per coulomb. 1 amp is 1 coulomb/second. 1 Watt is 1 joule per second. Doing the math (coulombs cancel each other out), this explains how we get to the unit of watts.

Output

For my output device, I hooked up a speaker play a few songs with push buttons. See below for breadboard practice leading up to this. I also practiced using new components within the circuit to amplify the sound and improve sound quality. I used the LM386 Low Voltage Audio Amplifier within the circuit.

LM386 Schematic

I used this schematic in the datasheet wire my circuit.

lm386 speaker circuit breadboard

Circuit in breadboard. Got to start learning about polarized and nonpolarized capacitors.

Eventually, I got to work with designing the circuit board in KiCAD, milling the board, then stuffing the board. All seemed fine and well...

take 1 sound board

My first attempt board is soldered and ready to go...or so I thought

Unfortunately, there was no sound produced! I used multimeter to test basic connections (found that the speaker pins were only at around 1.55V) and oscilloscope to see if I could see sound square waves.

oscilloscope

Signal is detected when I push the button to play a song

Mistake #1:

Then I realized I got my routing confused with the potentiometer. I routed the 5V power to one of the legs when it should have been just routed to the signal from Pin 26 of the Xiao board. As a quick fix, I was able to remedy this by cutting the trace so that it only goes to the pin needed on the LM386 amplifier and by soldering on a connector pin directly to the leg of the potentiometer. However, the sound still didn't work....

Mistake #2:

Next, I used this device in the lab to measure one of the capacitors. According to the datatsheet's schematic, it should be at 0.05 μF but this was measuring at 522.2 nF. That was one problem to fix. But removing that capacitor should have still produced sound in theory even if the quality was worse but sadly I still didn't have a working board...

measuring capacitance

Measuring capacitance of one of the capacitors I placed

Mistake #3
Finally, I realized that the footprint I used on KiCad didn't quite match up with the schematic I was following on the LM386 datasheet. I was using bad pin logic and thus routing a few of my pins incorrectly to ground--so in effect I was routing my signal in straight to ground rather than over to the speakers. Oops!

schematic mistake

I switched pins 2 and 3 in the wiring. And I incorrectly routed the potentiometer pin to 5V but that should go to a connector that links back with pin 26 on the XIAO RP2040 board.

We live and we learn....Time to begin again.

Back in KiCAD, I fixed my errors by wiring the circuit correctly and by adding in a connector for signal input.

sound board take two

On Friday, I can get back in the lab to mill the board and hopefully it will work this time! More soon...

Learnings + Resources

Before completing my assingment documented above, I tested several outputs.

8Ω 0.25 W Speaker
I read up on this mini speaker we had on Adafruit's site here, then followed this arduino speaker tutorial to learn how to wire it up. As advised, I added a 200Ω resistor in series.

speaker basic tests

Set up for testing the speaker using basic code provided on website. I connected the speaker to pin

Next I found this build electronic cirucits site for more code for playing simple melodies.

Next, I wanted to try my hand at adding a button input and seeing if I could create code that would play the song once the button was pressed. And once I got that, I challenged myself to have three buttons that would each play a different song when pressed. After a lot of trial and error within Arduino's IDE (luckily it tells you when there is an error in the code), I got it! See design files for the code used. Mostly, one thing notable was that the note Duration was much bigger than the other melodies. I'm assuming that's because it still needs to be an integer but the was a desire for more specific time. So within the loop function I just input 100,000 in place of the 1000 when calculating note duration and that worked. At first it was a bad droning sound.

songs on speaker breadboard

Set up for my speaker circuit. The breadboard I was using had something weird going on with ground so I used another breadboard's ground rail.

Video coming soon

Here is a video of playing through each song

Learning Outputs with Quentin

The next day, Quentin came by the lab to visit and we worked through more output circuits...

First, we worked on amplifying the sound of the above circuit using a transistor in the circuit. We used this N-Channel MOSFET transistor. I read more about transistors in Forrest Mim's Getting Started in Electronics guide. Mims describes transistors as "semiconductor devices with three leads" where "a very small current or voltage at one lead can control a much larger current flowing through the other two leads" meaning they "can be used as amplifiers and switches" (48). As explained in class, a MOSFET is a type of transistor that has a very low dissipation. N-MOSFETS go down to ground.

I didn't document this exact set pt but later, I hooked up a few different speakers that are 8 Ohm 0.5 W to my original circuit (with a transistor + resistor as Quentin taught):

quentin's circuit new speaker

Here, I replicated the circuit that Quentin improved by using the transistor using a different speaker type.

Back in the lab...

We connected a motor:

Video coming soon

Motor output

And we connected a 12 V LED which we ended up using for the group assignment.

LED circuit

Here is the LED

Through this we learned more and more about circuits which is documented in group assignment above.

Adafruit Mono 2.5W Class D Audio Amplifier

Since the audio output for the bigger speakers was low, I next learned another way to amplify audio using Adafruit's Mono 2.5W Class D Audio Amplifier in my circuit. I also found this tutorial video helpful for guidance on how to wire up this board.

After a little pin resoldering, I set it up with breadboard. It was loud! I got a tool to turn the onboard potentiometer of the Adafruit all the way down to protect the speaker. Then, with some help from Will, I wired in a potentiometer to help control the sound.

adafruit sound

Wiring up speaker with adafruit's audio amplifier board

Video coming soon

Sound can get much louder using the 2.5 W Class D audio amplifier! With the potentiometer, I can control volume

LM386 Low Power Audio Power Amplifier
Next, I tried using another amplifier component: the LM386 After reading its datasheetI began to wire up a breadboard circuit based on the provided schematic (Figure 9-1). I also noted that this requires at least 5 volts of power supply (no more than 12V) so I would ensure that this was connected to the 5V pin on the RP2040.

This was my first time using capacitors. As Sparkfun explains on their website, capacitors are the "workhorses of energy storage" and can filter high frequency noise among other uses. I learned there are polarized and nonpolarized capacitors and how to read the units (i.e. microfarads, picofarads, etc.).

Grove - Temperature Sensor
For my assignment this week I wanted to practice using LCD screen and displaying temperature. This would be practically helpful to include in my final radio design. So I learned to use the Grove - Temperature Sensor board. The demo code on this website didn't seem to work but I found another on a github page on the sensor here which did vary the temperature as I provided heat and cool air. Now, I wanted to figure out how to connect an LCD screen that would display the temperature.

Grove--LCD RGB Backlight

This week, I also wanted to try a different output display. We had this Grove--LCD RGB Backlight Screen in the lab. This was simple enough to hook up to power (it take 5V), ground, SDA (P6 on my XIAO board), and SCL (P7 on my XIAO board). Hoewver, after much trial and error I couldn't get this (or another screen) to work properly. So I'll try again when I can.

Resources

Found this resistor color code calculator online.

Found this Ohm's Law Calculator on DigiKey's website.

Design Files

To be updated when assignment is complete