4 ms·
I did something similar on a Raspberry Pi using the GPIO pins one afternoon when bored. I made a 4-bit R2R DAC [1] using typical 5% tolerance resistors and fed
by retrac 3y ago
I did something similar on a Raspberry Pi using the GPIO pins one afternoon when bored. I made a 4-bit R2R DAC [1] using typical 5% tolerance resistors and fed it directly into a small speaker. I shrunk a 16 bit audio file down to 4 bits and then toggled the GPIO pins in a loop in Python from Linux userspace around 40 kHz. The result was easily intelligible speech, and easily recognizable, if not exactly pleasant, music. I was surprised how good the results were considering it was made of literally nothing but wire. It was quite noisy, which I assume was from the clock jitter running with an inexactly timed update loop, and the zero filtering.
[1] https://en.wikipedia.org/wiki/Resistor_ladder#R%E2%80%932R_resistor_ladder_network_(digital_to_analog_conversion) https://en.wikipedia.org/wiki/Resistor_ladder#R%E2%80%932R_r...
- TickleSteve 3y agoIf you're doing that from user space, the noise will be from scheduling delays as Linux context-switches your process to run other stuff. You can minimise that type of effect thru use of cpu-affinity but not get rid of it completely.
- willis936 3y agoA company I'm working was getting awful SFDR values on a 12-bit DAC and not meeting requirements, which I didn't loosen up on. It turns out that they were using linux userspace to set the values for rapid bringup and moving to a bare metal application fixed it up. 250 times a second linux interrupts were causing delayed samples.