How To Make (almost) Anything
CBA Section - Week 9 Group Assignment
2025
| Amplitude | I (amp) | V (v) | Power (w) |
|---|---|---|---|
| 4000 | 0.020 | 0.195 | 0.0039 |
| 8000 | 0.045 | 0.380 | 0.0171 |
| 16000 | 0.095 | 0.770 | 0.07315 |
| 32000 | 0.185 | 1.555 | 0.2877 |
Test code
#include "AudioTools.h"
/**
* Pinout:
* D0 - I2S BCLK
* D2 - I2S LRC
* D10 - I2S DIN (to speaker)
*/
#define I2S_BCLK D0
#define I2S_LRC D2
#define I2S_DIN D10
const int freqs[] = {220, 440, 660, 880};
const int amps[] = {4000, 8000, 16000, 32000};
int freqIndex = 0;
int ampIndex = 0;
unsigned long lastChange = 0;
const int sampleRate = 22000; // sample rate in Hz
AudioInfo info(sampleRate, 1, 16);
SineWaveGenerator<int16_t> sineWave(32000); // sine wave with max amplitude of 4000
GeneratedSoundStream<int16_t> sound(sineWave); // stream generated from sine wave
I2SStream out;
StreamCopy copier(out, sound); // copies sound into i2s
void setup() {
Serial.begin(115200);
Serial.println("I2S Sine Wave Playback");
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// start I2S with custom pinout
Serial.println("Starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.copyFrom(info);
config.pin_bck = I2S_BCLK;
config.pin_ws = I2S_LRC;
config.pin_data = I2S_DIN;
out.begin(config);
// Setup sine wave
sineWave.begin(info, freqs[0]);
Serial.println("Started sine wave playback");
}
void loop() {
if (millis() - lastChange >= 2000) {
lastChange = millis();
freqIndex = (freqIndex + 1) % 4;
if (freqIndex == 0) {
ampIndex = (ampIndex + 1) % 4;
}
sineWave.setFrequency(freqs[freqIndex]);
sineWave.setAmplitude(amps[ampIndex]);
}
copier.copy();
}
Sara and Dimitar met up to measure the power consumption of two output devices: a NEMA8 with a gearbox and a DC motor. For the NEMA8, we ran the motor at a speed of 10 rev/s with a constant current and used a multimeter to measure the current through each of the wires in turn. The first one was 115 mA. We tried holding the motor shaft to add resistance and see what happened. This increased the current to around 190 mA and caused the motor to stall. After unplugging and replugging the board, we testing the remaining wires in turn, which also came out to ~115 mA each. The image on the left is probing the black wire yielding ~115 mA, and the image on the right is while holding the motor shaft, yielding the ~190 mA reading.
We then measured the difference in voltage between pairs. The NEMA8 data sheet shows that the black and green wires are a pair, so we measured between those, which came out to ~3.7 V. Since P = I * V, we found that P = (2 coils) * (115 mA) * 3.7 V which means power = 851 mW. We also noticed some leakage current when the board was plugged in but the motor wasn’t moving (shown on the left). On the right is a photo of the voltage measurement.
Following this, we used a power supply to power a DC motor at 3 V and 0.038 A. We measured the voltage to be 2.959 V and the current to be 38.83 mA, which matched this. We calculated power from P = I * V to be P = 38 mA * 3 V = 114 mW. Here are some images from those measurements.
Having validated that the voltage and current readings at the power supply match the DMM readings at the motor, we used them to record the current at 8V, 7V, 6V, 5V, 4V, 3V (again), 2V and 1V (in that order), with the motor unloaded. The results are below: