Skip to the content
2 layers24.1 × 58.2 mmMax98357-amp, the printed circuit board in 3D

Educational and experimental PCB designs for Raspberry pi related products and peripherals

Size
24.1 × 58.2 mm
Copper layers
2
Thickness
1.6 mm
Parts
18
Nets
14
Pads
60
Tracks, vias
92, 4
Pours
3
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
11 Feb 2023
Updated
6 May 2026

Overview

Max98357-amp is an open-source printed circuit board by CoryParsnipson, from the CoryParsnipson/electronics-experiments repository on GitHub, published under the MIT licence. It is a 2-layer board of 24.1 × 58.2 mm with 18 parts on 14 nets, routed with 92 tracks and 4 vias.

Its parts include 8 connectors, 4 capacitors, 2 resistors, 1 IC and 1 switch. It belongs with the audio and music boards of this library.

README

555-timer-pwm-with-digipot/README.md

555-timer-pwm-with-digipot

This is a hardware pwm signal generator using a 555 timer. The design used here is one that uses two diodes attached to both ends of a potentiometer to make the duty cycle adjustable without changing the frequency. A twist on the usual design is that this project also uses a digital potentiometer (a.k.a. digipot) so that the duty cycle can be adjusted programmatically with a microcontroller via an I2C interface.

The purpose of this project is to provide digital access to an adjustable PWM signal to dim an lcd backlight driver. (See ap5726-lcd-backlight-driver.) The output signal of this project can be fed into the enable signal of an lcd backlight driver.

Disclaimer

This project is not recommended for real usage. This is not a very good way to generate a PWM signal compared to other methods. See Post Mortem for more detailed information.

KiCAD Version

Current version: KiCAD 7.0.2.

This was originally made with KiCAD 7.0.2.

Description

50% Duty Cycle Output Signal

555 Timer Real PCB

PWM Generation using 555-timer in Astable Multivibrator Mode

A good explanation of how 555-timers work and how they operate in astable-multivibrator mode can be found at How to Generate PWM Signal using 555 Timer IC, also listed as [1] in References. The author does a good job of explaining the functional logic and how it works. Basically, a 555-timer can be used to emit signal pulses at very specific, user-settable delays. This is known as "monostable" mode. A 555-timer can also be induced to oscillate like a clock signal by using feedback loops. This mode of operation is known as "astable" because it changes value by itself and "multi-vibrator" because it assumes different values.

Frequency Independent 555-oscillator using a potentiometer

Unfortunately, the author of [1] doesn't explain the PWM oscillator circuit in detail and really drops the ball at the end. I found a second page, 555 Circuits Part 1, ([2] under References) that describes creating a PWM generator step-by-step starting from 555-timer astable mode. I am basing this project's circuit off of the "Fully Independent 555 Oscillator". [2] goes into much more detail about the circuit design. These two webpages together, I feel, are a very good primer into 555 circuits.

Schematic for Project Design

555 Timer with Digipot Schematic in KiCAD

The schematic was created by following the block diagram for the frequency independent 555-oscillator shown above. The DS3502 digipot is incorporated using the layout copied from the Adafruit breakout board. The SDA and SCL signals require 10k pull up resistors. The A0 and A1 pins are hooked up to solder jumper pads for configurability. To change the I2C address, bridge the solder pins. The digipot also needs decoupling capacitors close to the V+ and Vin pins.

PCB Layout Notes

555 Timer with Digipot PCB layout in KiCAD

  • Decoupling caps for VCC and V+ pins of the digipot must be kept in the vicinity of their respective pins.
  • SDA and SCL may benefit from ferrite beads. For a similar reason, I made sure that the ground plane on the back copper is behind both these traces as well as the digipot. Not sure if that's how it works though...

Component Selection

Selection of C, RA, and RB

As explained by [1] and [2], the frequency and duty cycle that the oscillator will assume can be adjusted by selecting values for the three main components, the capacitor C, the fixed resistor RA, and the potentiometer RB.

Duty Cycle = R<sub>A</sub> / (R<sub>A</sub> + R<sub>B</sub>)

The duty cycle is solely determined by the ratio of both resistors. Where RA is the "top" resistor, in series with the capacitor charging path, and RB is the bottom resistor, in series with the discharge path. As you can see from the formula, the duty cycle can theoretically go up to 100%, but RA is constraining the lower limit. We want this to be small.

  • RA = 499 ohms
  • RB = 10k ohms (total potentiometer resistance value)

These resistor values can give us a minimum 5% duty cycle. This most likely is not enough to completely turn off the LEDs. That is something I wish I knew before I started, that this particular design is not able to achieve a full duty cycle range. (As a note, other methods of generating PWM signals can achieve a full 0-100% duty cycle range.)

The last component to select is the value of the charging/discharging capacitor. This capacitor has the most influence on frequency.

Frequency = 1.25 / ((R<sub>A</sub> + R<sub>B</sub>) * C)

The frequency we want should be <= 2 kHz, because this design is being made to control the enable signal of the AP5726 white led driver, and that chip is expecting an unfiltered PWM signal to be under 2 kHz. Going with the previous select resistor values, and a capacitor that is 0.1 uF, we get an expected frequency of 1190 Hz.

NOTE: One can still use this circuit and insert different valued components to change the duty cycle and frequency. This PCB layout uses 0805 (2012 metric) surface mount size resistors and capacitors.

The 1.25 constant in this formula comes from the inverse of 0.8, which itself had been changed from its original value of 0.693. This value is the ln(2), derived from some sort of manipulation of an exponential growth/decay formula. The site [2] mentions that the value was changed to 0.8 to account for using diodes with lower than usual threshold voltage. The derivation of this is not something I was able to find or come up with myself... In my experiment, this does not accurately reflect the empirically observed frequency that ended up being half the estimated value.

I was able to take that measurement and deduce that in my real component, the 1.25 factor is actually 0.546 for some reason.

50% Duty Cycle Output Signal

This was done by taking the frequency measurement here and plugging that back into the frequency formula to solve for the "1.25" term. To get back to an expected 1190 Hz, one could halve the capacitor value to use 0.05 uF (50 nF) for a frequency of 1040.10 Hz. This is if 5V input voltage is used. If 3.3V will be used, the capacitor value may have to be reduced by a factor of 30%. (See Post Mortem for more information about this...)

555-timer

The TLC555CDR 555-timer is recommended for it's small form factor, low pin count, and ability to run at 3.3V.

Digipot

The DS3502 was used because it was available in breakout board form from Adafruit. However, in retrospect, the MCP4561T-103E (Alternative digipot with low wiper resistance) is a much better part with similar features. (See Post Mortem for why this is.) This PCB layout is not designed to work with the MCP4561T-103E as-is. The pins differ between the two chips.

Diodes

This design needs fast switching small signal diodes, preferably with a low threshold voltage. The BAT34W-TP schottky diodes were chosen.

Using a Digital Potentiometer

Pinout and Hookup

Raspberry PI 3 I2C Pinout

The SDA and SCL pins of the PCB should be hooked up to the corresponding SDA and SCL pins of your microcontroller of choice. I used a Raspberry Pi 3, as depicted in the above picture. One also needs to make sure the I2C peripheral is enabled and reboot the RPi. And that's all for the interfacing setup!

I2C interaction

One may use the available raspberry pi package "i2c-tools":

sudo apt-get install i2c-tools

This package provides a basic way to talk to I2C devices, using i2cdetect, i2cset, and i2cget.

text
#> i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

#> i2cget -y 1 0x28 0x00
0x40

#> i2cset -y 1 0x28 0x00 0x00                 # set the digipot to 0 (shortest duty cycle)
#> i2cset -y 1 0x28 0x00 0x7F                 # set the digipot to 127 (longest duty cycle)

If everything is working correctly, you should see a device on I2C port 1 address 0x28. (This may differ if you've bridged the A0 and/or A1 pins). Upon intial start-up you should see a read to the digipot register will return 0x40, which is halfway to 128, corresponding to a 50% duty cycle.

Post Mortem

This design was originally going to be used together with an ap5726-lcd-backlight-driver to dim LEDs. Unfortunately, this design was not performing to expectations.

Problems with this design

Duty Cycle Range is Unacceptable

Min and Max Duty Cycle of Built 555-timer

Here is a video of me writing the min and max values to the digipot and the subsequent duty cycle generated by those values. The difference is not very noticeable...

I measured the duty cycle of both min and max values. First, here is the total period measurement:

555-timer Period Measurement: 398 Hz at 3.3V

My oscilloscope shows 398 Hz frequency or 2.520 ms period. Here is the minimum duty cycle:

555-timer Minimum Duty Cycle Measurement: 960us

The high pulse is 960 us long. This corresponds to a duty cycle of 38.1%! Terrible!

And the max duty cycle:

555-timer Maximum Duty Cycle Measurement: 2.040ms

The high pulse is 2.040 ms long. This corresponds to a duty cycle of 81%! Also terrible!

For reference, here is a pwm cycle coming from a Raspberry Pi, that is able to go fully from 0 to 100% duty cycle:

Raspberry Pi PWM signal demonstration

Frequency is Unpredictable

Using a fudge factor of 0.8 instead of 0.692 (a.k.a. the ln(2)) is due to adding in fast switching diodes that have a threshold voltage of about 0.4-0.5 volts instead of 0.7 volts. In the real world, the diode characteristics can still vary enough to make the actual frequency different. After putting together this circuit in real life, the frequency of the PWM signal was observed to be around 520 Hz @ 5V VCC and a 1190 Hz signal was expected.

The frequency is also dependent on input voltage. So while the frequency was in the 500 Hz range at 5V, it gets lower at 3.3V. At such voltage, the frequency was recorded to be around 390 Hz.

It is unknown exactly why there is a discrepancy...

Digipot Wiper Resistance Cannot be Ignored

The DS3502 digipot has a nominal wiper resistance of 5000 ohms. This is quite large and cannot be ignored when doing frequency calculations. This large resistance shows up on both the charge and discharge timing, reducing the duty cycle range from 5% - 100% to around 30% - 80%. This is not good, and the qualitative difference in LED brightness is barely perceptable. The lower duty cycle range is especially important to being able to dim the LEDs to near shutoff.

If I disconnect the digipot and use a 10k resistor and a short circuit to connect the RL, RW, and RH pins into the 555-timer, I can see what the actual duty cycle limits are without the digipot characteristics getting in the way.

If I put the 10k resistor across RW and RH, this will simulate minimum duty cycle:

Minimum Duty Period Debug Minimum Duty Cycle Debug

The period here is 910 us and the duty cycle is high for 50 us. That corresponds to a 5.47% duty cycle. Very close to the calculated value!

Putting the 10k resistor across RW and RL will be equivalent to maximum duty cycle:

Maximum Duty Cycle Debug

This is very, very close to 100%. So this is pretty definitive evidence that the 5000 ohm wiper resistance is messing things up.

Design Uses Too Many Components

This design uses too many expensive components. The DS3502 (and similar) digipots are about $1.80 USD. This design also requires a 555-timer, 2 expensive diodes, 5 resistors, and 4 ceramic capacitors. Overall, the design costs around $5-7 USD for this single functional block. (Compare to using an ATTiny25, which is ~$1 USD and aside from 2 pull up resistors for I2C signals, is the only part you need.)

Possible Mitigations

There are a few things one can implement to improve upon this design, however, none of them change the fact that it is unsuitable for real world usage.

  • Replace DS3502 digipot with one that has smaller wiper resistance
    For instance, the MCP4561T-103E not only has a nominal wiper resistance of 75 ohms but it has 257 steps instead of the DS3502's 127. This will probably improve the duty cycle range drastically. Combined with using a slightly smaller charging resistor (RA), you could get to the theoretical 5% minimum duty cycle.

  • Implement negative resistance op amp circuit
    Negating the wiper resistance of a digipot has been thought of before. One may attempt to use an op amp to create a circuit that would negate the wiper resistance of the digipot. Article here.

    This was not done for this project. An alternate method will be chosen to dim the LEDs.

Possible Alternatives

  • Use a microcontroller to generate the PWM signal. Using an extra wire from a Raspberry Pi and generating a PWM signal from it works really well, at the cost of requiring an entire Raspberry Pi and an extra wire to generate the signal. If one wants to embed an microcontroller into the PCB so that the user will not have to supply their own microcontroller, one can use an ATTiny25. This microcontroller does not require any external components and can run off 3.3V. So the user simply needs to incorporate the footprint onto the PCB and then write fireware to configure I2C, non-volatile memory storage, and enable PWM generation on one of the pins.

    Here is a good explanation of how a microcontroller is able to generate a PWM signal.

  • Use multi-op-amps in an astable vibrator configuration. This is similar to using a 555-timer, except the design is more complicated. The benefits are that the frequency will be more stable with the op-amps and the wiper resistance of the digipot will not matter because you can use a comparator op-amp to adjust to the digipot's output range.

References/Further Reading

  1. How to Generate PWM Signal using 555 Timer IC?
  2. 555 Circuits Part 1
  3. NE555DR Datasheet
  4. DS3502 Datasheet
  5. DS3502 Adafruit Breakout Board
  6. MCP4561T-103E (Alternative digipot with low wiper resistance)
  7. Negating Wiper Resistance with Negative Resistance
  8. ATTiny25
  9. How do Microcontroller generate PWM signals?

Parts

18
QtyValueFootprintReferences
4Conn_01x02_MaleConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ2, J3, J4, J8
2Conn_01x01_MaleConnector_PinHeader_2.54mm:PinHeader_1x01_P2.54mm_VerticalJ5, J6
2FerriteBeadResistor_SMD:R_0603_1608MetricFB1, FB2
10.1uFCapacitor_SMD:C_0603_1608MetricC2
110uFCapacitor_SMD:C_0603_1608MetricC1
1200kResistor_SMD:R_0603_1608MetricR1
1220pFCapacitor_SMD:C_0603_1608MetricC3
1220pfCapacitor_SMD:C_0603_1608MetricC4
1680kResistor_SMD:R_0603_1608MetricR2
1AS01808AO-mountproject:AS01808AO-mountS1
1Conn_01x07_MaleConnector_PinHeader_2.54mm:PinHeader_1x07_P2.54mm_VerticalJ1
1MAX98357project:MAX98357-TQFN16-T1633+4U1
1Screw_Terminal_01x02TerminalBlock_Phoenix:TerminalBlock_Phoenix_PT-1,5-2-3.5-H_1x02_P3.50mm_HorizontalJ7

More from CoryParsnipson/electronics-experiments

5
  • 2 layers58.8 × 55.4 mmRetrocution usb hub, the printed circuit board in 3D

    Retrocution usb hub

    CoryParsnipson/electronics-experiments

    Educational and experimental PCB designs for Raspberry pi related products and peripherals

    35 parts1MIT
  • 4 layers64.1 × 57.2 mmDsi signals, the printed circuit board in 3D

    Dsi signals

    CoryParsnipson/electronics-experiments

    Educational and experimental PCB designs for Raspberry pi related products and peripherals

    21 parts1MIT
  • 2 layers32.6 × 15.4 mm555-timer pwm with digipot, the printed circuit board in 3D

    555-timer pwm with digipot

    CoryParsnipson/electronics-experiments

    Educational and experimental PCB designs for Raspberry pi related products and peripherals

    19 parts1MIT
  • 2 layers18.3 × 14.6 mmAp5726-lcd backlight driver, the printed circuit board in 3D

    Ap5726-lcd backlight driver

    CoryParsnipson/electronics-experiments

    Educational and experimental PCB designs for Raspberry pi related products and peripherals

    9 parts1MIT
  • 2 layers27.4 × 29.7 mmAs01808ao enclosure, the printed circuit board in 3D

    As01808ao enclosure

    CoryParsnipson/electronics-experiments

    Educational and experimental PCB designs for Raspberry pi related products and peripherals

    2 parts1MIT

Similar boards

  • 2 layers27.9 × 16.5 mmPowerSSO-24 breakout, the printed circuit board in 3D

    PowerSSO-24 breakout

    rusefi/rusefi

    rusefi - GPL internal combustion engine control unit

    18 parts1.2k
  • 2 layers42.7 × 13.7 mmStm32-mini12864, the printed circuit board in 3D

    Stm32-mini12864

    VoronDesign/Voron-Hardware

    Cool Hardware designed by the Voron Design group

    18 parts1.1kGPL-3.0
  • 2 layers41.2 × 46.6 mmThumb cluster left, the printed circuit board in 3D

    Thumb cluster left

    JesusFreke/lalboard

    A 3D-printed keyboard inspired by the DataHand

    18 parts993
  • 2 layers44 × 51.3 mm4272MAVcoder R4, the printed circuit board in 3D

    4272MAVcoder R4

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    18 parts915
  • 2 layers28.3 × 14.3 mmTap Photosensor PCB, the printed circuit board in 3D

    Tap Photosensor PCB

    VoronDesign/Voron-Tap

    Tap is a nozzle-based z-probe for the V2 and Trident printer designs. The entire toolhead moves to trigger an optical switch. Tap offers many advantages:

    18 parts716GPL-3.0
  • 2 layers20.3 × 15.2 mmL0 stepper driver, the printed circuit board in 3D

    L0 stepper driver

    Luos-io/luos_engine

    Open-source and real-time orchestrator for cyber-physical-systems, to easily design, test and deploy embedded applications and digital twins.

    18 parts546MIT
  • 2 layersMooltipass, the printed circuit board in 3D

    Mooltipass

    limpkin/mooltipass

    Github repository dedicated to the mooltipass project

    18 parts531
  • 2 layers42.5 × 28.8 mmC5VRX JACK DIY V2, the printed circuit board in 3D

    C5VRX JACK DIY V2

    Twotoz/C5VRX

    Ultra-minimal, zero-CPU 5.8 GHz analog FPV video receiver using ESP32-C5 Wi-Fi 6 PHY MODEM_DIAG, BitScrambler WBFM demodulation & resistor DAC CVBS

    18 parts515GPL-3.0

Questions

How big is the Max98357-amp PCB?

It measures 24.1 × 58.2 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Max98357-amp use?

18 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Max98357-amp KiCad files?

From the CoryParsnipson/electronics-experiments repository on GitHub, at the commit this page was made from: the board is max98357-amp/max98357-amp.kicad_pcb and its schematic 555-timer-pwm-with-digipot/555-timer-pwm-with-digipot.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Max98357-amp design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).