Sine Lab

Electronics Projects and Guides

Measure Your Crypto Rig's Power Usage

As most of you know, cryptocurrency mining has been quite popular over the past several years. And following that trend, my brother put together a mining computer. After ethereum’s switch to proof-of-stake, the older mining methods no longer work, which is what my brother was doing. So he had to switch to other coins like ergo and flux. The problem now is that these coins earn less than Ethereum used to. And with a desire to add more graphics cards, power usage is an issue too. So, the question is whether his crypto rig is both within a reasonable power limit and if the rig is currently profitable? Let’s find out.

The Sine Lab: Part 2

This video is the second part to a series about building a function generator. If you haven’t seen the first part, I recommend that you do that first so that you know why the design we have currently is the way that it is. It is linked in the description. The first part covers using a microcontroller and a DAC to generate an output waveform. In this video, we will make the waveform centered around zero volts and allow the user to alter the amplitude. Anyways, let’s get the video started.

Dynamo Radio Repair

When I was browsing a local antique store, I found this pretty old, but interseting radio. Apparently, it is very useful for emergency situations, since you don’t need to plug it in or even bring your own batteries. That is because you can charge it up in three different ways. First, you can leave it outside to charge using the solar panel when it is sunny outside. You can also crank this shaft, which is a dyanmo generator. And finally, you can plug it into a 3VDC power source to get it to work. The rest isn’t that special. There is an antenna that extends a few feet. You can also select between FM and AM channels. And finally, there is an audio jack at the back as well. The only problem is that it doesn’t work as it should. So the question is: should we fix it or scrap it? Let’s find out.

Random Number Generation

Random numbers are a very useful thing to have. Why else would we have created dice to roll and coins to flip? We use random numbers to make decisions where there would be indecision, or when we need digital security. However, if you have studied random numbers, you may come to the conclusion that truely random numbers are very difficult to produce. In theory, you could calculate which way a group of dice will land based on a certain throw. The same applies to code because it is meant to be predictable and output the same result everytime. So, how is it possible for us to use code to generate these random numbers even though the code itself is not random and is actually very predictable? And do the methods we use differ when using a microcontroller or a desktop computer? Let’s find out.

The Sine Lab: Part 1

Every electronics workbench has several very important tools. A multimeter, a power supply, maybe even an oscilloscope. These tools are all extremely important for electronics work because they allow us to inspect our circuits and determine whether everything is working properly. However, there is still one amazing useful tool that is still missing. And that is the function generator. A function generator may not be one of the most commonly used tools, but it is incredible for testing circuits where we need quickly repeating patterns. Maybe we need a triangle wave to test out a boost converter, or a square wave to generate a cpu clock. So, in this video we will research the possible ways to create a function generator and ultimately make one ourselves.

Motorized Spider

Halloween is quickly approaching, and what better way to prepare than making a decoration of our own? And what better decoration to make than a spider climbing from the its web? So, in this video we will be finding the best way to make this spider, and setting it up to spook up my house for halloween. It will be so scary that no one will dare trick or treat here again.

Adjustable Electronic Load

In a previous video, I made a pre-regulating power supply. And while it works fine, and can handle loads up to one amp, testing it can be a bit tedious. You would need several different power resistors to test a supply like this, not to mention the calculations you need to run to ensure you pick the correct resistor and get the correct results. Isn’t there an easier way to simulate a load so that we can more easily test power supplies? Well, yes. In this video I will show you how to create an adjustable load which allows you to specify just how much current you draw from a voltage source.

AVR Port Simulator

Microcontrollers are extrememly popular in circuits nowadays, and that is for good reason. They can be programmed to do just about anything and replace otherwise very complicated hardware. Take, for instance, the Arduino and, by extension, the atmega series of microcontrollers. These devices allow us to manipute hardware by writing software. The only problem is that writing code for and understanding these microcontrollers isn’t exactly as straightforward as making a circuit out of transistors. So, in this video, I will provide the very basics to writing code for a microcontroller, specifically the atmega series of microcontrollers, so that you can start making programmable circuits of your own and move beyond the confines of Arduino boards.
Today’s video will cover basic software controlled I/O. Every microcontroller has something similar to what I will describe, so don’t worry if you are trying to understand another microcontroller, the general ideas are similar. This code should also generally work in the Arduino IDE as well. Take a look at your datasheet if you are unsure. I will give you some example code and run it on an actual AVR and then explain how it works. This is the code that we will be using. I will explain it all in a second, but I will show you what it does first. As we can see it blinks each LED in an alternating pattern. To explain how the AVR can do this, I have created this PCB to demonstrate how the AVR handles I/O on its digital pins, and you, the user, are the CPU. I know it looks complicated but if we break it down you will understand how it works completely. Let’s start in the bottom of the PCB. This is where I introduce the concept of registers. Basically, a register is a piece of hardware that stores binary data, in this case 8 bits of data. The CPU can read and write to it. It’s almost like RAM except its faster and has a purpose in controlling hardware directly. You, as the CPU, can read from it by looking at the LEDs. An LED that is on is a ‘1’, and an LED that is OFF is a ‘0’. You can write to it by selecting ones and zeros on the switches and then pressing the write button. We can see in our code that the first two lines of the main function are the DDRB and the PORTB registers. The silkscreen on the PCB represents these registers. Let’s write these values into the registers. 0xff represents all ones, so we can write that in. 0xaa is simply alternating 1’s and 0’s. While its great that we can save this data, how do these registers directly affect the output? Well, we can take a look in the datasheet to find out. We can see that the PORT register is connected to the output through this component, which is a buffer. A buffer simply outputs the same logic level as its input, so a 1 on the input leads to a 1 on the output. We can already see that the output, which is the green LEDs at the top by the way, matches the PORT register. But what about the line connecting to the buffer from the side? Well that is the enable pin. The enable pin does exactly what it says, and when it is a 0, the output of the buffer is high impedance. The buffer is implemented on the board as U2 and U3, and they are the SN74HCT125 buffer ics.
Why would we want a high impedance output? Well, sometimes, we want to use the pin as an input and don’t want some output messing with it. That is why the register is called the Data-Direction-Register. A one makes the pin an output and a zero makes it an input. So, in the arduino programming method, you can sort of think of the PORT register as digitalWrite and the DDR register as pinMode, the difference is that you are changing 8 pins at once. When we set the pin as an input, we can see that it is driven by external connections. However, the PORT register still has one more trick up its sleeve. When the pin is set as an input, the PORT register can be driven high to set the pull-up resistor. This basically just connects the pin to VCC through a 10k resistor. This allows the external world to drive the pin, but it will be high by default if the external interference is high impedance. This just keeps the pin from floating. Remember, the pull-up resistor is only active when DDR is 0 and PORT is 1. That finally brings us to the PIN register. This register is read-only, and it doesn’t matter if the pin is an input or output. This is how you read input, you can also read output if you find the need to do that. Now let’s continue on with the code. Once we enter the loop, the first instruction deals with the PORT register. This line of code basically reads PORTB equals PORTB xor’ed to 0xff. First, remember that 0xff is 8 bits of 1’s. If you are unaware of bitwise operators, the arrow is the xor operator. An xor is basically when one input is a one the output is a one, however if both are ones or both are zeros, the output is zero. This operator is useful for alternating bits, and you can select which one by setting the appropriate bit. Anyways, since we are the CPU, we need to look at each bit and xor it with a one. That means that each one will become a zero and each zero will become a one, alternating the output. And obviously delay just means that we have to wait. We can now repeat that process forever because we are in an infinite loop. Now that you understand how to write code this way without the arduino libraries, why would you want to do this. Isn’t it easier to refer to each pin individually instead of having to deal with entire registers with 8 pins at once. Well in some ways it is better and in others it isn’t. So, yes while it is true that it is easier to understand initially and can lead to easier code in certain circumstances it does have its drawbacks compared to the method that we used here today. First, the arduino functions such as pinMode or digitalWrite are a whole lot slower than writing to the DDR and PORT registers because the arduino has to lookup where each pin is located. For example, pin 13 on the arduino correlates to pin 5 on PORTB. Arduino has to find out where pin 13 is whereas our code already knows where PORTB and DDRB are. Second, writing to the registers like this can lead to situations where we can take advantage of controlling 8 bits at once. We can read the register and write an 8 bit number to it, making it especially convenient in this example to alternate all 8 bits at once. This video serves as my introduction to microcontrollers that go beyond arduino. This red board here simply provides an interface where you can directly interact with the ideas I talked about in this video so that you can learn more about it and experiment. If you want one for yourself, I’ve left the schematic in the description. If you enjoyed this video and found it helpful, please consider subscribing so that you can see my other videos. Have a good one.

Life-Sized Op-Amp

Data in electronics can be generally divided into two categories: digital and analog. With digital having two electrical states, and analog having infinite states. And it is quite often that we have to run mathematical operations in our circuits. For digital, this is quite easy as we can use a microcontroller or a full adder to accomplish such tasks. However, analog is a bit more tricky to get setup, and that is because of the famous operational amplifier, also known simply as an op-amp. How can we use such a component to calculate operations for us? Well in this video, I will show you how to not only use an op-amp, but also how to build one for yourself. Let’s make it.

How to Choose a Heatsink

In power electronics, we use a lot of current. Unfortunately, a lot of power is also dissapated as heat. Depending on how much power you are using, you may find that your system is producing too much heat, and causing the destruction of your ICs. Linear regulators are especially vunerable to overheating, because they dissapte a very large amount of heat while in use. But how can we combat the heat, and allow our ICs to continue functioning even with the heat? Well, we can use a heatsink. Heatsinks basically increase the area in which the disapated heat can go and decrease the overall temperature, saving our circuit. So, in this video I will explain the best way to determine which heatsink your project needs.