Mini Museum: Arduino Uno

The Arduino Uno has been an important part of the electronics hobbyist scene its release in 2010 (as a refinement of earlier boards such as the Arduino Duemilanove.)

A typical Arduino Uno R3 microcontroller board.

I picked one up in 2011 to see what this new “Arduino” craze was all about, and discovered what is still to this day the easiest way I’ve found to get a microcontroller-based whatever up and running. The Arduino IDE, and especially the included libraries and example sketches, make programming as easy as it gets (at least, for the era before LLMs could plausibly write most simple sketches for you.)

Due to its popularity over the past fourteen years or so, the Uno is still somewhat relevant in the Maker community, although it is inevitably being replaced by newer boards such as Espressif’s ESP32. But the IDE and libraries have proven so popular and easy to use that even newer boards like the ESP32 can be readily programmed in the Arduino IDE, once you have downloaded and selected the appropriate core.

The example in the Museum is a garden-variety Arduino Uno R3 board — the “default” model of Arduino. If someone talks about an “Arduino” project and doesn’t specify which board they used — it’s a good bet it’s this one. The Uno is, at least currently, the poster child for all things Arduino, and it deserves its small but important place in the Museum.

Working with a 16MHz, 8-bit microcontroller with 32kB of Flash in 2024, on a workstation with an AI-capable GPU with over a thousand cores does seem quaint — but the Arduino ecosystem (mostly, the libraries) was and is absolutely a revolution in hobby electronics.

Arduino Uno specs:

  • Microcontroller: AVR Atmega328P (20MHz, 8-bit, 32kB flash, 2kB RAM, 1kB EEPROM)
  • Operating voltage: 5V (USB, or 7-12V DC supply via onboard regulator)
  • Analog input pins: 6 (A0 through A5; these can also do basic digital I/O)
  • Digital I/O pins: 14 (6 capable of PWM output)
  • Interface: USB-B
  • Compatibility: Windows / Linux / Macintosh
Posted in Arduino, C, Coding, Digital, Electronics, Mini Museum, Tools, Toys | Tagged , , , , , , , , , | Leave a comment

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