Recording Sound to an SD Card with a Microcontroller.

Recording Sound to an SD Card with a Microcontroller.

In one of my previous articles we learned to work with an SD card, and of course it would be good to put that knowledge into practice. That's how the idea of recording sound to an SD card and then listening to it on a computer was born. We won't be able to make anything worthwhile, because we can't create new files or increase their size; these limitations are imposed by the library. But the principles of working with sound laid out in this article...

A Few Words About Pointers in C.

A Few Words About Pointers in C.

When learning C, beginners often have questions about pointers. I think everyone has roughly the same questions, so I'll describe the ones I had. What is a pointer for? Why do people always write "pointer to type", and how does a pointer to uint16_t differ from a pointer to uint8_t? And who invented pointers anyway? Before answering these questions, let's recall what...

Connecting an SD Card to a Microcontroller.

Connecting an SD Card to a Microcontroller.

In one of my previous articles we displayed an image from an SD card on a display, but a few points were left out: first, connecting the card itself; second, only some of the Petit FatFs library functions were covered. Let's look at these points in more detail. Communication with the card is possible over one of two interfaces, SPI or SD. I should say that the SD interface can work in one-bit...

How a Multiplexer Works.

How a Multiplexer Works.
Схемотехника

A multiplexer is a switch that connects many inputs to one output according to a given digital code. In fact, multiplexers come in two kinds: analog and digital. Analog ones are built on field-effect transistors and pass the signal in both directions, while digital ones replicate the signal from the selected input to the output. Below we'll talk about the analog multiplexer...

How to Get a DC Voltage from PWM.

How to Get a DC Voltage from PWM.
Схемотехника

Every beginner electronics enthusiast knows how to get a DC voltage from PWM. It's simple: pass the PWM through a low-pass filter (in the simplest case an RC network), and you get a DC voltage at the filter output, right? In fact, I think it's all much more interesting: when trying to get a DC voltage from PWM, the following questions arise: How do you choose the values...

STM32 Debugging over SWD.

STM32 Debugging over SWD.
STM32

STM32 has a very convenient interface for debugging and flashing the MCU: Serial Wire Debug, SWD for short. Its convenience is that debugging requires connecting only two data pins plus two power pins. The wiring diagram looks like this. Once the pins are connected, you need to enable SWD debugging in the development environment; in KEIL this is done as follows...

Canon Rebel XT (EOS 350D) Camera Repair.

Canon Rebel XT (EOS 350D) Camera Repair.
Железо

The other day someone brought me a CANON 350d camera with the diagnosis "won't turn on" and asked me to take a look. They also said it had already been taken apart and a loose screw had been found inside, which was put back in place, but the camera still didn't work. After a bit of googling, I learned that the loose screw is a common ailment of these cameras and isn't always curable. Since I had never repaired cameras before, I gladly agreed...

How to Get a Negative Voltage.

How to Get a Negative Voltage.
Схемотехника

It turns out that when negative voltage comes up, the first question people have is: "How can that be? How can a voltage be negative?" So I'd like to dwell a little on what negative voltage is and where it can be useful. If someone asks me what floor I live on, I'll say without thinking that it's the fifth, and my answer is clear to everyone; it's all because...

Reverse Polarity Protection.

Reverse Polarity Protection.
Схемотехника

To power my devices during debugging, I use ordinary phone chargers with a pin header connector soldered to their output. To tell plus from minus, I file a notch in one of the pins, but through carelessness I still sometimes make a mistake and connect the wires the wrong way round. I won't talk about the consequences of reverse polarity; instead I'll tell you how to avoid it. But first, a couple of words about what reverse polarity is...

STM32 SPI3 Not Working.

STM32 SPI3 Not Working.
STM32

Usually, before building a device, I implement the basic functionality on a breadboard, and this time was no exception. After the basic functionality was implemented, I started routing the board, and along the way it turned out that it was much easier to route the board using SPI3 rather than SPI2, which was used in the project. Why make things hard for myself, I thought at the time, and routed the board using SPI3...

Handling Tactile Button Presses.

Handling Tactile Button Presses.

Usually a programmer's first program prints the string "Hello world" on the screen, while an embedded developer blinks an LED, maybe also adding a button to change the LED's state. It's the button I wanted to talk about: a button that toggles something is usually called a tactile button. It's usually connected according to one of the circuits shown below. But a much more interesting question...

STM32 Low-Power Modes.

STM32 Low-Power Modes.
STM32

First I'd like to say a couple of words about the microcontroller's supply voltages: STM32 needs 2 to 3.6V for normal operation, and the built-in regulator provides 1.8 volts to power the core. Below is a schematic of the controller's overall power supply. As you can see, the power supply is divided into domains, each responsible for powering certain peripherals/parts of the MCU. You can reduce consumption...

How to Test an Op-Amp.

How to Test an Op-Amp.
Схемотехника

The other day I bought an operational amplifier (op-amp) in a shop for $1.5, came home, soldered it in, and silence. I had no doubt that the op-amp was to blame for the circuit not working, so I desoldered it and decided to test it. I connected the inverting input to the output, applied power and a voltage to the inverting input (1V); a working op-amp should output what I applied to its input, and that is essentially what testing...

STM32 Delay Function.

STM32 Delay Function.
STM32

The first thing I noticed after switching from AVR to STM32 was the absence of the familiar delay functions delay_us() and delay_ms(). Well, if they're missing, they're missing, I thought at the time, and whenever I needed a delay, I did it like this...

SPI STM32.

SPI STM32.
STM32

We won't go over how the protocol works, since it was covered here; let's go straight to the capabilities of the STM32 SPI module: full-duplex synchronous transfer using 3 lines; simplex synchronous transfer using two lines, with the option of a bidirectional data line; 8- or 16-bit frame format; operation in Master or Slave mode; in Master mode 8...

Analyzing Op-Amp Circuits.

Analyzing Op-Amp Circuits.
Схемотехника

In the article about measuring negative voltage with an ADC, most of the circuits described were built on op-amps, and to a reader unfamiliar with op-amps the material might have seemed complicated, so I'll try to explain in simple terms the rules I use when analyzing op-amp circuits. In short, op-amp circuits aren't difficult; they're very easy. There are 3 ways to use an op-amp: without feedback, with positive...

The Programmer Can't See the Microcontroller.

The Programmer Can't See the Microcontroller.

I think many people have read online that if you set the fuses incorrectly, you won't be able to flash the MCU with standard tools anymore. Which fuses can be set incorrectly? The Atmega16 microcontroller has several such fuses: SPIEN and JTAGEN, which enable programming the microcontroller via SPI and JTAG; RSTDISBL, which allows the reset pin to be used as an additional I/O line; also...

Inside the SMD4.2

Inside the SMD4.2
Схемотехника

In one of my previous articles I described how I came to the conclusion that my project needed a stepper motor. After a suitable one was chosen based on its parameters, the question of buying a driver came up, but I didn't want to buy one: it cost about $70... I decided to look for a driver circuit on the internet. Everything I found at the time was based on a microcontroller, and the cost of the circuits I found was also...

Connecting the FL86STH65-2808A Stepper Motor to a Microcontroller.

Connecting the FL86STH65-2808A Stepper Motor to a Microcontroller.

The other day I got my hands on an FL86STH65-2808A stepper motor with an SMD-4.2 driver, and the task was to learn to control it with a microcontroller. First, the motor needs to be connected to the driver: 8 wires come out of the motor, and they can be connected in two ways, as shown in the picture below. With the windings connected in series, maximum torque can only be achieved at low...

How to Measure Negative Voltage with an ADC, Part 2...

How to Measure Negative Voltage with an ADC, Part 2...
Схемотехника

There are several more methods of measuring negative voltage with an ADC that deserve attention. One of them can be seen in the currently popular DSO138 kit. As you can see, this circuit doesn't use a summing amplifier, but the principle is the same as described in the previous article. Let's recall it: we need to set an offset equal to half the ADC's dynamic range (in this...