genuinequality

Download free music MP3s on genuine quality, the world’s largest online music catalogue, powered by your scrobbles. Free listening, videos, photos, The world’s largest online music catalogue, powered by your scrobbles. Free listening, videos, photos, stats, charts, biographies and concerts. stats, charts, biographies and concerts.

Monday, February 19, 2024

Raspberry Pi Pico Synth_Dexed? – Part 6

Kevin posted: " One last thing I definitely wanted for my PicoDexed was the option for PWM output. This post is by way of a short coda detailing how to do PWM on a Raspberry Pi Pico. Part 1 where I work out how to build Synth_Dexed using the Pico SDK and get some s"
Read on blog or Reader
Site logo image Simple DIY Electronic Music Projects Read on blog or Reader

Raspberry Pi Pico Synth_Dexed? – Part 6

Kevin

February 19

One last thing I definitely wanted for my PicoDexed was the option for PWM output. This post is by way of a short coda detailing how to do PWM on a Raspberry Pi Pico.

  • Part 1 where I work out how to build Synth_Dexed using the Pico SDK and get some sounds coming out.
  • Part 2 where I take a detailed look at the performance with a diversion into the workings of the pico_audio library and floating point maths on the pico, on the way.
  • Part 3 where I managed to get up to 16-note polyphony, by overclocking, and some basic serial MIDI support.
  • Part 4 for the full MIDI implementation, voice loading, SysEx control and USB-MIDI.
  • Part 5 details different options for building hardware to run PicoDexed.

The latest code can be found on GitHub here: https://github.com/diyelectromusic/picodexed

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to microcontrollers, see the Getting Started pages.

PWM Output Circuit

The official "Hardware Design with the RP2040" guide includes a PWM circuit as follows (see section 3.4.1).

Several others have used a slightly simplified version of this circuit, essentially omitting the buffer stage (U3) and perhaps only implementing a single channel. See for example - Raspberry Pi Pico PWM Audio Output Circuit (Jeremy S. Cook) and "pico-pwm-audio" (Robin Grosset).

An alternative is this circuit used by Tod Kurt for his Circuitpython-tricks - "The output circuitry to get line-out levels is a simple 10:1 voltage-divider and a 1uF capacitor to recenter the signal around 0 volts":

I'm going with Jeremy S. Cook and Robin Grosset and using the following (diagram from here):

Raspberry Pi Pico Audio PWM

There appears to be two ways of getting audio style PWM signals out of a Pico:

  • Use the PWM peripherals.
  • Use the PIO.

It would appear that Raspberry Pi's pico_audio library in the pico-extras repository uses PIO. I haven't found a clear explanation as to why the built-in PWM peripherals haven't been used.

Here are some other resources that show alternative descriptions of PWM for audion on a Pico:

  • Ben Everard's PIO tutorial in Hackspace magazine - a simplified PIO PWM driver.
  • chipfire's rppico-pwm-sound synthesizer - uses the Pico SDK and DMA to the PWM peripheral.
  • Pico Playground sine wave example - uses the Pico Extra's pico_audio library and PIO PWM.
  • Robin Grosset's Raspberry Pi Pico PWM Audio Project - uses the Pico SDK and the PWM peripheral.

As I'm using the pico_audio library for I2S audio, I'm going to use the default PWM pico_audio library too.

To initialise the pico_audio PWM library requires the following:

const audio_pwm_channel_config_t config =
{
.core = {
.base_pin = base_pin,
.dma_channel = dma_ch,
.pio_sm = pio_sm
},
.pattern = 3,
};

const struct audio_format *output_format;
output_format = audio_pwm_setup(pAudioFormat, -1, &config);
bool status = audio_pwm_default_connect(pBufferPool, false);
audio_pwm_set_enabled(true);

Everything else is the same as for I2S.

At present, overclocking the Pico causes the PWM frequencies to be messed up, so for now the recommended configuration is 8-note polyphony, 24000 sample rate and no overclocking.

The build uses GPIO 20 for PWM.

Closing Thoughts

I've uploaded a prototype PWM UF2 file to GitHub too now in case anyone wants to give that a go too: https://github.com/diyelectromusic/picodexed

Hopefully there is enough information in the above to get something up and running.

Kevin

Comment
Like
Tip icon image You can also reply to this email to leave a comment.

Simple DIY Electronic Music Projects © 2024. Manage your email settings or unsubscribe.

WordPress.com and Jetpack Logos

Get the Jetpack app

Subscribe, bookmark, and get real-time notifications - all from one app!

Download Jetpack on Google Play Download Jetpack from the App Store
WordPress.com Logo and Wordmark title=

Automattic, Inc. - 60 29th St. #343, San Francisco, CA 94110  

Posted by BigPalaceNews at 10:35 AM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Search This Blog

About Me

BigPalaceNews
View my complete profile

Blog Archive

  • July (29)
  • June (136)
  • May (82)
  • April (84)
  • March (87)
  • February (90)
  • January (74)
  • December (72)
  • November (95)
  • October (105)
  • September (112)
  • August (116)
  • July (96)
  • June (100)
  • May (105)
  • April (95)
  • March (131)
  • February (111)
  • January (104)
  • December (98)
  • November (87)
  • October (126)
  • September (104)
  • August (97)
  • July (112)
  • June (113)
  • May (132)
  • April (162)
  • March (150)
  • February (342)
  • January (232)
  • December (260)
  • November (149)
  • October (179)
  • September (371)
  • August (379)
  • July (360)
  • June (385)
  • May (391)
  • April (395)
  • March (419)
  • February (356)
  • January (437)
  • December (438)
  • November (400)
  • October (472)
  • September (460)
  • August (461)
  • July (469)
  • June (451)
  • May (464)
  • April (506)
  • March (483)
  • February (420)
  • January (258)
  • December (197)
  • November (145)
  • October (117)
  • September (150)
  • August (132)
  • July (133)
  • June (117)
  • May (190)
  • January (48)
Powered by Blogger.