med-mastodon.com is one of the many independent Mastodon servers you can use to participate in the fediverse.
Medical community on Mastodon

Administered by:

Server stats:

347
active users

#RaspberryPiPico

4 posts2 participants0 posts today
Continued thread

I've used other RP2040 boards besides the Raspberry Pi Pico and others have their place but it's really difficult to beat that $4 USD price for a Raspberry Pi Pico when you just need a cheap microcontroller.

What you get for that price is pretty amazing, and I've probably used at least a few hundred of them in the past couple years.

I would guess that 98% of my microcontroller needs are a cheap board I can program using the Arduino IDE along with any of the zillion of existing libraries out there.

Thanks to Earle Philhower's arduino-pico project I switched to using the $4 USD Raspberry Pi Pico years ago, and I was using the Teensy LC boards before that but those were discontinued. (I like the Teensy boards but they are more than I need for 98% of my projects.)

I made some progress on the Beat Bike!

The magnet mounted on the wheel passes a reed switch which is sensed by the control box (with a Raspberry Pi Pico) and then triggers the drum machine to step through the programmed sequence.

Still a lot of work to do, mostly mounting everything onto the bike, and some more code to write, but the proof of concept is all good.

Pico Touch Board Audio

I wanted to go back to my Pico Touch Board PCB Design and see if there was a way to make it more stand-alone. The original design was to make it a MIDI controller, but that isn’t the only option.

https://makertube.net/w/tADSyrPrUdR1mx7yKRXZTC

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

These are the key Arduino tutorials for the main concepts used in this project:

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

Parts list

  • Pico Touch Board PCB – built
  • Resistors: 1x 220Ω, 1x 1K
  • Capacitor: 1x 100nF ceramic, 1x 22uF electrolytic
  • Breadboard and jumper wires

The Circuit

Most of the GPIO are linked out to the touch pads, but the three analog inputs are still available. They are added on to the header on the right hand side of the board at the top, so we can use one of these as an audio output.

Initially, I thought of connecting it to an 8Ω speaker. If I was using an Arduino then I’d use a 220Ω resistor in series to limit the current to less than 20mA. But as I’m using a Pico, the maximum current has to be a lot less. I seem to recall it is a little complicated, and there are some options, but I have a figure of around 4mA that I tend to work to. It is also running at 3.3V, which means that it would need an in series resistor of 3.3 / 0.004 = 825Ω. This would work, but the speaker will be really quiet!

So I ditched that idea (there is a software reason too, but I’ll talk about that in a moment) and went straight to a PWM output with a low-pass filter to try to give me some vaguely useful as a line-out signal.

I’ve not done the calculations, but instead went a bit “hand-wavy”, combing a 1K and 220Ω resistor to drop the voltage, along with a 100nF capacitor. I’ve also added a 22uF capacitor to remove the DC bias.

That seems to give me something useful, but as you can see from the trace below of a square wave PWM output, there is a lot of room for improvement!

The Code

I wanted to stick with Circuitpython, so my initial thought was to use simpleio.tone() to generate a tone based on a frequency from an IO pin. However, this has the problem that the code is blocking whilst the tone is playing which isn’t very useful.

Instead I went straight to synthio. It turns out that using synthio was actually a lot easier than the “simple” simpleio…

Here is the basic code to generate an ASR-shaped square wave on a PWM audio output on GPIO 28 based on the touch pads as input.

import board
import touchio
import synthio
import audiopwmio
from adafruit_debouncer import Debouncer, Button

audio = audiopwmio.PWMAudioOut(board.GP28)
synth = synthio.Synthesizer(sample_rate=22050)
audio.play(synth)
synth.envelope = synthio.Envelope(attack_time=0.1, release_time=0.6, sustain_level=1.0)

touchpins = [
board.GP2, board.GP3, board.GP4, board.GP5,
board.GP6, board.GP7, board.GP8, board.GP9,
board.GP10, board.GP11, board.GP12, board.GP13,
board.GP14, board.GP15, board.GP16, board.GP17,
board.GP18, board.GP19, board.GP20, board.GP21, board.GP22
]

THRESHOLD = 1000
touchpads = []
for pin in touchpins:
t = touchio.TouchIn(pin)
t.threshold = t.raw_value + THRESHOLD
touchpads.append(Button(t, value_when_pressed=True))

while True:
for i in range (len(touchpads)):
t = touchpads[i]
t.update()

if t.rose:
synth.press(60+i)

if t.fell:
synth.release(60+i)

Battery Power

One last thing I wanted to explore was if it was possible to power the touchboard with batteries. I left in a number of power options, so for this one I’m using the 5V/GND pin header. I’ve included a couple of capacitors for smoothing, and need to add the 1N5817 diode as shown below.

This requires the following additional components:

  • 1x 1N5817 Schottky diode.
  • 1x 100nF ceramic capacitor.
  • 1x 47uF electrolytic capacitor.
  • Jumper wires.
  • 3 or 4 battery box.

The 5V/GND header pins connect to the Raspberry Pi Pico’s VSYS pin via the Schottky diode. The 1N5817 has a typical voltage drop of 0.45V, so combined with the Raspberry Pi’s accepted input voltage of 1.8V to 5.5V this means that ideally two or three AA batteries (at 1.5V each) would work. Four 1.2V rechargeables might be an option too.

It might be possible to get away with four 1.5V AAs, but that would give an input voltage of just over 5.5V, so I think that is probably pushing things too far. It might be a good use for some spent AAs though that are no longer reading a full 1.5V…

One of the downsides of battery power is that the touch works best when your fingers are at the same GND potential as the board. It works best if the GND pin of the (unpopulated) barrel jack is touched when using the board.

Closing Thoughts

With hindsight it would have been useful to have included a simple PWM output stage on the original board, but it is relatively straight forward to add one.

It might even be worth me making an add-on board that will connect to the header pins of the power and analog pins containing the simple passive filter components.

What is pretty impressive though, is how easy it is to use synthio with Circuitpython.

Kevin

Had my first encounter with a Raspberry Pi Pico today.

I needed a MCU that could enumerate two USB serial ports to a host, have a UART interface for an external device, and control a heap of GPIOs. The RPi Pico was a little light on GPIOs, but add a couple of I²C expanders, and we were in business. The idea was one USB serial interface (call it port 1) would be for control commands, and serial traffic on the other (port 2).

The UART on the thing is hooked up to a multiplexing circuit with two RS-485 transceivers and a TTL buffer, so via port 1, I can put port 2 into any of: TTL serial, RS-485 (via either transceiver), or RS-422 (both transceivers, using one for receive and the other for transmit). The GPIOs sense things through optical isolators and tickle devices via reed relays.

Haven't wired the thing up yet, but TinyUSB has a dual CDC-ACM example that was a doddle to get going on the Pico… so I don't expect it to be a big job.

Not sure if this can be done in #MicroPython … I think I'll be using C, but that's fine, C will get the job done.

Tomorrow should be interesting.

Continued thread

2/3
Aber es gab diverse Issues...
#RaspAP z.B. ist trotz eigentlich guter Funktionalität für mich nicht zu gebrauchen. Leaken der echten IP in einigen #VPN Situationen - vor allem aber gibts mit RaspAP derzeit bekannte Stabilitätsprobleme mit dem aktuellen #RaspberryOS auf dem #RaspberryPiPico.

Und jetzt scripte ich mir seit 2 Tagen nen Wolf alle RaspAP Funktionalität mittels #NetworkManager (#nmcli), #dnsmasq und #iptables zu ersetzen.

#piSpot Projekt.

Ursprünglich war gedacht mittels #RaspAP und #PiHole einen mobilen Hotspot zu bauen.

Mögliche Internetquellen sollten sein
#eth, #wlan, #wwan + optinal #vpn oder/und #Tor.

#RaspberryPi und #RaspberryPiPico sind als Ziel-Hardware gedacht.

Captive Registrierung sollte automatisch erfolgen und im Passwort-Zweifel auch vom Terminal aus bedient werden können.

Ich hatte das zu 90% ziemlich schnell realisiert - und schon 2 Tage lang in der Stadt alle möglichen Wlan getestet.
1/3

For the last month or so I've been working on seeing how far I can push CircuitPython into emulating a TB-303 bass synth. With the new audiofilters library, you can "stack" filters to make two two-pole filters seem like a 4-pole filter, getting close to that squelchy sound we need. My efforts so far:
youtube.com/watch?v=1AflpXbEIno
#circuitpython #tb303 #synthdiy #raspberrypipico

Clockwork PicoCalc is a retro handheld powered by a Raspberry Pi Pico

The PicoCalc is a new handheld with a retro design. At first glance it looks more like a graphing calculator than a modern handheld device. But it sports a QWERTY keyboard, a 4 inch display, and a mainboard designed to accommodate a Raspberry Pi Pico.

Available for $75 from the Clockwork Pi store, it’s also the latest in a line of retro-inspired, modular, and open source products from the […]

#clockwork #clockworkPi #handheld #mcu #openHardware #picocalc #raspberryPiPico

Read more: liliputing.com/clockwork-picoc

I've now put up the designs for my own take on a MIDI touch board based on the Raspberry Pi PIco, based on ideas from my Pico Touch Keyboard that I published before. It's something I've been meaning to do for some time!

As well as 21 GPIO touch pads with holes that are Lego compatible, this includes serial MIDI IN/OUT.

With hindsight, I should have added a PWM filter too :)

diyelectromusic.com/2025/03/02