Components: Capacitors

Capacitors: More Than Just Stored Charge

Capacitors are everywhere in modern electronics, from tiny capacitors on microprocessor boards to the massive ones that help start large motors. They are essential components, often taken for granted, yet understanding how they function can give us insights into everything from power smoothing to signal processing. In this post, we’ll explore the fundamental properties of capacitors, their behavior in circuits, and some practical applications.

Various types of capacitors. (Image: Wikimedia)

Basic Mathematical Model: How Capacitors Work

At its core, a capacitor is a device that stores electric charge. It consists of two conductive plates separated by an insulating material (the dielectric). When voltage is applied across these plates, positive charge builds up on one plate, and negative charge on the other, creating an electric field. The amount of charge a capacitor can store per volt applied is called capacitance, measured in farads (F).

Capacitors Oppose Changes in Voltage

A key property of capacitors is their ability to oppose rapid changes in voltage. This property, related to the equation I=C*dV/dt, means that when a voltage across a capacitor changes, the capacitor either charges or discharges to oppose this change. In other words, capacitors “smooth out” sudden shifts in voltage, which makes them valuable in both DC and AC applications.


Capacitor Behavior at DC and AC

Behavior at DC

In a DC circuit, once a capacitor is charged to the applied voltage, it essentially behaves like an open circuit. No more current flows, and the capacitor simply stores charge. This is why, in many DC applications, capacitors are often used for energy storage or smoothing, as they can provide short bursts of power when needed but do not continuously conduct current.

Behavior at Increasing Frequencies

In AC circuits, capacitors act very differently. As the frequency of the AC signal increases, capacitors allow more current to flow. This behavior is due to their impedance, which decreases with frequency, given by Z=1/(jωC), where is the angular frequency. This property makes capacitors useful for filtering applications, as they can “pass” higher frequencies and “block” lower ones.


Basic Uses of Capacitors

Power Decoupling: Filtration and Smoothing

One of the most common applications for capacitors is in power decoupling. In digital circuits, especially where microprocessors and other ICs are present, there are often rapid fluctuations in current demand. Without decoupling capacitors, these fluctuations can lead to noise on the power supply lines, which can disrupt the operation of sensitive components. By placing capacitors across the power supply, these spikes in demand can be smoothed out, as the capacitors act as local charge reservoirs.

AC Coupling of a Signal

Another vital use for capacitors is in AC coupling, which is essential for isolating the DC component of a signal. In audio circuits or amplifiers, capacitors are often used to “block” any DC bias while allowing the AC (signal) component to pass through. This is commonly referred to as “capacitive coupling,” and it ensures that each stage of a circuit can be biased independently while still passing the signal along.


Sample Circuits Featuring Capacitors

Let’s look at a few practical circuits that demonstrate how capacitors are applied:


  1. Low-Pass Filter: One of the simplest applications of a capacitor is in a low-pass filter, where it’s paired with a resistor to create a circuit that allows only low frequencies to pass while attenuating higher ones. In this case, the capacitor blocks high-frequency components, acting as a filter to remove noise or unwanted high-frequency signals.



  2. RC Timing Circuit: Capacitors are also crucial in timing circuits. When combined with a resistor, the time it takes to charge or discharge a capacitor can be carefully controlled, creating predictable delays. This concept is essential in applications like timers and oscillators, where precise timing is needed.



  3. Decoupling Network: For digital systems, capacitors are often placed close to ICs in parallel with a power supply line to act as decoupling capacitors. By filtering out transient voltage spikes, they ensure the ICs receive a stable power supply.



Additional Capacitor Considerations

Capacitor Types and Their Applications

Not all capacitors are created equal. Depending on the application, you might encounter ceramic capacitors, electrolytic capacitors, tantalum capacitors, and more. Each has unique characteristics and is suited to specific tasks. For instance, ceramic capacitors are generally used for decoupling due to their low equivalent series resistance (ESR) and stability, while electrolytic capacitors are often preferred for bulk storage in power supplies due to their high capacitance values.

ESR and Leakage

A capacitor’s equivalent series resistance (ESR) is another important factor, particularly in high-frequency applications where lower ESR capacitors are desirable for efficiency and stability. Additionally, capacitors aren’t perfect insulators and often exhibit leakage, where a small current continues to flow through them even when fully charged. This leakage can be significant in sensitive circuits and should be accounted for during design.


Conclusion: Small but Mighty Components

Capacitors may seem simple at first glance, but their unique properties make them indispensable in nearly every branch of electronics. Whether they’re being used to smooth out power, couple AC signals, or provide precise timing, capacitors are essential tools in the engineer’s toolkit. Understanding their behavior and how they can be used to manipulate signals or control power can deepen your appreciation of both the versatility and elegance of electronics.

This article was coauthored by GPT-4o.

Posted in Components, Electronics | Tagged , , , , , | Leave a comment

Cómo se llama su LLAmA?

Large Language Models (LLMs) such as ChatGPT are dramatically changing how many information tasks (notably, writing code) are done. Thus far, these models have generally required extremely powerful servers, running multiple H200 tensor core processors, sometimes with hundreds of gigabytes of available memory.

Recently, though, there has been a good deal of success in paring these huge models down to a size where modern home PC workstations (or apparently, even a modern Raspberry Pi!) can run them. In just a few minutes, I was able to download “Ollama” server software for Meta’s “Llama” LLM models, select a model to try, and host it locally on my PC. With a little more setup (setting an environment variable to get the server to listen to the local network and not just 127.0.0.1), the Llama server was available across my local network — and I was able to chat with it via a Llama client app for my Android phone.

As a test, I asked the first model I tried (Llama 3.1) to write an article for this blog, describing how to set up a similar Llama server. Oddly, it insisted that it could not help with this, since Meta’s LLM models are not intended to run on home servers. (It even stuck to its guns after I pointed out that it was, in fact, running on my main home PC workstation, Scientia.)

So I loaded up Llama 3.2 (a smaller but newer model), and gave it the same request.
Here’s the response I got — pasted directly from the text file I used to save it.

Setting Up Your Own LLaMA LLM Server: A Step-by-Step Guide

The Llama Large Language Model (LLM) has revolutionized the field of natural language processing, enabling rapid advancements in areas such as conversational AI, text generation, and more. While access to pre-trained LLaMA models can be limited, setting up your own server at home can provide unparalleled flexibility and control over the model’s configuration.

Hardware Requirements

Before embarking on this project, it’s essential to understand the hardware requirements for popular LLaMA model sizes:

  • Small: 8-16 GB RAM, NVIDIA Tesla V100 or A100 GPU (optional)
  • Medium: 32-64 GB RAM, NVIDIA A100 GPU
  • Large: 128-256 GB RAM, multiple NVIDIA A100 GPUs
  • Huge: 512-1024 GB RAM, multiple high-end NVIDIA A100 GPUs

For a home setup, it’s recommended to start with the Small or Medium model sizes. This will allow you to test and refine your LLaMA server without incurring significant hardware costs.

Setup and Configuration

To set up your own LLaMA LLM server at home, follow these steps:

  1. Choose a Hardware Platform: Select a suitable platform for your server, such as:
    • Raspberry Pi (for small models)
    • NVIDIA Tesla V100 or A100 GPU-based servers (for medium to large models)
    • High-end desktops or workstations
  2. Install the Required Software:
    • Install the PyTorch library and its dependencies.
    • Configure your system’s network settings for optimal performance.
  3. Download the LLaMA Model: Use the official Hugging Face repository to download the desired LLaMA model size.
  4. Prepare the Dataset: Prepare a suitable dataset for fine-tuning the LLaMA model, such as a large text corpus or a custom dataset of your choice.
  5. Configure the Training Script: Write a training script using PyTorch and customize it to suit your needs. You can use the official Hugging Face LLaMA training script as a starting point.

Tips and Considerations

  • Power Consumption: Be mindful of power consumption when choosing hardware, especially for larger model sizes.
  • Memory and Storage: Ensure sufficient memory (RAM) and storage to accommodate the LLaMA model and your dataset.
  • Cooling Systems: If using high-end GPUs, consider investing in a reliable cooling system to prevent overheating.

Conclusion

Setting up your own LLaMA LLM server at home can be a rewarding experience for AI enthusiasts and researchers. By following these steps and considering the typical hardware requirements, you can create a custom setup that suits your needs. Remember to carefully evaluate power consumption, memory, and storage requirements to ensure optimal performance.

Despite what it claims about the availability of trained models, this was produced by an as-downloaded copy of Llama 3.2 without any additional local training or prompt engineering. Not bad, for a free, relatively easy-to-use model that I can run on existing hardware and have as a local resource. I think I’ll still keep my GPT subscription, but it’s definitely impressive to be able to host your own LLM at home. (And the responses are fast — much faster than I’ve seen even with quick cloud-hosted models like GPT-4 Turbo.)

I love living in the future!

Posted in Uncategorized | Leave a comment

Laser Spirograph

Many Generation-X geeks like me have happy memories of creating weird and wonderful geometric drawings with a Spirograph set — a toy invented in the 1960s in its modern form.

It occurred to me that the Lissajous-like patterns that the Spirograph produced would work well as laser engraver line art. The Spirograph’s gears can be easily replaced with lines of code, calculating the position the “pen” would be at for a given angle of rotation.

A series of tests of the Spirograph algorithm (with one moving “gear”.)
Circles-in-circles can produce some surprisingly straight paths!

Engraving was done (for the spirograph designs) at 10mm/s and 50% power, on an Atomstack 40W laser. The algorithm has constants for the radii of the outer (fixed) and inner (moving) circles. The point radius (corresponding to which hole is used for the pen) is a variable, but is typically held fixed for a complete cycle of 2N*pi radians. (The large hexagon in the above image is a sequence with the same inner and outer radii, and 31 different point radii from -15mm to 15mm.

Here’s the GitHub. Have fun!

Posted in BASIC, Laser Cutter, Toys | Tagged , , , | Leave a comment

The USB-C High Voltage Hydra: Don’t Get Bit!

Multi-connector USB-C charging cables, which allow you to charge multiple devices simultaneously using a single USB-A port, are certainly convenient. These cables typically feature one data-capable connector and multiple charging-only connectors, making them seemingly ideal for powering multiple devices on the go. However, as with many technological conveniences, there are hidden risks.

Recently, I purchased a 1-to-4 USB-A to USB-C charging cable. This cable includes one data cable and three charging cables. Initially, it seemed like a great way to simplify my charging setup. However, I soon discovered a significant design flaw: the voltage on the V+ line follows the voltage requested by the device on the data cable.

The monster. Whatever voltage the data connector (weirdly in orange) requests, everybody gets(!!)

USB defaults to +5VDC power, which has been the standard since USB first came out. (How much current a device should draw is another discussion.) But with the USB-C Power Delivery (PD) specification, USB-C capable devices can request higher voltages and/or current limits, which will then cause the power supply to change to that higher voltage.

For example, when I connected my Samsung A71 phone to a power bank via this cable’s data connector, it requested and received 9V on the power rail (as measured by a handy passthrough USB analyzer.) This 9V was then applied across the V+ lines on the other three cables, potentially subjecting any devices connected to the charging-only connectors to a voltage they were not designed to handle. (Needless to say, I suspect this cable is not standards-compliant. Hey, it was cheap.)

USB-C Power Delivery (PD) is a specification that allows devices to negotiate the power they receive. This negotiation can result in voltages of 5V, 9V, 15V, or even 20V, depending on the device’s requirements and the charger’s capabilities. While PD provides a great way to supply more power when needed, it also introduces risks when multiple devices are connected without proper isolation.

Not all USB-C devices are tolerant of higher voltages. Many devices that do not support PD negotiation are only rated for 5V. If these devices are exposed to higher voltages, they can be damaged or even rendered inoperable. This makes it crucial to ensure that devices on the charging-only connectors are either capable of handling the higher voltage or are protected from it.

If you’re charging four of the same type of thing (like those USB-rechargeable AA batteries), such cables will probably generally work (as long as the individual devices don’t draw too much power without negotiating for it.) But if you just plug in devices to charge them (as many purchasers of these cables will no doubt do), take care that the data-cable device doesn’t see a native USB-C connection, request 20V to fast-charge itself, and fry the rest of the devices connected to the cable.

After all, power is proportional to V2, so a device drawing 1x power at 5V will draw 16x the power at 20V, assuming it is essentially a resistive load. This will usually end with some part of the device releasing its magic smoke due to trying to dissipate 16x as much power as it should.

So, while there are good uses for such cables — use them carefully!

Coauthored with GPT-4o.
(They wrote the article from a description I provided; I edited for style.)

Posted in Design, Digital Citizenship, Electronics, Power | Tagged , , , , | Leave a comment